blob: 139b21b4f1011b4b184de73f8d47ca02a45fc5e2 [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +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
Georg Brandlbcd64a32009-03-31 21:45:18 +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
Ronald Oussoren5640ce22008-06-05 12:58:24 +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 Oussoren3c0a1262010-01-17 19:27:57 +000081AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +000082AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +000083 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +000084[
85 case $enableval in
86 yes)
87 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000088 if test ! -d "${enableval}"
89 then
90 enableval=/
91 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +000092 ;;
93 esac
94 case $enableval in
95 no)
96 UNIVERSALSDK=
97 enable_universalsdk=
98 ;;
99 *)
100 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000101 if test ! -d "${UNIVERSALSDK}"
102 then
103 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
104 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000105 ;;
106 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000107
Ronald Oussoren988117f2006-04-29 11:31:35 +0000108],[
109 UNIVERSALSDK=
110 enable_universalsdk=
111])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000112if test -n "${UNIVERSALSDK}"
113then
114 AC_MSG_RESULT(${UNIVERSALSDK})
115else
116 AC_MSG_RESULT(no)
117fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000118AC_SUBST(UNIVERSALSDK)
119
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000120AC_SUBST(ARCH_RUN_32BIT)
121
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000122UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000123AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000124AC_MSG_CHECKING(for --with-universal-archs)
125AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000126 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000127[
128 AC_MSG_RESULT($withval)
129 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000130 if test "${enable_universalsdk}" ; then
131 :
132 else
133 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
134 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000135],
136[
137 AC_MSG_RESULT(32-bit)
138])
139
140
141
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000142AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000143 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000144 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000145[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000146 if test "${enable_framework}"; then
147 :
148 else
149 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
150 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000151 PYTHONFRAMEWORK=${withval}
152 PYTHONFRAMEWORKDIR=${withval}.framework
153 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
154 ],[
155 PYTHONFRAMEWORK=Python
156 PYTHONFRAMEWORKDIR=Python.framework
157 PYTHONFRAMEWORKIDENTIFIER=org.python.python
158])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000159dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000160AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000161 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000162[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000163 case $enableval in
164 yes)
165 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000166 esac
167 case $enableval in
168 no)
169 PYTHONFRAMEWORK=
170 PYTHONFRAMEWORKDIR=no-framework
171 PYTHONFRAMEWORKPREFIX=
172 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000173 FRAMEWORKINSTALLFIRST=
174 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000175 FRAMEWORKALTINSTALLFIRST=
176 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000177 if test "x${prefix}" = "xNONE"; then
178 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
179 else
180 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
181 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000182 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000183 ;;
184 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000185 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000186 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000187 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000188 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000189 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
190 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000191 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000192
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000193 if test "x${prefix}" = "xNONE" ; then
194 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000195
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000196 else
197 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
198 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000199
200 case "${enableval}" in
201 /System*)
202 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
203 if test "${prefix}" = "NONE" ; then
204 # See below
205 FRAMEWORKUNIXTOOLSPREFIX="/usr"
206 fi
207 ;;
208
209 /Library*)
210 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
211 ;;
212
213 */Library/Frameworks)
214 MDIR="`dirname "${enableval}"`"
215 MDIR="`dirname "${MDIR}"`"
216 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
217
218 if test "${prefix}" = "NONE"; then
219 # User hasn't specified the
220 # --prefix option, but wants to install
221 # the framework in a non-default location,
222 # ensure that the compatibility links get
223 # installed relative to that prefix as well
224 # instead of in /usr/local.
225 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
226 fi
227 ;;
228
229 *)
230 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
231 ;;
232 esac
233
Jack Jansen127e56e2001-09-11 14:41:54 +0000234 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000235
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000236 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000237 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000238 AC_CONFIG_FILES(Mac/Makefile)
239 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
240 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000241 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
242 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000243 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000244 ],[
245 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000246 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000247 PYTHONFRAMEWORKPREFIX=
248 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000249 FRAMEWORKINSTALLFIRST=
250 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000251 FRAMEWORKALTINSTALLFIRST=
252 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000253 if test "x${prefix}" = "xNONE" ; then
254 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
255 else
256 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
257 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000258 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000259
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000260])
261AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000262AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000263AC_SUBST(PYTHONFRAMEWORKDIR)
264AC_SUBST(PYTHONFRAMEWORKPREFIX)
265AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000266AC_SUBST(FRAMEWORKINSTALLFIRST)
267AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000268AC_SUBST(FRAMEWORKALTINSTALLFIRST)
269AC_SUBST(FRAMEWORKALTINSTALLLAST)
270AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000271AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000272
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000273##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000274## AS_HELP_STRING([--with-dyld],
275## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000276##
Guido van Rossumb418f891996-07-30 18:06:02 +0000277# Set name for machine-dependent library files
278AC_SUBST(MACHDEP)
279AC_MSG_CHECKING(MACHDEP)
280if test -z "$MACHDEP"
281then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000282 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000283 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000284 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000285 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000286 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000287 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000288 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000289 ac_md_system=`echo $ac_sys_system |
290 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
291 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000292 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000293 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000294
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000295 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000296 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000297 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000298 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000299 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000300 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000301 esac
302fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000303
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000304# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
305# disable features if it is defined, without any means to access these
306# features as extensions. For these systems, we skip the definition of
307# _XOPEN_SOURCE. Before adding a system to the list to gain access to
308# some feature, make sure there is no alternative way to access this
309# feature. Also, when using wildcards, make sure you have verified the
310# need for not defining _XOPEN_SOURCE on all systems matching the
311# wildcard, and that the wildcard does not include future systems
312# (which may remove their limitations).
313dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
314case $ac_sys_system/$ac_sys_release in
315 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
316 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000317 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000318 # In addition, Stefan Krah confirms that issue #1244610 exists through
319 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200320 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000321 define_xopen_source=no
322 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
323 # also defined. This can be overridden by defining _BSD_SOURCE
324 # As this has a different meaning on Linux, only define it on OpenBSD
325 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
326 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200327 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000328 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
329 # also defined. This can be overridden by defining _BSD_SOURCE
330 # As this has a different meaning on Linux, only define it on OpenBSD
331 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
332 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000333 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
334 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
335 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000336 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000337 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000338 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
339 # request to enable features supported by the standard as a request
340 # to disable features not supported by the standard. The best way
341 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
342 # entirely and define __EXTENSIONS__ instead.
343 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000344 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000345 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
346 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000347 # Reconfirmed for 7.1.4 by Martin v. Loewis.
348 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000349 define_xopen_source=no;;
350 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000351 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000352 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000353 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000354 # On FreeBSD 4, the math functions C89 does not cover are never defined
355 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
356 FreeBSD/4.*)
357 define_xopen_source=no;;
358 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
359 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
360 # identifies itself as Darwin/7.*
361 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
362 # disables platform specific features beyond repair.
363 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
364 # has no effect, don't bother defining them
365 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000366 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000367 Darwin/1@<:@0-9@:>@.*)
368 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000369 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
370 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
371 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000372 AIX/4)
373 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000374 AIX/5)
375 if test `uname -r` -eq 1; then
376 define_xopen_source=no
377 fi
378 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000379 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
380 # defining NI_NUMERICHOST.
381 QNX/6.3.2)
382 define_xopen_source=no
383 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000384
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000385esac
386
387if test $define_xopen_source = yes
388then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000389 AC_DEFINE(_XOPEN_SOURCE, 600,
390 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000391
392 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
393 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
394 # several APIs are not declared. Since this is also needed in some
395 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000396 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
397 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000398
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000399 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
400
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000401fi
402
Guido van Rossum91922671997-10-09 20:24:13 +0000403#
404# SGI compilers allow the specification of the both the ABI and the
405# ISA on the command line. Depending on the values of these switches,
406# different and often incompatable code will be generated.
407#
408# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
409# thus supply support for various ABI/ISA combinations. The MACHDEP
410# variable is also adjusted.
411#
412AC_SUBST(SGI_ABI)
413if test ! -z "$SGI_ABI"
414then
415 CC="cc $SGI_ABI"
416 LDFLAGS="$SGI_ABI $LDFLAGS"
417 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
418fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000419AC_MSG_RESULT($MACHDEP)
420
Jack Jansen83f898c2002-12-30 22:23:40 +0000421# And add extra plat-mac for darwin
422AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000423AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000424AC_MSG_CHECKING(EXTRAPLATDIR)
425if test -z "$EXTRAPLATDIR"
426then
427 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000428 darwin)
429 EXTRAPLATDIR="\$(PLATMACDIRS)"
430 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
431 ;;
432 *)
433 EXTRAPLATDIR=""
434 EXTRAMACHDEPPATH=""
435 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000436 esac
437fi
438AC_MSG_RESULT($EXTRAPLATDIR)
439
Jack Jansen6b08a402004-06-03 12:41:45 +0000440# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
441# it may influence the way we can build extensions, so distutils
442# needs to check it
443AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000444AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000445CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000446EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000447
Mark Dickinson65134662008-04-25 16:11:04 +0000448AC_MSG_CHECKING(machine type as reported by uname -m)
449ac_sys_machine=`uname -m`
450AC_MSG_RESULT($ac_sys_machine)
451
Guido van Rossum627b2d71993-12-24 10:39:16 +0000452# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000453
454# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
455# for debug/optimization stuff. BASECFLAGS is for flags that are required
456# just to get things to compile and link. Users are free to override OPT
457# when running configure or make. The build should not break if they do.
458# BASECFLAGS should generally not be messed with, however.
459
460# XXX shouldn't some/most/all of this code be merged with the stuff later
461# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000462AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000463AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000464 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000465[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000466 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000467 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000468 without_gcc=yes;;
469 yes) CC=gcc
470 without_gcc=no;;
471 *) CC=$withval
472 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000473 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000474 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000475 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000476 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000477 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000478 case $BE_HOST_CPU in
479 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000480 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000481 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000482 BASECFLAGS="$BASECFLAGS -export pragma"
483 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000484 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000485 ;;
486 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000487 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000488 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000489 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000490 ;;
491 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000492 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000493 ;;
494 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000495 AR="\$(srcdir)/Modules/ar_beos"
496 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000497 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000498 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000499 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000500AC_MSG_RESULT($without_gcc)
501
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000502# If the user switches compilers, we can't believe the cache
503if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
504then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000505 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
506(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000507fi
508
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000509# If the user set CFLAGS, use this instead of the automatically
510# determined setting
511preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000512AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000513if test ! -z "$preset_cflags"
514then
515 CFLAGS=$preset_cflags
516fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000517
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000518AC_SUBST(CXX)
519AC_SUBST(MAINCC)
520AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
521AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000522 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000523 [compile main() and link python executable with C++ compiler]),
524[
525
526 case $withval in
527 no) with_cxx_main=no
528 MAINCC='$(CC)';;
529 yes) with_cxx_main=yes
530 MAINCC='$(CXX)';;
531 *) with_cxx_main=yes
532 MAINCC=$withval
533 if test -z "$CXX"
534 then
535 CXX=$withval
536 fi;;
537 esac], [
538 with_cxx_main=no
539 MAINCC='$(CC)'
540])
541AC_MSG_RESULT($with_cxx_main)
542
543preset_cxx="$CXX"
544if test -z "$CXX"
545then
546 case "$CC" in
547 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
548 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
549 esac
550 if test "$CXX" = "notfound"
551 then
552 CXX=""
553 fi
554fi
555if test -z "$CXX"
556then
557 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
558 if test "$CXX" = "notfound"
559 then
560 CXX=""
561 fi
562fi
563if test "$preset_cxx" != "$CXX"
564then
565 AC_MSG_WARN([
566
567 By default, distutils will build C++ extension modules with "$CXX".
568 If this is not intended, then set CXX on the configure command line.
569 ])
570fi
571
572
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000573# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000574AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000575
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000576# Check for unsupported systems
577case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000578atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000579 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
580 echo See README for details.
581 exit 1;;
582esac
583
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000584AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000585AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000586AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000587 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000588[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000589 case $withval in
590 no) EXEEXT=;;
591 yes) EXEEXT=.exe;;
592 *) EXEEXT=$withval;;
593 esac])
594AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000595
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000596# Test whether we're running on a non-case-sensitive system, in which
597# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000598AC_SUBST(BUILDEXEEXT)
599AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000600if test ! -d CaseSensitiveTestDir; then
601mkdir CaseSensitiveTestDir
602fi
603
604if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000605then
Jack Jansen1999ef42001-12-06 21:47:20 +0000606 AC_MSG_RESULT(yes)
607 BUILDEXEEXT=.exe
608else
609 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000610 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000611fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000612rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000613
Guido van Rossumdd997f71998-10-07 19:58:26 +0000614case $MACHDEP in
615bsdos*)
616 case $CC in
617 gcc) CC="$CC -D_HAVE_BSDI";;
618 esac;;
619esac
620
Guido van Rossum84561611997-08-21 00:08:11 +0000621case $ac_sys_system in
622hp*|HP*)
623 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000624 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000625 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000626SunOS*)
627 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000628 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000629 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000630esac
631
Martin v. Löwise8964d42001-03-06 12:09:07 +0000632
Neil Schemenauer61c51152001-01-26 16:18:16 +0000633AC_SUBST(LIBRARY)
634AC_MSG_CHECKING(LIBRARY)
635if test -z "$LIBRARY"
636then
637 LIBRARY='libpython$(VERSION).a'
638fi
639AC_MSG_RESULT($LIBRARY)
640
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000641# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000642# name of the library into which to insert object files). BLDLIBRARY is also
643# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
644# is blank as the main program is not linked directly against LDLIBRARY.
645# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
646# systems without shared libraries, LDLIBRARY is the same as LIBRARY
647# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
648# DLLLIBRARY is the shared (i.e., DLL) library.
649#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000650# RUNSHARED is used to run shared python without installed libraries
651#
652# INSTSONAME is the name of the shared library that will be use to install
653# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000654AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000655AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000656AC_SUBST(BLDLIBRARY)
657AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000658AC_SUBST(INSTSONAME)
659AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000660LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000661BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000662INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000663DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000664LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000665RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000666
Guido van Rossumfb842551997-08-06 23:42:07 +0000667# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000668# If CXX is set, and if it is needed to link a main function that was
669# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
670# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000671# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000672# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000673AC_SUBST(LINKCC)
674AC_MSG_CHECKING(LINKCC)
675if test -z "$LINKCC"
676then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000677 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000678 case $ac_sys_system in
679 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000680 exp_extra="\"\""
681 if test $ac_sys_release -ge 5 -o \
682 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
683 exp_extra="."
684 fi
685 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000686 QNX*)
687 # qcc must be used because the other compilers do not
688 # support -N.
689 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000690 esac
691fi
692AC_MSG_RESULT($LINKCC)
693
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000694# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
695# make sure we default having it set to "no": this is used by
696# distutils.unixccompiler to know if it should add --enable-new-dtags
697# to linker command lines, and failing to detect GNU ld simply results
698# in the same bahaviour as before.
699AC_SUBST(GNULD)
700AC_MSG_CHECKING(for GNU ld)
701ac_prog=ld
702if test "$GCC" = yes; then
703 ac_prog=`$CC -print-prog-name=ld`
704fi
705case `"$ac_prog" -V 2>&1 < /dev/null` in
706 *GNU*)
707 GNULD=yes;;
708 *)
709 GNULD=no;;
710esac
711AC_MSG_RESULT($GNULD)
712
Martin v. Löwis1142de32002-03-29 16:28:31 +0000713AC_MSG_CHECKING(for --enable-shared)
714AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000715 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000716
Martin v. Löwis1142de32002-03-29 16:28:31 +0000717if test -z "$enable_shared"
718then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000719 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000720 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000721 enable_shared="yes";;
722 *)
723 enable_shared="no";;
724 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000725fi
726AC_MSG_RESULT($enable_shared)
727
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000728AC_MSG_CHECKING(for --enable-profiling)
729AC_ARG_ENABLE(profiling,
Matthias Klose22520ea2010-05-08 10:14:46 +0000730 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000731[ac_save_cc="$CC"
732 CC="$CC -pg"
Matthias Klosec511b472010-05-08 11:01:39 +0000733 AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
734 [ac_enable_profiling="yes"],
735 [ac_enable_profiling="no"],
736 [ac_enable_profiling="no"])
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000737 CC="$ac_save_cc"])
738AC_MSG_RESULT($ac_enable_profiling)
739
740case "$ac_enable_profiling" in
741 "yes")
742 BASECFLAGS="-pg $BASECFLAGS"
743 LDFLAGS="-pg $LDFLAGS"
744 ;;
745esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000746
747AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000748
Guido van Rossumb8552162001-09-05 14:58:11 +0000749# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
750# library that we build, but we do not want to link against it (we
751# will find it with a -framework option). For this reason there is an
752# extra variable BLDLIBRARY against which Python and the extension
753# modules are linked, BLDLIBRARY. This is normally the same as
754# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000755if test "$enable_framework"
756then
757 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000758 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000759 BLDLIBRARY=''
760else
761 BLDLIBRARY='$(LDLIBRARY)'
762fi
763
Martin v. Löwis1142de32002-03-29 16:28:31 +0000764# Other platforms follow
765if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000766 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000767 case $ac_sys_system in
768 BeOS*)
769 LDLIBRARY='libpython$(VERSION).so'
770 ;;
771 CYGWIN*)
772 LDLIBRARY='libpython$(VERSION).dll.a'
773 DLLLIBRARY='libpython$(VERSION).dll'
774 ;;
775 SunOS*)
776 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000777 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000778 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000779 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000780 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200781 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000782 LDLIBRARY='libpython$(VERSION).so'
783 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000784 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000785 case $ac_sys_system in
786 FreeBSD*)
787 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
788 ;;
789 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000790 INSTSONAME="$LDLIBRARY".$SOVERSION
791 ;;
792 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000793 case `uname -m` in
794 ia64)
795 LDLIBRARY='libpython$(VERSION).so'
796 ;;
797 *)
798 LDLIBRARY='libpython$(VERSION).sl'
799 ;;
800 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000801 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000802 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000803 ;;
804 OSF*)
805 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000806 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000807 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000808 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000809 atheos*)
810 LDLIBRARY='libpython$(VERSION).so'
811 BLDLIBRARY='-L. -lpython$(VERSION)'
812 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
813 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000814 Darwin*)
815 LDLIBRARY='libpython$(VERSION).dylib'
816 BLDLIBRARY='-L. -lpython$(VERSION)'
817 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
818 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000819 AIX*)
820 LDLIBRARY='libpython$(VERSION).so'
821 RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
822 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000823
Martin v. Löwis1142de32002-03-29 16:28:31 +0000824 esac
Jason Tishler30765592003-09-04 11:04:06 +0000825else # shared is disabled
826 case $ac_sys_system in
827 CYGWIN*)
828 BLDLIBRARY='$(LIBRARY)'
829 LDLIBRARY='libpython$(VERSION).dll.a'
830 ;;
831 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000832fi
833
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000834AC_MSG_RESULT($LDLIBRARY)
835
Guido van Rossum627b2d71993-12-24 10:39:16 +0000836AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000837AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000838AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000839
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000840# tweak ARFLAGS only if the user didn't set it on the command line
841AC_SUBST(ARFLAGS)
842if test -z "$ARFLAGS"
843then
844 ARFLAGS="rc"
845fi
846
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000847AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000848AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000849if test $SVNVERSION = found
850then
851 SVNVERSION="svnversion \$(srcdir)"
852else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000853 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000854fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000855
Georg Brandl3a5508e2011-03-06 10:42:21 +0100856AC_SUBST(HGVERSION)
857AC_SUBST(HGTAG)
858AC_SUBST(HGBRANCH)
859AC_CHECK_PROG(HAS_HG, hg, found, not-found)
860if test $HAS_HG = found
861then
862 HGVERSION="hg id -i \$(srcdir)"
863 HGTAG="hg id -t \$(srcdir)"
864 HGBRANCH="hg id -b \$(srcdir)"
865else
866 HGVERSION=""
867 HGTAG=""
868 HGBRANCH=""
869fi
870
Neil Schemenauera42c8272001-03-31 00:01:55 +0000871case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000872bsdos*|hp*|HP*)
873 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000874 if test -z "$INSTALL"
875 then
876 INSTALL="${srcdir}/install-sh -c"
877 fi
878esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000879AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000880
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000881# Not every filesystem supports hard links
882AC_SUBST(LN)
883if test -z "$LN" ; then
884 case $ac_sys_system in
885 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000886 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000887 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000888 *) LN=ln;;
889 esac
890fi
891
Fred Drake9f715822001-07-11 06:27:00 +0000892# Check for --with-pydebug
893AC_MSG_CHECKING(for --with-pydebug)
894AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +0000895 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000896[
Fred Drake9f715822001-07-11 06:27:00 +0000897if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000898then
899 AC_DEFINE(Py_DEBUG, 1,
900 [Define if you want to build an interpreter with many run-time checks.])
901 AC_MSG_RESULT(yes);
902 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000903else AC_MSG_RESULT(no); Py_DEBUG='false'
904fi],
905[AC_MSG_RESULT(no)])
906
Skip Montanarodecc6a42003-01-01 20:07:49 +0000907# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
908# merged with this chunk of code?
909
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000910# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000911# ------------------------
912# (The following bit of code is complicated enough - please keep things
913# indented properly. Just pretend you're editing Python code. ;-)
914
915# There are two parallel sets of case statements below, one that checks to
916# see if OPT was set and one that does BASECFLAGS setting based upon
917# compiler and platform. BASECFLAGS tweaks need to be made even if the
918# user set OPT.
919
920# tweak OPT based on compiler and platform, only if the user didn't set
921# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000922AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +0000923if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000924then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000925 case $GCC in
926 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000927 if test "$CC" != 'g++' ; then
928 STRICT_PROTO="-Wstrict-prototypes"
929 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +0000930 # For gcc 4.x we need to use -fwrapv so lets check if its supported
931 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
932 WRAP="-fwrapv"
933 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000934 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000935 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000936 if test "$Py_DEBUG" = 'true' ; then
937 # Optimization messes up debuggers, so turn it off for
938 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +0000939 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000940 else
Guido van Rossum7c862f82007-12-13 20:50:10 +0000941 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000942 fi
943 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000944 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000945 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000946 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000947 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000948 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000949 SCO_SV*) OPT="$OPT -m486 -DSCO5"
950 ;;
951 esac
Fred Drake9f715822001-07-11 06:27:00 +0000952 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000953
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000954 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000955 OPT="-O"
956 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000957 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000958fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000959
Skip Montanarodecc6a42003-01-01 20:07:49 +0000960AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000961
962# The -arch flags for universal builds on OSX
963UNIVERSAL_ARCH_FLAGS=
964AC_SUBST(UNIVERSAL_ARCH_FLAGS)
965
Skip Montanarodecc6a42003-01-01 20:07:49 +0000966# tweak BASECFLAGS based on compiler and platform
967case $GCC in
968yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000969 # Python violates C99 rules, by casting between incompatible
970 # pointer types. GCC may generate bad code as a result of that,
971 # so use -fno-strict-aliasing if supported.
972 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
973 ac_save_cc="$CC"
974 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +0000975 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +0000976 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +0000977 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +0000978 [ac_cv_no_strict_aliasing_ok=yes],
979 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000980 CC="$ac_save_cc"
981 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
982 if test $ac_cv_no_strict_aliasing_ok = yes
983 then
984 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
985 fi
Mark Dickinson65134662008-04-25 16:11:04 +0000986
987 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
988 # support. Without this, treatment of subnormals doesn't follow
989 # the standard.
990 case $ac_sys_machine in
991 alpha*)
992 BASECFLAGS="$BASECFLAGS -mieee"
993 ;;
994 esac
995
Skip Montanarodecc6a42003-01-01 20:07:49 +0000996 case $ac_sys_system in
997 SCO_SV*)
998 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
999 ;;
1000 # is there any other compiler on Darwin besides gcc?
1001 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001002 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1003 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001004 if test "${CC}" = gcc
1005 then
1006 AC_MSG_CHECKING(which compiler should be used)
1007 case "${UNIVERSALSDK}" in
1008 */MacOSX10.4u.sdk)
1009 # Build using 10.4 SDK, force usage of gcc when the
1010 # compiler is gcc, otherwise the user will get very
1011 # confusing error messages when building on OSX 10.6
1012 CC=gcc-4.0
1013 CPP=cpp-4.0
1014 ;;
1015 esac
1016 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001017 fi
1018
Benjamin Peterson4347c442008-07-17 15:59:24 +00001019 # Calculate the right deployment target for this build.
1020 #
1021 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1022 if test ${cur_target} '>' 10.2; then
1023 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001024 if test ${enable_universalsdk}; then
1025 if test "${UNIVERSAL_ARCHS}" = "all"; then
1026 # Ensure that the default platform for a
1027 # 4-way universal build is OSX 10.5,
1028 # that's the first OS release where
1029 # 4-way builds make sense.
1030 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001031
1032 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1033 cur_target='10.5'
1034
1035 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1036 cur_target='10.5'
1037
1038 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1039 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001040 fi
1041 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001042 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001043 # On Intel macs default to a deployment
1044 # target of 10.4, that's the first OSX
1045 # release with Intel support.
1046 cur_target="10.4"
1047 fi
1048 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001049 fi
1050 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1051
1052 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1053 # environment with a value that is the same as what we'll use
1054 # in the Makefile to ensure that we'll get the same compiler
1055 # environment during configure and build time.
1056 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1057 export MACOSX_DEPLOYMENT_TARGET
1058 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1059
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001060 if test "${enable_universalsdk}"; then
1061 UNIVERSAL_ARCH_FLAGS=""
1062 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1063 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1064 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001065 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001066
1067 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1068 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1069 LIPO_32BIT_FLAGS=""
1070 ARCH_RUN_32BIT="true"
1071
1072 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1073 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1074 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001075 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001076
1077 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1078 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1079 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001080 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001081
1082 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1083 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1084 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001085 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001086
1087 else
1088 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1089
1090 fi
1091
1092
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001093 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1094 if test "${UNIVERSALSDK}" != "/"
1095 then
1096 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1097 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1098 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001099 fi
1100
1101 fi
1102
1103
Skip Montanarodecc6a42003-01-01 20:07:49 +00001104 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001105 OSF*)
1106 BASECFLAGS="$BASECFLAGS -mieee"
1107 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001108 esac
1109 ;;
1110
1111*)
1112 case $ac_sys_system in
1113 OpenUNIX*|UnixWare*)
1114 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1115 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001116 OSF*)
1117 BASECFLAGS="$BASECFLAGS -ieee -std"
1118 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001119 SCO_SV*)
1120 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1121 ;;
1122 esac
1123 ;;
1124esac
1125
Fred Drakee1ceaa02001-12-04 20:55:47 +00001126if test "$Py_DEBUG" = 'true'; then
1127 :
1128else
1129 OPT="-DNDEBUG $OPT"
1130fi
1131
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001132if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001133then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001134 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001135fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001136
Neal Norwitz020c46a2006-01-07 21:39:28 +00001137# disable check for icc since it seems to pass, but generates a warning
1138if test "$CC" = icc
1139then
1140 ac_cv_opt_olimit_ok=no
1141fi
1142
Guido van Rossum91922671997-10-09 20:24:13 +00001143AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1144AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1145[ac_save_cc="$CC"
1146CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001147AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001148 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001149 [ac_cv_opt_olimit_ok=yes],
1150 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001151 )
Guido van Rossum91922671997-10-09 20:24:13 +00001152CC="$ac_save_cc"])
1153AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001154if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001155 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001156 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1157 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1158 # environment?
1159 Darwin*)
1160 ;;
1161 *)
1162 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1163 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001164 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001165else
1166 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1167 AC_CACHE_VAL(ac_cv_olimit_ok,
1168 [ac_save_cc="$CC"
1169 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001170 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001171 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001172 [ac_cv_olimit_ok=yes],
1173 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001174 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001175 CC="$ac_save_cc"])
1176 AC_MSG_RESULT($ac_cv_olimit_ok)
1177 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001178 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001179 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001180fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001181
Martin v. Löwisaac13162006-10-19 10:58:46 +00001182# Check whether GCC supports PyArg_ParseTuple format
1183if test "$GCC" = "yes"
1184then
1185 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1186 save_CFLAGS=$CFLAGS
1187 CFLAGS="$CFLAGS -Werror"
Matthias Klosec511b472010-05-08 11:01:39 +00001188 AC_COMPILE_IFELSE([
1189 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1190 ],[
1191 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1192 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1193 AC_MSG_RESULT(yes)
1194 ],[
1195 AC_MSG_RESULT(no)
1196 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001197 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001198fi
1199
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001200# On some compilers, pthreads are available without further options
1201# (e.g. MacOS X). On some of these systems, the compiler will not
1202# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1203# So we have to see first whether pthreads are available without
1204# options before we can check whether -Kpthread improves anything.
1205AC_MSG_CHECKING(whether pthreads are available without options)
1206AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001207[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001208#include <pthread.h>
1209
1210void* routine(void* p){return NULL;}
1211
1212int main(){
1213 pthread_t p;
1214 if(pthread_create(&p,NULL,routine,NULL)!=0)
1215 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001216 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001217 return 0;
1218}
Matthias Klosec511b472010-05-08 11:01:39 +00001219]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001220 ac_cv_pthread_is_default=yes
1221 ac_cv_kthread=no
1222 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001223],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001224])
1225AC_MSG_RESULT($ac_cv_pthread_is_default)
1226
1227
1228if test $ac_cv_pthread_is_default = yes
1229then
1230 ac_cv_kpthread=no
1231else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001232# -Kpthread, if available, provides the right #defines
1233# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001234# Some compilers won't report that they do not support -Kpthread,
1235# so we need to run a program to see whether it really made the
1236# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001237AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1238AC_CACHE_VAL(ac_cv_kpthread,
1239[ac_save_cc="$CC"
1240CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001241AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001242#include <pthread.h>
1243
1244void* routine(void* p){return NULL;}
1245
1246int main(){
1247 pthread_t p;
1248 if(pthread_create(&p,NULL,routine,NULL)!=0)
1249 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001250 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001251 return 0;
1252}
Matthias Klosec511b472010-05-08 11:01:39 +00001253]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001254CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001255AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001256fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001257
Skip Montanarod8d39a02003-07-10 20:44:10 +00001258if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001259then
1260# -Kthread, if available, provides the right #defines
1261# and linker options to make pthread_create available
1262# Some compilers won't report that they do not support -Kthread,
1263# so we need to run a program to see whether it really made the
1264# function available.
1265AC_MSG_CHECKING(whether $CC accepts -Kthread)
1266AC_CACHE_VAL(ac_cv_kthread,
1267[ac_save_cc="$CC"
1268CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001269AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001270#include <pthread.h>
1271
1272void* routine(void* p){return NULL;}
1273
1274int main(){
1275 pthread_t p;
1276 if(pthread_create(&p,NULL,routine,NULL)!=0)
1277 return 1;
1278 (void)pthread_detach(p);
1279 return 0;
1280}
Matthias Klosec511b472010-05-08 11:01:39 +00001281]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001282CC="$ac_save_cc"])
1283AC_MSG_RESULT($ac_cv_kthread)
1284fi
1285
Skip Montanarod8d39a02003-07-10 20:44:10 +00001286if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001287then
1288# -pthread, if available, provides the right #defines
1289# and linker options to make pthread_create available
1290# Some compilers won't report that they do not support -pthread,
1291# so we need to run a program to see whether it really made the
1292# function available.
1293AC_MSG_CHECKING(whether $CC accepts -pthread)
1294AC_CACHE_VAL(ac_cv_thread,
1295[ac_save_cc="$CC"
1296CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001297AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001298#include <pthread.h>
1299
1300void* routine(void* p){return NULL;}
1301
1302int main(){
1303 pthread_t p;
1304 if(pthread_create(&p,NULL,routine,NULL)!=0)
1305 return 1;
1306 (void)pthread_detach(p);
1307 return 0;
1308}
Matthias Klosec511b472010-05-08 11:01:39 +00001309]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001310CC="$ac_save_cc"])
1311AC_MSG_RESULT($ac_cv_pthread)
1312fi
1313
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001314# If we have set a CC compiler flag for thread support then
1315# check if it works for CXX, too.
1316ac_cv_cxx_thread=no
1317if test ! -z "$CXX"
1318then
1319AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1320ac_save_cxx="$CXX"
1321
1322if test "$ac_cv_kpthread" = "yes"
1323then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001324 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001325 ac_cv_cxx_thread=yes
1326elif test "$ac_cv_kthread" = "yes"
1327then
1328 CXX="$CXX -Kthread"
1329 ac_cv_cxx_thread=yes
1330elif test "$ac_cv_pthread" = "yes"
1331then
1332 CXX="$CXX -pthread"
1333 ac_cv_cxx_thread=yes
1334fi
1335
1336if test $ac_cv_cxx_thread = yes
1337then
1338 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1339 $CXX -c conftest.$ac_ext 2>&5
1340 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1341 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1342 then
1343 ac_cv_cxx_thread=yes
1344 else
1345 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001346 fi
1347 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001348fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001349AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001350fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001351CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001352
Fred Drakece81d592000-07-09 14:39:29 +00001353dnl # check for ANSI or K&R ("traditional") preprocessor
1354dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001355dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001356dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1357dnl int foo;
1358dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001359dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001360dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001361
Guido van Rossum627b2d71993-12-24 10:39:16 +00001362# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001363AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001364AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1365fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001366ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001367shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001368unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001369sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1370sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001371sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001372sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001373sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis0347a9a2006-10-27 07:06:52 +00001374sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001375bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001376AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001377AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001378
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001379# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001380AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001381#ifdef HAVE_CURSES_H
1382#include <curses.h>
1383#endif
1384])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001385
Martin v. Löwis11017b12006-01-14 18:12:57 +00001386# On Linux, netlink.h requires asm/types.h
1387AC_CHECK_HEADERS(linux/netlink.h,,,[
1388#ifdef HAVE_ASM_TYPES_H
1389#include <asm/types.h>
1390#endif
1391#ifdef HAVE_SYS_SOCKET_H
1392#include <sys/socket.h>
1393#endif
1394])
1395
Guido van Rossum627b2d71993-12-24 10:39:16 +00001396# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001397was_it_defined=no
1398AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001399AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1400 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1401])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001402AC_MSG_RESULT($was_it_defined)
1403
Neal Norwitz11690112002-07-30 01:08:28 +00001404# Check whether using makedev requires defining _OSF_SOURCE
1405AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001406AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001407#if defined(MAJOR_IN_MKDEV)
1408#include <sys/mkdev.h>
1409#elif defined(MAJOR_IN_SYSMACROS)
1410#include <sys/sysmacros.h>
1411#else
1412#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001413#endif ]], [[ makedev(0, 0) ]])],
1414[ac_cv_has_makedev=yes],
1415[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001416if test "$ac_cv_has_makedev" = "no"; then
1417 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001418 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001419#define _OSF_SOURCE 1
1420#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001421 ]], [[ makedev(0, 0) ]])],
1422[ac_cv_has_makedev=yes],
1423[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001424 if test "$ac_cv_has_makedev" = "yes"; then
1425 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1426 fi
1427fi
1428AC_MSG_RESULT($ac_cv_has_makedev)
1429if test "$ac_cv_has_makedev" = "yes"; then
1430 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1431fi
1432
Martin v. Löwis399a6892002-10-04 10:22:02 +00001433# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1434# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1435# defined, but the compiler does not support pragma redefine_extname,
1436# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1437# structures (such as rlimit64) without declaring them. As a
1438# work-around, disable LFS on such configurations
1439
1440use_lfs=yes
1441AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001442AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001443#define _LARGEFILE_SOURCE 1
1444#define _FILE_OFFSET_BITS 64
1445#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001446]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001447AC_MSG_RESULT($sol_lfs_bug)
1448if test "$sol_lfs_bug" = "yes"; then
1449 use_lfs=no
1450fi
1451
1452if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001453# Two defines needed to enable largefile support on various platforms
1454# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001455case $ac_sys_system/$ac_sys_release in
1456AIX*)
1457 AC_DEFINE(_LARGE_FILES, 1,
1458 [This must be defined on AIX systems to enable large file support.])
1459 ;;
1460esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001461AC_DEFINE(_LARGEFILE_SOURCE, 1,
1462[This must be defined on some systems to enable large file support.])
1463AC_DEFINE(_FILE_OFFSET_BITS, 64,
1464[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001465fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001466
Guido van Rossum300fda71996-08-19 21:58:16 +00001467# Add some code to confdefs.h so that the test for off_t works on SCO
1468cat >> confdefs.h <<\EOF
1469#if defined(SCO_DS)
1470#undef _OFF_T
1471#endif
1472EOF
1473
Guido van Rossumef2255b2000-03-10 22:30:29 +00001474# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001475AC_TYPE_MODE_T
1476AC_TYPE_OFF_T
1477AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001478AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001479AC_TYPE_SIZE_T
1480AC_TYPE_UID_T
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001481AC_TYPE_UINT32_T
1482AC_TYPE_UINT64_T
1483AC_TYPE_INT32_T
1484AC_TYPE_INT64_T
Christian Heimes951cc0f2008-01-31 23:08:23 +00001485AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001486 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001487
Guido van Rossumef2255b2000-03-10 22:30:29 +00001488# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001489# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001490AC_CHECK_SIZEOF(int, 4)
1491AC_CHECK_SIZEOF(long, 4)
1492AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001493AC_CHECK_SIZEOF(short, 2)
1494AC_CHECK_SIZEOF(float, 4)
1495AC_CHECK_SIZEOF(double, 8)
1496AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001497AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001498AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001499
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001500AC_MSG_CHECKING(for long long support)
1501have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001502AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001503 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1504 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001505],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001506AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001507if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001508AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001509fi
1510
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001511AC_MSG_CHECKING(for long double support)
1512have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001513AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001514 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1515 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001516],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001517AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001518if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001519AC_CHECK_SIZEOF(long double, 12)
1520fi
1521
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001522AC_MSG_CHECKING(for _Bool support)
1523have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001524AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001525 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1526 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001527],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001528AC_MSG_RESULT($have_c99_bool)
1529if test "$have_c99_bool" = yes ; then
1530AC_CHECK_SIZEOF(_Bool, 1)
1531fi
1532
Martin v. Löwisebe26702006-10-02 14:55:51 +00001533AC_CHECK_TYPES(uintptr_t,
1534 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001535 [], [#ifdef HAVE_STDINT_H
1536 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001537 #endif
1538 #ifdef HAVE_INTTYPES_H
1539 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001540 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001541
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001542AC_CHECK_SIZEOF(off_t, [], [
1543#ifdef HAVE_SYS_TYPES_H
1544#include <sys/types.h>
1545#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001546])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001547
1548AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001549if test "$have_long_long" = yes
1550then
1551if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001552 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001553 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1554 [Defined to enable large file support when an off_t is bigger than a long
1555 and long long is available and at least as big as an off_t. You may need
1556 to add some flags for configuration and compilation to enable this mode.
1557 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001558 AC_MSG_RESULT(yes)
1559else
1560 AC_MSG_RESULT(no)
1561fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001562else
1563 AC_MSG_RESULT(no)
1564fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001565
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001566AC_CHECK_SIZEOF(time_t, [], [
1567#ifdef HAVE_SYS_TYPES_H
1568#include <sys/types.h>
1569#endif
1570#ifdef HAVE_TIME_H
1571#include <time.h>
1572#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001573])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001574
Trent Mick635f6fb2000-08-23 21:33:05 +00001575# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001576ac_save_cc="$CC"
1577if test "$ac_cv_kpthread" = "yes"
1578then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001579elif test "$ac_cv_kthread" = "yes"
1580then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001581elif test "$ac_cv_pthread" = "yes"
1582then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001583fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001584AC_MSG_CHECKING(for pthread_t)
1585have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001586AC_COMPILE_IFELSE([
1587 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1588],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001589AC_MSG_RESULT($have_pthread_t)
1590if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001591 AC_CHECK_SIZEOF(pthread_t, [], [
1592#ifdef HAVE_PTHREAD_H
1593#include <pthread.h>
1594#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001595 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001596fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001597CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001598
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001599AC_MSG_CHECKING(for --enable-toolbox-glue)
1600AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001601 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001602
1603if test -z "$enable_toolbox_glue"
1604then
1605 case $ac_sys_system/$ac_sys_release in
1606 Darwin/*)
1607 enable_toolbox_glue="yes";;
1608 *)
1609 enable_toolbox_glue="no";;
1610 esac
1611fi
1612case "$enable_toolbox_glue" in
1613yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001614 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001615 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001616 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1617 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001618 ;;
1619*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001620 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001621 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001622 ;;
1623esac
1624AC_MSG_RESULT($enable_toolbox_glue)
1625
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001626
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001627AC_SUBST(OTHER_LIBTOOL_OPT)
1628case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001629 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001630 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1631 ;;
1632 Darwin/*)
1633 OTHER_LIBTOOL_OPT=""
1634 ;;
1635esac
1636
Ronald Oussoren25967582009-09-06 10:00:26 +00001637
1638ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001639AC_SUBST(LIBTOOL_CRUFT)
1640case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001641 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001642 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1643 if test "${enable_universalsdk}"; then
1644 :
1645 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001646 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001647 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001648 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001649 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001650 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001651 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001652 if test ${gcc_version} '<' 4.0
1653 then
1654 LIBTOOL_CRUFT="-lcc_dynamic"
1655 else
1656 LIBTOOL_CRUFT=""
1657 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001658 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001659 #include <unistd.h>
1660 int main(int argc, char*argv[])
1661 {
1662 if (sizeof(long) == 4) {
1663 return 0;
1664 } else {
1665 return 1;
1666 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001667 }
Matthias Klosec511b472010-05-08 11:01:39 +00001668 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001669
1670 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001671 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001672 i386)
1673 MACOSX_DEFAULT_ARCH="i386"
1674 ;;
1675 ppc)
1676 MACOSX_DEFAULT_ARCH="ppc"
1677 ;;
1678 *)
1679 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1680 ;;
1681 esac
1682 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001683 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001684 i386)
1685 MACOSX_DEFAULT_ARCH="x86_64"
1686 ;;
1687 ppc)
1688 MACOSX_DEFAULT_ARCH="ppc64"
1689 ;;
1690 *)
1691 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1692 ;;
1693 esac
1694
1695 #ARCH_RUN_32BIT="true"
1696 fi
1697
1698 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001699 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001700 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001701esac
1702
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001703AC_MSG_CHECKING(for --enable-framework)
1704if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001705then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001706 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001707 # -F. is needed to allow linking to the framework while
1708 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001709 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1710 [Define if you want to produce an OpenStep/Rhapsody framework
1711 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001712 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001713 if test $enable_shared = "yes"
1714 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001715 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
Ronald Oussoren450d5612009-06-08 21:12:41 +00001716 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001717else
1718 AC_MSG_RESULT(no)
1719fi
1720
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001721AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001722case $ac_sys_system/$ac_sys_release in
1723 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001724 AC_DEFINE(WITH_DYLD, 1,
1725 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1726 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1727 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001728 AC_MSG_RESULT(always on for Darwin)
1729 ;;
1730 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001731 AC_MSG_RESULT(no)
1732 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001733esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001734
Guido van Rossumac405f61994-09-12 10:56:06 +00001735# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001736AC_SUBST(SO)
1737AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001738AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001739AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001740AC_SUBST(CCSHARED)
1741AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001742# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001743# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001744AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001745if test -z "$SO"
1746then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001747 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001748 hp*|HP*)
1749 case `uname -m` in
1750 ia64) SO=.so;;
1751 *) SO=.sl;;
1752 esac
1753 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001754 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001755 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001756 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001757else
1758 # this might also be a termcap variable, see #610332
1759 echo
1760 echo '====================================================================='
1761 echo '+ +'
1762 echo '+ WARNING: You have set SO in your environment. +'
1763 echo '+ Do you really mean to change the extension for shared libraries? +'
1764 echo '+ Continuing in 10 seconds to let you to ponder. +'
1765 echo '+ +'
1766 echo '====================================================================='
1767 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001768fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001769AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001770
Neal Norwitz58e28882006-05-19 07:00:58 +00001771AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001772# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001773# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001774# (Shared libraries in this instance are shared modules to be loaded into
1775# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001776AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001777if test -z "$LDSHARED"
1778then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001779 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001780 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001781 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001782 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001783 ;;
1784 BeOS*)
1785 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001786 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001787 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001788 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001789 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001790 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001791 if test "$GCC" = "yes" ; then
1792 LDSHARED='$(CC) -shared'
1793 LDCXXSHARED='$(CXX) -shared'
1794 else
1795 LDSHARED='$(CC) -G'
1796 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001797 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001798 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001799 if test "$GCC" = "yes" ; then
1800 LDSHARED='$(CC) -shared'
1801 LDCXXSHARED='$(CXX) -shared'
1802 else
1803 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001804 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001805 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001806 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001807 LDSHARED='$(CC) -bundle'
1808 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001809 if test "$enable_framework" ; then
1810 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001811 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1812 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001813 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001814 else
1815 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001816 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001817 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001818 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001819 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001820 LDSHARED='$(CC) -bundle'
1821 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001822 if test "$enable_framework" ; then
1823 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001824 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1825 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001826 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001827 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001828 # No framework, use the Python app as bundle-loader
1829 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001830 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001831 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001832 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001833 Darwin/*)
1834 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1835 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001836
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001837 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001838 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001839 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001840 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001841 fi
Stefan Krah3a3e2032010-11-28 15:30:05 +00001842 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
1843 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001844 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001845 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00001846 LDSHARED='$(CC) -bundle'
1847 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001848 if test "$enable_framework" ; then
1849 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001850 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1851 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001852 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001853 else
1854 # No framework, use the Python app as bundle-loader
1855 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1856 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001857 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001858 fi
1859 fi
1860 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001861 Linux*|GNU*|QNX*)
1862 LDSHARED='$(CC) -shared'
1863 LDCXXSHARED='$(CXX) -shared';;
1864 BSD/OS*/4*)
1865 LDSHARED="gcc -shared"
1866 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001867 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001868 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001869 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00001870 LDSHARED='$(CC) -shared'
1871 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001872 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00001873 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001874 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001875 OpenBSD*)
1876 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1877 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00001878 LDSHARED='$(CC) -shared $(CCSHARED)'
1879 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001880 else
1881 case `uname -r` in
1882 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1883 LDSHARED="ld -Bshareable ${LDFLAGS}"
1884 ;;
1885 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001886 LDSHARED='$(CC) -shared $(CCSHARED)'
1887 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001888 ;;
1889 esac
1890 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001891 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00001892 LDSHARED='$(CC) -shared'
1893 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001894 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001895 if test "$GCC" = "yes" ; then
1896 LDSHARED='$(CC) -shared'
1897 LDCXXSHARED='$(CXX) -shared'
1898 else
1899 LDSHARED='$(CC) -G'
1900 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001901 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001902 SCO_SV*)
1903 LDSHARED='$(CC) -Wl,-G,-Bexport'
1904 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1905 CYGWIN*)
1906 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1907 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
1908 atheos*)
1909 LDSHARED="gcc -shared"
1910 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001911 *) LDSHARED="ld";;
1912 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001913fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001914AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001915LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001916BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001917# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001918# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001919AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001920if test -z "$CCSHARED"
1921then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001922 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001923 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00001924 then CCSHARED="-fPIC";
1925 elif test `uname -p` = sparc;
1926 then CCSHARED="-xcode=pic32";
1927 else CCSHARED="-Kpic";
1928 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001929 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001930 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001931 else CCSHARED="+z";
1932 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001933 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001934 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001935 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001936 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001937 if test "$GCC" = "yes"
1938 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001939 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001940 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001941 SCO_SV*)
1942 if test "$GCC" = "yes"
1943 then CCSHARED="-fPIC"
1944 else CCSHARED="-Kpic -belf"
1945 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001946 IRIX*/6*) case $CC in
1947 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001948 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001949 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001950 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001951 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001952fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001953AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001954# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001955# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001956AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001957if test -z "$LINKFORSHARED"
1958then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001959 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001960 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001961 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001962 LINKFORSHARED="-Wl,-E -Wl,+s";;
1963# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001964 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001965 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001966 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001967 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001968 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1969 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001970 # not used by the core itself but which needs to be in the core so
1971 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001972 # -prebind is no longer used, because it actually seems to give a
1973 # slowdown in stead of a speedup, maybe due to the large number of
1974 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001975
1976 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001977 if test "$enable_framework"
1978 then
Jack Jansenda49e192005-01-07 13:08:22 +00001979 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001980 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001981 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001982 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001983 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001984 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001985 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001986 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1987 then
1988 LINKFORSHARED="-Wl,--export-dynamic"
1989 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001990 SunOS/5*) case $CC in
1991 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001992 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001993 then
1994 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001995 fi;;
1996 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001997 CYGWIN*)
1998 if test $enable_shared = "no"
1999 then
2000 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2001 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002002 QNX*)
2003 # -Wl,-E causes the symbols to be added to the dynamic
2004 # symbol table so that they can be found when a module
2005 # is loaded. -N 2048K causes the stack size to be set
2006 # to 2048 kilobytes so that the stack doesn't overflow
2007 # when running test_compile.py.
2008 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002009 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002010fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002011AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002012
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002013
Neil Schemenauer61c51152001-01-26 16:18:16 +00002014AC_SUBST(CFLAGSFORSHARED)
2015AC_MSG_CHECKING(CFLAGSFORSHARED)
2016if test ! "$LIBRARY" = "$LDLIBRARY"
2017then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002018 case $ac_sys_system in
2019 CYGWIN*)
2020 # Cygwin needs CCSHARED when building extension DLLs
2021 # but not when building the interpreter DLL.
2022 CFLAGSFORSHARED='';;
2023 *)
2024 CFLAGSFORSHARED='$(CCSHARED)'
2025 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002026fi
2027AC_MSG_RESULT($CFLAGSFORSHARED)
2028
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002029# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2030# library (with --enable-shared).
2031# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002032# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2033# if it is not required, since it creates a dependency of the shared library
2034# to LIBS. This, in turn, means that applications linking the shared libpython
2035# don't need to link LIBS explicitly. The default should be only changed
2036# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002037AC_SUBST(SHLIBS)
2038AC_MSG_CHECKING(SHLIBS)
2039case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002040 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002041 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002042esac
2043AC_MSG_RESULT($SHLIBS)
2044
2045
Guido van Rossum627b2d71993-12-24 10:39:16 +00002046# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002047AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2048AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002049
Skip Montanaro4d756af2008-12-01 01:55:22 +00002050# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002051if test "$with_threads" = "yes" -o -z "$with_threads"; then
2052 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2053 # posix4 on Solaris 2.6
2054 # pthread (first!) on Linux
2055fi
2056
Martin v. Löwis19d17342003-06-14 21:03:05 +00002057# check if we need libintl for locale functions
2058AC_CHECK_LIB(intl, textdomain,
2059 AC_DEFINE(WITH_LIBINTL, 1,
2060 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002061
2062# checks for system dependent C++ extensions support
2063case "$ac_sys_system" in
2064 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002065 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002066 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002067 [[loadAndInit("", 0, "")]])
2068 ],[
2069 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002070 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2071 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002072 AC_MSG_RESULT(yes)
2073 ],[
2074 AC_MSG_RESULT(no)
2075 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002076 *) ;;
2077esac
2078
Guido van Rossum70c7f481998-03-26 18:44:10 +00002079# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002080# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002081AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002082AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002083
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002084case "$ac_sys_system" in
2085BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002086AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2087;;
2088esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002089
Guido van Rossumc5a39031996-07-31 17:35:03 +00002090AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002091AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002092 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002093[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002094AC_MSG_RESULT($withval)
2095LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002096],
2097[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002098
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002099AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2100
Benjamin Peterson2c196742009-12-31 03:17:18 +00002101# Check for use of the system expat library
2102AC_MSG_CHECKING(for --with-system-expat)
2103AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002104 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2105 [],
2106 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002107
2108AC_MSG_RESULT($with_system_expat)
2109
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002110# Check for use of the system libffi library
2111AC_MSG_CHECKING(for --with-system-ffi)
2112AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002113 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2114 [],
2115 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002116
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002117if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002118 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2119else
2120 LIBFFI_INCLUDEDIR=""
2121fi
2122AC_SUBST(LIBFFI_INCLUDEDIR)
2123
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002124AC_MSG_RESULT($with_system_ffi)
2125
Matthias Klose10cbe482009-04-29 17:18:19 +00002126# Check for --with-dbmliborder
2127AC_MSG_CHECKING(for --with-dbmliborder)
2128AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002129 AS_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'.]),
Matthias Klose10cbe482009-04-29 17:18:19 +00002130[
2131if test x$with_dbmliborder = xyes
2132then
2133AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2134else
2135 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2136 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2137 then
2138 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2139 fi
2140 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002141fi])
2142AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002143
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002144# Determine if signalmodule should be used.
2145AC_SUBST(USE_SIGNAL_MODULE)
2146AC_SUBST(SIGNAL_OBJS)
2147AC_MSG_CHECKING(for --with-signal-module)
2148AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002149 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002150
2151if test -z "$with_signal_module"
2152then with_signal_module="yes"
2153fi
2154AC_MSG_RESULT($with_signal_module)
2155
2156if test "${with_signal_module}" = "yes"; then
2157 USE_SIGNAL_MODULE=""
2158 SIGNAL_OBJS=""
2159else
2160 USE_SIGNAL_MODULE="#"
2161 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2162fi
2163
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002164# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002165AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002166USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002167
Guido van Rossum54d93d41997-01-22 20:51:58 +00002168AC_MSG_CHECKING(for --with-dec-threads)
2169AC_SUBST(LDLAST)
2170AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002171 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002172[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002173AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002174LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002175if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002176 with_thread="$withval";
2177fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002178[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002179
Martin v. Löwis11437992002-04-12 09:54:03 +00002180# Templates for things AC_DEFINEd more than once.
2181# For a single AC_DEFINE, no template is needed.
2182AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2183AH_TEMPLATE(_REENTRANT,
2184 [Define to force use of thread-safe errno, h_errno, and other functions])
2185AH_TEMPLATE(WITH_THREAD,
2186 [Define if you want to compile in rudimentary thread support])
2187
Guido van Rossum54d93d41997-01-22 20:51:58 +00002188AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002189dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002190AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002191 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002192
Barry Warsawc0d24d82000-06-29 16:12:00 +00002193# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002194dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002195AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002196 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002197 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002198
2199if test -z "$with_threads"
2200then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002201fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002202AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002203
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002204AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002205if test "$with_threads" = "no"
2206then
2207 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002208elif test "$ac_cv_pthread_is_default" = yes
2209then
2210 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002211 # Defining _REENTRANT on system with POSIX threads should not hurt.
2212 AC_DEFINE(_REENTRANT)
2213 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002214 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002215elif test "$ac_cv_kpthread" = "yes"
2216then
2217 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002218 if test "$ac_cv_cxx_thread" = "yes"; then
2219 CXX="$CXX -Kpthread"
2220 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002221 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002222 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002223 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002224elif test "$ac_cv_kthread" = "yes"
2225then
2226 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002227 if test "$ac_cv_cxx_thread" = "yes"; then
2228 CXX="$CXX -Kthread"
2229 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002230 AC_DEFINE(WITH_THREAD)
2231 posix_threads=yes
2232 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002233elif test "$ac_cv_pthread" = "yes"
2234then
2235 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002236 if test "$ac_cv_cxx_thread" = "yes"; then
2237 CXX="$CXX -pthread"
2238 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002239 AC_DEFINE(WITH_THREAD)
2240 posix_threads=yes
2241 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002242else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002243 if test ! -z "$with_threads" -a -d "$with_threads"
2244 then LDFLAGS="$LDFLAGS -L$with_threads"
2245 fi
2246 if test ! -z "$withval" -a -d "$withval"
2247 then LDFLAGS="$LDFLAGS -L$withval"
2248 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002249
2250 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002251 # define _POSIX_THREADS in unistd.h. Some apparently don't
2252 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002253 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2254 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002255 [
2256#include <unistd.h>
2257#ifdef _POSIX_THREADS
2258yes
2259#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002260 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2261 AC_MSG_RESULT($unistd_defines_pthreads)
2262
Martin v. Löwis130fb172001-07-19 11:00:41 +00002263 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002264 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2265 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002266 AC_DEFINE(HURD_C_THREADS, 1,
2267 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002268 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002269 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002270 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2271 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002272 AC_DEFINE(MACH_C_THREADS, 1,
2273 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002274 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002275 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002276 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002277 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002278 [AC_MSG_RESULT($withval)
2279 AC_DEFINE([WITH_THREAD])
2280 AC_DEFINE([HAVE_PTH], 1,
2281 [Define if you have GNU PTH threads.])
2282 LIBS="-lpth $LIBS"
2283 THREADOBJ="Python/thread.o"],
2284 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002285
2286 # Just looking for pthread_create in libpthread is not enough:
2287 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2288 # So we really have to include pthread.h, and then link.
2289 _libs=$LIBS
2290 LIBS="$LIBS -lpthread"
2291 AC_MSG_CHECKING([for pthread_create in -lpthread])
Matthias Klosec511b472010-05-08 11:01:39 +00002292 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002293
Matthias Klosec511b472010-05-08 11:01:39 +00002294void * start_routine (void *arg) { exit (0); }]], [[
2295pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002296 AC_MSG_RESULT(yes)
2297 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002298 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002299 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002300 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002301 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002302 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002303 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002304 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2305 AC_DEFINE(ATHEOS_THREADS, 1,
2306 [Define this if you have AtheOS threads.])
2307 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002308 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002309 AC_DEFINE(BEOS_THREADS, 1,
2310 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002311 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002312 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002313 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002314 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002315 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002316 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002317 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002318 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002319 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002320 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002321 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002322 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002323 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002324 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002325 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002326 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002327 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002328 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002329 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002330
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002331 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2332 LIBS="$LIBS -lmpc"
2333 THREADOBJ="Python/thread.o"
2334 USE_THREAD_MODULE=""])
2335
2336 if test "$posix_threads" != "yes"; then
2337 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2338 LIBS="$LIBS -lthread"
2339 THREADOBJ="Python/thread.o"
2340 USE_THREAD_MODULE=""])
2341 fi
2342
2343 if test "$USE_THREAD_MODULE" != "#"
2344 then
2345 # If the above checks didn't disable threads, (at least) OSF1
2346 # needs this '-threads' argument during linking.
2347 case $ac_sys_system in
2348 OSF1) LDLAST=-threads;;
2349 esac
2350 fi
2351fi
2352
2353if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002354 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002355 AC_DEFINE(_POSIX_THREADS, 1,
2356 [Define if you have POSIX threads,
2357 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002358 fi
2359
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002360 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2361 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002362 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002363 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002364 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002365 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002366 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002367 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002368 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002369 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002370 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002371 esac
2372
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002373 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2374 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Matthias Klosec511b472010-05-08 11:01:39 +00002375 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002376 void *foo(void *parm) {
2377 return NULL;
2378 }
2379 main() {
2380 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002381 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002382 if (pthread_attr_init(&attr)) exit(-1);
2383 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002384 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002385 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002386 }]])],
2387 [ac_cv_pthread_system_supported=yes],
2388 [ac_cv_pthread_system_supported=no],
2389 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002390 ])
2391 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2392 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002393 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002394 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002395 AC_CHECK_FUNCS(pthread_sigmask,
2396 [case $ac_sys_system in
2397 CYGWIN*)
2398 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2399 [Define if pthread_sigmask() does not work on your system.])
2400 ;;
2401 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002402fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002403
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002404
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002405# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002406AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002407AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002408AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002409[ --enable-ipv6 Enable ipv6 (with ipv4) support
2410 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002411[ case "$enableval" in
2412 no)
2413 AC_MSG_RESULT(no)
2414 ipv6=no
2415 ;;
2416 *) AC_MSG_RESULT(yes)
2417 AC_DEFINE(ENABLE_IPV6)
2418 ipv6=yes
2419 ;;
2420 esac ],
2421
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002422[
2423dnl the check does not work on cross compilation case...
Matthias Klosec511b472010-05-08 11:01:39 +00002424 AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002425#include <sys/types.h>
2426#include <sys/socket.h>
2427main()
2428{
2429 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2430 exit(1);
2431 else
2432 exit(0);
2433}
Matthias Klosec511b472010-05-08 11:01:39 +00002434]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002435 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002436 ipv6=yes
2437],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002438 AC_MSG_RESULT(no)
2439 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002440],[
2441 AC_MSG_RESULT(no)
2442 ipv6=no
2443])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002444
2445if test "$ipv6" = "yes"; then
2446 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002447 AC_COMPILE_IFELSE([
2448 AC_LANG_PROGRAM([[#include <sys/types.h>
2449#include <netinet/in.h>]],
2450 [[struct sockaddr_in6 x;
2451 x.sin6_scope_id;]])
2452 ],[
2453 AC_MSG_RESULT(yes)
2454 ipv6=yes
2455 ],[
2456 AC_MSG_RESULT(no, IPv6 disabled)
2457 ipv6=no
2458 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002459fi
2460
2461if test "$ipv6" = "yes"; then
2462 AC_DEFINE(ENABLE_IPV6)
2463fi
2464])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002465
2466ipv6type=unknown
2467ipv6lib=none
2468ipv6trylibc=no
2469
2470if test "$ipv6" = "yes"; then
2471 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002472 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2473 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002474 case $i in
2475 inria)
2476 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002477 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002478#include <netinet/in.h>
2479#ifdef IPV6_INRIA_VERSION
2480yes
2481#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002482 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002483 ;;
2484 kame)
2485 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002486 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002487#include <netinet/in.h>
2488#ifdef __KAME__
2489yes
2490#endif],
2491 [ipv6type=$i;
2492 ipv6lib=inet6
2493 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002494 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002495 ;;
2496 linux-glibc)
2497 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002498 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002499#include <features.h>
2500#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2501yes
2502#endif],
2503 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002504 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002505 ;;
2506 linux-inet6)
2507 dnl http://www.v6.linux.or.jp/
2508 if test -d /usr/inet6; then
2509 ipv6type=$i
2510 ipv6lib=inet6
2511 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002512 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002513 fi
2514 ;;
2515 solaris)
2516 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002517 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002518 ipv6type=$i
2519 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002520 fi
2521 fi
2522 ;;
2523 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002524 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002525#include <sys/param.h>
2526#ifdef _TOSHIBA_INET6
2527yes
2528#endif],
2529 [ipv6type=$i;
2530 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002531 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002532 ;;
2533 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002534 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002535#include </usr/local/v6/include/sys/v6config.h>
2536#ifdef __V6D__
2537yes
2538#endif],
2539 [ipv6type=$i;
2540 ipv6lib=v6;
2541 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002542 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002543 ;;
2544 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002545 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002546#include <sys/param.h>
2547#ifdef _ZETA_MINAMI_INET6
2548yes
2549#endif],
2550 [ipv6type=$i;
2551 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002552 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002553 ;;
2554 esac
2555 if test "$ipv6type" != "unknown"; then
2556 break
2557 fi
2558 done
2559 AC_MSG_RESULT($ipv6type)
2560fi
2561
2562if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2563 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2564 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2565 echo "using lib$ipv6lib"
2566 else
2567 if test $ipv6trylibc = "yes"; then
2568 echo "using libc"
2569 else
2570 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2571 echo "You need to fetch lib$ipv6lib.a from appropriate"
2572 echo 'ipv6 kit and compile beforehand.'
2573 exit 1
2574 fi
2575 fi
2576fi
2577
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002578AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002579AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002580 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002581],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002582 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002583 AC_MSG_RESULT(yes)
2584],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002585 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002586])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002587
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002588# Check for --with-doc-strings
2589AC_MSG_CHECKING(for --with-doc-strings)
2590AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002591 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002592
2593if test -z "$with_doc_strings"
2594then with_doc_strings="yes"
2595fi
2596if test "$with_doc_strings" != "no"
2597then
2598 AC_DEFINE(WITH_DOC_STRINGS, 1,
2599 [Define if you want documentation strings in extension modules])
2600fi
2601AC_MSG_RESULT($with_doc_strings)
2602
Neil Schemenauera35c6882001-02-27 04:45:05 +00002603# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002604AC_MSG_CHECKING(for --with-tsc)
2605AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002606 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002607if test "$withval" != no
2608then
2609 AC_DEFINE(WITH_TSC, 1,
2610 [Define to profile with the Pentium timestamp counter])
2611 AC_MSG_RESULT(yes)
2612else AC_MSG_RESULT(no)
2613fi],
2614[AC_MSG_RESULT(no)])
2615
2616# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002617AC_MSG_CHECKING(for --with-pymalloc)
2618AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002619 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002620
2621if test -z "$with_pymalloc"
2622then with_pymalloc="yes"
2623fi
2624if test "$with_pymalloc" != "no"
2625then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002626 AC_DEFINE(WITH_PYMALLOC, 1,
2627 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002628fi
2629AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002630
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002631# Check for Valgrind support
2632AC_MSG_CHECKING([for --with-valgrind])
2633AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002634 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002635 with_valgrind=no)
2636AC_MSG_RESULT([$with_valgrind])
2637if test "$with_valgrind" != no; then
2638 AC_CHECK_HEADER([valgrind/valgrind.h],
2639 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2640 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2641 )
2642fi
2643
Barry Warsawef82cd72000-06-30 16:21:01 +00002644# Check for --with-wctype-functions
2645AC_MSG_CHECKING(for --with-wctype-functions)
2646AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002647 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002648[
Barry Warsawef82cd72000-06-30 16:21:01 +00002649if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002650then
2651 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2652 [Define if you want wctype.h functions to be used instead of the
2653 one supplied by Python itself. (see Include/unicodectype.h).])
2654 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002655else AC_MSG_RESULT(no)
2656fi],
2657[AC_MSG_RESULT(no)])
2658
Guido van Rossum68242b51996-05-28 22:53:03 +00002659# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002660AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002661DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002662
Guido van Rossume97ee181999-12-20 21:27:22 +00002663# the dlopen() function means we might want to use dynload_shlib.o. some
2664# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002665AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002666
2667# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2668# loading of modules.
2669AC_SUBST(DYNLOADFILE)
2670AC_MSG_CHECKING(DYNLOADFILE)
2671if test -z "$DYNLOADFILE"
2672then
2673 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002674 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2675 if test "$ac_cv_func_dlopen" = yes
2676 then DYNLOADFILE="dynload_shlib.o"
2677 else DYNLOADFILE="dynload_aix.o"
2678 fi
2679 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002680 BeOS*) DYNLOADFILE="dynload_beos.o";;
2681 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002682 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2683 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002684 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002685 *)
2686 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2687 # out any dynamic loading
2688 if test "$ac_cv_func_dlopen" = yes
2689 then DYNLOADFILE="dynload_shlib.o"
2690 else DYNLOADFILE="dynload_stub.o"
2691 fi
2692 ;;
2693 esac
2694fi
2695AC_MSG_RESULT($DYNLOADFILE)
2696if test "$DYNLOADFILE" != "dynload_stub.o"
2697then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002698 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2699 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002700fi
2701
Jack Jansenc49e5b72001-06-19 15:00:23 +00002702# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2703
2704AC_SUBST(MACHDEP_OBJS)
2705AC_MSG_CHECKING(MACHDEP_OBJS)
2706if test -z "$MACHDEP_OBJS"
2707then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002708 MACHDEP_OBJS=$extra_machdep_objs
2709else
2710 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002711fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002712AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002713
Guido van Rossum627b2d71993-12-24 10:39:16 +00002714# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002715AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2716 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002717 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002718 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitrou30b3b352009-12-02 20:37:54 +00002719 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002720 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002721 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002722 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2723 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002724 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002725 setlocale setregid setreuid setresuid setresgid \
2726 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002727 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002728 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002729 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002730
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002731# For some functions, having a definition is not sufficient, since
2732# we want to take their address.
2733AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002734AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2735 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2736 AC_MSG_RESULT(yes)],
2737 [AC_MSG_RESULT(no)
2738])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002739AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002740AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2741 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2742 AC_MSG_RESULT(yes)],
2743 [AC_MSG_RESULT(no)
2744])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002745AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002746AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2747 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2748 AC_MSG_RESULT(yes)],
2749 [AC_MSG_RESULT(no)
2750])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002751AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002752AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2753 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2754 AC_MSG_RESULT(yes)],
2755 [AC_MSG_RESULT(no)
2756])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002757AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002758AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2759 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2760 AC_MSG_RESULT(yes)],
2761 [AC_MSG_RESULT(no)
2762])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002763AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002764AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2765 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2766 AC_MSG_RESULT(yes)],
2767 [AC_MSG_RESULT(no)
2768])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002769AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002770AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2771 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2772 AC_MSG_RESULT(yes)],
2773 [AC_MSG_RESULT(no)
2774])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002775AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002776AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002777#include <sys/types.h>
2778#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002779 ]], [[int x=kqueue()]])],
2780 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2781 AC_MSG_RESULT(yes)],
2782 [AC_MSG_RESULT(no)
2783])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002784# On some systems (eg. FreeBSD 5), we would find a definition of the
2785# functions ctermid_r, setgroups in the library, but no prototype
2786# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2787# address to avoid compiler warnings and potential miscompilations
2788# because of the missing prototypes.
2789
2790AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002791AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002792#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002793]], [[void* p = ctermid_r]])],
2794 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2795 AC_MSG_RESULT(yes)],
2796 [AC_MSG_RESULT(no)
2797])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002798
Antoine Pitroub170f172010-09-10 18:47:36 +00002799AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2800 [AC_COMPILE_IFELSE(
2801 [AC_LANG_PROGRAM(
2802 [#include <sys/file.h>],
2803 [void* p = flock]
2804 )],
2805 [ac_cv_flock_decl=yes],
2806 [ac_cv_flock_decl=no]
2807 )
Matthias Klosec511b472010-05-08 11:01:39 +00002808])
Antoine Pitroub170f172010-09-10 18:47:36 +00002809if test "x${ac_cv_flock_decl}" = xyes; then
2810 AC_CHECK_FUNCS(flock,,
2811 AC_CHECK_LIB(bsd,flock,
2812 [AC_DEFINE(HAVE_FLOCK)
2813 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2814 ])
2815 )
Antoine Pitrou85729812010-09-07 14:55:24 +00002816fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002817
2818AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00002819AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002820#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002821]], [[void* p = getpagesize]])],
2822 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2823 AC_MSG_RESULT(yes)],
2824 [AC_MSG_RESULT(no)
2825])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002826
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002827dnl check for true
2828AC_CHECK_PROGS(TRUE, true, /bin/true)
2829
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002830dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2831dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002832AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002833 AC_CHECK_LIB(resolv, inet_aton)
2834)
2835
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002836# On Tru64, chflags seems to be present, but calling it will
2837# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00002838AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07002839AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002840#include <sys/stat.h>
2841#include <unistd.h>
2842int main(int argc, char*argv[])
2843{
2844 if(chflags(argv[0], 0) != 0)
2845 return 1;
2846 return 0;
2847}
Ned Deily43e10542011-06-27 23:41:53 -07002848]])],
Matthias Klosec511b472010-05-08 11:01:39 +00002849[ac_cv_have_chflags=yes],
2850[ac_cv_have_chflags=no],
2851[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00002852])
2853if test "$ac_cv_have_chflags" = cross ; then
2854 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2855fi
2856if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07002857 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002858fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002859
Gregory P. Smithbb213892009-11-02 01:37:37 +00002860AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07002861AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002862#include <sys/stat.h>
2863#include <unistd.h>
2864int main(int argc, char*argv[])
2865{
2866 if(lchflags(argv[0], 0) != 0)
2867 return 1;
2868 return 0;
2869}
Ned Deily43e10542011-06-27 23:41:53 -07002870]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00002871])
2872if test "$ac_cv_have_lchflags" = cross ; then
2873 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2874fi
2875if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07002876 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002877fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002878
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002879dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00002880dnl
2881dnl On MacOSX the linker will search for dylibs on the entire linker path
2882dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2883dnl to revert to a more traditional unix behaviour and make it possible to
2884dnl override the system libz with a local static library of libz. Temporarily
2885dnl add that flag to our CFLAGS as well to ensure that we check the version
2886dnl of libz that will be used by setup.py.
2887dnl The -L/usr/local/lib is needed as wel to get the same compilation
2888dnl environment as setup.py (and leaving it out can cause configure to use the
2889dnl wrong version of the library)
2890case $ac_sys_system/$ac_sys_release in
2891Darwin/*)
2892 _CUR_CFLAGS="${CFLAGS}"
2893 _CUR_LDFLAGS="${LDFLAGS}"
2894 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2895 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2896 ;;
2897esac
2898
Matthias Klose5183ebd2010-04-24 16:38:36 +00002899AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002900
Ronald Oussorenf8752642006-07-06 10:13:35 +00002901case $ac_sys_system/$ac_sys_release in
2902Darwin/*)
2903 CFLAGS="${_CUR_CFLAGS}"
2904 LDFLAGS="${_CUR_LDFLAGS}"
2905 ;;
2906esac
2907
Martin v. Löwise9416172003-05-03 10:12:45 +00002908AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00002909AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00002910#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002911]], [[void* p = hstrerror; hstrerror(0)]])],
2912 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2913 AC_MSG_RESULT(yes)],
2914 [AC_MSG_RESULT(no)
2915])
Martin v. Löwise9416172003-05-03 10:12:45 +00002916
2917AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00002918AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00002919#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002920#include <sys/socket.h>
2921#include <netinet/in.h>
2922#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002923]], [[void* p = inet_aton;inet_aton(0,0)]])],
2924 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2925 AC_MSG_RESULT(yes)],
2926 [AC_MSG_RESULT(no)
2927])
Martin v. Löwise9416172003-05-03 10:12:45 +00002928
2929AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00002930AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002931#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002932#include <sys/socket.h>
2933#include <netinet/in.h>
2934#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002935]], [[void* p = inet_pton]])],
2936 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2937 AC_MSG_RESULT(yes)],
2938 [AC_MSG_RESULT(no)
2939])
Martin v. Löwise9416172003-05-03 10:12:45 +00002940
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002941# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002942AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00002943AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002944#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002945#ifdef HAVE_GRP_H
2946#include <grp.h>
2947#endif
Matthias Klosec511b472010-05-08 11:01:39 +00002948]], [[void* p = setgroups]])],
2949 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2950 AC_MSG_RESULT(yes)],
2951 [AC_MSG_RESULT(no)
2952])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002953
Fred Drake8cef4cf2000-06-28 16:40:38 +00002954# check for openpty and forkpty
2955
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002956AC_CHECK_FUNCS(openpty,,
2957 AC_CHECK_LIB(util,openpty,
2958 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2959 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2960 )
2961)
2962AC_CHECK_FUNCS(forkpty,,
2963 AC_CHECK_LIB(util,forkpty,
2964 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2965 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2966 )
2967)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002968
Brett Cannonaa5778d2008-03-18 04:09:00 +00002969# Stuff for expat.
2970AC_CHECK_FUNCS(memmove)
2971
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002972# check for long file support functions
2973AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2974
Brett Cannonaa5778d2008-03-18 04:09:00 +00002975AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002976AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00002977 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
2978 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
2979 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002980)
Jack Jansen150753c2003-03-29 22:07:47 +00002981AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00002982 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
2983 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
2984 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002985)
2986AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00002987 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
2988 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
2989 [],
2990 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2991 [Define if gettimeofday() does not have second (timezone) argument
2992 This is the case on Motorola V4 (R40V4.2)])
2993 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002994)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002995
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002996AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00002997AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002998#if defined(MAJOR_IN_MKDEV)
2999#include <sys/mkdev.h>
3000#elif defined(MAJOR_IN_SYSMACROS)
3001#include <sys/sysmacros.h>
3002#else
3003#include <sys/types.h>
3004#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003005]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003006 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003007]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003008 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3009 [Define to 1 if you have the device macros.])
3010 AC_MSG_RESULT(yes)
3011],[
3012 AC_MSG_RESULT(no)
3013])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003014
3015# On OSF/1 V5.1, getaddrinfo is available, but a define
3016# for [no]getaddrinfo in netdb.h.
3017AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003018AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003019#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003020#include <sys/socket.h>
3021#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003022#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003023]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3024[have_getaddrinfo=yes],
3025[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003026AC_MSG_RESULT($have_getaddrinfo)
3027if test $have_getaddrinfo = yes
3028then
3029 AC_MSG_CHECKING(getaddrinfo bug)
3030 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003031 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003032#include <sys/types.h>
3033#include <netdb.h>
3034#include <string.h>
3035#include <sys/socket.h>
3036#include <netinet/in.h>
3037
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003038int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003039{
3040 int passive, gaierr, inet4 = 0, inet6 = 0;
3041 struct addrinfo hints, *ai, *aitop;
3042 char straddr[INET6_ADDRSTRLEN], strport[16];
3043
3044 for (passive = 0; passive <= 1; passive++) {
3045 memset(&hints, 0, sizeof(hints));
3046 hints.ai_family = AF_UNSPEC;
3047 hints.ai_flags = passive ? AI_PASSIVE : 0;
3048 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003049 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003050 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3051 (void)gai_strerror(gaierr);
3052 goto bad;
3053 }
3054 for (ai = aitop; ai; ai = ai->ai_next) {
3055 if (ai->ai_addr == NULL ||
3056 ai->ai_addrlen == 0 ||
3057 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3058 straddr, sizeof(straddr), strport, sizeof(strport),
3059 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3060 goto bad;
3061 }
3062 switch (ai->ai_family) {
3063 case AF_INET:
3064 if (strcmp(strport, "54321") != 0) {
3065 goto bad;
3066 }
3067 if (passive) {
3068 if (strcmp(straddr, "0.0.0.0") != 0) {
3069 goto bad;
3070 }
3071 } else {
3072 if (strcmp(straddr, "127.0.0.1") != 0) {
3073 goto bad;
3074 }
3075 }
3076 inet4++;
3077 break;
3078 case AF_INET6:
3079 if (strcmp(strport, "54321") != 0) {
3080 goto bad;
3081 }
3082 if (passive) {
3083 if (strcmp(straddr, "::") != 0) {
3084 goto bad;
3085 }
3086 } else {
3087 if (strcmp(straddr, "::1") != 0) {
3088 goto bad;
3089 }
3090 }
3091 inet6++;
3092 break;
3093 case AF_UNSPEC:
3094 goto bad;
3095 break;
3096 default:
3097 /* another family support? */
3098 break;
3099 }
3100 }
3101 }
3102
3103 if (!(inet4 == 0 || inet4 == 2))
3104 goto bad;
3105 if (!(inet6 == 0 || inet6 == 2))
3106 goto bad;
3107
3108 if (aitop)
3109 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003110 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003111
3112 bad:
3113 if (aitop)
3114 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003115 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003116}
Matthias Klosec511b472010-05-08 11:01:39 +00003117]]])],
3118[ac_cv_buggy_getaddrinfo=no],
3119[ac_cv_buggy_getaddrinfo=yes],
3120[ac_cv_buggy_getaddrinfo=yes]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003121fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003122
Benjamin Peterson75fed812010-11-01 01:47:19 +00003123AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3124
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003125if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003126then
3127 if test $ipv6 = yes
3128 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003129 echo 'Fatal: You must get working getaddrinfo() function.'
3130 echo ' or you can specify "--disable-ipv6"'.
3131 exit 1
3132 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003133else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003134 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003135fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003136
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003137AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003138
Guido van Rossum627b2d71993-12-24 10:39:16 +00003139# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003140AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003141AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003142AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003143AC_CHECK_MEMBERS([struct stat.st_rdev])
3144AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003145AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003146AC_CHECK_MEMBERS([struct stat.st_gen])
3147AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003148AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003149
3150AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003151AC_CACHE_VAL(ac_cv_header_time_altzone,[
3152 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3153 [ac_cv_header_time_altzone=yes],
3154 [ac_cv_header_time_altzone=no])
3155 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003156AC_MSG_RESULT($ac_cv_header_time_altzone)
3157if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003158 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003159fi
3160
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003161was_it_defined=no
3162AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003163AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003164#include <sys/types.h>
3165#include <sys/select.h>
3166#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003167]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003168 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3169 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3170 (which you can't on SCO ODT 3.0).])
3171 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003172],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003173AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003174
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003175AC_MSG_CHECKING(for addrinfo)
3176AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003177AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3178 [ac_cv_struct_addrinfo=yes],
3179 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003180AC_MSG_RESULT($ac_cv_struct_addrinfo)
3181if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003182 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003183fi
3184
3185AC_MSG_CHECKING(for sockaddr_storage)
3186AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003187AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003188# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003189# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3190 [ac_cv_struct_sockaddr_storage=yes],
3191 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003192AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3193if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003194 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003195fi
3196
Guido van Rossum627b2d71993-12-24 10:39:16 +00003197# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003198
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003199AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003200AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003201
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003202works=no
3203AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003204AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3205 [works=yes],
3206 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003207)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003208AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003209
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003210works=no
3211AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003212AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3213 [works=yes],
3214 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003215)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003216AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003217
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003218have_prototypes=no
3219AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003220AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3221 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3222 [Define if your compiler supports function prototype])
3223 have_prototypes=yes],
3224 []
3225)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003226AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003227
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003228works=no
3229AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003230AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003231#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003232int foo(int x, ...) {
3233 va_list va;
3234 va_start(va, x);
3235 va_arg(va, int);
3236 va_arg(va, char *);
3237 va_arg(va, double);
3238 return 0;
3239}
Matthias Klosec511b472010-05-08 11:01:39 +00003240]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003241 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3242 [Define if your compiler supports variable length function prototypes
3243 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3244 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003245],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003246AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003247
Dave Cole331708b2004-08-09 04:51:41 +00003248# check for socketpair
3249AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003250AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003251#include <sys/types.h>
3252#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003253]], [[void *x=socketpair]])],
3254 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3255 AC_MSG_RESULT(yes)],
3256 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003257)
3258
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003259# check if sockaddr has sa_len member
3260AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003261AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3262#include <sys/socket.h>]], [[struct sockaddr x;
3263x.sa_len = 0;]])],
3264 [AC_MSG_RESULT(yes)
3265 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3266 [AC_MSG_RESULT(no)]
3267)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003268
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003269va_list_is_array=no
3270AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003271AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003272#ifdef HAVE_STDARG_PROTOTYPES
3273#include <stdarg.h>
3274#else
3275#include <varargs.h>
3276#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003277]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003278 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3279 va_list_is_array=yes
3280])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003281AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003282
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003283# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003284AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3285 [Define this if you have some version of gethostbyname_r()])
3286
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003287AC_CHECK_FUNC(gethostbyname_r, [
3288 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3289 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3290 OLD_CFLAGS=$CFLAGS
3291 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003292 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003293# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003294 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003295 char *name;
3296 struct hostent *he, *res;
3297 char buffer[2048];
3298 int buflen = 2048;
3299 int h_errnop;
3300
3301 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003302 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003303 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003304 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3305 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003306 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003307 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003308 AC_MSG_RESULT(no)
3309 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003311# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003312 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003313 char *name;
3314 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003315 char buffer[2048];
3316 int buflen = 2048;
3317 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003318
Matthias Klosec511b472010-05-08 11:01:39 +00003319 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3320 ]])],
3321 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003322 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003323 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3324 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003325 AC_MSG_RESULT(yes)
3326 ], [
3327 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003328 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3329 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3330# include <netdb.h>
3331 ]], [[
3332 char *name;
3333 struct hostent *he;
3334 struct hostent_data data;
3335
3336 (void) gethostbyname_r(name, he, &data);
3337 ]])],
3338 [
3339 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3340 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3341 [Define this if you have the 3-arg version of gethostbyname_r().])
3342 AC_MSG_RESULT(yes)
3343 ], [
3344 AC_MSG_RESULT(no)
3345 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003346 ])
3347 ])
3348 CFLAGS=$OLD_CFLAGS
3349], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003350 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003351])
3352AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3353AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3354AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003355AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003356AC_SUBST(HAVE_GETHOSTBYNAME)
3357
Guido van Rossum627b2d71993-12-24 10:39:16 +00003358# checks for system services
3359# (none yet)
3360
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003361# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003362AC_CHECK_FUNC(__fpu_control,
3363 [],
3364 [AC_CHECK_LIB(ieee, __fpu_control)
3365])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003366
Guido van Rossum93274221997-05-09 02:42:00 +00003367# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003368AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003369AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003370 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003371[
Guido van Rossum93274221997-05-09 02:42:00 +00003372if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003373then
3374 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3375 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3376 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003377else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003378fi],
3379[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003380
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003381# check for --with-libm=...
3382AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003383case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003384Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003385BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003386*) LIBM=-lm
3387esac
Guido van Rossum93274221997-05-09 02:42:00 +00003388AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003389AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003390 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003391[
Guido van Rossum93274221997-05-09 02:42:00 +00003392if test "$withval" = no
3393then LIBM=
3394 AC_MSG_RESULT(force LIBM empty)
3395elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003396then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003397 AC_MSG_RESULT(set LIBM="$withval")
3398else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003399fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003400[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003401
3402# check for --with-libc=...
3403AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003404AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003405AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003406 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003407[
Guido van Rossum93274221997-05-09 02:42:00 +00003408if test "$withval" = no
3409then LIBC=
3410 AC_MSG_RESULT(force LIBC empty)
3411elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003412then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003413 AC_MSG_RESULT(set LIBC="$withval")
3414else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003415fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003416[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003417
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003418# **************************************************
3419# * Check for various properties of floating point *
3420# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003421
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003422AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3423AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003424AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003425#include <string.h>
3426int main() {
3427 double x = 9006104071832581.0;
3428 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3429 return 0;
3430 else
3431 return 1;
3432}
Matthias Klosec511b472010-05-08 11:01:39 +00003433]])],
3434[ac_cv_little_endian_double=yes],
3435[ac_cv_little_endian_double=no],
3436[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003437AC_MSG_RESULT($ac_cv_little_endian_double)
3438if test "$ac_cv_little_endian_double" = yes
3439then
3440 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3441 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3442 with the least significant byte first])
3443fi
3444
3445AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3446AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003447AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003448#include <string.h>
3449int main() {
3450 double x = 9006104071832581.0;
3451 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3452 return 0;
3453 else
3454 return 1;
3455}
Matthias Klosec511b472010-05-08 11:01:39 +00003456]])],
3457[ac_cv_big_endian_double=yes],
3458[ac_cv_big_endian_double=no],
3459[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003460AC_MSG_RESULT($ac_cv_big_endian_double)
3461if test "$ac_cv_big_endian_double" = yes
3462then
3463 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3464 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3465 with the most significant byte first])
3466fi
3467
3468# Some ARM platforms use a mixed-endian representation for doubles.
3469# While Python doesn't currently have full support for these platforms
3470# (see e.g., issue 1762561), we can at least make sure that float <-> string
3471# conversions work.
3472AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3473AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003474AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003475#include <string.h>
3476int main() {
3477 double x = 9006104071832581.0;
3478 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3479 return 0;
3480 else
3481 return 1;
3482}
Matthias Klosec511b472010-05-08 11:01:39 +00003483]])],
3484[ac_cv_mixed_endian_double=yes],
3485[ac_cv_mixed_endian_double=no],
3486[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003487AC_MSG_RESULT($ac_cv_mixed_endian_double)
3488if test "$ac_cv_mixed_endian_double" = yes
3489then
3490 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3491 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3492 in ARM mixed-endian order (byte order 45670123)])
3493fi
3494
3495# The short float repr introduced in Python 3.1 requires the
3496# correctly-rounded string <-> double conversion functions from
3497# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3498# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003499# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003500# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003501
3502# This inline assembler syntax may also work for suncc and icc,
3503# so we try it on all platforms.
3504
3505AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003506AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003507 unsigned short cw;
3508 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3509 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003510]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003511AC_MSG_RESULT($have_gcc_asm_for_x87)
3512if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003513then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003514 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3515 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003516fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003517
Mark Dickinson04b27232009-01-04 12:29:36 +00003518# Detect whether system arithmetic is subject to x87-style double
3519# rounding issues. The result of this test has little meaning on non
3520# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3521# mode is round-to-nearest and double rounding issues are present, and
3522# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3523AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003524# $BASECFLAGS may affect the result
3525ac_save_cc="$CC"
3526CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003527AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003528#include <stdlib.h>
3529#include <math.h>
3530int main() {
3531 volatile double x, y, z;
3532 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3533 x = 0.99999999999999989; /* 1-2**-53 */
3534 y = 1./x;
3535 if (y != 1.)
3536 exit(0);
3537 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3538 x = 1e16;
3539 y = 2.99999;
3540 z = x + y;
3541 if (z != 1e16+4.)
3542 exit(0);
3543 /* both tests show evidence of double rounding */
3544 exit(1);
3545}
Matthias Klosec511b472010-05-08 11:01:39 +00003546]])],
3547[ac_cv_x87_double_rounding=no],
3548[ac_cv_x87_double_rounding=yes],
3549[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003550CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003551AC_MSG_RESULT($ac_cv_x87_double_rounding)
3552if test "$ac_cv_x87_double_rounding" = yes
3553then
3554 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3555 [Define if arithmetic is subject to x87-style double rounding issue])
3556fi
3557
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003558# ************************************
3559# * Check for mathematical functions *
3560# ************************************
3561
3562LIBS_SAVE=$LIBS
3563LIBS="$LIBS $LIBM"
3564
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003565# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3566# -0. on some architectures.
3567AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3568AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003569AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003570#include <math.h>
3571#include <stdlib.h>
3572int main() {
3573 /* return 0 if either negative zeros don't exist
3574 on this platform or if negative zeros exist
3575 and tanh(-0.) == -0. */
3576 if (atan2(0., -1.) == atan2(-0., -1.) ||
3577 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3578 else exit(1);
3579}
Matthias Klosec511b472010-05-08 11:01:39 +00003580]])],
3581[ac_cv_tanh_preserves_zero_sign=yes],
3582[ac_cv_tanh_preserves_zero_sign=no],
3583[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003584AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3585if test "$ac_cv_tanh_preserves_zero_sign" = yes
3586then
3587 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3588 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3589fi
3590
3591AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3592AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3593AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3594
3595LIBS=$LIBS_SAVE
3596
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003597# For multiprocessing module, check that sem_open
3598# actually works. For FreeBSD versions <= 7.2,
3599# the kernel module that provides POSIX semaphores
3600# isn't loaded by default, so an attempt to call
3601# sem_open results in a 'Signal 12' error.
3602AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3603AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003604AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003605#include <unistd.h>
3606#include <fcntl.h>
3607#include <stdio.h>
3608#include <semaphore.h>
3609#include <sys/stat.h>
3610
3611int main(void) {
3612 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3613 if (a == SEM_FAILED) {
3614 perror("sem_open");
3615 return 1;
3616 }
3617 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003618 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003619 return 0;
3620}
Matthias Klosec511b472010-05-08 11:01:39 +00003621]])],
3622[ac_cv_posix_semaphores_enabled=yes],
3623[ac_cv_posix_semaphores_enabled=no],
3624[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003625)
3626AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3627if test $ac_cv_posix_semaphores_enabled = no
3628then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003629 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3630 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003631fi
3632
Jesse Noller355b1262009-04-02 00:03:28 +00003633# Multiprocessing check for broken sem_getvalue
3634AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003635AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003636AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003637#include <unistd.h>
3638#include <fcntl.h>
3639#include <stdio.h>
3640#include <semaphore.h>
3641#include <sys/stat.h>
3642
3643int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003644 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003645 int count;
3646 int res;
3647 if(a==SEM_FAILED){
3648 perror("sem_open");
3649 return 1;
3650
3651 }
3652 res = sem_getvalue(a, &count);
3653 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003654 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003655 return res==-1 ? 1 : 0;
3656}
Matthias Klosec511b472010-05-08 11:01:39 +00003657]])],
3658[ac_cv_broken_sem_getvalue=no],
3659[ac_cv_broken_sem_getvalue=yes],
3660[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003661)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003662AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3663if test $ac_cv_broken_sem_getvalue = yes
3664then
3665 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3666 [define to 1 if your sem_getvalue is broken.])
3667fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003668
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003669# determine what size digit to use for Python's longs
3670AC_MSG_CHECKING([digit size for Python's longs])
3671AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003672AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003673[case $enable_big_digits in
3674yes)
3675 enable_big_digits=30 ;;
3676no)
3677 enable_big_digits=15 ;;
3678[15|30])
3679 ;;
3680*)
3681 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3682esac
3683AC_MSG_RESULT($enable_big_digits)
3684AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3685],
3686[AC_MSG_RESULT(no value specified)])
3687
Guido van Rossumef2255b2000-03-10 22:30:29 +00003688# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003689AC_CHECK_HEADER(wchar.h, [
3690 AC_DEFINE(HAVE_WCHAR_H, 1,
3691 [Define if the compiler provides a wchar.h header file.])
3692 wchar_h="yes"
3693],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003694wchar_h="no"
3695)
3696
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003697# determine wchar_t size
3698if test "$wchar_h" = yes
3699then
Guido van Rossum67b26592001-10-20 14:21:45 +00003700 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003701fi
3702
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003703AC_MSG_CHECKING(for UCS-4 tcl)
3704have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003705AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003706#include <tcl.h>
3707#if TCL_UTF_MAX != 6
3708# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003709#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003710 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3711 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003712],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003713AC_MSG_RESULT($have_ucs4_tcl)
3714
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003715# check whether wchar_t is signed or not
3716if test "$wchar_h" = yes
3717then
3718 # check whether wchar_t is signed or not
3719 AC_MSG_CHECKING(whether wchar_t is signed)
3720 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003721 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003722 #include <wchar.h>
3723 int main()
3724 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003725 /* Success: exit code 0 */
3726 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003727 }
Matthias Klosec511b472010-05-08 11:01:39 +00003728 ]])],
3729 [ac_cv_wchar_t_signed=yes],
3730 [ac_cv_wchar_t_signed=no],
3731 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003732 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3733fi
3734
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003735AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003736dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003737AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003738 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003739 [],
3740 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003741
3742if test $enable_unicode = yes
3743then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003744 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003745 case "$have_ucs4_tcl" in
3746 yes) enable_unicode="ucs4"
3747 ;;
3748 *) enable_unicode="ucs2"
3749 ;;
3750 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003751fi
3752
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003753AH_TEMPLATE(Py_UNICODE_SIZE,
3754 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003755case "$enable_unicode" in
3756ucs2) unicode_size="2"
3757 AC_DEFINE(Py_UNICODE_SIZE,2)
3758 ;;
3759ucs4) unicode_size="4"
3760 AC_DEFINE(Py_UNICODE_SIZE,4)
3761 ;;
Ezio Melotti5820efb2010-02-27 00:05:42 +00003762*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003763esac
3764
Martin v. Löwis11437992002-04-12 09:54:03 +00003765AH_TEMPLATE(PY_UNICODE_TYPE,
3766 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003767
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003768AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003769if test "$enable_unicode" = "no"
3770then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003771 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003772 AC_MSG_RESULT(not used)
3773else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003774 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003775 AC_DEFINE(Py_USING_UNICODE, 1,
3776 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003777
3778 # wchar_t is only usable if it maps to an unsigned type
3779 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003780 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003781 then
3782 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003783 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3784 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003785 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003786 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003787 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3788 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3789 then
3790 PY_UNICODE_TYPE="unsigned short"
3791 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3792 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3793 then
3794 PY_UNICODE_TYPE="unsigned long"
3795 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3796 else
3797 PY_UNICODE_TYPE="no type found"
3798 fi
3799 AC_MSG_RESULT($PY_UNICODE_TYPE)
3800fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003801
3802# check for endianness
3803AC_C_BIGENDIAN
3804
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003805# Check whether right shifting a negative integer extends the sign bit
3806# or fills with zeros (like the Cray J90, according to Tim Peters).
3807AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003808AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003809AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003810int main()
3811{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003812 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003813}
Matthias Klosec511b472010-05-08 11:01:39 +00003814]])],
3815[ac_cv_rshift_extends_sign=yes],
3816[ac_cv_rshift_extends_sign=no],
3817[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003818AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3819if test "$ac_cv_rshift_extends_sign" = no
3820then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003821 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3822 [Define if i>>j for signed int i does not extend the sign bit
3823 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003824fi
3825
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003826# check for getc_unlocked and related locking functions
3827AC_MSG_CHECKING(for getc_unlocked() and friends)
3828AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00003829AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003830 FILE *f = fopen("/dev/null", "r");
3831 flockfile(f);
3832 getc_unlocked(f);
3833 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00003834]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003835AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3836if test "$ac_cv_have_getc_unlocked" = yes
3837then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003838 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3839 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003840fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003841
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003842# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003843# save the value of LIBS so we don't actually link Python with readline
3844LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003845
3846# On some systems we need to link readline to a termcap compatible
3847# library. NOTE: Keep the precedence of listed libraries synchronised
3848# with setup.py.
3849py_cv_lib_readline=no
3850AC_MSG_CHECKING([how to link readline libs])
3851for py_libtermcap in "" ncursesw ncurses curses termcap; do
3852 if test -z "$py_libtermcap"; then
3853 READLINE_LIBS="-lreadline"
3854 else
3855 READLINE_LIBS="-lreadline -l$py_libtermcap"
3856 fi
3857 LIBS="$READLINE_LIBS $LIBS_no_readline"
3858 AC_LINK_IFELSE(
3859 [AC_LANG_CALL([],[readline])],
3860 [py_cv_lib_readline=yes])
3861 if test $py_cv_lib_readline = yes; then
3862 break
3863 fi
3864done
3865# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3866#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00003867if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003868 AC_MSG_RESULT([none])
3869else
3870 AC_MSG_RESULT([$READLINE_LIBS])
3871 AC_DEFINE(HAVE_LIBREADLINE, 1,
3872 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003873fi
3874
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003875# check for readline 2.1
3876AC_CHECK_LIB(readline, rl_callback_handler_install,
3877 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003878 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003879
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003880# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00003881AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3882 [have_readline=yes],
3883 [have_readline=no]
3884)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003885if test $have_readline = yes
3886then
3887 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3888 [readline/readline.h],
3889 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3890 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00003891 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3892 [readline/readline.h],
3893 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3894 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003895fi
3896
Martin v. Löwis0daad592001-09-30 21:09:59 +00003897# check for readline 4.0
3898AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003899 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003900 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003901
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003902# also in 4.0
3903AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3904 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003905 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003906
Guido van Rossum353ae582001-07-10 16:45:32 +00003907# check for readline 4.2
3908AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003909 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003910 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003911
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003912# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00003913AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3914 [have_readline=yes],
3915 [have_readline=no]
3916)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003917if test $have_readline = yes
3918then
3919 AC_EGREP_HEADER([extern int rl_catch_signals;],
3920 [readline/readline.h],
3921 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3922 [Define if you can turn off readline's signal handling.]), )
3923fi
3924
Martin v. Löwis82bca632006-02-10 20:49:30 +00003925# End of readline checks: restore LIBS
3926LIBS=$LIBS_no_readline
3927
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003928AC_MSG_CHECKING(for broken nice())
3929AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00003930AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003931int main()
3932{
3933 int val1 = nice(1);
3934 if (val1 != -1 && val1 == nice(2))
3935 exit(0);
3936 exit(1);
3937}
Matthias Klosec511b472010-05-08 11:01:39 +00003938]])],
3939[ac_cv_broken_nice=yes],
3940[ac_cv_broken_nice=no],
3941[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003942AC_MSG_RESULT($ac_cv_broken_nice)
3943if test "$ac_cv_broken_nice" = yes
3944then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003945 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3946 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003947fi
3948
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003949AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003950AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00003951AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003952#include <poll.h>
3953
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003954int main()
3955{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003956 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003957 int poll_test;
3958
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003959 close (42);
3960
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003961 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003962 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003963 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003964 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003965 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003966 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003967 return 1;
3968}
Matthias Klosec511b472010-05-08 11:01:39 +00003969]])],
3970[ac_cv_broken_poll=yes],
3971[ac_cv_broken_poll=no],
3972[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003973AC_MSG_RESULT($ac_cv_broken_poll)
3974if test "$ac_cv_broken_poll" = yes
3975then
3976 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3977 [Define if poll() sets errno on invalid file descriptors.])
3978fi
3979
Brett Cannon43802422005-02-10 20:48:03 +00003980# Before we can test tzset, we need to check if struct tm has a tm_zone
3981# (which is not required by ISO C or UNIX spec) and/or if we support
3982# tzname[]
3983AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003984
Brett Cannon43802422005-02-10 20:48:03 +00003985# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003986AC_MSG_CHECKING(for working tzset())
3987AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00003988AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003989#include <stdlib.h>
3990#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003991#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003992
3993#if HAVE_TZNAME
3994extern char *tzname[];
3995#endif
3996
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003997int main()
3998{
Brett Cannon18367812003-09-19 00:59:16 +00003999 /* Note that we need to ensure that not only does tzset(3)
4000 do 'something' with localtime, but it works as documented
4001 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004002 This includes making sure that tzname is set properly if
4003 tm->tm_zone does not exist since it is the alternative way
4004 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004005
4006 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004007 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004008 */
4009
Brett Cannon43802422005-02-10 20:48:03 +00004010 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004011 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4012
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004013 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004014 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004015 if (localtime(&groundhogday)->tm_hour != 0)
4016 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004017#if HAVE_TZNAME
4018 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4019 if (strcmp(tzname[0], "UTC") ||
4020 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4021 exit(1);
4022#endif
Brett Cannon18367812003-09-19 00:59:16 +00004023
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004024 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004025 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004026 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004027 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004028#if HAVE_TZNAME
4029 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4030 exit(1);
4031#endif
Brett Cannon18367812003-09-19 00:59:16 +00004032
4033 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4034 tzset();
4035 if (localtime(&groundhogday)->tm_hour != 11)
4036 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004037#if HAVE_TZNAME
4038 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4039 exit(1);
4040#endif
4041
4042#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004043 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4044 exit(1);
4045 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4046 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004047#endif
Brett Cannon18367812003-09-19 00:59:16 +00004048
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004049 exit(0);
4050}
Matthias Klosec511b472010-05-08 11:01:39 +00004051]])],
4052[ac_cv_working_tzset=yes],
4053[ac_cv_working_tzset=no],
4054[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004055AC_MSG_RESULT($ac_cv_working_tzset)
4056if test "$ac_cv_working_tzset" = yes
4057then
4058 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4059 [Define if tzset() actually switches the local timezone in a meaningful way.])
4060fi
4061
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004062# Look for subsecond timestamps in struct stat
4063AC_MSG_CHECKING(for tv_nsec in struct stat)
4064AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004065AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004066struct stat st;
4067st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004068]])],
4069[ac_cv_stat_tv_nsec=yes],
4070[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004071AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4072if test "$ac_cv_stat_tv_nsec" = yes
4073then
4074 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4075 [Define if you have struct stat.st_mtim.tv_nsec])
4076fi
4077
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004078# Look for BSD style subsecond timestamps in struct stat
4079AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4080AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004081AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004082struct stat st;
4083st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004084]])],
4085[ac_cv_stat_tv_nsec2=yes],
4086[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004087AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4088if test "$ac_cv_stat_tv_nsec2" = yes
4089then
4090 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4091 [Define if you have struct stat.st_mtimensec])
4092fi
4093
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004094# On HP/UX 11.0, mvwdelch is a block with a return statement
4095AC_MSG_CHECKING(whether mvwdelch is an expression)
4096AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004097AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004098 int rtn;
4099 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004100]])],
4101[ac_cv_mvwdelch_is_expression=yes],
4102[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004103AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4104
4105if test "$ac_cv_mvwdelch_is_expression" = yes
4106then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004107 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4108 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004109fi
4110
4111AC_MSG_CHECKING(whether WINDOW has _flags)
4112AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004113AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004114 WINDOW *w;
4115 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004116]])],
4117[ac_cv_window_has_flags=yes],
4118[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004119AC_MSG_RESULT($ac_cv_window_has_flags)
4120
4121
4122if test "$ac_cv_window_has_flags" = yes
4123then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004124 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4125 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004126fi
4127
Walter Dörwald4994d952006-06-19 08:07:50 +00004128AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004129AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4130 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4131 AC_MSG_RESULT(yes)],
4132 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004133)
4134
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004135AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004136AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4137 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4138 AC_MSG_RESULT(yes)],
4139 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004140)
4141
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004142AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004143AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4144 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4145 AC_MSG_RESULT(yes)],
4146 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004147)
4148
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004149AC_MSG_CHECKING(for /dev/ptmx)
4150
4151if test -r /dev/ptmx
4152then
4153 AC_MSG_RESULT(yes)
4154 AC_DEFINE(HAVE_DEV_PTMX, 1,
4155 [Define if we have /dev/ptmx.])
4156else
4157 AC_MSG_RESULT(no)
4158fi
4159
4160AC_MSG_CHECKING(for /dev/ptc)
4161
4162if test -r /dev/ptc
4163then
4164 AC_MSG_RESULT(yes)
4165 AC_DEFINE(HAVE_DEV_PTC, 1,
4166 [Define if we have /dev/ptc.])
4167else
4168 AC_MSG_RESULT(no)
4169fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004170
Mark Dickinson82864d12009-11-15 16:18:58 +00004171if test "$have_long_long" = yes
4172then
4173 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4174 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004175 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004176 #include <stdio.h>
4177 #include <stddef.h>
4178 #include <string.h>
4179
4180 #ifdef HAVE_SYS_TYPES_H
4181 #include <sys/types.h>
4182 #endif
4183
4184 int main()
4185 {
4186 char buffer[256];
4187
4188 if (sprintf(buffer, "%lld", (long long)123) < 0)
4189 return 1;
4190 if (strcmp(buffer, "123"))
4191 return 1;
4192
4193 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4194 return 1;
4195 if (strcmp(buffer, "-123"))
4196 return 1;
4197
4198 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4199 return 1;
4200 if (strcmp(buffer, "123"))
4201 return 1;
4202
4203 return 0;
4204 }
Matthias Klosec511b472010-05-08 11:01:39 +00004205 ]]])],
4206 [ac_cv_have_long_long_format=yes],
4207 [ac_cv_have_long_long_format=no],
4208 [ac_cv_have_long_long_format=no])
Mark Dickinson82864d12009-11-15 16:18:58 +00004209 )
4210 AC_MSG_RESULT($ac_cv_have_long_long_format)
4211fi
4212
Mark Dickinson5ce84742009-12-31 20:48:04 +00004213if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004214then
4215 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4216 [Define to printf format modifier for long long type])
4217fi
4218
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004219if test $ac_sys_system = Darwin
4220then
4221 LIBS="$LIBS -framework CoreFoundation"
4222fi
4223
Mark Dickinson82864d12009-11-15 16:18:58 +00004224
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004225AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004226AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004227#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004228#include <stddef.h>
4229#include <string.h>
4230
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004231#ifdef HAVE_SYS_TYPES_H
4232#include <sys/types.h>
4233#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004234
4235#ifdef HAVE_SSIZE_T
4236typedef ssize_t Py_ssize_t;
4237#elif SIZEOF_VOID_P == SIZEOF_LONG
4238typedef long Py_ssize_t;
4239#else
4240typedef int Py_ssize_t;
4241#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004242
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004243int main()
4244{
4245 char buffer[256];
4246
Brett Cannon09d12362006-05-11 05:11:33 +00004247 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4248 return 1;
4249
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004250 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004251 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004252
4253 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4254 return 1;
4255
4256 if (strcmp(buffer, "-123"))
4257 return 1;
4258
Brett Cannon09d12362006-05-11 05:11:33 +00004259 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004260}
Matthias Klosec511b472010-05-08 11:01:39 +00004261]])],
4262[ac_cv_have_size_t_format=yes],
4263[ac_cv_have_size_t_format=no],
4264[ac_cv_have_size_t_format="cross -- assuming yes"
4265])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004266if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004267 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4268 [Define to printf format modifier for Py_ssize_t])
4269fi
Brett Cannon09d12362006-05-11 05:11:33 +00004270
Martin v. Löwis01c04012002-11-11 14:58:44 +00004271AC_CHECK_TYPE(socklen_t,,
4272 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004273 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004274#ifdef HAVE_SYS_TYPES_H
4275#include <sys/types.h>
4276#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004277#ifdef HAVE_SYS_SOCKET_H
4278#include <sys/socket.h>
4279#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004280])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004281
R. David Murray1d9d16e2010-10-16 00:43:13 +00004282case $ac_sys_system in
4283AIX*)
4284 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4285esac
4286
4287
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004288AC_SUBST(THREADHEADERS)
4289
4290for h in `(cd $srcdir;echo Python/thread_*.h)`
4291do
4292 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4293done
4294
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004295AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004296SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004297AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004298for dir in $SRCDIRS; do
4299 if test ! -d $dir; then
4300 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004301 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004302done
4303AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004304
Guido van Rossum627b2d71993-12-24 10:39:16 +00004305# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004306AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004307AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004308AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004309
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004310echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004311if test ! -f Modules/Setup
4312then
4313 cp $srcdir/Modules/Setup.dist Modules/Setup
4314fi
4315
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004316echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004317if test ! -f Modules/Setup.local
4318then
4319 echo "# Edit this file for local setup changes" >Modules/Setup.local
4320fi
4321
4322echo "creating Makefile"
4323$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4324 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004325 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004326
4327case $ac_sys_system in
4328BeOS)
4329 AC_MSG_WARN([
4330
4331 Support for BeOS is deprecated as of Python 2.6.
4332 See PEP 11 for the gory details.
4333 ])
4334 ;;
4335*) ;;
4336esac
4337
Neil Schemenauer66252162001-02-19 04:47:42 +00004338mv config.c Modules