blob: 0ae5003887727fc1349be768c880ea45abbe4d62 [file] [log] [blame]
Benjamin Petersonfbeb6b62008-05-26 16:04:49 +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)
Georg Brandl3ebb6b32011-02-20 10:37:07 +00006m4_define(PYTHON_VERSION, 3.3)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00008AC_PREREQ(2.65)
Alexandre Vassalottib89910f2009-07-18 00:33:23 +00009
Georg Brandle2e15612009-05-20 18:25:10 +000010AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050011
12AC_SUBST(HGVERSION)
13AC_SUBST(HGTAG)
14AC_SUBST(HGBRANCH)
15
Antoine Pitroud3b2aef2011-07-27 01:22:41 +020016if test -e $srcdir/.hg/dirstate
Benjamin Peterson8c6f88e2011-05-31 20:52:17 -050017then
18AC_CHECK_PROG(HAS_HG, hg, found, not-found)
19else
20HAS_HG=no-repository
21fi
22if test $HAS_HG = found
23then
24 HGVERSION="hg id -i \$(srcdir)"
25 HGTAG="hg id -t \$(srcdir)"
26 HGBRANCH="hg id -b \$(srcdir)"
27else
28 HGVERSION=""
29 HGTAG=""
30 HGBRANCH=""
31fi
32
Martin v. Löwis88afe662002-10-26 13:47:44 +000033AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000034AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000035
Matthias Kloseca2f6ec2012-03-15 21:30:11 +010036AC_CANONICAL_HOST
37
Benjamin Petersond23f8222009-04-05 19:13:16 +000038dnl Ensure that if prefix is specified, it does not end in a slash. If
39dnl it does, we get path names containing '//' which is both ugly and
40dnl can cause trouble.
41
42dnl Last slash shouldn't be stripped if prefix=/
43if test "$prefix" != "/"; then
44 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
45fi
46
Martin v. Löwis8316feb2003-06-14 07:48:07 +000047dnl This is for stuff that absolutely must end up in pyconfig.h.
48dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000049AH_TOP([
50#ifndef Py_PYCONFIG_H
51#define Py_PYCONFIG_H
52])
Martin v. Löwis11437992002-04-12 09:54:03 +000053AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000054/* Define the macros needed if on a UnixWare 7.x system. */
55#if defined(__USLC__) && defined(__SCO_VERSION__)
56#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
57#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000058
59#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000060])
61
Martin v. Löwis8316feb2003-06-14 07:48:07 +000062# We don't use PACKAGE_ variables, and they cause conflicts
63# with other autoconf-based packages that include Python.h
64grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
65rm confdefs.h
66mv confdefs.h.new confdefs.h
67
Guido van Rossum642b6781997-07-19 19:35:41 +000068AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000069VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000070
Georg Brandlde7d8342010-09-03 22:19:07 +000071# Version number of Python's own shared library file.
Martin v. Löwis1142de32002-03-29 16:28:31 +000072AC_SUBST(SOVERSION)
73SOVERSION=1.0
74
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000075# The later defininition of _XOPEN_SOURCE disables certain features
76# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
77AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
78
Martin v. Löwisbcd93962003-05-03 10:32:18 +000079# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
80# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
81# them.
82AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
83
Andrew MacIntyreabccf412003-07-02 13:53:25 +000084# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
85# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
86# them.
87AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
88
Martin v. Löwisd6320502004-08-12 13:45:08 +000089# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
90# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
91AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
92
Georg Brandlfcaf9102008-07-16 02:17:56 +000093# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
94# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
95# them.
96AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
97
98
Martin v. Löwise981a4e2002-11-11 13:26:51 +000099define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000100
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000101# Arguments passed to configure.
102AC_SUBST(CONFIG_ARGS)
103CONFIG_ARGS="$ac_configure_args"
104
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000105AC_MSG_CHECKING([for --enable-universalsdk])
Thomas Wouters477c8d52006-05-27 19:21:47 +0000106AC_ARG_ENABLE(universalsdk,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000107 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Thomas Wouters477c8d52006-05-27 19:21:47 +0000108[
109 case $enableval in
110 yes)
111 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000112 if test ! -d "${enableval}"
113 then
114 enableval=/
115 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000116 ;;
117 esac
118 case $enableval in
119 no)
120 UNIVERSALSDK=
121 enable_universalsdk=
122 ;;
123 *)
124 UNIVERSALSDK=$enableval
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000125 if test ! -d "${UNIVERSALSDK}"
126 then
127 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
128 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000129 ;;
130 esac
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000131
Thomas Wouters477c8d52006-05-27 19:21:47 +0000132],[
133 UNIVERSALSDK=
134 enable_universalsdk=
135])
Ronald Oussoren8af24c12010-02-07 12:03:42 +0000136if test -n "${UNIVERSALSDK}"
137then
138 AC_MSG_RESULT(${UNIVERSALSDK})
139else
140 AC_MSG_RESULT(no)
141fi
Thomas Wouters477c8d52006-05-27 19:21:47 +0000142AC_SUBST(UNIVERSALSDK)
143
Benjamin Peterson6794aa32008-07-16 20:33:37 +0000144AC_SUBST(ARCH_RUN_32BIT)
145
Georg Brandlfcaf9102008-07-16 02:17:56 +0000146UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000147AC_SUBST(LIPO_32BIT_FLAGS)
Georg Brandlfcaf9102008-07-16 02:17:56 +0000148AC_MSG_CHECKING(for --with-universal-archs)
149AC_ARG_WITH(universal-archs,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000150 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Georg Brandlfcaf9102008-07-16 02:17:56 +0000151[
152 AC_MSG_RESULT($withval)
153 UNIVERSAL_ARCHS="$withval"
154],
155[
156 AC_MSG_RESULT(32-bit)
157])
158
159
160
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000161AC_ARG_WITH(framework-name,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000162 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klosec80c93f2010-04-24 17:04:35 +0000163 [specify an alternate name of the framework built with --enable-framework]),
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000164[
165 PYTHONFRAMEWORK=${withval}
166 PYTHONFRAMEWORKDIR=${withval}.framework
167 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
168 ],[
169 PYTHONFRAMEWORK=Python
170 PYTHONFRAMEWORKDIR=Python.framework
171 PYTHONFRAMEWORKIDENTIFIER=org.python.python
172])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000173dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000174AC_ARG_ENABLE(framework,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000175 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000176[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000177 case $enableval in
178 yes)
179 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000180 esac
181 case $enableval in
182 no)
183 PYTHONFRAMEWORK=
184 PYTHONFRAMEWORKDIR=no-framework
185 PYTHONFRAMEWORKPREFIX=
186 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000187 FRAMEWORKINSTALLFIRST=
188 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000189 FRAMEWORKALTINSTALLFIRST=
190 FRAMEWORKALTINSTALLLAST=
191 if test "x${prefix}" = "xNONE"; then
192 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
193 else
194 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
195 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000196 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000197 ;;
198 *)
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000199 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000200 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Thomas Wouters477c8d52006-05-27 19:21:47 +0000201 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussorenf6ccbf62009-06-02 10:55:56 +0000202 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000203 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
204 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000205 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Georg Brandlfcaf9102008-07-16 02:17:56 +0000206
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000207 if test "x${prefix}" = "xNONE" ; then
208 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000209
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000210 else
211 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
212 fi
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000213
214 case "${enableval}" in
215 /System*)
216 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
217 if test "${prefix}" = "NONE" ; then
218 # See below
219 FRAMEWORKUNIXTOOLSPREFIX="/usr"
220 fi
221 ;;
222
223 /Library*)
224 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
225 ;;
226
227 */Library/Frameworks)
228 MDIR="`dirname "${enableval}"`"
229 MDIR="`dirname "${MDIR}"`"
230 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
231
232 if test "${prefix}" = "NONE"; then
233 # User hasn't specified the
234 # --prefix option, but wants to install
235 # the framework in a non-default location,
236 # ensure that the compatibility links get
237 # installed relative to that prefix as well
238 # instead of in /usr/local.
239 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
240 fi
241 ;;
242
243 *)
244 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
245 ;;
246 esac
247
Jack Jansen127e56e2001-09-11 14:41:54 +0000248 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Thomas Wouters477c8d52006-05-27 19:21:47 +0000249
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000250 # Add files for Mac specific code to the list of output
Thomas Wouters477c8d52006-05-27 19:21:47 +0000251 # files:
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000252 AC_CONFIG_FILES(Mac/Makefile)
253 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000254 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
255 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000256 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000257 ],[
258 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000259 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000260 PYTHONFRAMEWORKPREFIX=
261 PYTHONFRAMEWORKINSTALLDIR=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000262 FRAMEWORKINSTALLFIRST=
263 FRAMEWORKINSTALLLAST=
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000264 FRAMEWORKALTINSTALLFIRST=
265 FRAMEWORKALTINSTALLLAST=
266 if test "x${prefix}" = "xNONE" ; then
267 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
268 else
269 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
270 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000271 enable_framework=
Georg Brandlfcaf9102008-07-16 02:17:56 +0000272
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000273])
274AC_SUBST(PYTHONFRAMEWORK)
Christian Heimes81ee3ef2008-05-04 22:42:01 +0000275AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000276AC_SUBST(PYTHONFRAMEWORKDIR)
277AC_SUBST(PYTHONFRAMEWORKPREFIX)
278AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000279AC_SUBST(FRAMEWORKINSTALLFIRST)
280AC_SUBST(FRAMEWORKINSTALLLAST)
Thomas Wouters73e5a5b2006-06-08 15:35:45 +0000281AC_SUBST(FRAMEWORKALTINSTALLFIRST)
282AC_SUBST(FRAMEWORKALTINSTALLLAST)
283AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren86b33c82010-04-30 11:41:56 +0000284AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000285
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000286##AC_ARG_WITH(dyld,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000287## AS_HELP_STRING([--with-dyld],
Matthias Klosec80c93f2010-04-24 17:04:35 +0000288## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000289##
Guido van Rossumb418f891996-07-30 18:06:02 +0000290# Set name for machine-dependent library files
291AC_SUBST(MACHDEP)
292AC_MSG_CHECKING(MACHDEP)
293if test -z "$MACHDEP"
294then
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100295 # avoid using uname for cross builds
296 if test "$cross_compiling" = yes; then
297 # ac_sys_system and ac_sys_release are only used for setting
298 # `define_xopen_source' in the case statement below. For the
299 # current supported cross builds, this macro is not adjusted.
300 case "$host" in
301 *-*-linux*)
302 ac_sys_system=Linux
303 ;;
304 *-*-cygwin*)
305 ac_sys_system=Cygwin
306 ;;
307 *)
308 # for now, limit cross builds to known configurations
309 MACHDEP="unknown"
310 AC_MSG_ERROR([cross build not supported for $host])
311 esac
312 ac_sys_release=
313 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000314 ac_sys_system=`uname -s`
Benjamin Peterson8719ad52009-09-11 22:24:02 +0000315 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000316 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000317 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000318 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000319 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000320 fi
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100321 fi
322 ac_md_system=`echo $ac_sys_system |
323 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
324 ac_md_release=`echo $ac_sys_release |
325 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
326 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000327
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100328 case $MACHDEP in
Victor Stinner7209ff22011-08-21 00:00:16 +0200329 linux*) MACHDEP="linux";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000330 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000331 darwin*) MACHDEP="darwin";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000332 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000333 '') MACHDEP="unknown";;
Matthias Klosedf2aecb2012-03-15 22:19:28 +0100334 esac
Guido van Rossumb418f891996-07-30 18:06:02 +0000335fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000336
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000337# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
338# disable features if it is defined, without any means to access these
339# features as extensions. For these systems, we skip the definition of
340# _XOPEN_SOURCE. Before adding a system to the list to gain access to
341# some feature, make sure there is no alternative way to access this
342# feature. Also, when using wildcards, make sure you have verified the
343# need for not defining _XOPEN_SOURCE on all systems matching the
344# wildcard, and that the wildcard does not include future systems
345# (which may remove their limitations).
346dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
347case $ac_sys_system/$ac_sys_release in
348 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
349 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000350 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis19ed3c82010-02-15 21:45:06 +0000351 # In addition, Stefan Krah confirms that issue #1244610 exists through
352 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali54ef40b2011-07-22 23:52:02 +0200353 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000354 define_xopen_source=no
355 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
356 # also defined. This can be overridden by defining _BSD_SOURCE
357 # As this has a different meaning on Linux, only define it on OpenBSD
358 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
359 ;;
Charles-François Natali54ef40b2011-07-22 23:52:02 +0200360 OpenBSD/*)
Martin v. Löwis7671efc2010-02-15 08:35:16 +0000361 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
362 # also defined. This can be overridden by defining _BSD_SOURCE
363 # As this has a different meaning on Linux, only define it on OpenBSD
364 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
365 ;;
Thomas Wouters89f507f2006-12-13 04:49:30 +0000366 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
367 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
368 # Marc Recht
Benjamin Petersonf608c612008-11-16 18:33:53 +0000369 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000370 define_xopen_source=no;;
Martin v. Löwis1a415762010-05-28 15:44:20 +0000371 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
372 # request to enable features supported by the standard as a request
373 # to disable features not supported by the standard. The best way
374 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
375 # entirely and define __EXTENSIONS__ instead.
376 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000377 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000378 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
379 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000380 # Reconfirmed for 7.1.4 by Martin v. Loewis.
381 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000382 define_xopen_source=no;;
383 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000384 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000385 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000386 define_xopen_source=no;;
Martin v. Löwisb37509b2008-11-04 20:45:29 +0000387 # On FreeBSD 4, the math functions C89 does not cover are never defined
388 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
389 FreeBSD/4.*)
390 define_xopen_source=no;;
391 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
392 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
393 # identifies itself as Darwin/7.*
394 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
395 # disables platform specific features beyond repair.
396 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
397 # has no effect, don't bother defining them
398 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000399 define_xopen_source=no;;
Ronald Oussoren92fb9412010-03-09 06:40:19 +0000400 Darwin/1@<:@0-9@:>@.*)
Ronald Oussorenb8f11a62010-03-08 07:02:03 +0000401 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000402 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
403 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
404 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000405 AIX/4)
406 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000407 AIX/5)
408 if test `uname -r` -eq 1; then
409 define_xopen_source=no
410 fi
411 ;;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000412 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
413 # defining NI_NUMERICHOST.
414 QNX/6.3.2)
415 define_xopen_source=no
416 ;;
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000417
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000418esac
419
420if test $define_xopen_source = yes
421then
Victor Stinner14d098d2011-09-07 22:29:43 +0200422 # X/Open 7, incorporating POSIX.1-2008
423 AC_DEFINE(_XOPEN_SOURCE, 700,
Martin v. Löwis1a415762010-05-28 15:44:20 +0000424 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000425
426 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
427 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
428 # several APIs are not declared. Since this is also needed in some
429 # cases for HP-UX, we define it globally.
Martin v. Löwis1a415762010-05-28 15:44:20 +0000430 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
431 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000432
Victor Stinnerd169fdc2011-09-08 00:56:17 +0200433 AC_DEFINE(_POSIX_C_SOURCE, 200809L, Define to activate features from IEEE Stds 1003.1-2008)
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000434fi
435
Guido van Rossum91922671997-10-09 20:24:13 +0000436#
437# SGI compilers allow the specification of the both the ABI and the
438# ISA on the command line. Depending on the values of these switches,
439# different and often incompatable code will be generated.
440#
441# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
442# thus supply support for various ABI/ISA combinations. The MACHDEP
443# variable is also adjusted.
444#
445AC_SUBST(SGI_ABI)
446if test ! -z "$SGI_ABI"
447then
448 CC="cc $SGI_ABI"
449 LDFLAGS="$SGI_ABI $LDFLAGS"
450 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
451fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000452AC_MSG_RESULT($MACHDEP)
453
Jack Jansen6b08a402004-06-03 12:41:45 +0000454# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
455# it may influence the way we can build extensions, so distutils
456# needs to check it
457AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000458AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000459CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Thomas Wouters477c8d52006-05-27 19:21:47 +0000460EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000461
Guido van Rossum627b2d71993-12-24 10:39:16 +0000462# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000463
464# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
465# for debug/optimization stuff. BASECFLAGS is for flags that are required
466# just to get things to compile and link. Users are free to override OPT
467# when running configure or make. The build should not break if they do.
468# BASECFLAGS should generally not be messed with, however.
469
470# XXX shouldn't some/most/all of this code be merged with the stuff later
471# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000472AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000473AC_ARG_WITH(gcc,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000474 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000475[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000476 case $withval in
Benjamin Peterson960cf0f2009-01-09 04:11:44 +0000477 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000478 without_gcc=yes;;
479 yes) CC=gcc
480 without_gcc=no;;
481 *) CC=$withval
482 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000483 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000484 case $ac_sys_system in
Antoine Pitrouf6350d22010-09-21 15:19:14 +0000485 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000486 without_gcc=;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000487 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000488 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000489AC_MSG_RESULT($without_gcc)
490
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000491# If the user switches compilers, we can't believe the cache
492if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
493then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000494 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
495(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000496fi
497
Jeffrey Yasskind4fcdb12010-07-09 16:30:58 +0000498# Don't let AC_PROG_CC set the default CFLAGS. It normally sets -g -O2
499# when the compiler supports them, but we don't always want -O2, and
500# we set -g later.
501if test -z "$CFLAGS"; then
502 CFLAGS=
Marc-André Lemburgdf700f02010-04-30 17:29:56 +0000503fi
Jeffrey Yasskind4fcdb12010-07-09 16:30:58 +0000504AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000505
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000506AC_SUBST(CXX)
507AC_SUBST(MAINCC)
508AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
509AC_ARG_WITH(cxx_main,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000510 AS_HELP_STRING([--with-cxx-main=<compiler>],
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000511 [compile main() and link python executable with C++ compiler]),
512[
513
514 case $withval in
515 no) with_cxx_main=no
516 MAINCC='$(CC)';;
517 yes) with_cxx_main=yes
518 MAINCC='$(CXX)';;
519 *) with_cxx_main=yes
520 MAINCC=$withval
521 if test -z "$CXX"
522 then
523 CXX=$withval
524 fi;;
525 esac], [
526 with_cxx_main=no
527 MAINCC='$(CC)'
528])
529AC_MSG_RESULT($with_cxx_main)
530
531preset_cxx="$CXX"
532if test -z "$CXX"
533then
534 case "$CC" in
535 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
536 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
537 esac
538 if test "$CXX" = "notfound"
539 then
540 CXX=""
541 fi
542fi
543if test -z "$CXX"
544then
545 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
546 if test "$CXX" = "notfound"
547 then
548 CXX=""
549 fi
550fi
551if test "$preset_cxx" != "$CXX"
552then
553 AC_MSG_WARN([
554
555 By default, distutils will build C++ extension modules with "$CXX".
556 If this is not intended, then set CXX on the configure command line.
557 ])
558fi
559
560
Martin v. Löwis48e14d32011-05-09 07:37:45 +0200561AC_MSG_CHECKING([for -Wl,--no-as-needed])
562save_LDFLAGS="$LDFLAGS"
563LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
564AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
565 [NO_AS_NEEDED="-Wl,--no-as-needed"
566 AC_MSG_RESULT([yes])],
567 [NO_AS_NEEDED=""
568 AC_MSG_RESULT([no])])
569LDFLAGS="$save_LDFLAGS"
570AC_SUBST(NO_AS_NEEDED)
571
572
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000573# checks for UNIX variants that set C preprocessor variables
Matthias Kloseaf30c5d2010-04-25 18:43:42 +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
Guido van Rossumcd16bf62007-06-13 18:07:49 +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 Klose2b8733f2010-04-25 18:34:36 +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;;
626esac
627
Martin v. Löwise8964d42001-03-06 12:09:07 +0000628
Neil Schemenauer61c51152001-01-26 16:18:16 +0000629AC_SUBST(LIBRARY)
630AC_MSG_CHECKING(LIBRARY)
631if test -z "$LIBRARY"
632then
Barry Warsawf040d7d2010-10-18 17:09:07 +0000633 LIBRARY='libpython$(VERSION)$(ABIFLAGS).a'
Neil Schemenauer61c51152001-01-26 16:18:16 +0000634fi
635AC_MSG_RESULT($LIBRARY)
636
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000637# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000638# name of the library into which to insert object files). BLDLIBRARY is also
639# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
640# is blank as the main program is not linked directly against LDLIBRARY.
641# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
642# systems without shared libraries, LDLIBRARY is the same as LIBRARY
643# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
644# DLLLIBRARY is the shared (i.e., DLL) library.
645#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000646# RUNSHARED is used to run shared python without installed libraries
647#
648# INSTSONAME is the name of the shared library that will be use to install
649# on the system - some systems like version suffix, others don't
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000650#
651# LDVERSION is the shared library version number, normally the Python version
652# with the ABI build flags appended.
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000653AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000654AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000655AC_SUBST(BLDLIBRARY)
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +0000656AC_SUBST(PY3LIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000657AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000658AC_SUBST(INSTSONAME)
659AC_SUBST(RUNSHARED)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000660AC_SUBST(LDVERSION)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000661LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000662BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000663INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000664DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000665LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000666RUNSHARED=''
Barry Warsaw14d98ac2010-11-24 19:43:47 +0000667LDVERSION="$VERSION"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000668
Guido van Rossumfb842551997-08-06 23:42:07 +0000669# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000670# If CXX is set, and if it is needed to link a main function that was
671# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
672# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000673# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000674# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000675AC_SUBST(LINKCC)
676AC_MSG_CHECKING(LINKCC)
677if test -z "$LINKCC"
678then
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000679 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000680 case $ac_sys_system in
681 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000682 exp_extra="\"\""
683 if test $ac_sys_release -ge 5 -o \
684 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
685 exp_extra="."
686 fi
687 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Georg Brandlf78e02b2008-06-10 17:40:04 +0000688 QNX*)
689 # qcc must be used because the other compilers do not
690 # support -N.
691 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000692 esac
693fi
694AC_MSG_RESULT($LINKCC)
695
Tarek Ziadébe720e02009-05-09 11:55:12 +0000696# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
697# make sure we default having it set to "no": this is used by
698# distutils.unixccompiler to know if it should add --enable-new-dtags
699# to linker command lines, and failing to detect GNU ld simply results
700# in the same bahaviour as before.
701AC_SUBST(GNULD)
702AC_MSG_CHECKING(for GNU ld)
703ac_prog=ld
704if test "$GCC" = yes; then
705 ac_prog=`$CC -print-prog-name=ld`
706fi
707case `"$ac_prog" -V 2>&1 < /dev/null` in
708 *GNU*)
709 GNULD=yes;;
710 *)
711 GNULD=no;;
712esac
713AC_MSG_RESULT($GNULD)
714
Daniel Stutzbacha606faa2010-08-31 19:51:07 +0000715AC_C_INLINE
716if test "$ac_cv_c_inline" != no ; then
Benjamin Petersond7f73e92010-09-05 00:09:07 +0000717 AC_DEFINE(USE_INLINE, 1, [Define to use the C99 inline keyword.])
Daniel Stutzbacha606faa2010-08-31 19:51:07 +0000718 AC_SUBST(USE_INLINE)
719fi
720
721
Martin v. Löwis1142de32002-03-29 16:28:31 +0000722AC_MSG_CHECKING(for --enable-shared)
723AC_ARG_ENABLE(shared,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000724 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000725
Martin v. Löwis1142de32002-03-29 16:28:31 +0000726if test -z "$enable_shared"
727then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000728 case $ac_sys_system in
Antoine Pitrou6103ab12009-10-24 20:11:21 +0000729 CYGWIN*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000730 enable_shared="yes";;
731 *)
732 enable_shared="no";;
733 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000734fi
735AC_MSG_RESULT($enable_shared)
736
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000737AC_MSG_CHECKING(for --enable-profiling)
738AC_ARG_ENABLE(profiling,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000739 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000740[ac_save_cc="$CC"
741 CC="$CC -pg"
Matthias Kloseb159a552010-04-25 21:00:44 +0000742 AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
743 [ac_enable_profiling="yes"],
744 [ac_enable_profiling="no"],
745 [ac_enable_profiling="no"])
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000746 CC="$ac_save_cc"])
747AC_MSG_RESULT($ac_enable_profiling)
748
749case "$ac_enable_profiling" in
750 "yes")
751 BASECFLAGS="-pg $BASECFLAGS"
752 LDFLAGS="-pg $LDFLAGS"
753 ;;
754esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000755
756AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000757
Guido van Rossumb8552162001-09-05 14:58:11 +0000758# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
759# library that we build, but we do not want to link against it (we
760# will find it with a -framework option). For this reason there is an
761# extra variable BLDLIBRARY against which Python and the extension
762# modules are linked, BLDLIBRARY. This is normally the same as
763# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000764if test "$enable_framework"
765then
766 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000767 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000768 BLDLIBRARY=''
769else
770 BLDLIBRARY='$(LDLIBRARY)'
771fi
772
Martin v. Löwis1142de32002-03-29 16:28:31 +0000773# Other platforms follow
774if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000775 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000776 case $ac_sys_system in
Martin v. Löwis1142de32002-03-29 16:28:31 +0000777 CYGWIN*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000778 LDLIBRARY='libpython$(LDVERSION).dll.a'
779 DLLLIBRARY='libpython$(LDVERSION).dll'
Martin v. Löwis1142de32002-03-29 16:28:31 +0000780 ;;
781 SunOS*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000782 LDLIBRARY='libpython$(LDVERSION).so'
783 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(LDVERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000784 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000785 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis9b142aa2011-02-05 20:26:52 +0000786 if test "$with_pydebug" != yes
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +0000787 then
788 PY3LIBRARY=libpython3.so
789 fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000790 ;;
Charles-François Natali749400a2011-07-24 22:41:18 +0200791 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000792 LDLIBRARY='libpython$(LDVERSION).so'
793 BLDLIBRARY='-L. -lpython$(LDVERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000794 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000795 case $ac_sys_system in
796 FreeBSD*)
797 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
798 ;;
799 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000800 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis9b142aa2011-02-05 20:26:52 +0000801 if test "$with_pydebug" != yes
Martin v. Löwisd1fc34d2010-12-30 14:55:47 +0000802 then
803 PY3LIBRARY=libpython3.so
804 fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000805 ;;
806 hp*|HP*)
Thomas Wouters477c8d52006-05-27 19:21:47 +0000807 case `uname -m` in
808 ia64)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000809 LDLIBRARY='libpython$(LDVERSION).so'
Thomas Wouters477c8d52006-05-27 19:21:47 +0000810 ;;
811 *)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000812 LDLIBRARY='libpython$(LDVERSION).sl'
Thomas Wouters477c8d52006-05-27 19:21:47 +0000813 ;;
814 esac
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000815 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000816 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000817 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000818 Darwin*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000819 LDLIBRARY='libpython$(LDVERSION).dylib'
820 BLDLIBRARY='-L. -lpython$(LDVERSION)'
Georg Brandlb1441c72009-01-03 22:33:39 +0000821 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
822 ;;
Antoine Pitrou8e6b4072010-09-10 19:44:44 +0000823 AIX*)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000824 LDLIBRARY='libpython$(LDVERSION).so'
Antoine Pitrou8e6b4072010-09-10 19:44:44 +0000825 RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
826 ;;
Georg Brandlb1441c72009-01-03 22:33:39 +0000827
Martin v. Löwis1142de32002-03-29 16:28:31 +0000828 esac
Jason Tishler30765592003-09-04 11:04:06 +0000829else # shared is disabled
830 case $ac_sys_system in
831 CYGWIN*)
832 BLDLIBRARY='$(LIBRARY)'
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000833 LDLIBRARY='libpython$(LDVERSION).dll.a'
Jason Tishler30765592003-09-04 11:04:06 +0000834 ;;
835 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000836fi
837
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000838AC_MSG_RESULT($LDLIBRARY)
839
Guido van Rossum627b2d71993-12-24 10:39:16 +0000840AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000841AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000842AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000843
Tarek Ziadé5662d3e2009-05-07 21:24:43 +0000844# tweak ARFLAGS only if the user didn't set it on the command line
845AC_SUBST(ARFLAGS)
846if test -z "$ARFLAGS"
847then
848 ARFLAGS="rc"
849fi
850
Ralf Schmitt023f3a72011-05-31 17:10:03 -0500851AC_SUBST(DISABLE_ASDLGEN)
852DISABLE_ASDLGEN=""
853AC_CHECK_PROG(HAS_PYTHON, python, found, not-found)
854if test $HAS_HG != found -o $HAS_PYTHON != found
855then
856 DISABLE_ASDLGEN="@echo hg: $HAS_HG, python: $HAS_PYTHON! cannot run \$(srcdir)/Parser/asdl_c.py #"
857fi
858
859
Neil Schemenauera42c8272001-03-31 00:01:55 +0000860case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000861bsdos*|hp*|HP*)
862 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000863 if test -z "$INSTALL"
864 then
865 INSTALL="${srcdir}/install-sh -c"
866 fi
867esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000868AC_PROG_INSTALL
Matthias Klose93a0ef12012-03-15 18:08:34 +0100869AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +0000870
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000871# Not every filesystem supports hard links
872AC_SUBST(LN)
873if test -z "$LN" ; then
874 case $ac_sys_system in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000875 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000876 *) LN=ln;;
877 esac
878fi
879
Barry Warsaw35f3a2c2010-09-03 18:30:30 +0000880# For calculating the .so ABI tag.
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000881AC_SUBST(ABIFLAGS)
882ABIFLAGS=""
Barry Warsaw35f3a2c2010-09-03 18:30:30 +0000883
Fred Drake9f715822001-07-11 06:27:00 +0000884# Check for --with-pydebug
885AC_MSG_CHECKING(for --with-pydebug)
886AC_ARG_WITH(pydebug,
Matthias Klose2b8733f2010-04-25 18:34:36 +0000887 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000888[
Fred Drake9f715822001-07-11 06:27:00 +0000889if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000890then
891 AC_DEFINE(Py_DEBUG, 1,
892 [Define if you want to build an interpreter with many run-time checks.])
893 AC_MSG_RESULT(yes);
894 Py_DEBUG='true'
Barry Warsaw8cf4eae2010-10-16 01:04:07 +0000895 ABIFLAGS="${ABIFLAGS}d"
Fred Drake9f715822001-07-11 06:27:00 +0000896else AC_MSG_RESULT(no); Py_DEBUG='false'
897fi],
898[AC_MSG_RESULT(no)])
899
Skip Montanarodecc6a42003-01-01 20:07:49 +0000900# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
901# merged with this chunk of code?
902
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000903# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000904# ------------------------
905# (The following bit of code is complicated enough - please keep things
906# indented properly. Just pretend you're editing Python code. ;-)
907
908# There are two parallel sets of case statements below, one that checks to
909# see if OPT was set and one that does BASECFLAGS setting based upon
910# compiler and platform. BASECFLAGS tweaks need to be made even if the
911# user set OPT.
912
913# tweak OPT based on compiler and platform, only if the user didn't set
914# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000915AC_SUBST(OPT)
Benjamin Peterson65b4ec52010-03-23 21:02:34 +0000916if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000917then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000918 case $GCC in
919 yes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000920 if test "$CC" != 'g++' ; then
921 STRICT_PROTO="-Wstrict-prototypes"
922 fi
Christian Heimes38053212007-12-14 01:24:44 +0000923 # For gcc 4.x we need to use -fwrapv so lets check if its supported
924 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
925 WRAP="-fwrapv"
926 fi
Stefan Krah962055d2011-09-14 15:14:08 +0200927
928 # Clang also needs -fwrapv
Stefan Krahaf04ff22011-12-08 22:20:31 +0100929 case $CC in
930 *clang*) WRAP="-fwrapv"
931 ;;
932 esac
Stefan Krah962055d2011-09-14 15:14:08 +0200933
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 Dickinsonb2153e92010-05-05 22:31:36 +0000939 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000940 else
Christian Heimes38053212007-12-14 01:24:44 +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 *)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +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)
Georg Brandlfcaf9102008-07-16 02:17:56 +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)
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000969 # Python doesn't violate C99 aliasing rules, but older versions of
970 # GCC produce warnings for legal Python code. Enable
971 # -fno-strict-aliasing on versions of GCC that support but produce
972 # warnings. See Issue3326
973 AC_MSG_CHECKING(whether $CC accepts and needs -fno-strict-aliasing)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000974 ac_save_cc="$CC"
975 CC="$CC -fno-strict-aliasing"
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000976 save_CFLAGS="$CFLAGS"
977 AC_CACHE_VAL(ac_cv_no_strict_aliasing,
Matthias Kloseb159a552010-04-25 21:00:44 +0000978 AC_COMPILE_IFELSE(
979 [
Mark Dickinson8c2b6f12010-05-11 09:23:07 +0000980 AC_LANG_PROGRAM([[]], [[]])
Matthias Kloseb159a552010-04-25 21:00:44 +0000981 ],[
982 CC="$ac_save_cc -fstrict-aliasing"
983 CFLAGS="$CFLAGS -Werror -Wstrict-aliasing"
984 AC_COMPILE_IFELSE(
985 [
Mark Dickinson8c2b6f12010-05-11 09:23:07 +0000986 AC_LANG_PROGRAM([[void f(int **x) {}]],
987 [[double *x; f((int **) &x);]])
Matthias Kloseb159a552010-04-25 21:00:44 +0000988 ],[
989 ac_cv_no_strict_aliasing=no
990 ],[
991 ac_cv_no_strict_aliasing=yes
992 ])
993 ],[
994 ac_cv_no_strict_aliasing=no
995 ]))
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000996 CFLAGS="$save_CFLAGS"
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000997 CC="$ac_save_cc"
Benjamin Petersone6c9d242010-03-30 17:34:47 +0000998 AC_MSG_RESULT($ac_cv_no_strict_aliasing)
999 if test $ac_cv_no_strict_aliasing = yes
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001000 then
1001 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1002 fi
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001003
Benjamin Peterson7ddbf102011-09-23 13:23:22 -04001004 AC_MSG_CHECKING(if we can turn off $CC unused result warning)
1005 ac_save_cc="$CC"
1006 CC="$CC -Wunused-result -Werror"
1007 save_CFLAGS="$CFLAGS"
1008 AC_CACHE_VAL(ac_cv_disable_unused_result_warning,
1009 AC_COMPILE_IFELSE(
1010 [
1011 AC_LANG_PROGRAM([[]], [[]])
1012 ],[
1013 ac_cv_disable_unused_result_warning=yes
1014 ],[
1015 ac_cv_disable_unused_result_warning=no
1016 ]))
1017 CFLAGS="$save_CFLAGS"
1018 CC="$ac_save_cc"
1019 AC_MSG_RESULT($ac_cv_disable_unused_result_warning)
1020
1021 if test $ac_cv_disable_unused_result_warning = yes
1022 then
1023 BASECFLAGS="$BASECFLAGS -Wno-unused-result"
1024 fi
1025
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001026 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1027 # support. Without this, treatment of subnormals doesn't follow
1028 # the standard.
Matthias Klosedf2aecb2012-03-15 22:19:28 +01001029 case $host in
Mark Dickinsonb0e2b4c2008-04-26 20:48:56 +00001030 alpha*)
1031 BASECFLAGS="$BASECFLAGS -mieee"
1032 ;;
1033 esac
1034
Skip Montanarodecc6a42003-01-01 20:07:49 +00001035 case $ac_sys_system in
1036 SCO_SV*)
1037 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1038 ;;
1039 # is there any other compiler on Darwin besides gcc?
1040 Darwin*)
Christian Heimesb186d002008-03-18 15:15:01 +00001041 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1042 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussoren666028b2010-04-18 19:07:43 +00001043 if test "${CC}" = gcc
1044 then
1045 AC_MSG_CHECKING(which compiler should be used)
1046 case "${UNIVERSALSDK}" in
1047 */MacOSX10.4u.sdk)
1048 # Build using 10.4 SDK, force usage of gcc when the
1049 # compiler is gcc, otherwise the user will get very
1050 # confusing error messages when building on OSX 10.6
1051 CC=gcc-4.0
1052 CPP=cpp-4.0
1053 ;;
1054 esac
1055 AC_MSG_RESULT($CC)
1056 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001057
1058
Thomas Wouters477c8d52006-05-27 19:21:47 +00001059 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001060 UNIVERSAL_ARCH_FLAGS=""
1061 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1062 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
Benjamin Peterson6794aa32008-07-16 20:33:37 +00001063 ARCH_RUN_32BIT=""
Benjamin Peterson051858e2010-04-11 22:14:02 +00001064 LIPO_32BIT_FLAGS=""
Georg Brandlfcaf9102008-07-16 02:17:56 +00001065 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1066 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +00001067 LIPO_32BIT_FLAGS=""
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001068 ARCH_RUN_32BIT="true"
Georg Brandlfcaf9102008-07-16 02:17:56 +00001069
1070 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1071 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +00001072 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +00001073 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Georg Brandlfcaf9102008-07-16 02:17:56 +00001074
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001075 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1076 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +00001077 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +00001078 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001079
1080 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1081 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
Ronald Oussoren6f6c5622009-12-24 14:03:19 +00001082 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren564f7f22010-02-11 13:23:08 +00001083 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001084
Georg Brandlfcaf9102008-07-16 02:17:56 +00001085 else
Ronald Oussoren74f29b42009-09-20 20:09:26 +00001086 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
Georg Brandlfcaf9102008-07-16 02:17:56 +00001087
1088 fi
1089
1090
Ronald Oussoren666028b2010-04-18 19:07:43 +00001091 CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
1092 if test "${UNIVERSALSDK}" != "/"
1093 then
1094 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
1095 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren712979d2010-04-20 19:51:33 +00001096 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001097 fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00001098 fi
1099
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001100 # Calculate the right deployment target for this build.
1101 #
1102 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1103 if test ${cur_target} '>' 10.2; then
1104 cur_target=10.3
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001105 if test ${enable_universalsdk}; then
1106 if test "${UNIVERSAL_ARCHS}" = "all"; then
1107 # Ensure that the default platform for a
1108 # 4-way universal build is OSX 10.5,
1109 # that's the first OS release where
1110 # 4-way builds make sense.
1111 cur_target='10.5'
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001112
1113 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1114 cur_target='10.5'
1115
1116 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1117 cur_target='10.5'
1118
1119 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1120 cur_target='10.5'
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001121 fi
1122 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001123 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001124 # On Intel macs default to a deployment
1125 # target of 10.4, that's the first OSX
1126 # release with Intel support.
1127 cur_target="10.4"
1128 fi
1129 fi
Benjamin Peterson67c38e22008-07-17 16:10:34 +00001130 fi
1131 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1132
1133 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1134 # environment with a value that is the same as what we'll use
1135 # in the Makefile to ensure that we'll get the same compiler
1136 # environment during configure and build time.
1137 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1138 export MACOSX_DEPLOYMENT_TARGET
1139 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1140
Skip Montanarodecc6a42003-01-01 20:07:49 +00001141 ;;
1142 esac
1143 ;;
1144
1145*)
1146 case $ac_sys_system in
1147 OpenUNIX*|UnixWare*)
1148 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1149 ;;
1150 SCO_SV*)
1151 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1152 ;;
1153 esac
1154 ;;
1155esac
1156
Fred Drakee1ceaa02001-12-04 20:55:47 +00001157if test "$Py_DEBUG" = 'true'; then
1158 :
1159else
1160 OPT="-DNDEBUG $OPT"
1161fi
1162
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001163if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001164then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001165 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001166fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001167
Thomas Wouters89f507f2006-12-13 04:49:30 +00001168# Check whether GCC supports PyArg_ParseTuple format
1169if test "$GCC" = "yes"
1170then
1171 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1172 save_CFLAGS=$CFLAGS
1173 CFLAGS="$CFLAGS -Werror"
Matthias Kloseb159a552010-04-25 21:00:44 +00001174 AC_COMPILE_IFELSE([
1175 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1176 ],[
1177 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1178 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1179 AC_MSG_RESULT(yes)
1180 ],[
1181 AC_MSG_RESULT(no)
1182 ])
Thomas Wouters89f507f2006-12-13 04:49:30 +00001183 CFLAGS=$save_CFLAGS
1184fi
1185
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001186# On some compilers, pthreads are available without further options
1187# (e.g. MacOS X). On some of these systems, the compiler will not
1188# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1189# So we have to see first whether pthreads are available without
1190# options before we can check whether -Kpthread improves anything.
1191AC_MSG_CHECKING(whether pthreads are available without options)
1192AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Kloseb159a552010-04-25 21:00:44 +00001193[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001194#include <pthread.h>
1195
1196void* routine(void* p){return NULL;}
1197
1198int main(){
1199 pthread_t p;
1200 if(pthread_create(&p,NULL,routine,NULL)!=0)
1201 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001202 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001203 return 0;
1204}
Matthias Kloseb159a552010-04-25 21:00:44 +00001205]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001206 ac_cv_pthread_is_default=yes
1207 ac_cv_kthread=no
1208 ac_cv_pthread=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001209],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001210])
1211AC_MSG_RESULT($ac_cv_pthread_is_default)
1212
1213
1214if test $ac_cv_pthread_is_default = yes
1215then
1216 ac_cv_kpthread=no
1217else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001218# -Kpthread, if available, provides the right #defines
1219# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001220# Some compilers won't report that they do not support -Kpthread,
1221# so we need to run a program to see whether it really made the
1222# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001223AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1224AC_CACHE_VAL(ac_cv_kpthread,
1225[ac_save_cc="$CC"
1226CC="$CC -Kpthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00001227AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001228#include <pthread.h>
1229
1230void* routine(void* p){return NULL;}
1231
1232int main(){
1233 pthread_t p;
1234 if(pthread_create(&p,NULL,routine,NULL)!=0)
1235 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001236 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001237 return 0;
1238}
Matthias Kloseb159a552010-04-25 21:00:44 +00001239]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001240CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001241AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001242fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001243
Skip Montanarod8d39a02003-07-10 20:44:10 +00001244if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001245then
1246# -Kthread, if available, provides the right #defines
1247# and linker options to make pthread_create available
1248# Some compilers won't report that they do not support -Kthread,
1249# so we need to run a program to see whether it really made the
1250# function available.
1251AC_MSG_CHECKING(whether $CC accepts -Kthread)
1252AC_CACHE_VAL(ac_cv_kthread,
1253[ac_save_cc="$CC"
1254CC="$CC -Kthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00001255AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001256#include <pthread.h>
1257
1258void* routine(void* p){return NULL;}
1259
1260int main(){
1261 pthread_t p;
1262 if(pthread_create(&p,NULL,routine,NULL)!=0)
1263 return 1;
1264 (void)pthread_detach(p);
1265 return 0;
1266}
Matthias Kloseb159a552010-04-25 21:00:44 +00001267]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001268CC="$ac_save_cc"])
1269AC_MSG_RESULT($ac_cv_kthread)
1270fi
1271
Skip Montanarod8d39a02003-07-10 20:44:10 +00001272if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001273then
1274# -pthread, if available, provides the right #defines
1275# and linker options to make pthread_create available
1276# Some compilers won't report that they do not support -pthread,
1277# so we need to run a program to see whether it really made the
1278# function available.
1279AC_MSG_CHECKING(whether $CC accepts -pthread)
1280AC_CACHE_VAL(ac_cv_thread,
1281[ac_save_cc="$CC"
1282CC="$CC -pthread"
Matthias Kloseb159a552010-04-25 21:00:44 +00001283AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001284#include <pthread.h>
1285
1286void* routine(void* p){return NULL;}
1287
1288int main(){
1289 pthread_t p;
1290 if(pthread_create(&p,NULL,routine,NULL)!=0)
1291 return 1;
1292 (void)pthread_detach(p);
1293 return 0;
1294}
Matthias Kloseb159a552010-04-25 21:00:44 +00001295]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001296CC="$ac_save_cc"])
1297AC_MSG_RESULT($ac_cv_pthread)
1298fi
1299
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001300# If we have set a CC compiler flag for thread support then
1301# check if it works for CXX, too.
1302ac_cv_cxx_thread=no
1303if test ! -z "$CXX"
1304then
1305AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1306ac_save_cxx="$CXX"
1307
1308if test "$ac_cv_kpthread" = "yes"
1309then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001310 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001311 ac_cv_cxx_thread=yes
1312elif test "$ac_cv_kthread" = "yes"
1313then
1314 CXX="$CXX -Kthread"
1315 ac_cv_cxx_thread=yes
1316elif test "$ac_cv_pthread" = "yes"
1317then
1318 CXX="$CXX -pthread"
1319 ac_cv_cxx_thread=yes
1320fi
1321
1322if test $ac_cv_cxx_thread = yes
1323then
1324 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1325 $CXX -c conftest.$ac_ext 2>&5
1326 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1327 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1328 then
1329 ac_cv_cxx_thread=yes
1330 else
1331 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001332 fi
1333 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001334fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001335AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001336fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001337CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001338
Fred Drakece81d592000-07-09 14:39:29 +00001339dnl # check for ANSI or K&R ("traditional") preprocessor
1340dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Kloseb159a552010-04-25 21:00:44 +00001341dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001342dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1343dnl int foo;
1344dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Kloseb159a552010-04-25 21:00:44 +00001345dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001346dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001347
Guido van Rossum627b2d71993-12-24 10:39:16 +00001348# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001349AC_HEADER_STDC
Benjamin Petersonb77fe172011-09-13 17:20:47 -04001350AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
Thomas Wouters0e3f5912006-08-11 14:57:12 +00001351fcntl.h grp.h \
Jesus Cead8b9ae62011-11-14 19:07:41 +01001352ieeefp.h io.h langinfo.h libintl.h ncurses.h process.h pthread.h \
Benjamin Peterson94b580d2011-08-02 17:30:04 -05001353sched.h shadow.h signal.h stdint.h stropts.h termios.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001354unistd.h utime.h \
Jesus Cead8b9ae62011-11-14 19:07:41 +01001355poll.h sys/devpoll.h sys/epoll.h sys/poll.h \
Antoine Pitroubcf2b592012-02-08 23:28:36 +01001356sys/audioio.h sys/xattr.h sys/bsdtty.h sys/event.h sys/file.h sys/ioctl.h \
Martin v. Löwis9d6c6692012-02-03 17:44:58 +01001357sys/kern_control.h sys/loadavg.h sys/lock.h sys/mkdev.h sys/modem.h \
Jesus Cead8b9ae62011-11-14 19:07:41 +01001358sys/param.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \
Martin v. Löwis9d6c6692012-02-03 17:44:58 +01001359sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00001360sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \
Gregory P. Smith3b1f2c32011-05-15 12:18:23 -07001361libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussoren755740f2010-02-07 19:56:39 +00001362bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001363AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001364AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001365
Gregory P. Smith3b1f2c32011-05-15 12:18:23 -07001366# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first.
1367AC_CHECK_HEADERS([net/if.h], [], [],
1368[#include <stdio.h>
1369#ifdef STDC_HEADERS
1370# include <stdlib.h>
1371# include <stddef.h>
1372#else
1373# ifdef HAVE_STDLIB_H
1374# include <stdlib.h>
1375# endif
1376#endif
1377#ifdef HAVE_SYS_SOCKET_H
1378# include <sys/socket.h>
1379#endif
1380])
1381
1382
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001383# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e72004-11-30 22:09:37 +00001384AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001385#ifdef HAVE_CURSES_H
1386#include <curses.h>
1387#endif
1388])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001389
Martin v. Löwis11017b12006-01-14 18:12:57 +00001390# On Linux, netlink.h requires asm/types.h
1391AC_CHECK_HEADERS(linux/netlink.h,,,[
1392#ifdef HAVE_ASM_TYPES_H
1393#include <asm/types.h>
1394#endif
1395#ifdef HAVE_SYS_SOCKET_H
1396#include <sys/socket.h>
1397#endif
1398])
1399
Charles-François Natali47413c12011-10-06 19:47:44 +02001400# On Linux, can.h and can/raw.h require sys/socket.h
1401AC_CHECK_HEADERS(linux/can.h linux/can/raw.h,,,[
1402#ifdef HAVE_SYS_SOCKET_H
1403#include <sys/socket.h>
1404#endif
1405])
1406
Guido van Rossum627b2d71993-12-24 10:39:16 +00001407# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001408was_it_defined=no
1409AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001410AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1411 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1412])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001413AC_MSG_RESULT($was_it_defined)
1414
Neal Norwitz11690112002-07-30 01:08:28 +00001415AC_MSG_CHECKING(for makedev)
Jesus Cea740f53a2010-04-28 11:35:30 +00001416AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1417#if defined(MAJOR_IN_MKDEV)
1418#include <sys/mkdev.h>
1419#elif defined(MAJOR_IN_SYSMACROS)
1420#include <sys/sysmacros.h>
1421#else
1422#include <sys/types.h>
1423#endif
1424]], [[
1425 makedev(0, 0) ]])
Matthias Kloseb159a552010-04-25 21:00:44 +00001426],[ac_cv_has_makedev=yes],[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001427AC_MSG_RESULT($ac_cv_has_makedev)
1428if test "$ac_cv_has_makedev" = "yes"; then
1429 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1430fi
1431
Martin v. Löwis399a6892002-10-04 10:22:02 +00001432# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1433# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1434# defined, but the compiler does not support pragma redefine_extname,
1435# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1436# structures (such as rlimit64) without declaring them. As a
1437# work-around, disable LFS on such configurations
1438
1439use_lfs=yes
1440AC_MSG_CHECKING(Solaris LFS bug)
Matthias Kloseb159a552010-04-25 21:00:44 +00001441AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001442#define _LARGEFILE_SOURCE 1
1443#define _FILE_OFFSET_BITS 64
1444#include <sys/resource.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00001445]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001446AC_MSG_RESULT($sol_lfs_bug)
1447if test "$sol_lfs_bug" = "yes"; then
1448 use_lfs=no
1449fi
1450
1451if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001452# Two defines needed to enable largefile support on various platforms
1453# These may affect some typedefs
Georg Brandl216e4042011-02-19 08:58:23 +00001454case $ac_sys_system/$ac_sys_release in
1455AIX*)
1456 AC_DEFINE(_LARGE_FILES, 1,
1457 [This must be defined on AIX systems to enable large file support.])
1458 ;;
1459esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001460AC_DEFINE(_LARGEFILE_SOURCE, 1,
1461[This must be defined on some systems to enable large file support.])
1462AC_DEFINE(_FILE_OFFSET_BITS, 64,
1463[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001464fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001465
Guido van Rossum300fda71996-08-19 21:58:16 +00001466# Add some code to confdefs.h so that the test for off_t works on SCO
1467cat >> confdefs.h <<\EOF
1468#if defined(SCO_DS)
1469#undef _OFF_T
1470#endif
1471EOF
1472
Guido van Rossumef2255b2000-03-10 22:30:29 +00001473# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001474AC_TYPE_MODE_T
1475AC_TYPE_OFF_T
1476AC_TYPE_PID_T
Matthias Klosebada4c32010-04-25 21:18:48 +00001477AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001478AC_TYPE_SIZE_T
1479AC_TYPE_UID_T
Mark Dickinsonbd792642009-03-18 20:06:12 +00001480AC_TYPE_UINT32_T
1481AC_TYPE_UINT64_T
1482AC_TYPE_INT32_T
1483AC_TYPE_INT64_T
Christian Heimes400adb02008-02-01 08:12:03 +00001484AC_CHECK_TYPE(ssize_t,
Matthias Klosec80c93f2010-04-24 17:04:35 +00001485 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001486
Guido van Rossumef2255b2000-03-10 22:30:29 +00001487# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001488# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001489AC_CHECK_SIZEOF(int, 4)
1490AC_CHECK_SIZEOF(long, 4)
1491AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001492AC_CHECK_SIZEOF(short, 2)
1493AC_CHECK_SIZEOF(float, 4)
1494AC_CHECK_SIZEOF(double, 8)
1495AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001496AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001497AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001498
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001499AC_MSG_CHECKING(for long long support)
1500have_long_long=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001501AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001502 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1503 have_long_long=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001504],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001505AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001506if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001507AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001508fi
1509
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001510AC_MSG_CHECKING(for long double support)
1511have_long_double=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001512AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001513 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1514 have_long_double=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001515],[])
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001516AC_MSG_RESULT($have_long_double)
1517if test "$have_long_double" = yes ; then
1518AC_CHECK_SIZEOF(long double, 16)
1519fi
1520
1521
Thomas Woutersb2137042007-02-01 18:02:27 +00001522AC_MSG_CHECKING(for _Bool support)
1523have_c99_bool=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001524AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Thomas Woutersb2137042007-02-01 18:02:27 +00001525 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1526 have_c99_bool=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001527],[])
Thomas Woutersb2137042007-02-01 18:02:27 +00001528AC_MSG_RESULT($have_c99_bool)
1529if test "$have_c99_bool" = yes ; then
1530AC_CHECK_SIZEOF(_Bool, 1)
1531fi
1532
Thomas Wouters89f507f2006-12-13 04:49:30 +00001533AC_CHECK_TYPES(uintptr_t,
1534 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1535 [], [#ifdef HAVE_STDINT_H
1536 #include <stdint.h>
Antoine Pitrou1bf29b72010-10-10 08:10:16 +00001537 #endif
1538 #ifdef HAVE_INTTYPES_H
1539 #include <inttypes.h>
Thomas Wouters89f507f2006-12-13 04:49:30 +00001540 #endif])
1541
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001542AC_CHECK_SIZEOF(off_t, [], [
1543#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001544#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001545#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 Dickinson2df5d282009-12-31 21:22:50 +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 Dickinson2df5d282009-12-31 21:22:50 +00001562else
1563 AC_MSG_RESULT(no)
1564fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001565
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001566AC_CHECK_SIZEOF(time_t, [], [
1567#ifdef HAVE_SYS_TYPES_H
1568#include <sys/types.h>
1569#endif
1570#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001571#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001572#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
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001584
Trent Mick635f6fb2000-08-23 21:33:05 +00001585AC_MSG_CHECKING(for pthread_t)
1586have_pthread_t=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001587AC_COMPILE_IFELSE([
1588 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1589],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001590AC_MSG_RESULT($have_pthread_t)
1591if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001592 AC_CHECK_SIZEOF(pthread_t, [], [
1593#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001594#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001595#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001596 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001597fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001598CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001599
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001600AC_SUBST(OTHER_LIBTOOL_OPT)
1601case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001602 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001603 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1604 ;;
1605 Darwin/*)
1606 OTHER_LIBTOOL_OPT=""
1607 ;;
1608esac
1609
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001610
1611ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001612AC_SUBST(LIBTOOL_CRUFT)
1613case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001614 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001615 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1616 if test "${enable_universalsdk}"; then
1617 :
1618 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001619 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001620 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001621 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001622 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001623 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001624 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001625 if test ${gcc_version} '<' 4.0
1626 then
1627 LIBTOOL_CRUFT="-lcc_dynamic"
1628 else
1629 LIBTOOL_CRUFT=""
1630 fi
Matthias Kloseb159a552010-04-25 21:00:44 +00001631 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001632 #include <unistd.h>
1633 int main(int argc, char*argv[])
1634 {
1635 if (sizeof(long) == 4) {
1636 return 0;
1637 } else {
1638 return 1;
1639 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001640 }
Matthias Kloseb159a552010-04-25 21:00:44 +00001641 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001642
1643 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001644 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001645 i386)
1646 MACOSX_DEFAULT_ARCH="i386"
1647 ;;
1648 ppc)
1649 MACOSX_DEFAULT_ARCH="ppc"
1650 ;;
1651 *)
1652 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1653 ;;
1654 esac
1655 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001656 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001657 i386)
1658 MACOSX_DEFAULT_ARCH="x86_64"
1659 ;;
1660 ppc)
1661 MACOSX_DEFAULT_ARCH="ppc64"
1662 ;;
1663 *)
1664 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1665 ;;
1666 esac
1667
1668 #ARCH_RUN_32BIT="true"
1669 fi
1670
1671 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001672 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001673 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001674esac
1675
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001676AC_MSG_CHECKING(for --enable-framework)
1677if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001678then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001679 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001680 # -F. is needed to allow linking to the framework while
1681 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001682 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1683 [Define if you want to produce an OpenStep/Rhapsody framework
1684 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001685 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001686 if test $enable_shared = "yes"
1687 then
1688 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1689 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001690else
1691 AC_MSG_RESULT(no)
1692fi
1693
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001694AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001695case $ac_sys_system/$ac_sys_release in
1696 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001697 AC_DEFINE(WITH_DYLD, 1,
1698 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1699 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1700 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001701 AC_MSG_RESULT(always on for Darwin)
1702 ;;
1703 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001704 AC_MSG_RESULT(no)
1705 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001706esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001707
Guido van Rossumac405f61994-09-12 10:56:06 +00001708# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001709AC_SUBST(SO)
1710AC_SUBST(LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001711AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001712AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001713AC_SUBST(CCSHARED)
1714AC_SUBST(LINKFORSHARED)
Georg Brandlb1441c72009-01-03 22:33:39 +00001715
Thomas Wouters477c8d52006-05-27 19:21:47 +00001716AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001717# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001718# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001719# (Shared libraries in this instance are shared modules to be loaded into
1720# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001721AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001722if test -z "$LDSHARED"
1723then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001724 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001725 AIX*)
Georg Brandl9a829be2011-02-15 15:44:51 +00001726 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001727 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001728 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001729 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001730 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001731 SunOS/5*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001732 if test "$GCC" = "yes" ; then
1733 LDSHARED='$(CC) -shared'
1734 LDCXXSHARED='$(CXX) -shared'
1735 else
1736 LDSHARED='$(CC) -G'
1737 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a6632000-05-26 12:22:54 +00001738 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001739 hp*|HP*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001740 if test "$GCC" = "yes" ; then
1741 LDSHARED='$(CC) -shared'
1742 LDCXXSHARED='$(CXX) -shared'
1743 else
1744 LDSHARED='ld -b'
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001745 fi ;;
Jack Jansen418c3b12001-11-14 10:59:57 +00001746 Darwin/1.3*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00001747 LDSHARED='$(CC) -bundle'
1748 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001749 if test "$enable_framework" ; then
1750 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001751 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1752 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001753 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001754 else
1755 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001756 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001757 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001758 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001759 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00001760 LDSHARED='$(CC) -bundle'
1761 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001762 if test "$enable_framework" ; then
1763 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001764 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1765 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001766 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001767 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001768 # No framework, use the Python app as bundle-loader
1769 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001770 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001771 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001772 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001773 Darwin/*)
1774 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1775 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001776
Georg Brandlfcaf9102008-07-16 02:17:56 +00001777 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001778 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001779 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001780 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001781 fi
Antoine Pitroud4958c22010-10-13 17:01:10 +00001782 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
1783 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001784 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001785 else
Antoine Pitroud4958c22010-10-13 17:01:10 +00001786 LDSHARED='$(CC) -bundle'
1787 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001788 if test "$enable_framework" ; then
1789 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001790 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1791 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001792 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001793 else
1794 # No framework, use the Python app as bundle-loader
1795 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1796 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001797 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001798 fi
1799 fi
1800 ;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001801 Linux*|GNU*|QNX*)
1802 LDSHARED='$(CC) -shared'
1803 LDCXXSHARED='$(CXX) -shared';;
1804 BSD/OS*/4*)
1805 LDSHARED="gcc -shared"
1806 LDCXXSHARED="g++ -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001807 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001808 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001809 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00001810 LDSHARED='$(CC) -shared'
1811 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001812 else
Antoine Pitroud4958c22010-10-13 17:01:10 +00001813 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001814 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001815 OpenBSD*)
1816 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1817 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00001818 LDSHARED='$(CC) -shared $(CCSHARED)'
1819 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001820 else
1821 case `uname -r` in
1822 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1823 LDSHARED="ld -Bshareable ${LDFLAGS}"
1824 ;;
1825 *)
Antoine Pitroud4958c22010-10-13 17:01:10 +00001826 LDSHARED='$(CC) -shared $(CCSHARED)'
1827 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001828 ;;
1829 esac
1830 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001831 NetBSD*|DragonFly*)
Antoine Pitrouece919e2011-01-02 20:45:21 +00001832 LDSHARED='$(CC) -shared'
1833 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001834 OpenUNIX*|UnixWare*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001835 if test "$GCC" = "yes" ; then
1836 LDSHARED='$(CC) -shared'
1837 LDCXXSHARED='$(CXX) -shared'
1838 else
1839 LDSHARED='$(CC) -G'
1840 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001841 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001842 SCO_SV*)
1843 LDSHARED='$(CC) -Wl,-G,-Bexport'
1844 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1845 CYGWIN*)
1846 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1847 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001848 *) LDSHARED="ld";;
1849 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001850fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001851AC_MSG_RESULT($LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001852LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001853BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001854# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001855# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001856AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001857if test -z "$CCSHARED"
1858then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001859 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001860 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001861 then CCSHARED="-fPIC";
1862 elif test `uname -p` = sparc;
1863 then CCSHARED="-xcode=pic32";
1864 else CCSHARED="-Kpic";
1865 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001866 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001867 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001868 else CCSHARED="+z";
1869 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001870 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001871 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001872 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001873 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001874 if test "$GCC" = "yes"
1875 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001876 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001877 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001878 SCO_SV*)
1879 if test "$GCC" = "yes"
1880 then CCSHARED="-fPIC"
1881 else CCSHARED="-Kpic -belf"
1882 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001883 IRIX*/6*) case $CC in
1884 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001885 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001886 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001887 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001888fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001889AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001890# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001891# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001892AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001893if test -z "$LINKFORSHARED"
1894then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001895 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001896 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001897 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001898 LINKFORSHARED="-Wl,-E -Wl,+s";;
1899# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001900 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001901 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001902 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001903 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001904 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001905 if test "$enable_framework"
1906 then
Jack Jansenda49e192005-01-07 13:08:22 +00001907 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001908 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001909 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001910 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001911 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001912 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001913 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001914 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1915 then
1916 LINKFORSHARED="-Wl,--export-dynamic"
1917 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001918 SunOS/5*) case $CC in
1919 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001920 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001921 then
1922 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001923 fi;;
1924 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001925 CYGWIN*)
1926 if test $enable_shared = "no"
1927 then
1928 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1929 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001930 QNX*)
1931 # -Wl,-E causes the symbols to be added to the dynamic
1932 # symbol table so that they can be found when a module
1933 # is loaded. -N 2048K causes the stack size to be set
1934 # to 2048 kilobytes so that the stack doesn't overflow
1935 # when running test_compile.py.
1936 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001937 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001938fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001939AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001940
Georg Brandl93de2162008-07-16 02:21:06 +00001941
Neil Schemenauer61c51152001-01-26 16:18:16 +00001942AC_SUBST(CFLAGSFORSHARED)
1943AC_MSG_CHECKING(CFLAGSFORSHARED)
1944if test ! "$LIBRARY" = "$LDLIBRARY"
1945then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001946 case $ac_sys_system in
1947 CYGWIN*)
1948 # Cygwin needs CCSHARED when building extension DLLs
1949 # but not when building the interpreter DLL.
1950 CFLAGSFORSHARED='';;
1951 *)
1952 CFLAGSFORSHARED='$(CCSHARED)'
1953 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001954fi
1955AC_MSG_RESULT($CFLAGSFORSHARED)
1956
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001957# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1958# library (with --enable-shared).
1959# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001960# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1961# if it is not required, since it creates a dependency of the shared library
1962# to LIBS. This, in turn, means that applications linking the shared libpython
1963# don't need to link LIBS explicitly. The default should be only changed
1964# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001965AC_SUBST(SHLIBS)
1966AC_MSG_CHECKING(SHLIBS)
1967case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001968 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001969 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001970esac
1971AC_MSG_RESULT($SHLIBS)
1972
1973
Guido van Rossum627b2d71993-12-24 10:39:16 +00001974# checks for libraries
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00001975AC_CHECK_LIB(sendfile, sendfile)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001976AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1977AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001978
Georg Brandleee31162008-12-07 15:15:22 +00001979# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001980if test "$with_threads" = "yes" -o -z "$with_threads"; then
1981 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1982 # posix4 on Solaris 2.6
1983 # pthread (first!) on Linux
1984fi
1985
Martin v. Löwis19d17342003-06-14 21:03:05 +00001986# check if we need libintl for locale functions
1987AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001988 [AC_DEFINE(WITH_LIBINTL, 1,
1989 [Define to 1 if libintl is needed for locale functions.])
1990 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001991
1992# checks for system dependent C++ extensions support
1993case "$ac_sys_system" in
1994 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Kloseb159a552010-04-25 21:00:44 +00001995 AC_LINK_IFELSE([
Georg Brandl59e87bd2011-02-15 19:48:59 +00001996 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Kloseb159a552010-04-25 21:00:44 +00001997 [[loadAndInit("", 0, "")]])
1998 ],[
1999 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002000 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2001 and you want support for AIX C++ shared extension modules.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002002 AC_MSG_RESULT(yes)
2003 ],[
2004 AC_MSG_RESULT(no)
2005 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002006 *) ;;
2007esac
2008
Guido van Rossum70c7f481998-03-26 18:44:10 +00002009# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002010AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002011AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002012
Guido van Rossumc5a39031996-07-31 17:35:03 +00002013AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002014AC_ARG_WITH(libs,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002015 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002016[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002017AC_MSG_RESULT($withval)
2018LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002019],
2020[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002021
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00002022AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2023
Benjamin Petersonb2d90462009-12-31 03:23:10 +00002024# Check for use of the system expat library
2025AC_MSG_CHECKING(for --with-system-expat)
2026AC_ARG_WITH(system_expat,
Benjamin Peterson79263252010-10-31 16:50:44 +00002027 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2028 [],
2029 [with_system_expat="no"])
Benjamin Petersonb2d90462009-12-31 03:23:10 +00002030
2031AC_MSG_RESULT($with_system_expat)
2032
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002033# Check for use of the system libffi library
2034AC_MSG_CHECKING(for --with-system-ffi)
2035AC_ARG_WITH(system_ffi,
Benjamin Peterson79263252010-10-31 16:50:44 +00002036 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2037 [],
2038 [with_system_ffi="no"])
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002039
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00002040if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00002041 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2042else
2043 LIBFFI_INCLUDEDIR=""
2044fi
2045AC_SUBST(LIBFFI_INCLUDEDIR)
2046
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002047AC_MSG_RESULT($with_system_ffi)
2048
Benjamin Peterson076ed002010-10-31 17:11:02 +00002049# Check for support for loadable sqlite extensions
2050AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
2051AC_ARG_ENABLE(loadable-sqlite-extensions,
2052 AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module]),
2053 [],
2054 [enable_loadable_sqlite_extensions="no"])
2055
2056AC_MSG_RESULT($enable_loadable_sqlite_extensions)
2057
Matthias Klose55708cc2009-04-30 08:06:49 +00002058# Check for --with-dbmliborder
2059AC_MSG_CHECKING(for --with-dbmliborder)
2060AC_ARG_WITH(dbmliborder,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002061 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 Klose55708cc2009-04-30 08:06:49 +00002062[
2063if test x$with_dbmliborder = xyes
2064then
2065AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2066else
2067 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2068 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2069 then
2070 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2071 fi
2072 done
2073fi])
2074AC_MSG_RESULT($with_dbmliborder)
2075
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002076# Determine if signalmodule should be used.
2077AC_SUBST(USE_SIGNAL_MODULE)
2078AC_SUBST(SIGNAL_OBJS)
2079AC_MSG_CHECKING(for --with-signal-module)
2080AC_ARG_WITH(signal-module,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002081 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002082
2083if test -z "$with_signal_module"
2084then with_signal_module="yes"
2085fi
2086AC_MSG_RESULT($with_signal_module)
2087
2088if test "${with_signal_module}" = "yes"; then
2089 USE_SIGNAL_MODULE=""
2090 SIGNAL_OBJS=""
2091else
2092 USE_SIGNAL_MODULE="#"
2093 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2094fi
2095
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002096# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002097AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002098USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002099
Guido van Rossum54d93d41997-01-22 20:51:58 +00002100AC_SUBST(LDLAST)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002101
Martin v. Löwis11437992002-04-12 09:54:03 +00002102# Templates for things AC_DEFINEd more than once.
2103# For a single AC_DEFINE, no template is needed.
Martin v. Löwis11437992002-04-12 09:54:03 +00002104AH_TEMPLATE(_REENTRANT,
2105 [Define to force use of thread-safe errno, h_errno, and other functions])
2106AH_TEMPLATE(WITH_THREAD,
2107 [Define if you want to compile in rudimentary thread support])
2108
Guido van Rossum54d93d41997-01-22 20:51:58 +00002109AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002110dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002111AC_ARG_WITH(threads,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002112 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002113
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002114# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002115dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002116AC_ARG_WITH(thread,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002117 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002118 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002119
2120if test -z "$with_threads"
2121then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002122fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002123AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002124
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002125AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002126if test "$with_threads" = "no"
2127then
2128 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002129elif test "$ac_cv_pthread_is_default" = yes
2130then
2131 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002132 # Defining _REENTRANT on system with POSIX threads should not hurt.
2133 AC_DEFINE(_REENTRANT)
2134 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002135 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002136elif test "$ac_cv_kpthread" = "yes"
2137then
2138 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002139 if test "$ac_cv_cxx_thread" = "yes"; then
2140 CXX="$CXX -Kpthread"
2141 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002142 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002143 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002144 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002145elif test "$ac_cv_kthread" = "yes"
2146then
2147 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002148 if test "$ac_cv_cxx_thread" = "yes"; then
2149 CXX="$CXX -Kthread"
2150 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002151 AC_DEFINE(WITH_THREAD)
2152 posix_threads=yes
2153 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002154elif test "$ac_cv_pthread" = "yes"
2155then
2156 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002157 if test "$ac_cv_cxx_thread" = "yes"; then
2158 CXX="$CXX -pthread"
2159 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002160 AC_DEFINE(WITH_THREAD)
2161 posix_threads=yes
2162 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002163else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002164 if test ! -z "$with_threads" -a -d "$with_threads"
2165 then LDFLAGS="$LDFLAGS -L$with_threads"
2166 fi
2167 if test ! -z "$withval" -a -d "$withval"
2168 then LDFLAGS="$LDFLAGS -L$withval"
2169 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002170
2171 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002172 # define _POSIX_THREADS in unistd.h. Some apparently don't
2173 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002174 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2175 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002176 [
2177#include <unistd.h>
2178#ifdef _POSIX_THREADS
2179yes
2180#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002181 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2182 AC_MSG_RESULT($unistd_defines_pthreads)
2183
Martin v. Löwis130fb172001-07-19 11:00:41 +00002184 AC_DEFINE(_REENTRANT)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002185 # Just looking for pthread_create in libpthread is not enough:
2186 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2187 # So we really have to include pthread.h, and then link.
2188 _libs=$LIBS
2189 LIBS="$LIBS -lpthread"
2190 AC_MSG_CHECKING([for pthread_create in -lpthread])
Matthias Kloseb159a552010-04-25 21:00:44 +00002191 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002192
Matthias Kloseb159a552010-04-25 21:00:44 +00002193void * start_routine (void *arg) { exit (0); }]], [[
2194pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002195 AC_MSG_RESULT(yes)
2196 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002197 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002198 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002199 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002200 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002201 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002202 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002203 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002204 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002205 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002206 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002207 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002208 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002209 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002210 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002211 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002212 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002213 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002214 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002215 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002216 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002217 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002218 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002219 USE_THREAD_MODULE="#"])
Antoine Pitrou37009202011-07-08 23:47:50 +02002220 ])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002221
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002222 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2223 LIBS="$LIBS -lmpc"
2224 THREADOBJ="Python/thread.o"
2225 USE_THREAD_MODULE=""])
2226
2227 if test "$posix_threads" != "yes"; then
2228 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2229 LIBS="$LIBS -lthread"
2230 THREADOBJ="Python/thread.o"
2231 USE_THREAD_MODULE=""])
2232 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002233fi
2234
2235if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002236 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002237 AC_DEFINE(_POSIX_THREADS, 1,
2238 [Define if you have POSIX threads,
2239 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002240 fi
2241
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002242 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2243 case $ac_sys_system/$ac_sys_release in
Charles-François Natali996f6062011-07-21 19:45:31 +02002244 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002245 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002246 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002247 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002248 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002249 ;;
Charles-François Natali996f6062011-07-21 19:45:31 +02002250 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002251 [Define if the Posix semaphores do not work on your system])
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002252 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002253 esac
2254
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002255 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2256 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Matthias Kloseb159a552010-04-25 21:00:44 +00002257 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002258 void *foo(void *parm) {
2259 return NULL;
2260 }
2261 main() {
2262 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002263 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002264 if (pthread_attr_init(&attr)) exit(-1);
2265 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002266 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002267 exit(0);
Matthias Kloseb159a552010-04-25 21:00:44 +00002268 }]])],
2269 [ac_cv_pthread_system_supported=yes],
2270 [ac_cv_pthread_system_supported=no],
2271 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002272 ])
2273 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2274 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002275 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002276 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002277 AC_CHECK_FUNCS(pthread_sigmask,
2278 [case $ac_sys_system in
2279 CYGWIN*)
2280 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2281 [Define if pthread_sigmask() does not work on your system.])
2282 ;;
2283 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002284fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002285
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002286
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002287# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002288AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002289AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002290AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002291[ --enable-ipv6 Enable ipv6 (with ipv4) support
2292 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002293[ case "$enableval" in
2294 no)
2295 AC_MSG_RESULT(no)
2296 ipv6=no
2297 ;;
2298 *) AC_MSG_RESULT(yes)
2299 AC_DEFINE(ENABLE_IPV6)
2300 ipv6=yes
2301 ;;
2302 esac ],
2303
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002304[
2305dnl the check does not work on cross compilation case...
Matthias Kloseb159a552010-04-25 21:00:44 +00002306 AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002307#include <sys/types.h>
2308#include <sys/socket.h>
2309main()
2310{
2311 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2312 exit(1);
2313 else
2314 exit(0);
2315}
Matthias Kloseb159a552010-04-25 21:00:44 +00002316]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002317 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00002318 ipv6=yes
2319],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002320 AC_MSG_RESULT(no)
2321 ipv6=no
Matthias Kloseb159a552010-04-25 21:00:44 +00002322],[
2323 AC_MSG_RESULT(no)
2324 ipv6=no
2325])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002326
2327if test "$ipv6" = "yes"; then
2328 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Kloseb159a552010-04-25 21:00:44 +00002329 AC_COMPILE_IFELSE([
2330 AC_LANG_PROGRAM([[#include <sys/types.h>
2331#include <netinet/in.h>]],
2332 [[struct sockaddr_in6 x;
2333 x.sin6_scope_id;]])
2334 ],[
2335 AC_MSG_RESULT(yes)
2336 ipv6=yes
2337 ],[
2338 AC_MSG_RESULT(no, IPv6 disabled)
2339 ipv6=no
2340 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002341fi
2342
2343if test "$ipv6" = "yes"; then
2344 AC_DEFINE(ENABLE_IPV6)
2345fi
2346])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002347
2348ipv6type=unknown
2349ipv6lib=none
2350ipv6trylibc=no
2351
2352if test "$ipv6" = "yes"; then
2353 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002354 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2355 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002356 case $i in
2357 inria)
2358 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002359 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002360#include <netinet/in.h>
2361#ifdef IPV6_INRIA_VERSION
2362yes
2363#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002364 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002365 ;;
2366 kame)
2367 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002368 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002369#include <netinet/in.h>
2370#ifdef __KAME__
2371yes
2372#endif],
2373 [ipv6type=$i;
2374 ipv6lib=inet6
2375 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002376 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002377 ;;
2378 linux-glibc)
2379 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002380 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002381#include <features.h>
2382#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2383yes
2384#endif],
2385 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002386 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002387 ;;
2388 linux-inet6)
2389 dnl http://www.v6.linux.or.jp/
2390 if test -d /usr/inet6; then
2391 ipv6type=$i
2392 ipv6lib=inet6
2393 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002394 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002395 fi
2396 ;;
2397 solaris)
2398 if test -f /etc/netconfig; then
Antoine Pitrouf3fcd9f2011-01-03 18:53:50 +00002399 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002400 ipv6type=$i
2401 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002402 fi
2403 fi
2404 ;;
2405 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002406 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002407#include <sys/param.h>
2408#ifdef _TOSHIBA_INET6
2409yes
2410#endif],
2411 [ipv6type=$i;
2412 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002413 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002414 ;;
2415 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002416 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002417#include </usr/local/v6/include/sys/v6config.h>
2418#ifdef __V6D__
2419yes
2420#endif],
2421 [ipv6type=$i;
2422 ipv6lib=v6;
2423 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002424 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002425 ;;
2426 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002427 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002428#include <sys/param.h>
2429#ifdef _ZETA_MINAMI_INET6
2430yes
2431#endif],
2432 [ipv6type=$i;
2433 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002434 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002435 ;;
2436 esac
2437 if test "$ipv6type" != "unknown"; then
2438 break
2439 fi
2440 done
2441 AC_MSG_RESULT($ipv6type)
2442fi
2443
2444if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2445 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2446 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2447 echo "using lib$ipv6lib"
2448 else
2449 if test $ipv6trylibc = "yes"; then
2450 echo "using libc"
2451 else
2452 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2453 echo "You need to fetch lib$ipv6lib.a from appropriate"
2454 echo 'ipv6 kit and compile beforehand.'
2455 exit 1
2456 fi
2457 fi
2458fi
2459
Georg Brandl93de2162008-07-16 02:21:06 +00002460AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Kloseb159a552010-04-25 21:00:44 +00002461AC_COMPILE_IFELSE([
2462 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
2463],[
Matthias Klosec80c93f2010-04-24 17:04:35 +00002464 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002465 AC_MSG_RESULT(yes)
2466],[
Georg Brandl93de2162008-07-16 02:21:06 +00002467 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00002468])
Georg Brandl93de2162008-07-16 02:21:06 +00002469
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002470# Check for --with-doc-strings
2471AC_MSG_CHECKING(for --with-doc-strings)
2472AC_ARG_WITH(doc-strings,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002473 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002474
2475if test -z "$with_doc_strings"
2476then with_doc_strings="yes"
2477fi
2478if test "$with_doc_strings" != "no"
2479then
2480 AC_DEFINE(WITH_DOC_STRINGS, 1,
2481 [Define if you want documentation strings in extension modules])
2482fi
2483AC_MSG_RESULT($with_doc_strings)
2484
Georg Brandl9976a512010-08-02 21:02:36 +00002485# Check if eval loop should use timestamp counter profiling
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002486AC_MSG_CHECKING(for --with-tsc)
2487AC_ARG_WITH(tsc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002488 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002489if test "$withval" != no
2490then
2491 AC_DEFINE(WITH_TSC, 1,
2492 [Define to profile with the Pentium timestamp counter])
2493 AC_MSG_RESULT(yes)
2494else AC_MSG_RESULT(no)
2495fi],
2496[AC_MSG_RESULT(no)])
2497
2498# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002499AC_MSG_CHECKING(for --with-pymalloc)
2500AC_ARG_WITH(pymalloc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002501 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002502
2503if test -z "$with_pymalloc"
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00002504then
2505 with_pymalloc="yes"
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00002506 ABIFLAGS="${ABIFLAGS}m"
Neil Schemenauer16c22972002-03-22 15:34:49 +00002507fi
2508if test "$with_pymalloc" != "no"
2509then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002510 AC_DEFINE(WITH_PYMALLOC, 1,
2511 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002512fi
2513AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002514
Benjamin Peterson05159c42009-12-03 03:01:27 +00002515# Check for Valgrind support
2516AC_MSG_CHECKING([for --with-valgrind])
2517AC_ARG_WITH([valgrind],
Matthias Klose2b8733f2010-04-25 18:34:36 +00002518 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson05159c42009-12-03 03:01:27 +00002519 with_valgrind=no)
2520AC_MSG_RESULT([$with_valgrind])
2521if test "$with_valgrind" != no; then
2522 AC_CHECK_HEADER([valgrind/valgrind.h],
2523 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2524 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2525 )
Jeffrey Yasskin39370832010-05-03 19:29:34 +00002526 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
Benjamin Peterson05159c42009-12-03 03:01:27 +00002527fi
2528
Guido van Rossum68242b51996-05-28 22:53:03 +00002529# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002530AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002531DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002532
Guido van Rossume97ee181999-12-20 21:27:22 +00002533# the dlopen() function means we might want to use dynload_shlib.o. some
2534# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002535AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002536
2537# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2538# loading of modules.
2539AC_SUBST(DYNLOADFILE)
2540AC_MSG_CHECKING(DYNLOADFILE)
2541if test -z "$DYNLOADFILE"
2542then
2543 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002544 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2545 if test "$ac_cv_func_dlopen" = yes
2546 then DYNLOADFILE="dynload_shlib.o"
2547 else DYNLOADFILE="dynload_aix.o"
2548 fi
2549 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002550 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002551 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2552 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002553 *)
2554 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2555 # out any dynamic loading
2556 if test "$ac_cv_func_dlopen" = yes
2557 then DYNLOADFILE="dynload_shlib.o"
2558 else DYNLOADFILE="dynload_stub.o"
2559 fi
2560 ;;
2561 esac
2562fi
2563AC_MSG_RESULT($DYNLOADFILE)
2564if test "$DYNLOADFILE" != "dynload_stub.o"
2565then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002566 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2567 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002568fi
2569
Jack Jansenc49e5b72001-06-19 15:00:23 +00002570# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2571
2572AC_SUBST(MACHDEP_OBJS)
2573AC_MSG_CHECKING(MACHDEP_OBJS)
2574if test -z "$MACHDEP_OBJS"
2575then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002576 MACHDEP_OBJS=$extra_machdep_objs
2577else
2578 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002579fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002580AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002581
Guido van Rossum627b2d71993-12-24 10:39:16 +00002582# checks for library functions
Antoine Pitroub1c54962010-10-14 15:05:38 +00002583AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
Gregory P. Smith1577cf72012-01-21 18:21:56 -08002584 clock confstr ctermid execv faccessat fchmod fchmodat fchown fchownat \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002585 fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
Ross Lagerwallb0ae53d2011-06-10 07:30:30 +02002586 futimens futimes gai_strerror \
2587 getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002588 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Gregory P. Smith5ed2e772011-05-15 00:26:45 -07002589 if_nameindex \
Antoine Pitrouf0effe62011-11-26 01:11:02 +01002590 initgroups kill killpg lchmod lchown lockf linkat lstat lutimes mmap \
2591 memrchr mbrtowc mkdirat mkfifo \
Charles-François Natalidaafdd52011-05-29 20:07:40 +02002592 mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002593 posix_fallocate posix_fadvise pread \
Victor Stinnerb3e72192011-05-08 01:46:11 +02002594 pthread_init pthread_kill putenv pwrite readlink readlinkat readv realpath renameat \
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00002595 select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \
Antoine Pitrou061cfb52011-02-28 22:25:22 +00002596 setgid sethostname \
Giampaolo Rodolà18e8bcb2011-02-25 20:57:54 +00002597 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
Charles-François Nataliea0d5fc2011-09-06 19:03:35 +02002598 sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
2599 sched_rr_get_interval \
Ross Lagerwallbc808222011-06-25 12:13:40 +02002600 sigaction sigaltstack siginterrupt sigpending sigrelse \
2601 sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002602 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002603 truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
2604 wcscoll wcsftime wcsxfrm writev _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002605
Gregory P. Smithdf300d52012-01-21 18:20:15 -08002606AC_CHECK_DECL(dirfd,
2607 AC_DEFINE(HAVE_DIRFD, 1,
2608 Define if you have the 'dirfd' function or macro.), ,
2609 [#include <sys/types.h>
2610 #include <dirent.h>])
2611
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002612# For some functions, having a definition is not sufficient, since
2613# we want to take their address.
2614AC_MSG_CHECKING(for chroot)
Matthias Kloseb159a552010-04-25 21:00:44 +00002615AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2616 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2617 AC_MSG_RESULT(yes)],
2618 [AC_MSG_RESULT(no)
2619])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002620AC_MSG_CHECKING(for link)
Matthias Kloseb159a552010-04-25 21:00:44 +00002621AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2622 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2623 AC_MSG_RESULT(yes)],
2624 [AC_MSG_RESULT(no)
2625])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002626AC_MSG_CHECKING(for symlink)
Matthias Kloseb159a552010-04-25 21:00:44 +00002627AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2628 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2629 AC_MSG_RESULT(yes)],
2630 [AC_MSG_RESULT(no)
2631])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002632AC_MSG_CHECKING(for fchdir)
Matthias Kloseb159a552010-04-25 21:00:44 +00002633AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2634 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2635 AC_MSG_RESULT(yes)],
2636 [AC_MSG_RESULT(no)
2637])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002638AC_MSG_CHECKING(for fsync)
Matthias Kloseb159a552010-04-25 21:00:44 +00002639AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2640 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2641 AC_MSG_RESULT(yes)],
2642 [AC_MSG_RESULT(no)
2643])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002644AC_MSG_CHECKING(for fdatasync)
Matthias Kloseb159a552010-04-25 21:00:44 +00002645AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2646 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2647 AC_MSG_RESULT(yes)],
2648 [AC_MSG_RESULT(no)
2649])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002650AC_MSG_CHECKING(for epoll)
Matthias Kloseb159a552010-04-25 21:00:44 +00002651AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2652 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2653 AC_MSG_RESULT(yes)],
2654 [AC_MSG_RESULT(no)
2655])
Benjamin Peterson95c16622011-12-27 15:36:32 -06002656AC_MSG_CHECKING(for epoll_create1)
2657AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create1]])],
2658 [AC_DEFINE(HAVE_EPOLL_CREATE1, 1, Define if you have the 'epoll_create1' function.)
2659 AC_MSG_RESULT(yes)],
2660 [AC_MSG_RESULT(no)
2661])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002662AC_MSG_CHECKING(for kqueue)
Matthias Kloseb159a552010-04-25 21:00:44 +00002663AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002664#include <sys/types.h>
2665#include <sys/event.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002666 ]], [[int x=kqueue()]])],
2667 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2668 AC_MSG_RESULT(yes)],
2669 [AC_MSG_RESULT(no)
2670])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002671# On some systems (eg. FreeBSD 5), we would find a definition of the
2672# functions ctermid_r, setgroups in the library, but no prototype
2673# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2674# address to avoid compiler warnings and potential miscompilations
2675# because of the missing prototypes.
2676
2677AC_MSG_CHECKING(for ctermid_r)
Matthias Kloseb159a552010-04-25 21:00:44 +00002678AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002679#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002680]], [[void* p = ctermid_r]])],
2681 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2682 AC_MSG_RESULT(yes)],
2683 [AC_MSG_RESULT(no)
2684])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002685
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00002686AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2687 [AC_COMPILE_IFELSE(
2688 [AC_LANG_PROGRAM(
2689 [#include <sys/file.h>],
2690 [void* p = flock]
2691 )],
2692 [ac_cv_flock_decl=yes],
2693 [ac_cv_flock_decl=no]
2694 )
Matthias Kloseb159a552010-04-25 21:00:44 +00002695])
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00002696if test "x${ac_cv_flock_decl}" = xyes; then
2697 AC_CHECK_FUNCS(flock,,
2698 AC_CHECK_LIB(bsd,flock,
2699 [AC_DEFINE(HAVE_FLOCK)
2700 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2701 ])
2702 )
Antoine Pitroua3000072010-09-07 14:52:42 +00002703fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002704
2705AC_MSG_CHECKING(for getpagesize)
Matthias Kloseb159a552010-04-25 21:00:44 +00002706AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002707#include <unistd.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002708]], [[void* p = getpagesize]])],
2709 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2710 AC_MSG_RESULT(yes)],
2711 [AC_MSG_RESULT(no)
2712])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002713
Victor Stinner984890f2011-11-24 13:53:38 +01002714AC_MSG_CHECKING(for broken unsetenv)
2715AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2716#include <stdlib.h>
2717]], [[int res = unsetenv("DUMMY")]])],
2718 [AC_MSG_RESULT(no)],
2719 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
2720 AC_MSG_RESULT(yes)
2721])
2722
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002723dnl check for true
2724AC_CHECK_PROGS(TRUE, true, /bin/true)
2725
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002726dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2727dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002728AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002729 AC_CHECK_LIB(resolv, inet_aton)
2730)
2731
Christian Heimesd0764e22007-12-04 15:00:33 +00002732# On Tru64, chflags seems to be present, but calling it will
2733# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002734AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07002735AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002736#include <sys/stat.h>
2737#include <unistd.h>
2738int main(int argc, char*argv[])
2739{
2740 if(chflags(argv[0], 0) != 0)
2741 return 1;
2742 return 0;
2743}
Ned Deily3eb67d52011-06-28 00:00:28 -07002744]])],
Matthias Kloseb159a552010-04-25 21:00:44 +00002745[ac_cv_have_chflags=yes],
2746[ac_cv_have_chflags=no],
2747[ac_cv_have_chflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002748])
2749if test "$ac_cv_have_chflags" = cross ; then
2750 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2751fi
2752if test "$ac_cv_have_chflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07002753 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002754fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002755
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002756AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07002757AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002758#include <sys/stat.h>
2759#include <unistd.h>
2760int main(int argc, char*argv[])
2761{
2762 if(lchflags(argv[0], 0) != 0)
2763 return 1;
2764 return 0;
2765}
Ned Deily3eb67d52011-06-28 00:00:28 -07002766]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002767])
2768if test "$ac_cv_have_lchflags" = cross ; then
2769 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2770fi
2771if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07002772 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002773fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002774
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002775dnl Check if system zlib has *Copy() functions
2776dnl
2777dnl On MacOSX the linker will search for dylibs on the entire linker path
2778dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2779dnl to revert to a more traditional unix behaviour and make it possible to
2780dnl override the system libz with a local static library of libz. Temporarily
2781dnl add that flag to our CFLAGS as well to ensure that we check the version
2782dnl of libz that will be used by setup.py.
2783dnl The -L/usr/local/lib is needed as wel to get the same compilation
2784dnl environment as setup.py (and leaving it out can cause configure to use the
2785dnl wrong version of the library)
2786case $ac_sys_system/$ac_sys_release in
2787Darwin/*)
2788 _CUR_CFLAGS="${CFLAGS}"
2789 _CUR_LDFLAGS="${LDFLAGS}"
2790 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2791 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2792 ;;
2793esac
2794
Matthias Klosec80c93f2010-04-24 17:04:35 +00002795AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002796
2797case $ac_sys_system/$ac_sys_release in
2798Darwin/*)
2799 CFLAGS="${_CUR_CFLAGS}"
2800 LDFLAGS="${_CUR_LDFLAGS}"
2801 ;;
2802esac
2803
Martin v. Löwise9416172003-05-03 10:12:45 +00002804AC_MSG_CHECKING(for hstrerror)
Matthias Kloseb159a552010-04-25 21:00:44 +00002805AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00002806#include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002807]], [[void* p = hstrerror; hstrerror(0)]])],
2808 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2809 AC_MSG_RESULT(yes)],
2810 [AC_MSG_RESULT(no)
2811])
Martin v. Löwise9416172003-05-03 10:12:45 +00002812
2813AC_MSG_CHECKING(for inet_aton)
Matthias Kloseb159a552010-04-25 21:00:44 +00002814AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00002815#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002816#include <sys/socket.h>
2817#include <netinet/in.h>
2818#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002819]], [[void* p = inet_aton;inet_aton(0,0)]])],
2820 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2821 AC_MSG_RESULT(yes)],
2822 [AC_MSG_RESULT(no)
2823])
Martin v. Löwise9416172003-05-03 10:12:45 +00002824
2825AC_MSG_CHECKING(for inet_pton)
Matthias Kloseb159a552010-04-25 21:00:44 +00002826AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002827#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002828#include <sys/socket.h>
2829#include <netinet/in.h>
2830#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002831]], [[void* p = inet_pton]])],
2832 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2833 AC_MSG_RESULT(yes)],
2834 [AC_MSG_RESULT(no)
2835])
Martin v. Löwise9416172003-05-03 10:12:45 +00002836
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002837# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002838AC_MSG_CHECKING(for setgroups)
Matthias Kloseb159a552010-04-25 21:00:44 +00002839AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002840#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002841#ifdef HAVE_GRP_H
2842#include <grp.h>
2843#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00002844]], [[void* p = setgroups]])],
2845 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2846 AC_MSG_RESULT(yes)],
2847 [AC_MSG_RESULT(no)
2848])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002849
Fred Drake8cef4cf2000-06-28 16:40:38 +00002850# check for openpty and forkpty
2851
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002852AC_CHECK_FUNCS(openpty,,
2853 AC_CHECK_LIB(util,openpty,
2854 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2855 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2856 )
2857)
2858AC_CHECK_FUNCS(forkpty,,
2859 AC_CHECK_LIB(util,forkpty,
2860 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2861 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2862 )
2863)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002864
Christian Heimesb186d002008-03-18 15:15:01 +00002865# Stuff for expat.
2866AC_CHECK_FUNCS(memmove)
2867
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002868# check for long file support functions
2869AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2870
Christian Heimesb186d002008-03-18 15:15:01 +00002871AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002872AC_CHECK_FUNCS(getpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00002873 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
2874 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
2875 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002876)
Jack Jansen150753c2003-03-29 22:07:47 +00002877AC_CHECK_FUNCS(setpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00002878 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
2879 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
2880 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002881)
2882AC_CHECK_FUNCS(gettimeofday,
Matthias Kloseb159a552010-04-25 21:00:44 +00002883 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
2884 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
2885 [],
2886 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2887 [Define if gettimeofday() does not have second (timezone) argument
2888 This is the case on Motorola V4 (R40V4.2)])
2889 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002890)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002891
Victor Stinnere0be4232011-10-25 13:06:09 +02002892AC_CHECK_FUNCS(clock_gettime, [], [
2893 AC_CHECK_LIB(rt, clock_gettime, [
2894 AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
2895 AC_DEFINE(TIMEMODULE_LIB, [rt],
2896 [Library needed by timemodule.c: librt may be needed for clock_gettime()])
2897 ])
2898])
2899
2900AC_CHECK_FUNCS(clock_getres, [], [
2901 AC_CHECK_LIB(rt, clock_getres, [
2902 AC_DEFINE(HAVE_CLOCK_GETRES, 1)
2903 ])
2904])
2905
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002906AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Kloseb159a552010-04-25 21:00:44 +00002907AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002908#if defined(MAJOR_IN_MKDEV)
2909#include <sys/mkdev.h>
2910#elif defined(MAJOR_IN_SYSMACROS)
2911#include <sys/sysmacros.h>
2912#else
2913#include <sys/types.h>
2914#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00002915]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002916 makedev(major(0),minor(0));
Matthias Kloseb159a552010-04-25 21:00:44 +00002917]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002918 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2919 [Define to 1 if you have the device macros.])
2920 AC_MSG_RESULT(yes)
2921],[
2922 AC_MSG_RESULT(no)
2923])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002924
2925# On OSF/1 V5.1, getaddrinfo is available, but a define
2926# for [no]getaddrinfo in netdb.h.
2927AC_MSG_CHECKING(for getaddrinfo)
Matthias Kloseb159a552010-04-25 21:00:44 +00002928AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002929#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002930#include <sys/socket.h>
2931#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002932#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002933]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
2934[have_getaddrinfo=yes],
2935[have_getaddrinfo=no])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002936AC_MSG_RESULT($have_getaddrinfo)
2937if test $have_getaddrinfo = yes
2938then
2939 AC_MSG_CHECKING(getaddrinfo bug)
2940 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00002941 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002942#include <sys/types.h>
2943#include <netdb.h>
2944#include <string.h>
2945#include <sys/socket.h>
2946#include <netinet/in.h>
2947
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002948int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002949{
2950 int passive, gaierr, inet4 = 0, inet6 = 0;
2951 struct addrinfo hints, *ai, *aitop;
2952 char straddr[INET6_ADDRSTRLEN], strport[16];
2953
2954 for (passive = 0; passive <= 1; passive++) {
2955 memset(&hints, 0, sizeof(hints));
2956 hints.ai_family = AF_UNSPEC;
2957 hints.ai_flags = passive ? AI_PASSIVE : 0;
2958 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002959 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002960 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2961 (void)gai_strerror(gaierr);
2962 goto bad;
2963 }
2964 for (ai = aitop; ai; ai = ai->ai_next) {
2965 if (ai->ai_addr == NULL ||
2966 ai->ai_addrlen == 0 ||
2967 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2968 straddr, sizeof(straddr), strport, sizeof(strport),
2969 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2970 goto bad;
2971 }
2972 switch (ai->ai_family) {
2973 case AF_INET:
2974 if (strcmp(strport, "54321") != 0) {
2975 goto bad;
2976 }
2977 if (passive) {
2978 if (strcmp(straddr, "0.0.0.0") != 0) {
2979 goto bad;
2980 }
2981 } else {
2982 if (strcmp(straddr, "127.0.0.1") != 0) {
2983 goto bad;
2984 }
2985 }
2986 inet4++;
2987 break;
2988 case AF_INET6:
2989 if (strcmp(strport, "54321") != 0) {
2990 goto bad;
2991 }
2992 if (passive) {
2993 if (strcmp(straddr, "::") != 0) {
2994 goto bad;
2995 }
2996 } else {
2997 if (strcmp(straddr, "::1") != 0) {
2998 goto bad;
2999 }
3000 }
3001 inet6++;
3002 break;
3003 case AF_UNSPEC:
3004 goto bad;
3005 break;
3006 default:
3007 /* another family support? */
3008 break;
3009 }
3010 }
3011 }
3012
3013 if (!(inet4 == 0 || inet4 == 2))
3014 goto bad;
3015 if (!(inet6 == 0 || inet6 == 2))
3016 goto bad;
3017
3018 if (aitop)
3019 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003020 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003021
3022 bad:
3023 if (aitop)
3024 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003025 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003026}
Matthias Kloseb159a552010-04-25 21:00:44 +00003027]]])],
3028[ac_cv_buggy_getaddrinfo=no],
3029[ac_cv_buggy_getaddrinfo=yes],
Matthias Klose96350132012-03-15 20:42:23 +01003030[
3031if test "${enable_ipv6+set}" = set; then
3032 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3033else
3034 ac_cv_buggy_getaddrinfo=yes
3035fi]))
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003036fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003037
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003038AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3039
Mark Dickinson2df5d282009-12-31 21:22:50 +00003040if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003041then
3042 if test $ipv6 = yes
3043 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003044 echo 'Fatal: You must get working getaddrinfo() function.'
3045 echo ' or you can specify "--disable-ipv6"'.
3046 exit 1
3047 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003048else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003049 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003050fi
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003051
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003052AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003053
Guido van Rossum627b2d71993-12-24 10:39:16 +00003054# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003055AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003056AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003057AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003058AC_CHECK_MEMBERS([struct stat.st_rdev])
3059AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003060AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003061AC_CHECK_MEMBERS([struct stat.st_gen])
3062AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003063AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003064
3065AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Kloseb159a552010-04-25 21:00:44 +00003066AC_CACHE_VAL(ac_cv_header_time_altzone,[
3067 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3068 [ac_cv_header_time_altzone=yes],
3069 [ac_cv_header_time_altzone=no])
3070 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003071AC_MSG_RESULT($ac_cv_header_time_altzone)
3072if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003073 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003074fi
3075
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003076was_it_defined=no
3077AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Kloseb159a552010-04-25 21:00:44 +00003078AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003079#include <sys/types.h>
3080#include <sys/select.h>
3081#include <sys/time.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003082]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003083 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3084 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3085 (which you can't on SCO ODT 3.0).])
3086 was_it_defined=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003087],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003088AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003089
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003090AC_MSG_CHECKING(for addrinfo)
3091AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00003092AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3093 [ac_cv_struct_addrinfo=yes],
3094 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003095AC_MSG_RESULT($ac_cv_struct_addrinfo)
3096if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003097 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003098fi
3099
3100AC_MSG_CHECKING(for sockaddr_storage)
3101AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Kloseb159a552010-04-25 21:00:44 +00003102AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003103# include <sys/types.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003104# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3105 [ac_cv_struct_sockaddr_storage=yes],
3106 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003107AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3108if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003109 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003110fi
3111
Guido van Rossum627b2d71993-12-24 10:39:16 +00003112# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003113
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003114AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003115AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003116
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003117works=no
3118AC_MSG_CHECKING(for working volatile)
Matthias Kloseb159a552010-04-25 21:00:44 +00003119AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3120 [works=yes],
3121 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003122)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003123AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003124
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003125works=no
3126AC_MSG_CHECKING(for working signed char)
Matthias Kloseb159a552010-04-25 21:00:44 +00003127AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3128 [works=yes],
3129 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003130)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003131AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003132
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003133have_prototypes=no
3134AC_MSG_CHECKING(for prototypes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003135AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3136 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3137 [Define if your compiler supports function prototype])
3138 have_prototypes=yes],
3139 []
3140)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003141AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003142
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003143works=no
3144AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Kloseb159a552010-04-25 21:00:44 +00003145AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003146#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003147int foo(int x, ...) {
3148 va_list va;
3149 va_start(va, x);
3150 va_arg(va, int);
3151 va_arg(va, char *);
3152 va_arg(va, double);
3153 return 0;
3154}
Matthias Kloseb159a552010-04-25 21:00:44 +00003155]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003156 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3157 [Define if your compiler supports variable length function prototypes
3158 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3159 works=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003160],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003161AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003162
Dave Cole331708b2004-08-09 04:51:41 +00003163# check for socketpair
3164AC_MSG_CHECKING(for socketpair)
Matthias Kloseb159a552010-04-25 21:00:44 +00003165AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003166#include <sys/types.h>
3167#include <sys/socket.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003168]], [[void *x=socketpair]])],
3169 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3170 AC_MSG_RESULT(yes)],
3171 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003172)
3173
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003174# check if sockaddr has sa_len member
3175AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Kloseb159a552010-04-25 21:00:44 +00003176AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3177#include <sys/socket.h>]], [[struct sockaddr x;
3178x.sa_len = 0;]])],
3179 [AC_MSG_RESULT(yes)
3180 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3181 [AC_MSG_RESULT(no)]
3182)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003183
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003184va_list_is_array=no
3185AC_MSG_CHECKING(whether va_list is an array)
Matthias Kloseb159a552010-04-25 21:00:44 +00003186AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003187#ifdef HAVE_STDARG_PROTOTYPES
3188#include <stdarg.h>
3189#else
3190#include <varargs.h>
3191#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00003192]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003193 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3194 va_list_is_array=yes
3195])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003196AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003197
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003198# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003199AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3200 [Define this if you have some version of gethostbyname_r()])
3201
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003202AC_CHECK_FUNC(gethostbyname_r, [
3203 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3204 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3205 OLD_CFLAGS=$CFLAGS
3206 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003208# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003209 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003210 char *name;
3211 struct hostent *he, *res;
3212 char buffer[2048];
3213 int buflen = 2048;
3214 int h_errnop;
3215
3216 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Kloseb159a552010-04-25 21:00:44 +00003217 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003218 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003219 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3220 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003221 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003222 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003223 AC_MSG_RESULT(no)
3224 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Kloseb159a552010-04-25 21:00:44 +00003225 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003226# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003227 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003228 char *name;
3229 struct hostent *he;
Matthias Kloseb159a552010-04-25 21:00:44 +00003230 char buffer[2048];
3231 int buflen = 2048;
3232 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003233
Matthias Kloseb159a552010-04-25 21:00:44 +00003234 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3235 ]])],
3236 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003237 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Kloseb159a552010-04-25 21:00:44 +00003238 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3239 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003240 AC_MSG_RESULT(yes)
3241 ], [
3242 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00003243 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3244 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3245# include <netdb.h>
3246 ]], [[
3247 char *name;
3248 struct hostent *he;
3249 struct hostent_data data;
3250
3251 (void) gethostbyname_r(name, he, &data);
3252 ]])],
3253 [
3254 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3255 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3256 [Define this if you have the 3-arg version of gethostbyname_r().])
3257 AC_MSG_RESULT(yes)
3258 ], [
3259 AC_MSG_RESULT(no)
3260 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003261 ])
3262 ])
3263 CFLAGS=$OLD_CFLAGS
3264], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003265 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003266])
3267AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3268AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3269AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003270AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003271AC_SUBST(HAVE_GETHOSTBYNAME)
3272
Guido van Rossum627b2d71993-12-24 10:39:16 +00003273# checks for system services
3274# (none yet)
3275
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003276# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003277AC_CHECK_FUNC(__fpu_control,
3278 [],
3279 [AC_CHECK_LIB(ieee, __fpu_control)
3280])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003281
Guido van Rossum93274221997-05-09 02:42:00 +00003282# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003283AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003284AC_ARG_WITH(fpectl,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003285 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003286[
Guido van Rossum93274221997-05-09 02:42:00 +00003287if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003288then
3289 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3290 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3291 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003292else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003293fi],
3294[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003295
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003296# check for --with-libm=...
3297AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003298case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003299Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003300*) LIBM=-lm
3301esac
Guido van Rossum93274221997-05-09 02:42:00 +00003302AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003303AC_ARG_WITH(libm,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003304 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003305[
Guido van Rossum93274221997-05-09 02:42:00 +00003306if test "$withval" = no
3307then LIBM=
3308 AC_MSG_RESULT(force LIBM empty)
3309elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003310then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003311 AC_MSG_RESULT(set LIBM="$withval")
3312else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003313fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003314[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003315
3316# check for --with-libc=...
3317AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003318AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003319AC_ARG_WITH(libc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003320 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003321[
Guido van Rossum93274221997-05-09 02:42:00 +00003322if test "$withval" = no
3323then LIBC=
3324 AC_MSG_RESULT(force LIBC empty)
3325elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003326then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003327 AC_MSG_RESULT(set LIBC="$withval")
3328else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003329fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003330[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003331
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003332# **************************************************
3333# * Check for various properties of floating point *
3334# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003335
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003336AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3337AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003338AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003339#include <string.h>
3340int main() {
3341 double x = 9006104071832581.0;
3342 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3343 return 0;
3344 else
3345 return 1;
3346}
Matthias Kloseb159a552010-04-25 21:00:44 +00003347]])],
3348[ac_cv_little_endian_double=yes],
3349[ac_cv_little_endian_double=no],
3350[ac_cv_little_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003351AC_MSG_RESULT($ac_cv_little_endian_double)
3352if test "$ac_cv_little_endian_double" = yes
3353then
3354 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3355 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3356 with the least significant byte first])
3357fi
3358
3359AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3360AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003361AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003362#include <string.h>
3363int main() {
3364 double x = 9006104071832581.0;
3365 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3366 return 0;
3367 else
3368 return 1;
3369}
Matthias Kloseb159a552010-04-25 21:00:44 +00003370]])],
3371[ac_cv_big_endian_double=yes],
3372[ac_cv_big_endian_double=no],
3373[ac_cv_big_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003374AC_MSG_RESULT($ac_cv_big_endian_double)
3375if test "$ac_cv_big_endian_double" = yes
3376then
3377 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3378 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3379 with the most significant byte first])
3380fi
3381
3382# Some ARM platforms use a mixed-endian representation for doubles.
3383# While Python doesn't currently have full support for these platforms
3384# (see e.g., issue 1762561), we can at least make sure that float <-> string
3385# conversions work.
3386AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3387AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003388AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003389#include <string.h>
3390int main() {
3391 double x = 9006104071832581.0;
3392 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3393 return 0;
3394 else
3395 return 1;
3396}
Matthias Kloseb159a552010-04-25 21:00:44 +00003397]])],
3398[ac_cv_mixed_endian_double=yes],
3399[ac_cv_mixed_endian_double=no],
3400[ac_cv_mixed_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003401AC_MSG_RESULT($ac_cv_mixed_endian_double)
3402if test "$ac_cv_mixed_endian_double" = yes
3403then
3404 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3405 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3406 in ARM mixed-endian order (byte order 45670123)])
3407fi
3408
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003409# The short float repr introduced in Python 3.1 requires the
3410# correctly-rounded string <-> double conversion functions from
3411# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3412# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003413# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003414# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003415
3416# This inline assembler syntax may also work for suncc and icc,
3417# so we try it on all platforms.
3418
3419AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Kloseb159a552010-04-25 21:00:44 +00003420AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003421 unsigned short cw;
3422 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3423 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Kloseb159a552010-04-25 21:00:44 +00003424]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003425AC_MSG_RESULT($have_gcc_asm_for_x87)
3426if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003427then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003428 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3429 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003430fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003431
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003432# Detect whether system arithmetic is subject to x87-style double
3433# rounding issues. The result of this test has little meaning on non
3434# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3435# mode is round-to-nearest and double rounding issues are present, and
3436# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3437AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003438# $BASECFLAGS may affect the result
3439ac_save_cc="$CC"
3440CC="$CC $BASECFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003441AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003442#include <stdlib.h>
3443#include <math.h>
3444int main() {
3445 volatile double x, y, z;
3446 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3447 x = 0.99999999999999989; /* 1-2**-53 */
3448 y = 1./x;
3449 if (y != 1.)
3450 exit(0);
3451 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3452 x = 1e16;
3453 y = 2.99999;
3454 z = x + y;
3455 if (z != 1e16+4.)
3456 exit(0);
3457 /* both tests show evidence of double rounding */
3458 exit(1);
3459}
Matthias Kloseb159a552010-04-25 21:00:44 +00003460]])],
3461[ac_cv_x87_double_rounding=no],
3462[ac_cv_x87_double_rounding=yes],
3463[ac_cv_x87_double_rounding=no])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003464CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003465AC_MSG_RESULT($ac_cv_x87_double_rounding)
3466if test "$ac_cv_x87_double_rounding" = yes
3467then
3468 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3469 [Define if arithmetic is subject to x87-style double rounding issue])
3470fi
3471
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003472# ************************************
3473# * Check for mathematical functions *
3474# ************************************
3475
3476LIBS_SAVE=$LIBS
3477LIBS="$LIBS $LIBM"
3478
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003479AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
Victor Stinner8f9f8d62011-05-09 12:45:41 +02003480AC_CHECK_FUNCS([hypot lgamma log1p log2 round tgamma])
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003481AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3482
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003483# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3484# -0. on some architectures.
3485AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3486AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003487AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003488#include <math.h>
3489#include <stdlib.h>
3490int main() {
3491 /* return 0 if either negative zeros don't exist
3492 on this platform or if negative zeros exist
3493 and tanh(-0.) == -0. */
3494 if (atan2(0., -1.) == atan2(-0., -1.) ||
3495 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3496 else exit(1);
3497}
Matthias Kloseb159a552010-04-25 21:00:44 +00003498]])],
3499[ac_cv_tanh_preserves_zero_sign=yes],
3500[ac_cv_tanh_preserves_zero_sign=no],
3501[ac_cv_tanh_preserves_zero_sign=no])])
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003502AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3503if test "$ac_cv_tanh_preserves_zero_sign" = yes
3504then
3505 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3506 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3507fi
3508
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003509if test "$ac_cv_func_log1p" = yes
3510then
3511 # On some versions of AIX, log1p(-0.) returns 0. instead of
3512 # -0. See issue #9920.
3513 AC_MSG_CHECKING(whether log1p drops the sign of negative zero)
3514 AC_CACHE_VAL(ac_cv_log1p_drops_zero_sign, [
3515 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3516 #include <math.h>
3517 #include <stdlib.h>
3518 int main() {
3519 /* Fail if the signs of log1p(-0.) and -0. can be
3520 distinguished. */
3521 if (atan2(log1p(-0.), -1.) == atan2(-0., -1.))
3522 return 0;
3523 else
3524 return 1;
3525 }
3526 ]])],
3527 [ac_cv_log1p_drops_zero_sign=no],
3528 [ac_cv_log1p_drops_zero_sign=yes],
3529 [ac_cv_log1p_drops_zero_sign=no])])
3530 AC_MSG_RESULT($ac_cv_log1p_drops_zero_sign)
3531fi
3532if test "$ac_cv_log1p_drops_zero_sign" = yes
3533then
3534 AC_DEFINE(LOG1P_DROPS_ZERO_SIGN, 1,
3535 [Define if log1p(-0.) is 0. rather than -0.])
3536fi
Christian Heimes99170a52007-12-19 02:07:34 +00003537
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003538LIBS=$LIBS_SAVE
3539
Mark Dickinsona614f042009-11-28 12:48:43 +00003540# For multiprocessing module, check that sem_open
3541# actually works. For FreeBSD versions <= 7.2,
3542# the kernel module that provides POSIX semaphores
3543# isn't loaded by default, so an attempt to call
3544# sem_open results in a 'Signal 12' error.
3545AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3546AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Kloseb159a552010-04-25 21:00:44 +00003547AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsona614f042009-11-28 12:48:43 +00003548#include <unistd.h>
3549#include <fcntl.h>
3550#include <stdio.h>
3551#include <semaphore.h>
3552#include <sys/stat.h>
3553
3554int main(void) {
3555 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3556 if (a == SEM_FAILED) {
3557 perror("sem_open");
3558 return 1;
3559 }
3560 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003561 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003562 return 0;
3563}
Matthias Kloseb159a552010-04-25 21:00:44 +00003564]])],
3565[ac_cv_posix_semaphores_enabled=yes],
3566[ac_cv_posix_semaphores_enabled=no],
3567[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsona614f042009-11-28 12:48:43 +00003568)
3569AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3570if test $ac_cv_posix_semaphores_enabled = no
3571then
3572 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3573 [Define if POSIX semaphores aren't enabled on your system])
3574fi
3575
Mark Dickinson10683072009-04-18 21:18:19 +00003576# Multiprocessing check for broken sem_getvalue
3577AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003578AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Kloseb159a552010-04-25 21:00:44 +00003579AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson10683072009-04-18 21:18:19 +00003580#include <unistd.h>
3581#include <fcntl.h>
3582#include <stdio.h>
3583#include <semaphore.h>
3584#include <sys/stat.h>
3585
3586int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003587 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003588 int count;
3589 int res;
3590 if(a==SEM_FAILED){
3591 perror("sem_open");
3592 return 1;
3593
3594 }
3595 res = sem_getvalue(a, &count);
3596 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003597 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003598 return res==-1 ? 1 : 0;
3599}
Matthias Kloseb159a552010-04-25 21:00:44 +00003600]])],
3601[ac_cv_broken_sem_getvalue=no],
3602[ac_cv_broken_sem_getvalue=yes],
3603[ac_cv_broken_sem_getvalue=yes])
Mark Dickinson10683072009-04-18 21:18:19 +00003604)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003605AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3606if test $ac_cv_broken_sem_getvalue = yes
3607then
3608 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3609 [define to 1 if your sem_getvalue is broken.])
3610fi
Mark Dickinson10683072009-04-18 21:18:19 +00003611
Mark Dickinsonbd792642009-03-18 20:06:12 +00003612# determine what size digit to use for Python's longs
3613AC_MSG_CHECKING([digit size for Python's longs])
3614AC_ARG_ENABLE(big-digits,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003615AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonbd792642009-03-18 20:06:12 +00003616[case $enable_big_digits in
3617yes)
3618 enable_big_digits=30 ;;
3619no)
3620 enable_big_digits=15 ;;
3621[15|30])
3622 ;;
3623*)
3624 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3625esac
3626AC_MSG_RESULT($enable_big_digits)
3627AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3628],
3629[AC_MSG_RESULT(no value specified)])
3630
Guido van Rossumef2255b2000-03-10 22:30:29 +00003631# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003632AC_CHECK_HEADER(wchar.h, [
3633 AC_DEFINE(HAVE_WCHAR_H, 1,
3634 [Define if the compiler provides a wchar.h header file.])
3635 wchar_h="yes"
3636],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003637wchar_h="no"
3638)
3639
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003640# determine wchar_t size
3641if test "$wchar_h" = yes
3642then
Guido van Rossum67b26592001-10-20 14:21:45 +00003643 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003644fi
3645
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003646AC_MSG_CHECKING(for UCS-4 tcl)
3647have_ucs4_tcl=no
Matthias Kloseb159a552010-04-25 21:00:44 +00003648AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003649#include <tcl.h>
3650#if TCL_UTF_MAX != 6
3651# error "NOT UCS4_TCL"
Matthias Kloseb159a552010-04-25 21:00:44 +00003652#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003653 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3654 have_ucs4_tcl=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003655],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003656AC_MSG_RESULT($have_ucs4_tcl)
3657
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003658# check whether wchar_t is signed or not
3659if test "$wchar_h" = yes
3660then
3661 # check whether wchar_t is signed or not
3662 AC_MSG_CHECKING(whether wchar_t is signed)
3663 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003664 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003665 #include <wchar.h>
3666 int main()
3667 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003668 /* Success: exit code 0 */
3669 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003670 }
Matthias Kloseb159a552010-04-25 21:00:44 +00003671 ]])],
3672 [ac_cv_wchar_t_signed=yes],
3673 [ac_cv_wchar_t_signed=no],
3674 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003675 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3676fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003677
Georg Brandl52d168a2008-01-07 18:10:24 +00003678# wchar_t is only usable if it maps to an unsigned type
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003679if test "$ac_cv_sizeof_wchar_t" -ge 2 \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003680 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003681then
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003682 HAVE_USABLE_WCHAR_T="yes"
Georg Brandl52d168a2008-01-07 18:10:24 +00003683 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3684 [Define if you have a useable wchar_t type defined in wchar.h; useable
3685 means wchar_t must be an unsigned type with at least 16 bits. (see
3686 Include/unicodeobject.h).])
Georg Brandl52d168a2008-01-07 18:10:24 +00003687else
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003688 HAVE_USABLE_WCHAR_T="no usable wchar_t found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003689fi
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003690AC_MSG_RESULT($HAVE_USABLE_WCHAR_T)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003691
3692# check for endianness
3693AC_C_BIGENDIAN
3694
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003695# ABI version string for Python extension modules. This appears between the
3696# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
3697# from the following attributes which affect the ABI of this Python build (in
3698# this order):
3699#
3700# * The Python implementation (always 'cpython-' for us)
3701# * The major and minor version numbers
3702# * --with-pydebug (adds a 'd')
3703# * --with-pymalloc (adds a 'm')
3704# * --with-wide-unicode (adds a 'u')
3705#
3706# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
Georg Brandlde7d8342010-09-03 22:19:07 +00003707# would get a shared library ABI version tag of 'cpython-32dmu' and shared
3708# libraries would be named 'foo.cpython-32dmu.so'.
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003709AC_SUBST(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003710AC_MSG_CHECKING(ABIFLAGS)
3711AC_MSG_RESULT($ABIFLAGS)
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003712AC_MSG_CHECKING(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003713SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003714AC_MSG_RESULT($SOABI)
3715
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003716AC_MSG_CHECKING(LDVERSION)
3717LDVERSION='$(VERSION)$(ABIFLAGS)'
3718AC_MSG_RESULT($LDVERSION)
3719
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003720# SO is the extension of shared libraries `(including the dot!)
3721# -- usually .so, .sl on HP-UX, .dll on Cygwin
3722AC_MSG_CHECKING(SO)
3723if test -z "$SO"
3724then
3725 case $ac_sys_system in
3726 hp*|HP*)
3727 case `uname -m` in
3728 ia64) SO=.so;;
3729 *) SO=.sl;;
3730 esac
3731 ;;
3732 CYGWIN*) SO=.dll;;
Matthias Klose3fbfea12010-10-14 15:24:22 +00003733 Linux*|GNU*)
3734 SO=.${SOABI}.so;;
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003735 *) SO=.so;;
3736 esac
3737else
3738 # this might also be a termcap variable, see #610332
Georg Brandlde7d8342010-09-03 22:19:07 +00003739 echo
3740 echo '====================================================================='
3741 echo '+ +'
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003742 echo '+ WARNING: You have set SO in your environment. +'
Georg Brandlde7d8342010-09-03 22:19:07 +00003743 echo '+ Do you really mean to change the extension for shared libraries? +'
3744 echo '+ Continuing in 10 seconds to let you to ponder. +'
3745 echo '+ +'
3746 echo '====================================================================='
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003747 sleep 10
3748fi
3749AC_MSG_RESULT($SO)
3750
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003751# Check whether right shifting a negative integer extends the sign bit
3752# or fills with zeros (like the Cray J90, according to Tim Peters).
3753AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003754AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003755AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003756int main()
3757{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003758 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003759}
Matthias Kloseb159a552010-04-25 21:00:44 +00003760]])],
3761[ac_cv_rshift_extends_sign=yes],
3762[ac_cv_rshift_extends_sign=no],
3763[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003764AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3765if test "$ac_cv_rshift_extends_sign" = no
3766then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003767 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3768 [Define if i>>j for signed int i does not extend the sign bit
3769 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003770fi
3771
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003772# check for getc_unlocked and related locking functions
3773AC_MSG_CHECKING(for getc_unlocked() and friends)
3774AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003775AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003776 FILE *f = fopen("/dev/null", "r");
3777 flockfile(f);
3778 getc_unlocked(f);
3779 funlockfile(f);
Matthias Kloseb159a552010-04-25 21:00:44 +00003780]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003781AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3782if test "$ac_cv_have_getc_unlocked" = yes
3783then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003784 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3785 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003786fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003787
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003788# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003789# save the value of LIBS so we don't actually link Python with readline
3790LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003791
3792# On some systems we need to link readline to a termcap compatible
3793# library. NOTE: Keep the precedence of listed libraries synchronised
3794# with setup.py.
3795py_cv_lib_readline=no
3796AC_MSG_CHECKING([how to link readline libs])
3797for py_libtermcap in "" ncursesw ncurses curses termcap; do
3798 if test -z "$py_libtermcap"; then
3799 READLINE_LIBS="-lreadline"
3800 else
3801 READLINE_LIBS="-lreadline -l$py_libtermcap"
3802 fi
3803 LIBS="$READLINE_LIBS $LIBS_no_readline"
3804 AC_LINK_IFELSE(
3805 [AC_LANG_CALL([],[readline])],
3806 [py_cv_lib_readline=yes])
3807 if test $py_cv_lib_readline = yes; then
3808 break
3809 fi
3810done
3811# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3812#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003813if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003814 AC_MSG_RESULT([none])
3815else
3816 AC_MSG_RESULT([$READLINE_LIBS])
3817 AC_DEFINE(HAVE_LIBREADLINE, 1,
3818 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003819fi
3820
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003821# check for readline 2.1
3822AC_CHECK_LIB(readline, rl_callback_handler_install,
3823 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003824 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003825
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003826# check for readline 2.2
Matthias Kloseb159a552010-04-25 21:00:44 +00003827AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3828 [have_readline=yes],
3829 [have_readline=no]
3830)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003831if test $have_readline = yes
3832then
3833 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3834 [readline/readline.h],
3835 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3836 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003837 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3838 [readline/readline.h],
3839 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3840 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003841fi
3842
Martin v. Löwis0daad592001-09-30 21:09:59 +00003843# check for readline 4.0
3844AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003845 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003846 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003847
Thomas Wouters89d996e2007-09-08 17:39:28 +00003848# also in 4.0
3849AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3850 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003851 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003852
Guido van Rossum353ae582001-07-10 16:45:32 +00003853# check for readline 4.2
3854AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003855 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003856 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003857
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003858# also in readline 4.2
Matthias Kloseb159a552010-04-25 21:00:44 +00003859AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3860 [have_readline=yes],
3861 [have_readline=no]
3862)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003863if test $have_readline = yes
3864then
3865 AC_EGREP_HEADER([extern int rl_catch_signals;],
3866 [readline/readline.h],
3867 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3868 [Define if you can turn off readline's signal handling.]), )
3869fi
3870
Martin v. Löwis82bca632006-02-10 20:49:30 +00003871# End of readline checks: restore LIBS
3872LIBS=$LIBS_no_readline
3873
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003874AC_MSG_CHECKING(for broken nice())
3875AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003876AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003877int main()
3878{
3879 int val1 = nice(1);
3880 if (val1 != -1 && val1 == nice(2))
3881 exit(0);
3882 exit(1);
3883}
Matthias Kloseb159a552010-04-25 21:00:44 +00003884]])],
3885[ac_cv_broken_nice=yes],
3886[ac_cv_broken_nice=no],
3887[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003888AC_MSG_RESULT($ac_cv_broken_nice)
3889if test "$ac_cv_broken_nice" = yes
3890then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003891 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3892 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003893fi
3894
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003895AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003896AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Kloseb159a552010-04-25 21:00:44 +00003897AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003898#include <poll.h>
3899
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003900int main()
3901{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003902 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003903 int poll_test;
3904
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003905 close (42);
3906
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003907 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003908 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003909 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003910 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003911 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003912 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003913 return 1;
3914}
Matthias Kloseb159a552010-04-25 21:00:44 +00003915]])],
3916[ac_cv_broken_poll=yes],
3917[ac_cv_broken_poll=no],
3918[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003919AC_MSG_RESULT($ac_cv_broken_poll)
3920if test "$ac_cv_broken_poll" = yes
3921then
3922 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3923 [Define if poll() sets errno on invalid file descriptors.])
3924fi
3925
Brett Cannon43802422005-02-10 20:48:03 +00003926# Before we can test tzset, we need to check if struct tm has a tm_zone
3927# (which is not required by ISO C or UNIX spec) and/or if we support
3928# tzname[]
3929AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003930
Brett Cannon43802422005-02-10 20:48:03 +00003931# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003932AC_MSG_CHECKING(for working tzset())
3933AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003934AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003935#include <stdlib.h>
3936#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003937#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003938
3939#if HAVE_TZNAME
3940extern char *tzname[];
3941#endif
3942
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003943int main()
3944{
Brett Cannon18367812003-09-19 00:59:16 +00003945 /* Note that we need to ensure that not only does tzset(3)
3946 do 'something' with localtime, but it works as documented
3947 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003948 This includes making sure that tzname is set properly if
3949 tm->tm_zone does not exist since it is the alternative way
3950 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003951
3952 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003953 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003954 */
3955
Brett Cannon43802422005-02-10 20:48:03 +00003956 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003957 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3958
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003959 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003960 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003961 if (localtime(&groundhogday)->tm_hour != 0)
3962 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003963#if HAVE_TZNAME
3964 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3965 if (strcmp(tzname[0], "UTC") ||
3966 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3967 exit(1);
3968#endif
Brett Cannon18367812003-09-19 00:59:16 +00003969
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003970 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003971 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003972 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003973 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003974#if HAVE_TZNAME
3975 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3976 exit(1);
3977#endif
Brett Cannon18367812003-09-19 00:59:16 +00003978
3979 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3980 tzset();
3981 if (localtime(&groundhogday)->tm_hour != 11)
3982 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003983#if HAVE_TZNAME
3984 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3985 exit(1);
3986#endif
3987
3988#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00003989 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3990 exit(1);
3991 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3992 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003993#endif
Brett Cannon18367812003-09-19 00:59:16 +00003994
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003995 exit(0);
3996}
Matthias Kloseb159a552010-04-25 21:00:44 +00003997]])],
3998[ac_cv_working_tzset=yes],
3999[ac_cv_working_tzset=no],
4000[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004001AC_MSG_RESULT($ac_cv_working_tzset)
4002if test "$ac_cv_working_tzset" = yes
4003then
4004 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4005 [Define if tzset() actually switches the local timezone in a meaningful way.])
4006fi
4007
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004008# Look for subsecond timestamps in struct stat
4009AC_MSG_CHECKING(for tv_nsec in struct stat)
4010AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Kloseb159a552010-04-25 21:00:44 +00004011AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004012struct stat st;
4013st.st_mtim.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004014]])],
4015[ac_cv_stat_tv_nsec=yes],
4016[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004017AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4018if test "$ac_cv_stat_tv_nsec" = yes
4019then
4020 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4021 [Define if you have struct stat.st_mtim.tv_nsec])
4022fi
4023
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004024# Look for BSD style subsecond timestamps in struct stat
4025AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4026AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Kloseb159a552010-04-25 21:00:44 +00004027AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004028struct stat st;
4029st.st_mtimespec.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004030]])],
4031[ac_cv_stat_tv_nsec2=yes],
4032[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004033AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4034if test "$ac_cv_stat_tv_nsec2" = yes
4035then
4036 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4037 [Define if you have struct stat.st_mtimensec])
4038fi
4039
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004040# On HP/UX 11.0, mvwdelch is a block with a return statement
4041AC_MSG_CHECKING(whether mvwdelch is an expression)
4042AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Kloseb159a552010-04-25 21:00:44 +00004043AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004044 int rtn;
4045 rtn = mvwdelch(0,0,0);
Matthias Kloseb159a552010-04-25 21:00:44 +00004046]])],
4047[ac_cv_mvwdelch_is_expression=yes],
4048[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004049AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4050
4051if test "$ac_cv_mvwdelch_is_expression" = yes
4052then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004053 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4054 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004055fi
4056
4057AC_MSG_CHECKING(whether WINDOW has _flags)
4058AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Kloseb159a552010-04-25 21:00:44 +00004059AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004060 WINDOW *w;
4061 w->_flags = 0;
Matthias Kloseb159a552010-04-25 21:00:44 +00004062]])],
4063[ac_cv_window_has_flags=yes],
4064[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004065AC_MSG_RESULT($ac_cv_window_has_flags)
4066
4067
4068if test "$ac_cv_window_has_flags" = yes
4069then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004070 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4071 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004072fi
4073
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004074AC_MSG_CHECKING(for is_term_resized)
Matthias Kloseb159a552010-04-25 21:00:44 +00004075AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4076 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4077 AC_MSG_RESULT(yes)],
4078 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004079)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00004080
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004081AC_MSG_CHECKING(for resize_term)
Matthias Kloseb159a552010-04-25 21:00:44 +00004082AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4083 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4084 AC_MSG_RESULT(yes)],
4085 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004086)
4087
4088AC_MSG_CHECKING(for resizeterm)
Matthias Kloseb159a552010-04-25 21:00:44 +00004089AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4090 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4091 AC_MSG_RESULT(yes)],
4092 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004093)
4094
Thomas Wouters89f507f2006-12-13 04:49:30 +00004095AC_MSG_CHECKING(for /dev/ptmx)
4096
4097if test -r /dev/ptmx
4098then
4099 AC_MSG_RESULT(yes)
4100 AC_DEFINE(HAVE_DEV_PTMX, 1,
4101 [Define if we have /dev/ptmx.])
4102else
4103 AC_MSG_RESULT(no)
4104fi
4105
4106AC_MSG_CHECKING(for /dev/ptc)
4107
4108if test -r /dev/ptc
4109then
4110 AC_MSG_RESULT(yes)
4111 AC_DEFINE(HAVE_DEV_PTC, 1,
4112 [Define if we have /dev/ptc.])
4113else
4114 AC_MSG_RESULT(no)
4115fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004116
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004117if test "$have_long_long" = yes
4118then
4119 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4120 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Kloseb159a552010-04-25 21:00:44 +00004121 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004122 #include <stdio.h>
4123 #include <stddef.h>
4124 #include <string.h>
4125
4126 #ifdef HAVE_SYS_TYPES_H
4127 #include <sys/types.h>
4128 #endif
4129
4130 int main()
4131 {
4132 char buffer[256];
4133
4134 if (sprintf(buffer, "%lld", (long long)123) < 0)
4135 return 1;
4136 if (strcmp(buffer, "123"))
4137 return 1;
4138
4139 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4140 return 1;
4141 if (strcmp(buffer, "-123"))
4142 return 1;
4143
4144 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4145 return 1;
4146 if (strcmp(buffer, "123"))
4147 return 1;
4148
4149 return 0;
4150 }
Matthias Kloseb159a552010-04-25 21:00:44 +00004151 ]]])],
4152 [ac_cv_have_long_long_format=yes],
4153 [ac_cv_have_long_long_format=no],
Matthias Klose3b739b12012-03-15 19:31:06 +01004154 [ac_cv_have_long_long_format="cross -- assuming no"
4155 if test x$GCC = xyes; then
4156 save_CFLAGS=$CFLAGS
4157 CFLAGS="$CFLAGS -Werror -Wformat"
4158 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4159 #include <stdio.h>
4160 #include <stddef.h>
4161 ]], [[
4162 char *buffer;
4163 sprintf(buffer, "%lld", (long long)123);
4164 sprintf(buffer, "%lld", (long long)-123);
4165 sprintf(buffer, "%llu", (unsigned long long)123);
4166 ]])],
4167 ac_cv_have_long_long_format=yes
4168 )
4169 CFLAGS=$save_CFLAGS
4170 fi])
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004171 )
4172 AC_MSG_RESULT($ac_cv_have_long_long_format)
4173fi
4174
Mark Dickinson89d7d412009-12-31 20:50:59 +00004175if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004176then
4177 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4178 [Define to printf format modifier for long long type])
4179fi
4180
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00004181if test $ac_sys_system = Darwin
4182then
4183 LIBS="$LIBS -framework CoreFoundation"
4184fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004185
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004186AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Kloseb159a552010-04-25 21:00:44 +00004187AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004188#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00004189#include <stddef.h>
4190#include <string.h>
4191
Christian Heimes2c181612007-12-17 20:04:13 +00004192#ifdef HAVE_SYS_TYPES_H
4193#include <sys/types.h>
4194#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00004195
4196#ifdef HAVE_SSIZE_T
4197typedef ssize_t Py_ssize_t;
4198#elif SIZEOF_VOID_P == SIZEOF_LONG
4199typedef long Py_ssize_t;
4200#else
4201typedef int Py_ssize_t;
4202#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00004203
Christian Heimes2c181612007-12-17 20:04:13 +00004204int main()
4205{
4206 char buffer[256];
4207
Thomas Wouters477c8d52006-05-27 19:21:47 +00004208 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4209 return 1;
4210
Thomas Wouters89f507f2006-12-13 04:49:30 +00004211 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004212 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004213
4214 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4215 return 1;
4216
4217 if (strcmp(buffer, "-123"))
4218 return 1;
4219
Thomas Wouters477c8d52006-05-27 19:21:47 +00004220 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004221}
Matthias Kloseb159a552010-04-25 21:00:44 +00004222]])],
4223 [ac_cv_have_size_t_format=yes],
4224 [ac_cv_have_size_t_format=no],
4225 [ac_cv_have_size_t_format="cross -- assuming yes"
4226])])
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004227if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004228 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4229 [Define to printf format modifier for Py_ssize_t])
4230fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004231
Martin v. Löwis01c04012002-11-11 14:58:44 +00004232AC_CHECK_TYPE(socklen_t,,
4233 AC_DEFINE(socklen_t,int,
Matthias Klosec80c93f2010-04-24 17:04:35 +00004234 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004235#ifdef HAVE_SYS_TYPES_H
4236#include <sys/types.h>
4237#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004238#ifdef HAVE_SYS_SOCKET_H
4239#include <sys/socket.h>
4240#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004241])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004242
Antoine Pitroufff95302008-09-03 18:58:51 +00004243AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004244AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Matthias Kloseb159a552010-04-25 21:00:44 +00004245AC_RUN_IFELSE([AC_LANG_SOURCE([[
Antoine Pitroufff95302008-09-03 18:58:51 +00004246#include<stdlib.h>
4247int main() {
4248 size_t len = -1;
4249 const char *str = "text";
4250 len = mbstowcs(NULL, str, 0);
4251 return (len != 4);
4252}
Matthias Kloseb159a552010-04-25 21:00:44 +00004253]])],
4254[ac_cv_broken_mbstowcs=no],
4255[ac_cv_broken_mbstowcs=yes],
4256[ac_cv_broken_mbstowcs=no]))
Antoine Pitroufff95302008-09-03 18:58:51 +00004257AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4258if test "$ac_cv_broken_mbstowcs" = yes
4259then
4260 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4261 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4262 wide chars that would be converted.])
4263fi
4264
Antoine Pitroub52ec782009-01-25 16:34:23 +00004265# Check for --with-computed-gotos
4266AC_MSG_CHECKING(for --with-computed-gotos)
4267AC_ARG_WITH(computed-gotos,
Antoine Pitrou042b1282010-08-13 21:15:58 +00004268 AS_HELP_STRING([--with(out)-computed-gotos],
4269 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
Antoine Pitroub52ec782009-01-25 16:34:23 +00004270[
Antoine Pitrou042b1282010-08-13 21:15:58 +00004271if test "$withval" = yes
Antoine Pitroub52ec782009-01-25 16:34:23 +00004272then
4273 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4274 [Define if you want to use computed gotos in ceval.c.])
4275 AC_MSG_RESULT(yes)
Antoine Pitrou042b1282010-08-13 21:15:58 +00004276fi
4277if test "$withval" = no
4278then
4279 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4280 [Define if you want to use computed gotos in ceval.c.])
4281 AC_MSG_RESULT(no)
4282fi
4283],
4284[AC_MSG_RESULT(no value specified)])
Antoine Pitroub52ec782009-01-25 16:34:23 +00004285
Matthias Kloseb17289e2012-03-15 19:51:34 +01004286AC_MSG_CHECKING(whether $CC supports computed gotos)
4287AC_CACHE_VAL(ac_cv_computed_gotos,
4288AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4289int main(int argc, char **argv)
4290{
4291 static void *targets[1] = { &&LABEL1 };
4292 goto LABEL2;
4293LABEL1:
4294 return 0;
4295LABEL2:
4296 goto *targets[0];
4297 return 1;
4298}
4299]]])],
4300[ac_cv_computed_gotos=yes],
4301[ac_cv_computed_gotos=no],
4302[if test "${with_computed_gotos+set}" = set; then
4303 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4304 else
4305 ac_cv_computed_gotos=no
4306 fi]))
4307AC_MSG_RESULT($ac_cv_computed_gotos)
4308case "$ac_cv_computed_gotos" in yes*)
4309 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4310 [Define if the C compiler supports computed gotos.])
4311esac
4312
R. David Murraye16cda92010-10-15 23:12:57 +00004313case $ac_sys_system in
4314AIX*)
4315 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4316esac
Antoine Pitroub52ec782009-01-25 16:34:23 +00004317
Jesus Cea6a792292010-05-03 21:18:48 +00004318
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004319AC_SUBST(THREADHEADERS)
4320
4321for h in `(cd $srcdir;echo Python/thread_*.h)`
4322do
4323 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4324done
4325
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004326AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004327SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004328AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004329for dir in $SRCDIRS; do
4330 if test ! -d $dir; then
4331 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004332 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004333done
4334AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004335
Guido van Rossum627b2d71993-12-24 10:39:16 +00004336# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004337AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrou8e6b4072010-09-10 19:44:44 +00004338AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004339AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004340
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004341echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004342if test ! -f Modules/Setup
4343then
4344 cp $srcdir/Modules/Setup.dist Modules/Setup
4345fi
4346
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004347echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004348if test ! -f Modules/Setup.local
4349then
4350 echo "# Edit this file for local setup changes" >Modules/Setup.local
4351fi
4352
4353echo "creating Makefile"
4354$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4355 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004356 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004357mv config.c Modules