blob: f1197b0503e914898c43915b68701ac956535b64 [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]),,)
Stefan Krah1919b7e2012-03-21 18:25:23 +01001486AC_CHECK_TYPE(__uint128_t,
1487 AC_DEFINE(HAVE_GCC_UINT128_T, 1, [Define if your compiler provides __uint128_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001488
Guido van Rossumef2255b2000-03-10 22:30:29 +00001489# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001490# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001491AC_CHECK_SIZEOF(int, 4)
1492AC_CHECK_SIZEOF(long, 4)
1493AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001494AC_CHECK_SIZEOF(short, 2)
1495AC_CHECK_SIZEOF(float, 4)
1496AC_CHECK_SIZEOF(double, 8)
1497AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001498AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes400adb02008-02-01 08:12:03 +00001499AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001500
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001501AC_MSG_CHECKING(for long long support)
1502have_long_long=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001503AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001504 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1505 have_long_long=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001506],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001507AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001508if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001509AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001510fi
1511
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001512AC_MSG_CHECKING(for long double support)
1513have_long_double=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001514AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001515 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1516 have_long_double=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001517],[])
Travis E. Oliphant9b307842007-10-12 22:06:37 +00001518AC_MSG_RESULT($have_long_double)
1519if test "$have_long_double" = yes ; then
1520AC_CHECK_SIZEOF(long double, 16)
1521fi
1522
1523
Thomas Woutersb2137042007-02-01 18:02:27 +00001524AC_MSG_CHECKING(for _Bool support)
1525have_c99_bool=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001526AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Thomas Woutersb2137042007-02-01 18:02:27 +00001527 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1528 have_c99_bool=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00001529],[])
Thomas Woutersb2137042007-02-01 18:02:27 +00001530AC_MSG_RESULT($have_c99_bool)
1531if test "$have_c99_bool" = yes ; then
1532AC_CHECK_SIZEOF(_Bool, 1)
1533fi
1534
Thomas Wouters89f507f2006-12-13 04:49:30 +00001535AC_CHECK_TYPES(uintptr_t,
1536 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1537 [], [#ifdef HAVE_STDINT_H
1538 #include <stdint.h>
Antoine Pitrou1bf29b72010-10-10 08:10:16 +00001539 #endif
1540 #ifdef HAVE_INTTYPES_H
1541 #include <inttypes.h>
Thomas Wouters89f507f2006-12-13 04:49:30 +00001542 #endif])
1543
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001544AC_CHECK_SIZEOF(off_t, [], [
1545#ifdef HAVE_SYS_TYPES_H
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001546#include <sys/types.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001547#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001548])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001549
1550AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson2df5d282009-12-31 21:22:50 +00001551if test "$have_long_long" = yes
1552then
1553if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001554 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001555 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1556 [Defined to enable large file support when an off_t is bigger than a long
1557 and long long is available and at least as big as an off_t. You may need
1558 to add some flags for configuration and compilation to enable this mode.
1559 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001560 AC_MSG_RESULT(yes)
1561else
1562 AC_MSG_RESULT(no)
1563fi
Mark Dickinson2df5d282009-12-31 21:22:50 +00001564else
1565 AC_MSG_RESULT(no)
1566fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001567
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001568AC_CHECK_SIZEOF(time_t, [], [
1569#ifdef HAVE_SYS_TYPES_H
1570#include <sys/types.h>
1571#endif
1572#ifdef HAVE_TIME_H
Fred Drakea3f6e912000-06-29 20:44:47 +00001573#include <time.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001574#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001575])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001576
Trent Mick635f6fb2000-08-23 21:33:05 +00001577# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001578ac_save_cc="$CC"
1579if test "$ac_cv_kpthread" = "yes"
1580then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001581elif test "$ac_cv_kthread" = "yes"
1582then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001583elif test "$ac_cv_pthread" = "yes"
1584then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001585fi
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001586
Trent Mick635f6fb2000-08-23 21:33:05 +00001587AC_MSG_CHECKING(for pthread_t)
1588have_pthread_t=no
Matthias Kloseb159a552010-04-25 21:00:44 +00001589AC_COMPILE_IFELSE([
1590 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1591],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001592AC_MSG_RESULT($have_pthread_t)
1593if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001594 AC_CHECK_SIZEOF(pthread_t, [], [
1595#ifdef HAVE_PTHREAD_H
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001596#include <pthread.h>
Alexandre Vassalotti0805b4a2009-07-17 05:47:33 +00001597#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001598 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001599fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001600CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001601
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001602AC_SUBST(OTHER_LIBTOOL_OPT)
1603case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001604 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001605 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1606 ;;
1607 Darwin/*)
1608 OTHER_LIBTOOL_OPT=""
1609 ;;
1610esac
1611
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001612
1613ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001614AC_SUBST(LIBTOOL_CRUFT)
1615case $ac_sys_system/$ac_sys_release in
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001616 Darwin/@<:@01567@:>@\..*)
Thomas Wouters477c8d52006-05-27 19:21:47 +00001617 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1618 if test "${enable_universalsdk}"; then
1619 :
1620 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001621 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001622 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001623 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001624 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001625 Darwin/*)
Ronald Oussoren9812a6c2010-02-07 11:53:18 +00001626 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001627 if test ${gcc_version} '<' 4.0
1628 then
1629 LIBTOOL_CRUFT="-lcc_dynamic"
1630 else
1631 LIBTOOL_CRUFT=""
1632 fi
Matthias Kloseb159a552010-04-25 21:00:44 +00001633 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001634 #include <unistd.h>
1635 int main(int argc, char*argv[])
1636 {
1637 if (sizeof(long) == 4) {
1638 return 0;
1639 } else {
1640 return 1;
1641 }
Ronald Oussoren3c064c12009-09-08 07:12:42 +00001642 }
Matthias Kloseb159a552010-04-25 21:00:44 +00001643 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001644
1645 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001646 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001647 i386)
1648 MACOSX_DEFAULT_ARCH="i386"
1649 ;;
1650 ppc)
1651 MACOSX_DEFAULT_ARCH="ppc"
1652 ;;
1653 *)
1654 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1655 ;;
1656 esac
1657 else
Ronald Oussorene3da75a2010-02-11 13:38:58 +00001658 case `/usr/bin/arch` in
Ronald Oussoren5bbab3e2009-09-06 11:01:15 +00001659 i386)
1660 MACOSX_DEFAULT_ARCH="x86_64"
1661 ;;
1662 ppc)
1663 MACOSX_DEFAULT_ARCH="ppc64"
1664 ;;
1665 *)
1666 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1667 ;;
1668 esac
1669
1670 #ARCH_RUN_32BIT="true"
1671 fi
1672
1673 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001674 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001675 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001676esac
1677
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001678AC_MSG_CHECKING(for --enable-framework)
1679if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001680then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001681 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001682 # -F. is needed to allow linking to the framework while
1683 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001684 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1685 [Define if you want to produce an OpenStep/Rhapsody framework
1686 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001687 AC_MSG_RESULT(yes)
Ronald Oussoren99aab652009-06-08 21:22:57 +00001688 if test $enable_shared = "yes"
1689 then
1690 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1691 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001692else
1693 AC_MSG_RESULT(no)
1694fi
1695
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001696AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001697case $ac_sys_system/$ac_sys_release in
1698 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001699 AC_DEFINE(WITH_DYLD, 1,
1700 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1701 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1702 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001703 AC_MSG_RESULT(always on for Darwin)
1704 ;;
1705 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001706 AC_MSG_RESULT(no)
1707 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001708esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001709
Guido van Rossumac405f61994-09-12 10:56:06 +00001710# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001711AC_SUBST(SO)
1712AC_SUBST(LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001713AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001714AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001715AC_SUBST(CCSHARED)
1716AC_SUBST(LINKFORSHARED)
Georg Brandlb1441c72009-01-03 22:33:39 +00001717
Thomas Wouters477c8d52006-05-27 19:21:47 +00001718AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001719# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001720# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001721# (Shared libraries in this instance are shared modules to be loaded into
1722# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001723AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001724if test -z "$LDSHARED"
1725then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001726 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001727 AIX*)
Georg Brandl9a829be2011-02-15 15:44:51 +00001728 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001729 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001730 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001731 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001732 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a6632000-05-26 12:22:54 +00001733 SunOS/5*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001734 if test "$GCC" = "yes" ; then
1735 LDSHARED='$(CC) -shared'
1736 LDCXXSHARED='$(CXX) -shared'
1737 else
1738 LDSHARED='$(CC) -G'
1739 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a6632000-05-26 12:22:54 +00001740 fi ;;
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001741 hp*|HP*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001742 if test "$GCC" = "yes" ; then
1743 LDSHARED='$(CC) -shared'
1744 LDCXXSHARED='$(CXX) -shared'
1745 else
1746 LDSHARED='ld -b'
Thomas Hellerf44b9a12008-04-04 10:18:23 +00001747 fi ;;
Jack Jansen418c3b12001-11-14 10:59:57 +00001748 Darwin/1.3*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00001749 LDSHARED='$(CC) -bundle'
1750 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001751 if test "$enable_framework" ; then
1752 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001753 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1754 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001755 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001756 else
1757 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001758 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001759 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001760 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001761 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Antoine Pitroud4958c22010-10-13 17:01:10 +00001762 LDSHARED='$(CC) -bundle'
1763 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001764 if test "$enable_framework" ; then
1765 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001766 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1767 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001768 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001769 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001770 # No framework, use the Python app as bundle-loader
1771 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001772 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001773 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001774 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001775 Darwin/*)
1776 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1777 # This allows an extension to be used in any Python
Thomas Wouters89d996e2007-09-08 17:39:28 +00001778
Georg Brandlfcaf9102008-07-16 02:17:56 +00001779 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001780 then
Thomas Wouters477c8d52006-05-27 19:21:47 +00001781 if test "${enable_universalsdk}"; then
Georg Brandlfcaf9102008-07-16 02:17:56 +00001782 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Thomas Wouters477c8d52006-05-27 19:21:47 +00001783 fi
Antoine Pitroud4958c22010-10-13 17:01:10 +00001784 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
1785 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001786 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001787 else
Antoine Pitroud4958c22010-10-13 17:01:10 +00001788 LDSHARED='$(CC) -bundle'
1789 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001790 if test "$enable_framework" ; then
1791 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001792 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1793 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001794 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001795 else
1796 # No framework, use the Python app as bundle-loader
1797 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1798 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001799 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001800 fi
1801 fi
1802 ;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001803 Linux*|GNU*|QNX*)
1804 LDSHARED='$(CC) -shared'
1805 LDCXXSHARED='$(CXX) -shared';;
1806 BSD/OS*/4*)
1807 LDSHARED="gcc -shared"
1808 LDCXXSHARED="g++ -shared";;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001809 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001810 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001811 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00001812 LDSHARED='$(CC) -shared'
1813 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001814 else
Antoine Pitroud4958c22010-10-13 17:01:10 +00001815 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001816 fi;;
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001817 OpenBSD*)
1818 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1819 then
Antoine Pitroud4958c22010-10-13 17:01:10 +00001820 LDSHARED='$(CC) -shared $(CCSHARED)'
1821 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001822 else
1823 case `uname -r` in
1824 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1825 LDSHARED="ld -Bshareable ${LDFLAGS}"
1826 ;;
1827 *)
Antoine Pitroud4958c22010-10-13 17:01:10 +00001828 LDSHARED='$(CC) -shared $(CCSHARED)'
1829 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Thomas Wouters1ba5b3b2006-06-08 14:52:47 +00001830 ;;
1831 esac
1832 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001833 NetBSD*|DragonFly*)
Antoine Pitrouece919e2011-01-02 20:45:21 +00001834 LDSHARED='$(CC) -shared'
1835 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001836 OpenUNIX*|UnixWare*)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001837 if test "$GCC" = "yes" ; then
1838 LDSHARED='$(CC) -shared'
1839 LDCXXSHARED='$(CXX) -shared'
1840 else
1841 LDSHARED='$(CC) -G'
1842 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001843 fi;;
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001844 SCO_SV*)
1845 LDSHARED='$(CC) -Wl,-G,-Bexport'
1846 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1847 CYGWIN*)
1848 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1849 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001850 *) LDSHARED="ld";;
1851 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001852fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001853AC_MSG_RESULT($LDSHARED)
Tarek Ziadé03d788d2010-04-03 08:46:49 +00001854LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001855BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001856# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001857# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001858AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001859if test -z "$CCSHARED"
1860then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001861 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001862 SunOS*) if test "$GCC" = yes;
Guido van Rossumd8faa362007-04-27 19:54:29 +00001863 then CCSHARED="-fPIC";
1864 elif test `uname -p` = sparc;
1865 then CCSHARED="-xcode=pic32";
1866 else CCSHARED="-Kpic";
1867 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001868 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001869 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001870 else CCSHARED="+z";
1871 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001872 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001873 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001874 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001875 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001876 if test "$GCC" = "yes"
1877 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001878 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001879 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001880 SCO_SV*)
1881 if test "$GCC" = "yes"
1882 then CCSHARED="-fPIC"
1883 else CCSHARED="-Kpic -belf"
1884 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001885 IRIX*/6*) case $CC in
1886 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001887 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001888 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001889 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001890fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001891AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001892# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001893# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001894AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001895if test -z "$LINKFORSHARED"
1896then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001897 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001898 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001899 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001900 LINKFORSHARED="-Wl,-E -Wl,+s";;
1901# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001902 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001903 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001904 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001905 Darwin/*)
Benjamin Peterson9c80cac2009-05-23 16:34:23 +00001906 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001907 if test "$enable_framework"
1908 then
Jack Jansenda49e192005-01-07 13:08:22 +00001909 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001910 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001911 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001912 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001913 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001914 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001915 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001916 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1917 then
1918 LINKFORSHARED="-Wl,--export-dynamic"
1919 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001920 SunOS/5*) case $CC in
1921 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001922 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001923 then
1924 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001925 fi;;
1926 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00001927 CYGWIN*)
1928 if test $enable_shared = "no"
1929 then
1930 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1931 fi;;
Georg Brandlf78e02b2008-06-10 17:40:04 +00001932 QNX*)
1933 # -Wl,-E causes the symbols to be added to the dynamic
1934 # symbol table so that they can be found when a module
1935 # is loaded. -N 2048K causes the stack size to be set
1936 # to 2048 kilobytes so that the stack doesn't overflow
1937 # when running test_compile.py.
1938 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00001939 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001940fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001941AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001942
Georg Brandl93de2162008-07-16 02:21:06 +00001943
Neil Schemenauer61c51152001-01-26 16:18:16 +00001944AC_SUBST(CFLAGSFORSHARED)
1945AC_MSG_CHECKING(CFLAGSFORSHARED)
1946if test ! "$LIBRARY" = "$LDLIBRARY"
1947then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00001948 case $ac_sys_system in
1949 CYGWIN*)
1950 # Cygwin needs CCSHARED when building extension DLLs
1951 # but not when building the interpreter DLL.
1952 CFLAGSFORSHARED='';;
1953 *)
1954 CFLAGSFORSHARED='$(CCSHARED)'
1955 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00001956fi
1957AC_MSG_RESULT($CFLAGSFORSHARED)
1958
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001959# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1960# library (with --enable-shared).
1961# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001962# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1963# if it is not required, since it creates a dependency of the shared library
1964# to LIBS. This, in turn, means that applications linking the shared libpython
1965# don't need to link LIBS explicitly. The default should be only changed
1966# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001967AC_SUBST(SHLIBS)
1968AC_MSG_CHECKING(SHLIBS)
1969case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001970 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00001971 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001972esac
1973AC_MSG_RESULT($SHLIBS)
1974
1975
Guido van Rossum627b2d71993-12-24 10:39:16 +00001976# checks for libraries
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00001977AC_CHECK_LIB(sendfile, sendfile)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001978AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1979AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00001980
Georg Brandleee31162008-12-07 15:15:22 +00001981# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00001982if test "$with_threads" = "yes" -o -z "$with_threads"; then
1983 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1984 # posix4 on Solaris 2.6
1985 # pthread (first!) on Linux
1986fi
1987
Martin v. Löwis19d17342003-06-14 21:03:05 +00001988# check if we need libintl for locale functions
1989AC_CHECK_LIB(intl, textdomain,
Brett Cannonc6d936e2009-06-07 20:09:53 +00001990 [AC_DEFINE(WITH_LIBINTL, 1,
1991 [Define to 1 if libintl is needed for locale functions.])
1992 LIBS="-lintl $LIBS"])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00001993
1994# checks for system dependent C++ extensions support
1995case "$ac_sys_system" in
1996 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Kloseb159a552010-04-25 21:00:44 +00001997 AC_LINK_IFELSE([
Georg Brandl59e87bd2011-02-15 19:48:59 +00001998 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Kloseb159a552010-04-25 21:00:44 +00001999 [[loadAndInit("", 0, "")]])
2000 ],[
2001 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002002 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2003 and you want support for AIX C++ shared extension modules.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002004 AC_MSG_RESULT(yes)
2005 ],[
2006 AC_MSG_RESULT(no)
2007 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002008 *) ;;
2009esac
2010
Guido van Rossum70c7f481998-03-26 18:44:10 +00002011# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002012AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002013AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002014
Guido van Rossumc5a39031996-07-31 17:35:03 +00002015AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002016AC_ARG_WITH(libs,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002017 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002018[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002019AC_MSG_RESULT($withval)
2020LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002021],
2022[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002023
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00002024AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2025
Benjamin Petersonb2d90462009-12-31 03:23:10 +00002026# Check for use of the system expat library
2027AC_MSG_CHECKING(for --with-system-expat)
2028AC_ARG_WITH(system_expat,
Benjamin Peterson79263252010-10-31 16:50:44 +00002029 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2030 [],
2031 [with_system_expat="no"])
Benjamin Petersonb2d90462009-12-31 03:23:10 +00002032
2033AC_MSG_RESULT($with_system_expat)
2034
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002035# Check for use of the system libffi library
2036AC_MSG_CHECKING(for --with-system-ffi)
2037AC_ARG_WITH(system_ffi,
Benjamin Peterson79263252010-10-31 16:50:44 +00002038 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2039 [],
2040 [with_system_ffi="no"])
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002041
Benjamin Peterson0f64b0b2010-03-09 21:49:52 +00002042if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Petersond78735d2010-01-01 16:04:23 +00002043 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2044else
2045 LIBFFI_INCLUDEDIR=""
2046fi
2047AC_SUBST(LIBFFI_INCLUDEDIR)
2048
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002049AC_MSG_RESULT($with_system_ffi)
2050
Stefan Krah60187b52012-03-23 19:06:27 +01002051# Check for use of the system libmpdec library
2052AC_MSG_CHECKING(for --with-system-libmpdec)
2053AC_ARG_WITH(system_libmpdec,
2054 AS_HELP_STRING([--with-system-libmpdec], [build _decimal module using an installed libmpdec library]),
2055 [],
2056 [with_system_libmpdec="no"])
2057
2058AC_MSG_RESULT($with_system_libmpdec)
2059
Benjamin Peterson076ed002010-10-31 17:11:02 +00002060# Check for support for loadable sqlite extensions
2061AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
2062AC_ARG_ENABLE(loadable-sqlite-extensions,
2063 AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module]),
2064 [],
2065 [enable_loadable_sqlite_extensions="no"])
2066
2067AC_MSG_RESULT($enable_loadable_sqlite_extensions)
2068
Matthias Klose55708cc2009-04-30 08:06:49 +00002069# Check for --with-dbmliborder
2070AC_MSG_CHECKING(for --with-dbmliborder)
2071AC_ARG_WITH(dbmliborder,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002072 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 +00002073[
2074if test x$with_dbmliborder = xyes
2075then
2076AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2077else
2078 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2079 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2080 then
2081 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2082 fi
2083 done
2084fi])
2085AC_MSG_RESULT($with_dbmliborder)
2086
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002087# Determine if signalmodule should be used.
2088AC_SUBST(USE_SIGNAL_MODULE)
2089AC_SUBST(SIGNAL_OBJS)
2090AC_MSG_CHECKING(for --with-signal-module)
2091AC_ARG_WITH(signal-module,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002092 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002093
2094if test -z "$with_signal_module"
2095then with_signal_module="yes"
2096fi
2097AC_MSG_RESULT($with_signal_module)
2098
2099if test "${with_signal_module}" = "yes"; then
2100 USE_SIGNAL_MODULE=""
2101 SIGNAL_OBJS=""
2102else
2103 USE_SIGNAL_MODULE="#"
2104 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2105fi
2106
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002107# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002108AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002109USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002110
Guido van Rossum54d93d41997-01-22 20:51:58 +00002111AC_SUBST(LDLAST)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002112
Martin v. Löwis11437992002-04-12 09:54:03 +00002113# Templates for things AC_DEFINEd more than once.
2114# For a single AC_DEFINE, no template is needed.
Martin v. Löwis11437992002-04-12 09:54:03 +00002115AH_TEMPLATE(_REENTRANT,
2116 [Define to force use of thread-safe errno, h_errno, and other functions])
2117AH_TEMPLATE(WITH_THREAD,
2118 [Define if you want to compile in rudimentary thread support])
2119
Guido van Rossum54d93d41997-01-22 20:51:58 +00002120AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002121dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002122AC_ARG_WITH(threads,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002123 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002124
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002125# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002126dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002127AC_ARG_WITH(thread,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002128 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002129 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002130
2131if test -z "$with_threads"
2132then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002133fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002134AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002135
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002136AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002137if test "$with_threads" = "no"
2138then
2139 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002140elif test "$ac_cv_pthread_is_default" = yes
2141then
2142 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002143 # Defining _REENTRANT on system with POSIX threads should not hurt.
2144 AC_DEFINE(_REENTRANT)
2145 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002146 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002147elif test "$ac_cv_kpthread" = "yes"
2148then
2149 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002150 if test "$ac_cv_cxx_thread" = "yes"; then
2151 CXX="$CXX -Kpthread"
2152 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002153 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002154 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002155 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002156elif test "$ac_cv_kthread" = "yes"
2157then
2158 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002159 if test "$ac_cv_cxx_thread" = "yes"; then
2160 CXX="$CXX -Kthread"
2161 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002162 AC_DEFINE(WITH_THREAD)
2163 posix_threads=yes
2164 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002165elif test "$ac_cv_pthread" = "yes"
2166then
2167 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002168 if test "$ac_cv_cxx_thread" = "yes"; then
2169 CXX="$CXX -pthread"
2170 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002171 AC_DEFINE(WITH_THREAD)
2172 posix_threads=yes
2173 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002174else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002175 if test ! -z "$with_threads" -a -d "$with_threads"
2176 then LDFLAGS="$LDFLAGS -L$with_threads"
2177 fi
2178 if test ! -z "$withval" -a -d "$withval"
2179 then LDFLAGS="$LDFLAGS -L$withval"
2180 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002181
2182 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002183 # define _POSIX_THREADS in unistd.h. Some apparently don't
2184 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002185 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2186 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002187 [
2188#include <unistd.h>
2189#ifdef _POSIX_THREADS
2190yes
2191#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002192 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2193 AC_MSG_RESULT($unistd_defines_pthreads)
2194
Martin v. Löwis130fb172001-07-19 11:00:41 +00002195 AC_DEFINE(_REENTRANT)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002196 # Just looking for pthread_create in libpthread is not enough:
2197 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2198 # So we really have to include pthread.h, and then link.
2199 _libs=$LIBS
2200 LIBS="$LIBS -lpthread"
2201 AC_MSG_CHECKING([for pthread_create in -lpthread])
Matthias Kloseb159a552010-04-25 21:00:44 +00002202 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002203
Matthias Kloseb159a552010-04-25 21:00:44 +00002204void * start_routine (void *arg) { exit (0); }]], [[
2205pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002206 AC_MSG_RESULT(yes)
2207 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002208 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002209 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002210 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002211 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002212 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002213 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002214 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002215 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002216 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002217 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002218 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002219 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002220 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002221 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002222 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002223 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002224 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002225 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002226 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002227 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002228 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002229 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002230 USE_THREAD_MODULE="#"])
Antoine Pitrou37009202011-07-08 23:47:50 +02002231 ])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002232
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002233 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2234 LIBS="$LIBS -lmpc"
2235 THREADOBJ="Python/thread.o"
2236 USE_THREAD_MODULE=""])
2237
2238 if test "$posix_threads" != "yes"; then
2239 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2240 LIBS="$LIBS -lthread"
2241 THREADOBJ="Python/thread.o"
2242 USE_THREAD_MODULE=""])
2243 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002244fi
2245
2246if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002247 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002248 AC_DEFINE(_POSIX_THREADS, 1,
2249 [Define if you have POSIX threads,
2250 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002251 fi
2252
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002253 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2254 case $ac_sys_system/$ac_sys_release in
Charles-François Natali996f6062011-07-21 19:45:31 +02002255 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002256 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002257 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002258 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002259 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002260 ;;
Charles-François Natali996f6062011-07-21 19:45:31 +02002261 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002262 [Define if the Posix semaphores do not work on your system])
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002263 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002264 esac
2265
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002266 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2267 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Matthias Kloseb159a552010-04-25 21:00:44 +00002268 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002269 void *foo(void *parm) {
2270 return NULL;
2271 }
2272 main() {
2273 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002274 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002275 if (pthread_attr_init(&attr)) exit(-1);
2276 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002277 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002278 exit(0);
Matthias Kloseb159a552010-04-25 21:00:44 +00002279 }]])],
2280 [ac_cv_pthread_system_supported=yes],
2281 [ac_cv_pthread_system_supported=no],
2282 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002283 ])
2284 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2285 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002286 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002287 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002288 AC_CHECK_FUNCS(pthread_sigmask,
2289 [case $ac_sys_system in
2290 CYGWIN*)
2291 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2292 [Define if pthread_sigmask() does not work on your system.])
2293 ;;
2294 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002295fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002296
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002297
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002298# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002299AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002300AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002301AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002302[ --enable-ipv6 Enable ipv6 (with ipv4) support
2303 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002304[ case "$enableval" in
2305 no)
2306 AC_MSG_RESULT(no)
2307 ipv6=no
2308 ;;
2309 *) AC_MSG_RESULT(yes)
2310 AC_DEFINE(ENABLE_IPV6)
2311 ipv6=yes
2312 ;;
2313 esac ],
2314
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002315[
2316dnl the check does not work on cross compilation case...
Matthias Kloseb159a552010-04-25 21:00:44 +00002317 AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002318#include <sys/types.h>
2319#include <sys/socket.h>
2320main()
2321{
2322 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2323 exit(1);
2324 else
2325 exit(0);
2326}
Matthias Kloseb159a552010-04-25 21:00:44 +00002327]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002328 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00002329 ipv6=yes
2330],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002331 AC_MSG_RESULT(no)
2332 ipv6=no
Matthias Kloseb159a552010-04-25 21:00:44 +00002333],[
2334 AC_MSG_RESULT(no)
2335 ipv6=no
2336])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002337
2338if test "$ipv6" = "yes"; then
2339 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Kloseb159a552010-04-25 21:00:44 +00002340 AC_COMPILE_IFELSE([
2341 AC_LANG_PROGRAM([[#include <sys/types.h>
2342#include <netinet/in.h>]],
2343 [[struct sockaddr_in6 x;
2344 x.sin6_scope_id;]])
2345 ],[
2346 AC_MSG_RESULT(yes)
2347 ipv6=yes
2348 ],[
2349 AC_MSG_RESULT(no, IPv6 disabled)
2350 ipv6=no
2351 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002352fi
2353
2354if test "$ipv6" = "yes"; then
2355 AC_DEFINE(ENABLE_IPV6)
2356fi
2357])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002358
2359ipv6type=unknown
2360ipv6lib=none
2361ipv6trylibc=no
2362
2363if test "$ipv6" = "yes"; then
2364 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002365 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2366 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002367 case $i in
2368 inria)
2369 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002370 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002371#include <netinet/in.h>
2372#ifdef IPV6_INRIA_VERSION
2373yes
2374#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002375 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002376 ;;
2377 kame)
2378 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002379 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002380#include <netinet/in.h>
2381#ifdef __KAME__
2382yes
2383#endif],
2384 [ipv6type=$i;
2385 ipv6lib=inet6
2386 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002387 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002388 ;;
2389 linux-glibc)
2390 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002391 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002392#include <features.h>
2393#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2394yes
2395#endif],
2396 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002397 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002398 ;;
2399 linux-inet6)
2400 dnl http://www.v6.linux.or.jp/
2401 if test -d /usr/inet6; then
2402 ipv6type=$i
2403 ipv6lib=inet6
2404 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002405 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002406 fi
2407 ;;
2408 solaris)
2409 if test -f /etc/netconfig; then
Antoine Pitrouf3fcd9f2011-01-03 18:53:50 +00002410 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002411 ipv6type=$i
2412 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002413 fi
2414 fi
2415 ;;
2416 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002417 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002418#include <sys/param.h>
2419#ifdef _TOSHIBA_INET6
2420yes
2421#endif],
2422 [ipv6type=$i;
2423 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002424 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002425 ;;
2426 v6d)
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 </usr/local/v6/include/sys/v6config.h>
2429#ifdef __V6D__
2430yes
2431#endif],
2432 [ipv6type=$i;
2433 ipv6lib=v6;
2434 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002435 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002436 ;;
2437 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002438 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002439#include <sys/param.h>
2440#ifdef _ZETA_MINAMI_INET6
2441yes
2442#endif],
2443 [ipv6type=$i;
2444 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002445 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002446 ;;
2447 esac
2448 if test "$ipv6type" != "unknown"; then
2449 break
2450 fi
2451 done
2452 AC_MSG_RESULT($ipv6type)
2453fi
2454
2455if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2456 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2457 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2458 echo "using lib$ipv6lib"
2459 else
2460 if test $ipv6trylibc = "yes"; then
2461 echo "using libc"
2462 else
2463 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2464 echo "You need to fetch lib$ipv6lib.a from appropriate"
2465 echo 'ipv6 kit and compile beforehand.'
2466 exit 1
2467 fi
2468 fi
2469fi
2470
Georg Brandl93de2162008-07-16 02:21:06 +00002471AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Kloseb159a552010-04-25 21:00:44 +00002472AC_COMPILE_IFELSE([
2473 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
2474],[
Matthias Klosec80c93f2010-04-24 17:04:35 +00002475 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002476 AC_MSG_RESULT(yes)
2477],[
Georg Brandl93de2162008-07-16 02:21:06 +00002478 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00002479])
Georg Brandl93de2162008-07-16 02:21:06 +00002480
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002481# Check for --with-doc-strings
2482AC_MSG_CHECKING(for --with-doc-strings)
2483AC_ARG_WITH(doc-strings,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002484 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002485
2486if test -z "$with_doc_strings"
2487then with_doc_strings="yes"
2488fi
2489if test "$with_doc_strings" != "no"
2490then
2491 AC_DEFINE(WITH_DOC_STRINGS, 1,
2492 [Define if you want documentation strings in extension modules])
2493fi
2494AC_MSG_RESULT($with_doc_strings)
2495
Georg Brandl9976a512010-08-02 21:02:36 +00002496# Check if eval loop should use timestamp counter profiling
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002497AC_MSG_CHECKING(for --with-tsc)
2498AC_ARG_WITH(tsc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002499 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002500if test "$withval" != no
2501then
2502 AC_DEFINE(WITH_TSC, 1,
2503 [Define to profile with the Pentium timestamp counter])
2504 AC_MSG_RESULT(yes)
2505else AC_MSG_RESULT(no)
2506fi],
2507[AC_MSG_RESULT(no)])
2508
2509# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002510AC_MSG_CHECKING(for --with-pymalloc)
2511AC_ARG_WITH(pymalloc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002512 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002513
2514if test -z "$with_pymalloc"
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00002515then
2516 with_pymalloc="yes"
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00002517 ABIFLAGS="${ABIFLAGS}m"
Neil Schemenauer16c22972002-03-22 15:34:49 +00002518fi
2519if test "$with_pymalloc" != "no"
2520then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002521 AC_DEFINE(WITH_PYMALLOC, 1,
2522 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002523fi
2524AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002525
Benjamin Peterson05159c42009-12-03 03:01:27 +00002526# Check for Valgrind support
2527AC_MSG_CHECKING([for --with-valgrind])
2528AC_ARG_WITH([valgrind],
Matthias Klose2b8733f2010-04-25 18:34:36 +00002529 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson05159c42009-12-03 03:01:27 +00002530 with_valgrind=no)
2531AC_MSG_RESULT([$with_valgrind])
2532if test "$with_valgrind" != no; then
2533 AC_CHECK_HEADER([valgrind/valgrind.h],
2534 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2535 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2536 )
Jeffrey Yasskin39370832010-05-03 19:29:34 +00002537 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
Benjamin Peterson05159c42009-12-03 03:01:27 +00002538fi
2539
Guido van Rossum68242b51996-05-28 22:53:03 +00002540# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002541AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002542DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002543
Guido van Rossume97ee181999-12-20 21:27:22 +00002544# the dlopen() function means we might want to use dynload_shlib.o. some
2545# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002546AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002547
2548# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2549# loading of modules.
2550AC_SUBST(DYNLOADFILE)
2551AC_MSG_CHECKING(DYNLOADFILE)
2552if test -z "$DYNLOADFILE"
2553then
2554 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002555 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2556 if test "$ac_cv_func_dlopen" = yes
2557 then DYNLOADFILE="dynload_shlib.o"
2558 else DYNLOADFILE="dynload_aix.o"
2559 fi
2560 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002561 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002562 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2563 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002564 *)
2565 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2566 # out any dynamic loading
2567 if test "$ac_cv_func_dlopen" = yes
2568 then DYNLOADFILE="dynload_shlib.o"
2569 else DYNLOADFILE="dynload_stub.o"
2570 fi
2571 ;;
2572 esac
2573fi
2574AC_MSG_RESULT($DYNLOADFILE)
2575if test "$DYNLOADFILE" != "dynload_stub.o"
2576then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002577 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2578 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002579fi
2580
Jack Jansenc49e5b72001-06-19 15:00:23 +00002581# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2582
2583AC_SUBST(MACHDEP_OBJS)
2584AC_MSG_CHECKING(MACHDEP_OBJS)
2585if test -z "$MACHDEP_OBJS"
2586then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002587 MACHDEP_OBJS=$extra_machdep_objs
2588else
2589 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002590fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002591AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002592
Guido van Rossum627b2d71993-12-24 10:39:16 +00002593# checks for library functions
Antoine Pitroub1c54962010-10-14 15:05:38 +00002594AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
Gregory P. Smith1577cf72012-01-21 18:21:56 -08002595 clock confstr ctermid execv faccessat fchmod fchmodat fchown fchownat \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002596 fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
Ross Lagerwallb0ae53d2011-06-10 07:30:30 +02002597 futimens futimes gai_strerror \
2598 getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002599 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Gregory P. Smith5ed2e772011-05-15 00:26:45 -07002600 if_nameindex \
Antoine Pitrouf0effe62011-11-26 01:11:02 +01002601 initgroups kill killpg lchmod lchown lockf linkat lstat lutimes mmap \
2602 memrchr mbrtowc mkdirat mkfifo \
Charles-François Natalidaafdd52011-05-29 20:07:40 +02002603 mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002604 posix_fallocate posix_fadvise pread \
Victor Stinnerb3e72192011-05-08 01:46:11 +02002605 pthread_init pthread_kill putenv pwrite readlink readlinkat readv realpath renameat \
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00002606 select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \
Antoine Pitrou061cfb52011-02-28 22:25:22 +00002607 setgid sethostname \
Giampaolo Rodolà18e8bcb2011-02-25 20:57:54 +00002608 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
Charles-François Nataliea0d5fc2011-09-06 19:03:35 +02002609 sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
2610 sched_rr_get_interval \
Ross Lagerwallbc808222011-06-25 12:13:40 +02002611 sigaction sigaltstack siginterrupt sigpending sigrelse \
2612 sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002613 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002614 truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
2615 wcscoll wcsftime wcsxfrm writev _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002616
Gregory P. Smithdf300d52012-01-21 18:20:15 -08002617AC_CHECK_DECL(dirfd,
2618 AC_DEFINE(HAVE_DIRFD, 1,
2619 Define if you have the 'dirfd' function or macro.), ,
2620 [#include <sys/types.h>
2621 #include <dirent.h>])
2622
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002623# For some functions, having a definition is not sufficient, since
2624# we want to take their address.
2625AC_MSG_CHECKING(for chroot)
Matthias Kloseb159a552010-04-25 21:00:44 +00002626AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2627 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2628 AC_MSG_RESULT(yes)],
2629 [AC_MSG_RESULT(no)
2630])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002631AC_MSG_CHECKING(for link)
Matthias Kloseb159a552010-04-25 21:00:44 +00002632AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2633 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2634 AC_MSG_RESULT(yes)],
2635 [AC_MSG_RESULT(no)
2636])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002637AC_MSG_CHECKING(for symlink)
Matthias Kloseb159a552010-04-25 21:00:44 +00002638AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2639 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2640 AC_MSG_RESULT(yes)],
2641 [AC_MSG_RESULT(no)
2642])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002643AC_MSG_CHECKING(for fchdir)
Matthias Kloseb159a552010-04-25 21:00:44 +00002644AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2645 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2646 AC_MSG_RESULT(yes)],
2647 [AC_MSG_RESULT(no)
2648])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002649AC_MSG_CHECKING(for fsync)
Matthias Kloseb159a552010-04-25 21:00:44 +00002650AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2651 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2652 AC_MSG_RESULT(yes)],
2653 [AC_MSG_RESULT(no)
2654])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002655AC_MSG_CHECKING(for fdatasync)
Matthias Kloseb159a552010-04-25 21:00:44 +00002656AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2657 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2658 AC_MSG_RESULT(yes)],
2659 [AC_MSG_RESULT(no)
2660])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002661AC_MSG_CHECKING(for epoll)
Matthias Kloseb159a552010-04-25 21:00:44 +00002662AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2663 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2664 AC_MSG_RESULT(yes)],
2665 [AC_MSG_RESULT(no)
2666])
Benjamin Peterson95c16622011-12-27 15:36:32 -06002667AC_MSG_CHECKING(for epoll_create1)
2668AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create1]])],
2669 [AC_DEFINE(HAVE_EPOLL_CREATE1, 1, Define if you have the 'epoll_create1' function.)
2670 AC_MSG_RESULT(yes)],
2671 [AC_MSG_RESULT(no)
2672])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002673AC_MSG_CHECKING(for kqueue)
Matthias Kloseb159a552010-04-25 21:00:44 +00002674AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002675#include <sys/types.h>
2676#include <sys/event.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002677 ]], [[int x=kqueue()]])],
2678 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2679 AC_MSG_RESULT(yes)],
2680 [AC_MSG_RESULT(no)
2681])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002682# On some systems (eg. FreeBSD 5), we would find a definition of the
2683# functions ctermid_r, setgroups in the library, but no prototype
2684# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2685# address to avoid compiler warnings and potential miscompilations
2686# because of the missing prototypes.
2687
2688AC_MSG_CHECKING(for ctermid_r)
Matthias Kloseb159a552010-04-25 21:00:44 +00002689AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002690#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002691]], [[void* p = ctermid_r]])],
2692 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2693 AC_MSG_RESULT(yes)],
2694 [AC_MSG_RESULT(no)
2695])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002696
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00002697AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2698 [AC_COMPILE_IFELSE(
2699 [AC_LANG_PROGRAM(
2700 [#include <sys/file.h>],
2701 [void* p = flock]
2702 )],
2703 [ac_cv_flock_decl=yes],
2704 [ac_cv_flock_decl=no]
2705 )
Matthias Kloseb159a552010-04-25 21:00:44 +00002706])
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00002707if test "x${ac_cv_flock_decl}" = xyes; then
2708 AC_CHECK_FUNCS(flock,,
2709 AC_CHECK_LIB(bsd,flock,
2710 [AC_DEFINE(HAVE_FLOCK)
2711 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2712 ])
2713 )
Antoine Pitroua3000072010-09-07 14:52:42 +00002714fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002715
2716AC_MSG_CHECKING(for getpagesize)
Matthias Kloseb159a552010-04-25 21:00:44 +00002717AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002718#include <unistd.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002719]], [[void* p = getpagesize]])],
2720 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2721 AC_MSG_RESULT(yes)],
2722 [AC_MSG_RESULT(no)
2723])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002724
Victor Stinner984890f2011-11-24 13:53:38 +01002725AC_MSG_CHECKING(for broken unsetenv)
2726AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2727#include <stdlib.h>
2728]], [[int res = unsetenv("DUMMY")]])],
2729 [AC_MSG_RESULT(no)],
2730 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
2731 AC_MSG_RESULT(yes)
2732])
2733
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002734dnl check for true
2735AC_CHECK_PROGS(TRUE, true, /bin/true)
2736
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002737dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2738dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002739AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002740 AC_CHECK_LIB(resolv, inet_aton)
2741)
2742
Christian Heimesd0764e22007-12-04 15:00:33 +00002743# On Tru64, chflags seems to be present, but calling it will
2744# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002745AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07002746AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002747#include <sys/stat.h>
2748#include <unistd.h>
2749int main(int argc, char*argv[])
2750{
2751 if(chflags(argv[0], 0) != 0)
2752 return 1;
2753 return 0;
2754}
Ned Deily3eb67d52011-06-28 00:00:28 -07002755]])],
Matthias Kloseb159a552010-04-25 21:00:44 +00002756[ac_cv_have_chflags=yes],
2757[ac_cv_have_chflags=no],
2758[ac_cv_have_chflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002759])
2760if test "$ac_cv_have_chflags" = cross ; then
2761 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2762fi
2763if test "$ac_cv_have_chflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07002764 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002765fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002766
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002767AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07002768AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002769#include <sys/stat.h>
2770#include <unistd.h>
2771int main(int argc, char*argv[])
2772{
2773 if(lchflags(argv[0], 0) != 0)
2774 return 1;
2775 return 0;
2776}
Ned Deily3eb67d52011-06-28 00:00:28 -07002777]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002778])
2779if test "$ac_cv_have_lchflags" = cross ; then
2780 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2781fi
2782if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07002783 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002784fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002785
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002786dnl Check if system zlib has *Copy() functions
2787dnl
2788dnl On MacOSX the linker will search for dylibs on the entire linker path
2789dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2790dnl to revert to a more traditional unix behaviour and make it possible to
2791dnl override the system libz with a local static library of libz. Temporarily
2792dnl add that flag to our CFLAGS as well to ensure that we check the version
2793dnl of libz that will be used by setup.py.
2794dnl The -L/usr/local/lib is needed as wel to get the same compilation
2795dnl environment as setup.py (and leaving it out can cause configure to use the
2796dnl wrong version of the library)
2797case $ac_sys_system/$ac_sys_release in
2798Darwin/*)
2799 _CUR_CFLAGS="${CFLAGS}"
2800 _CUR_LDFLAGS="${LDFLAGS}"
2801 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2802 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2803 ;;
2804esac
2805
Matthias Klosec80c93f2010-04-24 17:04:35 +00002806AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002807
2808case $ac_sys_system/$ac_sys_release in
2809Darwin/*)
2810 CFLAGS="${_CUR_CFLAGS}"
2811 LDFLAGS="${_CUR_LDFLAGS}"
2812 ;;
2813esac
2814
Martin v. Löwise9416172003-05-03 10:12:45 +00002815AC_MSG_CHECKING(for hstrerror)
Matthias Kloseb159a552010-04-25 21:00:44 +00002816AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00002817#include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002818]], [[void* p = hstrerror; hstrerror(0)]])],
2819 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2820 AC_MSG_RESULT(yes)],
2821 [AC_MSG_RESULT(no)
2822])
Martin v. Löwise9416172003-05-03 10:12:45 +00002823
2824AC_MSG_CHECKING(for inet_aton)
Matthias Kloseb159a552010-04-25 21:00:44 +00002825AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00002826#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002827#include <sys/socket.h>
2828#include <netinet/in.h>
2829#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002830]], [[void* p = inet_aton;inet_aton(0,0)]])],
2831 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2832 AC_MSG_RESULT(yes)],
2833 [AC_MSG_RESULT(no)
2834])
Martin v. Löwise9416172003-05-03 10:12:45 +00002835
2836AC_MSG_CHECKING(for inet_pton)
Matthias Kloseb159a552010-04-25 21:00:44 +00002837AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002838#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002839#include <sys/socket.h>
2840#include <netinet/in.h>
2841#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002842]], [[void* p = inet_pton]])],
2843 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2844 AC_MSG_RESULT(yes)],
2845 [AC_MSG_RESULT(no)
2846])
Martin v. Löwise9416172003-05-03 10:12:45 +00002847
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002848# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002849AC_MSG_CHECKING(for setgroups)
Matthias Kloseb159a552010-04-25 21:00:44 +00002850AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002851#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002852#ifdef HAVE_GRP_H
2853#include <grp.h>
2854#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00002855]], [[void* p = setgroups]])],
2856 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2857 AC_MSG_RESULT(yes)],
2858 [AC_MSG_RESULT(no)
2859])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002860
Fred Drake8cef4cf2000-06-28 16:40:38 +00002861# check for openpty and forkpty
2862
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002863AC_CHECK_FUNCS(openpty,,
2864 AC_CHECK_LIB(util,openpty,
2865 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2866 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2867 )
2868)
2869AC_CHECK_FUNCS(forkpty,,
2870 AC_CHECK_LIB(util,forkpty,
2871 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2872 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2873 )
2874)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002875
Christian Heimesb186d002008-03-18 15:15:01 +00002876# Stuff for expat.
2877AC_CHECK_FUNCS(memmove)
2878
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002879# check for long file support functions
2880AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2881
Christian Heimesb186d002008-03-18 15:15:01 +00002882AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002883AC_CHECK_FUNCS(getpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00002884 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
2885 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
2886 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002887)
Jack Jansen150753c2003-03-29 22:07:47 +00002888AC_CHECK_FUNCS(setpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00002889 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
2890 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
2891 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002892)
2893AC_CHECK_FUNCS(gettimeofday,
Matthias Kloseb159a552010-04-25 21:00:44 +00002894 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
2895 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
2896 [],
2897 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2898 [Define if gettimeofday() does not have second (timezone) argument
2899 This is the case on Motorola V4 (R40V4.2)])
2900 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002901)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002902
Victor Stinnere0be4232011-10-25 13:06:09 +02002903AC_CHECK_FUNCS(clock_gettime, [], [
2904 AC_CHECK_LIB(rt, clock_gettime, [
2905 AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
2906 AC_DEFINE(TIMEMODULE_LIB, [rt],
2907 [Library needed by timemodule.c: librt may be needed for clock_gettime()])
2908 ])
2909])
2910
2911AC_CHECK_FUNCS(clock_getres, [], [
2912 AC_CHECK_LIB(rt, clock_getres, [
2913 AC_DEFINE(HAVE_CLOCK_GETRES, 1)
2914 ])
2915])
2916
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002917AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Kloseb159a552010-04-25 21:00:44 +00002918AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002919#if defined(MAJOR_IN_MKDEV)
2920#include <sys/mkdev.h>
2921#elif defined(MAJOR_IN_SYSMACROS)
2922#include <sys/sysmacros.h>
2923#else
2924#include <sys/types.h>
2925#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00002926]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002927 makedev(major(0),minor(0));
Matthias Kloseb159a552010-04-25 21:00:44 +00002928]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002929 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2930 [Define to 1 if you have the device macros.])
2931 AC_MSG_RESULT(yes)
2932],[
2933 AC_MSG_RESULT(no)
2934])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002935
2936# On OSF/1 V5.1, getaddrinfo is available, but a define
2937# for [no]getaddrinfo in netdb.h.
2938AC_MSG_CHECKING(for getaddrinfo)
Matthias Kloseb159a552010-04-25 21:00:44 +00002939AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002940#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002941#include <sys/socket.h>
2942#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002943#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002944]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
2945[have_getaddrinfo=yes],
2946[have_getaddrinfo=no])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002947AC_MSG_RESULT($have_getaddrinfo)
2948if test $have_getaddrinfo = yes
2949then
2950 AC_MSG_CHECKING(getaddrinfo bug)
2951 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00002952 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002953#include <sys/types.h>
2954#include <netdb.h>
2955#include <string.h>
2956#include <sys/socket.h>
2957#include <netinet/in.h>
2958
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002959int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002960{
2961 int passive, gaierr, inet4 = 0, inet6 = 0;
2962 struct addrinfo hints, *ai, *aitop;
2963 char straddr[INET6_ADDRSTRLEN], strport[16];
2964
2965 for (passive = 0; passive <= 1; passive++) {
2966 memset(&hints, 0, sizeof(hints));
2967 hints.ai_family = AF_UNSPEC;
2968 hints.ai_flags = passive ? AI_PASSIVE : 0;
2969 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002970 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002971 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2972 (void)gai_strerror(gaierr);
2973 goto bad;
2974 }
2975 for (ai = aitop; ai; ai = ai->ai_next) {
2976 if (ai->ai_addr == NULL ||
2977 ai->ai_addrlen == 0 ||
2978 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2979 straddr, sizeof(straddr), strport, sizeof(strport),
2980 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2981 goto bad;
2982 }
2983 switch (ai->ai_family) {
2984 case AF_INET:
2985 if (strcmp(strport, "54321") != 0) {
2986 goto bad;
2987 }
2988 if (passive) {
2989 if (strcmp(straddr, "0.0.0.0") != 0) {
2990 goto bad;
2991 }
2992 } else {
2993 if (strcmp(straddr, "127.0.0.1") != 0) {
2994 goto bad;
2995 }
2996 }
2997 inet4++;
2998 break;
2999 case AF_INET6:
3000 if (strcmp(strport, "54321") != 0) {
3001 goto bad;
3002 }
3003 if (passive) {
3004 if (strcmp(straddr, "::") != 0) {
3005 goto bad;
3006 }
3007 } else {
3008 if (strcmp(straddr, "::1") != 0) {
3009 goto bad;
3010 }
3011 }
3012 inet6++;
3013 break;
3014 case AF_UNSPEC:
3015 goto bad;
3016 break;
3017 default:
3018 /* another family support? */
3019 break;
3020 }
3021 }
3022 }
3023
3024 if (!(inet4 == 0 || inet4 == 2))
3025 goto bad;
3026 if (!(inet6 == 0 || inet6 == 2))
3027 goto bad;
3028
3029 if (aitop)
3030 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003031 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003032
3033 bad:
3034 if (aitop)
3035 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003036 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003037}
Matthias Kloseb159a552010-04-25 21:00:44 +00003038]]])],
3039[ac_cv_buggy_getaddrinfo=no],
3040[ac_cv_buggy_getaddrinfo=yes],
Matthias Klose96350132012-03-15 20:42:23 +01003041[
3042if test "${enable_ipv6+set}" = set; then
3043 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3044else
3045 ac_cv_buggy_getaddrinfo=yes
3046fi]))
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003047fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003048
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003049AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3050
Mark Dickinson2df5d282009-12-31 21:22:50 +00003051if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003052then
3053 if test $ipv6 = yes
3054 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003055 echo 'Fatal: You must get working getaddrinfo() function.'
3056 echo ' or you can specify "--disable-ipv6"'.
3057 exit 1
3058 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003059else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003060 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003061fi
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003062
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003063AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003064
Guido van Rossum627b2d71993-12-24 10:39:16 +00003065# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003066AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003067AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003068AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003069AC_CHECK_MEMBERS([struct stat.st_rdev])
3070AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003071AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003072AC_CHECK_MEMBERS([struct stat.st_gen])
3073AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003074AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003075
3076AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Kloseb159a552010-04-25 21:00:44 +00003077AC_CACHE_VAL(ac_cv_header_time_altzone,[
3078 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3079 [ac_cv_header_time_altzone=yes],
3080 [ac_cv_header_time_altzone=no])
3081 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003082AC_MSG_RESULT($ac_cv_header_time_altzone)
3083if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003084 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003085fi
3086
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003087was_it_defined=no
3088AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Kloseb159a552010-04-25 21:00:44 +00003089AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003090#include <sys/types.h>
3091#include <sys/select.h>
3092#include <sys/time.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003093]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003094 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3095 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3096 (which you can't on SCO ODT 3.0).])
3097 was_it_defined=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003098],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003099AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003100
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003101AC_MSG_CHECKING(for addrinfo)
3102AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00003103AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3104 [ac_cv_struct_addrinfo=yes],
3105 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003106AC_MSG_RESULT($ac_cv_struct_addrinfo)
3107if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003108 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003109fi
3110
3111AC_MSG_CHECKING(for sockaddr_storage)
3112AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Kloseb159a552010-04-25 21:00:44 +00003113AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003114# include <sys/types.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003115# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3116 [ac_cv_struct_sockaddr_storage=yes],
3117 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003118AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3119if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003120 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003121fi
3122
Guido van Rossum627b2d71993-12-24 10:39:16 +00003123# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003124
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003125AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003126AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003127
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003128works=no
3129AC_MSG_CHECKING(for working volatile)
Matthias Kloseb159a552010-04-25 21:00:44 +00003130AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3131 [works=yes],
3132 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003133)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003134AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003135
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003136works=no
3137AC_MSG_CHECKING(for working signed char)
Matthias Kloseb159a552010-04-25 21:00:44 +00003138AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3139 [works=yes],
3140 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003141)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003142AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003143
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003144have_prototypes=no
3145AC_MSG_CHECKING(for prototypes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003146AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3147 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3148 [Define if your compiler supports function prototype])
3149 have_prototypes=yes],
3150 []
3151)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003152AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003153
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003154works=no
3155AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Kloseb159a552010-04-25 21:00:44 +00003156AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003157#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003158int foo(int x, ...) {
3159 va_list va;
3160 va_start(va, x);
3161 va_arg(va, int);
3162 va_arg(va, char *);
3163 va_arg(va, double);
3164 return 0;
3165}
Matthias Kloseb159a552010-04-25 21:00:44 +00003166]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003167 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3168 [Define if your compiler supports variable length function prototypes
3169 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3170 works=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003171],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003172AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003173
Dave Cole331708b2004-08-09 04:51:41 +00003174# check for socketpair
3175AC_MSG_CHECKING(for socketpair)
Matthias Kloseb159a552010-04-25 21:00:44 +00003176AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003177#include <sys/types.h>
3178#include <sys/socket.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003179]], [[void *x=socketpair]])],
3180 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3181 AC_MSG_RESULT(yes)],
3182 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003183)
3184
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003185# check if sockaddr has sa_len member
3186AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Kloseb159a552010-04-25 21:00:44 +00003187AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3188#include <sys/socket.h>]], [[struct sockaddr x;
3189x.sa_len = 0;]])],
3190 [AC_MSG_RESULT(yes)
3191 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3192 [AC_MSG_RESULT(no)]
3193)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003194
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003195va_list_is_array=no
3196AC_MSG_CHECKING(whether va_list is an array)
Matthias Kloseb159a552010-04-25 21:00:44 +00003197AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003198#ifdef HAVE_STDARG_PROTOTYPES
3199#include <stdarg.h>
3200#else
3201#include <varargs.h>
3202#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00003203]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003204 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3205 va_list_is_array=yes
3206])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003207AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003208
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003209# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003210AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3211 [Define this if you have some version of gethostbyname_r()])
3212
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003213AC_CHECK_FUNC(gethostbyname_r, [
3214 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3215 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3216 OLD_CFLAGS=$CFLAGS
3217 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003218 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003219# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003220 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003221 char *name;
3222 struct hostent *he, *res;
3223 char buffer[2048];
3224 int buflen = 2048;
3225 int h_errnop;
3226
3227 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Kloseb159a552010-04-25 21:00:44 +00003228 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003229 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003230 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3231 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003232 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003233 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003234 AC_MSG_RESULT(no)
3235 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Kloseb159a552010-04-25 21:00:44 +00003236 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003237# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003238 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003239 char *name;
3240 struct hostent *he;
Matthias Kloseb159a552010-04-25 21:00:44 +00003241 char buffer[2048];
3242 int buflen = 2048;
3243 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003244
Matthias Kloseb159a552010-04-25 21:00:44 +00003245 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3246 ]])],
3247 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003248 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Kloseb159a552010-04-25 21:00:44 +00003249 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3250 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003251 AC_MSG_RESULT(yes)
3252 ], [
3253 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00003254 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3255 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3256# include <netdb.h>
3257 ]], [[
3258 char *name;
3259 struct hostent *he;
3260 struct hostent_data data;
3261
3262 (void) gethostbyname_r(name, he, &data);
3263 ]])],
3264 [
3265 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3266 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3267 [Define this if you have the 3-arg version of gethostbyname_r().])
3268 AC_MSG_RESULT(yes)
3269 ], [
3270 AC_MSG_RESULT(no)
3271 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003272 ])
3273 ])
3274 CFLAGS=$OLD_CFLAGS
3275], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003276 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003277])
3278AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3279AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3280AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003281AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003282AC_SUBST(HAVE_GETHOSTBYNAME)
3283
Guido van Rossum627b2d71993-12-24 10:39:16 +00003284# checks for system services
3285# (none yet)
3286
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003287# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003288AC_CHECK_FUNC(__fpu_control,
3289 [],
3290 [AC_CHECK_LIB(ieee, __fpu_control)
3291])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003292
Guido van Rossum93274221997-05-09 02:42:00 +00003293# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003294AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003295AC_ARG_WITH(fpectl,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003296 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003297[
Guido van Rossum93274221997-05-09 02:42:00 +00003298if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003299then
3300 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3301 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3302 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003303else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003304fi],
3305[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003306
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003307# check for --with-libm=...
3308AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003309case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003310Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003311*) LIBM=-lm
3312esac
Guido van Rossum93274221997-05-09 02:42:00 +00003313AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003314AC_ARG_WITH(libm,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003315 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003316[
Guido van Rossum93274221997-05-09 02:42:00 +00003317if test "$withval" = no
3318then LIBM=
3319 AC_MSG_RESULT(force LIBM empty)
3320elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003321then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003322 AC_MSG_RESULT(set LIBM="$withval")
3323else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003324fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003325[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003326
3327# check for --with-libc=...
3328AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003329AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003330AC_ARG_WITH(libc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003331 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003332[
Guido van Rossum93274221997-05-09 02:42:00 +00003333if test "$withval" = no
3334then LIBC=
3335 AC_MSG_RESULT(force LIBC empty)
3336elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003337then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003338 AC_MSG_RESULT(set LIBC="$withval")
3339else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003340fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003341[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003342
Stefan Krah1919b7e2012-03-21 18:25:23 +01003343# **************************************
3344# * Check for gcc x64 inline assembler *
3345# **************************************
3346
3347AC_MSG_CHECKING(for x64 gcc inline assembler)
3348AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3349 __asm__ __volatile__ ("movq %rcx, %rax");
3350]])],[have_gcc_asm_for_x64=yes],[have_gcc_asm_for_x64=no])
3351AC_MSG_RESULT($have_gcc_asm_for_x64)
3352if test "$have_gcc_asm_for_x64" = yes
3353then
3354 AC_DEFINE(HAVE_GCC_ASM_FOR_X64, 1,
3355 [Define if we can use x64 gcc inline assembler])
3356fi
3357
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003358# **************************************************
3359# * Check for various properties of floating point *
3360# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003361
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003362AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3363AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003364AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003365#include <string.h>
3366int main() {
3367 double x = 9006104071832581.0;
3368 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3369 return 0;
3370 else
3371 return 1;
3372}
Matthias Kloseb159a552010-04-25 21:00:44 +00003373]])],
3374[ac_cv_little_endian_double=yes],
3375[ac_cv_little_endian_double=no],
3376[ac_cv_little_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003377AC_MSG_RESULT($ac_cv_little_endian_double)
3378if test "$ac_cv_little_endian_double" = yes
3379then
3380 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3381 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3382 with the least significant byte first])
3383fi
3384
3385AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3386AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003387AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003388#include <string.h>
3389int main() {
3390 double x = 9006104071832581.0;
3391 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3392 return 0;
3393 else
3394 return 1;
3395}
Matthias Kloseb159a552010-04-25 21:00:44 +00003396]])],
3397[ac_cv_big_endian_double=yes],
3398[ac_cv_big_endian_double=no],
3399[ac_cv_big_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003400AC_MSG_RESULT($ac_cv_big_endian_double)
3401if test "$ac_cv_big_endian_double" = yes
3402then
3403 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3404 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3405 with the most significant byte first])
3406fi
3407
3408# Some ARM platforms use a mixed-endian representation for doubles.
3409# While Python doesn't currently have full support for these platforms
3410# (see e.g., issue 1762561), we can at least make sure that float <-> string
3411# conversions work.
3412AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3413AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003414AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003415#include <string.h>
3416int main() {
3417 double x = 9006104071832581.0;
3418 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3419 return 0;
3420 else
3421 return 1;
3422}
Matthias Kloseb159a552010-04-25 21:00:44 +00003423]])],
3424[ac_cv_mixed_endian_double=yes],
3425[ac_cv_mixed_endian_double=no],
3426[ac_cv_mixed_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003427AC_MSG_RESULT($ac_cv_mixed_endian_double)
3428if test "$ac_cv_mixed_endian_double" = yes
3429then
3430 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3431 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3432 in ARM mixed-endian order (byte order 45670123)])
3433fi
3434
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003435# The short float repr introduced in Python 3.1 requires the
3436# correctly-rounded string <-> double conversion functions from
3437# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3438# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003439# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003440# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003441
3442# This inline assembler syntax may also work for suncc and icc,
3443# so we try it on all platforms.
3444
3445AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Kloseb159a552010-04-25 21:00:44 +00003446AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003447 unsigned short cw;
3448 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3449 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Kloseb159a552010-04-25 21:00:44 +00003450]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003451AC_MSG_RESULT($have_gcc_asm_for_x87)
3452if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003453then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003454 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3455 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003456fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003457
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003458# Detect whether system arithmetic is subject to x87-style double
3459# rounding issues. The result of this test has little meaning on non
3460# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3461# mode is round-to-nearest and double rounding issues are present, and
3462# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3463AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003464# $BASECFLAGS may affect the result
3465ac_save_cc="$CC"
3466CC="$CC $BASECFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003467AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003468#include <stdlib.h>
3469#include <math.h>
3470int main() {
3471 volatile double x, y, z;
3472 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3473 x = 0.99999999999999989; /* 1-2**-53 */
3474 y = 1./x;
3475 if (y != 1.)
3476 exit(0);
3477 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3478 x = 1e16;
3479 y = 2.99999;
3480 z = x + y;
3481 if (z != 1e16+4.)
3482 exit(0);
3483 /* both tests show evidence of double rounding */
3484 exit(1);
3485}
Matthias Kloseb159a552010-04-25 21:00:44 +00003486]])],
3487[ac_cv_x87_double_rounding=no],
3488[ac_cv_x87_double_rounding=yes],
3489[ac_cv_x87_double_rounding=no])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003490CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003491AC_MSG_RESULT($ac_cv_x87_double_rounding)
3492if test "$ac_cv_x87_double_rounding" = yes
3493then
3494 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3495 [Define if arithmetic is subject to x87-style double rounding issue])
3496fi
3497
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003498# ************************************
3499# * Check for mathematical functions *
3500# ************************************
3501
3502LIBS_SAVE=$LIBS
3503LIBS="$LIBS $LIBM"
3504
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003505AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
Victor Stinner8f9f8d62011-05-09 12:45:41 +02003506AC_CHECK_FUNCS([hypot lgamma log1p log2 round tgamma])
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003507AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3508
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003509# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3510# -0. on some architectures.
3511AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3512AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003513AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003514#include <math.h>
3515#include <stdlib.h>
3516int main() {
3517 /* return 0 if either negative zeros don't exist
3518 on this platform or if negative zeros exist
3519 and tanh(-0.) == -0. */
3520 if (atan2(0., -1.) == atan2(-0., -1.) ||
3521 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3522 else exit(1);
3523}
Matthias Kloseb159a552010-04-25 21:00:44 +00003524]])],
3525[ac_cv_tanh_preserves_zero_sign=yes],
3526[ac_cv_tanh_preserves_zero_sign=no],
3527[ac_cv_tanh_preserves_zero_sign=no])])
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003528AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3529if test "$ac_cv_tanh_preserves_zero_sign" = yes
3530then
3531 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3532 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3533fi
3534
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003535if test "$ac_cv_func_log1p" = yes
3536then
3537 # On some versions of AIX, log1p(-0.) returns 0. instead of
3538 # -0. See issue #9920.
3539 AC_MSG_CHECKING(whether log1p drops the sign of negative zero)
3540 AC_CACHE_VAL(ac_cv_log1p_drops_zero_sign, [
3541 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3542 #include <math.h>
3543 #include <stdlib.h>
3544 int main() {
3545 /* Fail if the signs of log1p(-0.) and -0. can be
3546 distinguished. */
3547 if (atan2(log1p(-0.), -1.) == atan2(-0., -1.))
3548 return 0;
3549 else
3550 return 1;
3551 }
3552 ]])],
3553 [ac_cv_log1p_drops_zero_sign=no],
3554 [ac_cv_log1p_drops_zero_sign=yes],
3555 [ac_cv_log1p_drops_zero_sign=no])])
3556 AC_MSG_RESULT($ac_cv_log1p_drops_zero_sign)
3557fi
3558if test "$ac_cv_log1p_drops_zero_sign" = yes
3559then
3560 AC_DEFINE(LOG1P_DROPS_ZERO_SIGN, 1,
3561 [Define if log1p(-0.) is 0. rather than -0.])
3562fi
Christian Heimes99170a52007-12-19 02:07:34 +00003563
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003564LIBS=$LIBS_SAVE
3565
Mark Dickinsona614f042009-11-28 12:48:43 +00003566# For multiprocessing module, check that sem_open
3567# actually works. For FreeBSD versions <= 7.2,
3568# the kernel module that provides POSIX semaphores
3569# isn't loaded by default, so an attempt to call
3570# sem_open results in a 'Signal 12' error.
3571AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3572AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Kloseb159a552010-04-25 21:00:44 +00003573AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsona614f042009-11-28 12:48:43 +00003574#include <unistd.h>
3575#include <fcntl.h>
3576#include <stdio.h>
3577#include <semaphore.h>
3578#include <sys/stat.h>
3579
3580int main(void) {
3581 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3582 if (a == SEM_FAILED) {
3583 perror("sem_open");
3584 return 1;
3585 }
3586 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003587 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003588 return 0;
3589}
Matthias Kloseb159a552010-04-25 21:00:44 +00003590]])],
3591[ac_cv_posix_semaphores_enabled=yes],
3592[ac_cv_posix_semaphores_enabled=no],
3593[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsona614f042009-11-28 12:48:43 +00003594)
3595AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3596if test $ac_cv_posix_semaphores_enabled = no
3597then
3598 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3599 [Define if POSIX semaphores aren't enabled on your system])
3600fi
3601
Mark Dickinson10683072009-04-18 21:18:19 +00003602# Multiprocessing check for broken sem_getvalue
3603AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003604AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Kloseb159a552010-04-25 21:00:44 +00003605AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson10683072009-04-18 21:18:19 +00003606#include <unistd.h>
3607#include <fcntl.h>
3608#include <stdio.h>
3609#include <semaphore.h>
3610#include <sys/stat.h>
3611
3612int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003613 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003614 int count;
3615 int res;
3616 if(a==SEM_FAILED){
3617 perror("sem_open");
3618 return 1;
3619
3620 }
3621 res = sem_getvalue(a, &count);
3622 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003623 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003624 return res==-1 ? 1 : 0;
3625}
Matthias Kloseb159a552010-04-25 21:00:44 +00003626]])],
3627[ac_cv_broken_sem_getvalue=no],
3628[ac_cv_broken_sem_getvalue=yes],
3629[ac_cv_broken_sem_getvalue=yes])
Mark Dickinson10683072009-04-18 21:18:19 +00003630)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003631AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3632if test $ac_cv_broken_sem_getvalue = yes
3633then
3634 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3635 [define to 1 if your sem_getvalue is broken.])
3636fi
Mark Dickinson10683072009-04-18 21:18:19 +00003637
Mark Dickinsonbd792642009-03-18 20:06:12 +00003638# determine what size digit to use for Python's longs
3639AC_MSG_CHECKING([digit size for Python's longs])
3640AC_ARG_ENABLE(big-digits,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003641AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonbd792642009-03-18 20:06:12 +00003642[case $enable_big_digits in
3643yes)
3644 enable_big_digits=30 ;;
3645no)
3646 enable_big_digits=15 ;;
3647[15|30])
3648 ;;
3649*)
3650 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3651esac
3652AC_MSG_RESULT($enable_big_digits)
3653AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3654],
3655[AC_MSG_RESULT(no value specified)])
3656
Guido van Rossumef2255b2000-03-10 22:30:29 +00003657# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003658AC_CHECK_HEADER(wchar.h, [
3659 AC_DEFINE(HAVE_WCHAR_H, 1,
3660 [Define if the compiler provides a wchar.h header file.])
3661 wchar_h="yes"
3662],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003663wchar_h="no"
3664)
3665
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003666# determine wchar_t size
3667if test "$wchar_h" = yes
3668then
Guido van Rossum67b26592001-10-20 14:21:45 +00003669 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003670fi
3671
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003672AC_MSG_CHECKING(for UCS-4 tcl)
3673have_ucs4_tcl=no
Matthias Kloseb159a552010-04-25 21:00:44 +00003674AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003675#include <tcl.h>
3676#if TCL_UTF_MAX != 6
3677# error "NOT UCS4_TCL"
Matthias Kloseb159a552010-04-25 21:00:44 +00003678#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003679 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3680 have_ucs4_tcl=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003681],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003682AC_MSG_RESULT($have_ucs4_tcl)
3683
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003684# check whether wchar_t is signed or not
3685if test "$wchar_h" = yes
3686then
3687 # check whether wchar_t is signed or not
3688 AC_MSG_CHECKING(whether wchar_t is signed)
3689 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003690 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003691 #include <wchar.h>
3692 int main()
3693 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003694 /* Success: exit code 0 */
3695 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003696 }
Matthias Kloseb159a552010-04-25 21:00:44 +00003697 ]])],
3698 [ac_cv_wchar_t_signed=yes],
3699 [ac_cv_wchar_t_signed=no],
3700 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003701 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3702fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003703
Georg Brandl52d168a2008-01-07 18:10:24 +00003704# wchar_t is only usable if it maps to an unsigned type
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003705if test "$ac_cv_sizeof_wchar_t" -ge 2 \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003706 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003707then
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003708 HAVE_USABLE_WCHAR_T="yes"
Georg Brandl52d168a2008-01-07 18:10:24 +00003709 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3710 [Define if you have a useable wchar_t type defined in wchar.h; useable
3711 means wchar_t must be an unsigned type with at least 16 bits. (see
3712 Include/unicodeobject.h).])
Georg Brandl52d168a2008-01-07 18:10:24 +00003713else
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003714 HAVE_USABLE_WCHAR_T="no usable wchar_t found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003715fi
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003716AC_MSG_RESULT($HAVE_USABLE_WCHAR_T)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003717
3718# check for endianness
3719AC_C_BIGENDIAN
3720
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003721# ABI version string for Python extension modules. This appears between the
3722# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
3723# from the following attributes which affect the ABI of this Python build (in
3724# this order):
3725#
3726# * The Python implementation (always 'cpython-' for us)
3727# * The major and minor version numbers
3728# * --with-pydebug (adds a 'd')
3729# * --with-pymalloc (adds a 'm')
3730# * --with-wide-unicode (adds a 'u')
3731#
3732# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
Georg Brandlde7d8342010-09-03 22:19:07 +00003733# would get a shared library ABI version tag of 'cpython-32dmu' and shared
3734# libraries would be named 'foo.cpython-32dmu.so'.
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003735AC_SUBST(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003736AC_MSG_CHECKING(ABIFLAGS)
3737AC_MSG_RESULT($ABIFLAGS)
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003738AC_MSG_CHECKING(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003739SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003740AC_MSG_RESULT($SOABI)
3741
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003742AC_MSG_CHECKING(LDVERSION)
3743LDVERSION='$(VERSION)$(ABIFLAGS)'
3744AC_MSG_RESULT($LDVERSION)
3745
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003746# SO is the extension of shared libraries `(including the dot!)
3747# -- usually .so, .sl on HP-UX, .dll on Cygwin
3748AC_MSG_CHECKING(SO)
3749if test -z "$SO"
3750then
3751 case $ac_sys_system in
3752 hp*|HP*)
3753 case `uname -m` in
3754 ia64) SO=.so;;
3755 *) SO=.sl;;
3756 esac
3757 ;;
3758 CYGWIN*) SO=.dll;;
Matthias Klose3fbfea12010-10-14 15:24:22 +00003759 Linux*|GNU*)
3760 SO=.${SOABI}.so;;
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003761 *) SO=.so;;
3762 esac
3763else
3764 # this might also be a termcap variable, see #610332
Georg Brandlde7d8342010-09-03 22:19:07 +00003765 echo
3766 echo '====================================================================='
3767 echo '+ +'
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003768 echo '+ WARNING: You have set SO in your environment. +'
Georg Brandlde7d8342010-09-03 22:19:07 +00003769 echo '+ Do you really mean to change the extension for shared libraries? +'
3770 echo '+ Continuing in 10 seconds to let you to ponder. +'
3771 echo '+ +'
3772 echo '====================================================================='
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003773 sleep 10
3774fi
3775AC_MSG_RESULT($SO)
3776
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003777# Check whether right shifting a negative integer extends the sign bit
3778# or fills with zeros (like the Cray J90, according to Tim Peters).
3779AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003780AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003781AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003782int main()
3783{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003784 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003785}
Matthias Kloseb159a552010-04-25 21:00:44 +00003786]])],
3787[ac_cv_rshift_extends_sign=yes],
3788[ac_cv_rshift_extends_sign=no],
3789[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003790AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3791if test "$ac_cv_rshift_extends_sign" = no
3792then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003793 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3794 [Define if i>>j for signed int i does not extend the sign bit
3795 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003796fi
3797
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003798# check for getc_unlocked and related locking functions
3799AC_MSG_CHECKING(for getc_unlocked() and friends)
3800AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003801AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003802 FILE *f = fopen("/dev/null", "r");
3803 flockfile(f);
3804 getc_unlocked(f);
3805 funlockfile(f);
Matthias Kloseb159a552010-04-25 21:00:44 +00003806]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003807AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3808if test "$ac_cv_have_getc_unlocked" = yes
3809then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003810 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3811 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003812fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003813
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003814# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003815# save the value of LIBS so we don't actually link Python with readline
3816LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003817
3818# On some systems we need to link readline to a termcap compatible
3819# library. NOTE: Keep the precedence of listed libraries synchronised
3820# with setup.py.
3821py_cv_lib_readline=no
3822AC_MSG_CHECKING([how to link readline libs])
3823for py_libtermcap in "" ncursesw ncurses curses termcap; do
3824 if test -z "$py_libtermcap"; then
3825 READLINE_LIBS="-lreadline"
3826 else
3827 READLINE_LIBS="-lreadline -l$py_libtermcap"
3828 fi
3829 LIBS="$READLINE_LIBS $LIBS_no_readline"
3830 AC_LINK_IFELSE(
3831 [AC_LANG_CALL([],[readline])],
3832 [py_cv_lib_readline=yes])
3833 if test $py_cv_lib_readline = yes; then
3834 break
3835 fi
3836done
3837# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3838#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003839if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003840 AC_MSG_RESULT([none])
3841else
3842 AC_MSG_RESULT([$READLINE_LIBS])
3843 AC_DEFINE(HAVE_LIBREADLINE, 1,
3844 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003845fi
3846
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003847# check for readline 2.1
3848AC_CHECK_LIB(readline, rl_callback_handler_install,
3849 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003850 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003851
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003852# check for readline 2.2
Matthias Kloseb159a552010-04-25 21:00:44 +00003853AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3854 [have_readline=yes],
3855 [have_readline=no]
3856)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003857if test $have_readline = yes
3858then
3859 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3860 [readline/readline.h],
3861 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3862 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003863 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3864 [readline/readline.h],
3865 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3866 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003867fi
3868
Martin v. Löwis0daad592001-09-30 21:09:59 +00003869# check for readline 4.0
3870AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003871 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003872 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003873
Thomas Wouters89d996e2007-09-08 17:39:28 +00003874# also in 4.0
3875AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3876 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003877 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003878
Guido van Rossum353ae582001-07-10 16:45:32 +00003879# check for readline 4.2
3880AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003881 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003882 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003883
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003884# also in readline 4.2
Matthias Kloseb159a552010-04-25 21:00:44 +00003885AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3886 [have_readline=yes],
3887 [have_readline=no]
3888)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003889if test $have_readline = yes
3890then
3891 AC_EGREP_HEADER([extern int rl_catch_signals;],
3892 [readline/readline.h],
3893 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3894 [Define if you can turn off readline's signal handling.]), )
3895fi
3896
Martin v. Löwis82bca632006-02-10 20:49:30 +00003897# End of readline checks: restore LIBS
3898LIBS=$LIBS_no_readline
3899
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003900AC_MSG_CHECKING(for broken nice())
3901AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003902AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003903int main()
3904{
3905 int val1 = nice(1);
3906 if (val1 != -1 && val1 == nice(2))
3907 exit(0);
3908 exit(1);
3909}
Matthias Kloseb159a552010-04-25 21:00:44 +00003910]])],
3911[ac_cv_broken_nice=yes],
3912[ac_cv_broken_nice=no],
3913[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003914AC_MSG_RESULT($ac_cv_broken_nice)
3915if test "$ac_cv_broken_nice" = yes
3916then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003917 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3918 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003919fi
3920
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003921AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003922AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Kloseb159a552010-04-25 21:00:44 +00003923AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003924#include <poll.h>
3925
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003926int main()
3927{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003928 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003929 int poll_test;
3930
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003931 close (42);
3932
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003933 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003934 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003935 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003936 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003937 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003938 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003939 return 1;
3940}
Matthias Kloseb159a552010-04-25 21:00:44 +00003941]])],
3942[ac_cv_broken_poll=yes],
3943[ac_cv_broken_poll=no],
3944[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003945AC_MSG_RESULT($ac_cv_broken_poll)
3946if test "$ac_cv_broken_poll" = yes
3947then
3948 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3949 [Define if poll() sets errno on invalid file descriptors.])
3950fi
3951
Brett Cannon43802422005-02-10 20:48:03 +00003952# Before we can test tzset, we need to check if struct tm has a tm_zone
3953# (which is not required by ISO C or UNIX spec) and/or if we support
3954# tzname[]
3955AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003956
Brett Cannon43802422005-02-10 20:48:03 +00003957# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003958AC_MSG_CHECKING(for working tzset())
3959AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003960AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003961#include <stdlib.h>
3962#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003963#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003964
3965#if HAVE_TZNAME
3966extern char *tzname[];
3967#endif
3968
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003969int main()
3970{
Brett Cannon18367812003-09-19 00:59:16 +00003971 /* Note that we need to ensure that not only does tzset(3)
3972 do 'something' with localtime, but it works as documented
3973 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003974 This includes making sure that tzname is set properly if
3975 tm->tm_zone does not exist since it is the alternative way
3976 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003977
3978 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003979 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003980 */
3981
Brett Cannon43802422005-02-10 20:48:03 +00003982 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003983 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3984
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003985 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003986 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003987 if (localtime(&groundhogday)->tm_hour != 0)
3988 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003989#if HAVE_TZNAME
3990 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3991 if (strcmp(tzname[0], "UTC") ||
3992 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3993 exit(1);
3994#endif
Brett Cannon18367812003-09-19 00:59:16 +00003995
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003996 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003997 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003998 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003999 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004000#if HAVE_TZNAME
4001 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4002 exit(1);
4003#endif
Brett Cannon18367812003-09-19 00:59:16 +00004004
4005 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4006 tzset();
4007 if (localtime(&groundhogday)->tm_hour != 11)
4008 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004009#if HAVE_TZNAME
4010 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4011 exit(1);
4012#endif
4013
4014#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004015 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4016 exit(1);
4017 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4018 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004019#endif
Brett Cannon18367812003-09-19 00:59:16 +00004020
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004021 exit(0);
4022}
Matthias Kloseb159a552010-04-25 21:00:44 +00004023]])],
4024[ac_cv_working_tzset=yes],
4025[ac_cv_working_tzset=no],
4026[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004027AC_MSG_RESULT($ac_cv_working_tzset)
4028if test "$ac_cv_working_tzset" = yes
4029then
4030 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4031 [Define if tzset() actually switches the local timezone in a meaningful way.])
4032fi
4033
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004034# Look for subsecond timestamps in struct stat
4035AC_MSG_CHECKING(for tv_nsec in struct stat)
4036AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Kloseb159a552010-04-25 21:00:44 +00004037AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004038struct stat st;
4039st.st_mtim.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004040]])],
4041[ac_cv_stat_tv_nsec=yes],
4042[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004043AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4044if test "$ac_cv_stat_tv_nsec" = yes
4045then
4046 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4047 [Define if you have struct stat.st_mtim.tv_nsec])
4048fi
4049
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004050# Look for BSD style subsecond timestamps in struct stat
4051AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4052AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Kloseb159a552010-04-25 21:00:44 +00004053AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004054struct stat st;
4055st.st_mtimespec.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004056]])],
4057[ac_cv_stat_tv_nsec2=yes],
4058[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004059AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4060if test "$ac_cv_stat_tv_nsec2" = yes
4061then
4062 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4063 [Define if you have struct stat.st_mtimensec])
4064fi
4065
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004066# On HP/UX 11.0, mvwdelch is a block with a return statement
4067AC_MSG_CHECKING(whether mvwdelch is an expression)
4068AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Kloseb159a552010-04-25 21:00:44 +00004069AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004070 int rtn;
4071 rtn = mvwdelch(0,0,0);
Matthias Kloseb159a552010-04-25 21:00:44 +00004072]])],
4073[ac_cv_mvwdelch_is_expression=yes],
4074[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004075AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4076
4077if test "$ac_cv_mvwdelch_is_expression" = yes
4078then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004079 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4080 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004081fi
4082
4083AC_MSG_CHECKING(whether WINDOW has _flags)
4084AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Kloseb159a552010-04-25 21:00:44 +00004085AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004086 WINDOW *w;
4087 w->_flags = 0;
Matthias Kloseb159a552010-04-25 21:00:44 +00004088]])],
4089[ac_cv_window_has_flags=yes],
4090[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004091AC_MSG_RESULT($ac_cv_window_has_flags)
4092
4093
4094if test "$ac_cv_window_has_flags" = yes
4095then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004096 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4097 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004098fi
4099
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004100AC_MSG_CHECKING(for is_term_resized)
Matthias Kloseb159a552010-04-25 21:00:44 +00004101AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4102 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4103 AC_MSG_RESULT(yes)],
4104 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004105)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00004106
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004107AC_MSG_CHECKING(for resize_term)
Matthias Kloseb159a552010-04-25 21:00:44 +00004108AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4109 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4110 AC_MSG_RESULT(yes)],
4111 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004112)
4113
4114AC_MSG_CHECKING(for resizeterm)
Matthias Kloseb159a552010-04-25 21:00:44 +00004115AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4116 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4117 AC_MSG_RESULT(yes)],
4118 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004119)
4120
Thomas Wouters89f507f2006-12-13 04:49:30 +00004121AC_MSG_CHECKING(for /dev/ptmx)
4122
4123if test -r /dev/ptmx
4124then
4125 AC_MSG_RESULT(yes)
4126 AC_DEFINE(HAVE_DEV_PTMX, 1,
4127 [Define if we have /dev/ptmx.])
4128else
4129 AC_MSG_RESULT(no)
4130fi
4131
4132AC_MSG_CHECKING(for /dev/ptc)
4133
4134if test -r /dev/ptc
4135then
4136 AC_MSG_RESULT(yes)
4137 AC_DEFINE(HAVE_DEV_PTC, 1,
4138 [Define if we have /dev/ptc.])
4139else
4140 AC_MSG_RESULT(no)
4141fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004142
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004143if test "$have_long_long" = yes
4144then
4145 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4146 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Kloseb159a552010-04-25 21:00:44 +00004147 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004148 #include <stdio.h>
4149 #include <stddef.h>
4150 #include <string.h>
4151
4152 #ifdef HAVE_SYS_TYPES_H
4153 #include <sys/types.h>
4154 #endif
4155
4156 int main()
4157 {
4158 char buffer[256];
4159
4160 if (sprintf(buffer, "%lld", (long long)123) < 0)
4161 return 1;
4162 if (strcmp(buffer, "123"))
4163 return 1;
4164
4165 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4166 return 1;
4167 if (strcmp(buffer, "-123"))
4168 return 1;
4169
4170 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4171 return 1;
4172 if (strcmp(buffer, "123"))
4173 return 1;
4174
4175 return 0;
4176 }
Matthias Kloseb159a552010-04-25 21:00:44 +00004177 ]]])],
4178 [ac_cv_have_long_long_format=yes],
4179 [ac_cv_have_long_long_format=no],
Matthias Klose3b739b12012-03-15 19:31:06 +01004180 [ac_cv_have_long_long_format="cross -- assuming no"
4181 if test x$GCC = xyes; then
4182 save_CFLAGS=$CFLAGS
4183 CFLAGS="$CFLAGS -Werror -Wformat"
4184 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4185 #include <stdio.h>
4186 #include <stddef.h>
4187 ]], [[
4188 char *buffer;
4189 sprintf(buffer, "%lld", (long long)123);
4190 sprintf(buffer, "%lld", (long long)-123);
4191 sprintf(buffer, "%llu", (unsigned long long)123);
4192 ]])],
4193 ac_cv_have_long_long_format=yes
4194 )
4195 CFLAGS=$save_CFLAGS
4196 fi])
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004197 )
4198 AC_MSG_RESULT($ac_cv_have_long_long_format)
4199fi
4200
Mark Dickinson89d7d412009-12-31 20:50:59 +00004201if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004202then
4203 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4204 [Define to printf format modifier for long long type])
4205fi
4206
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00004207if test $ac_sys_system = Darwin
4208then
4209 LIBS="$LIBS -framework CoreFoundation"
4210fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004211
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004212AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Kloseb159a552010-04-25 21:00:44 +00004213AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004214#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00004215#include <stddef.h>
4216#include <string.h>
4217
Christian Heimes2c181612007-12-17 20:04:13 +00004218#ifdef HAVE_SYS_TYPES_H
4219#include <sys/types.h>
4220#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00004221
4222#ifdef HAVE_SSIZE_T
4223typedef ssize_t Py_ssize_t;
4224#elif SIZEOF_VOID_P == SIZEOF_LONG
4225typedef long Py_ssize_t;
4226#else
4227typedef int Py_ssize_t;
4228#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00004229
Christian Heimes2c181612007-12-17 20:04:13 +00004230int main()
4231{
4232 char buffer[256];
4233
Thomas Wouters477c8d52006-05-27 19:21:47 +00004234 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4235 return 1;
4236
Thomas Wouters89f507f2006-12-13 04:49:30 +00004237 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004238 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004239
4240 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4241 return 1;
4242
4243 if (strcmp(buffer, "-123"))
4244 return 1;
4245
Thomas Wouters477c8d52006-05-27 19:21:47 +00004246 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004247}
Matthias Kloseb159a552010-04-25 21:00:44 +00004248]])],
4249 [ac_cv_have_size_t_format=yes],
4250 [ac_cv_have_size_t_format=no],
4251 [ac_cv_have_size_t_format="cross -- assuming yes"
4252])])
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004253if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004254 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4255 [Define to printf format modifier for Py_ssize_t])
4256fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004257
Martin v. Löwis01c04012002-11-11 14:58:44 +00004258AC_CHECK_TYPE(socklen_t,,
4259 AC_DEFINE(socklen_t,int,
Matthias Klosec80c93f2010-04-24 17:04:35 +00004260 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004261#ifdef HAVE_SYS_TYPES_H
4262#include <sys/types.h>
4263#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004264#ifdef HAVE_SYS_SOCKET_H
4265#include <sys/socket.h>
4266#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004267])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004268
Antoine Pitroufff95302008-09-03 18:58:51 +00004269AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004270AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Matthias Kloseb159a552010-04-25 21:00:44 +00004271AC_RUN_IFELSE([AC_LANG_SOURCE([[
Antoine Pitroufff95302008-09-03 18:58:51 +00004272#include<stdlib.h>
4273int main() {
4274 size_t len = -1;
4275 const char *str = "text";
4276 len = mbstowcs(NULL, str, 0);
4277 return (len != 4);
4278}
Matthias Kloseb159a552010-04-25 21:00:44 +00004279]])],
4280[ac_cv_broken_mbstowcs=no],
4281[ac_cv_broken_mbstowcs=yes],
4282[ac_cv_broken_mbstowcs=no]))
Antoine Pitroufff95302008-09-03 18:58:51 +00004283AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4284if test "$ac_cv_broken_mbstowcs" = yes
4285then
4286 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4287 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4288 wide chars that would be converted.])
4289fi
4290
Antoine Pitroub52ec782009-01-25 16:34:23 +00004291# Check for --with-computed-gotos
4292AC_MSG_CHECKING(for --with-computed-gotos)
4293AC_ARG_WITH(computed-gotos,
Antoine Pitrou042b1282010-08-13 21:15:58 +00004294 AS_HELP_STRING([--with(out)-computed-gotos],
4295 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
Antoine Pitroub52ec782009-01-25 16:34:23 +00004296[
Antoine Pitrou042b1282010-08-13 21:15:58 +00004297if test "$withval" = yes
Antoine Pitroub52ec782009-01-25 16:34:23 +00004298then
4299 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4300 [Define if you want to use computed gotos in ceval.c.])
4301 AC_MSG_RESULT(yes)
Antoine Pitrou042b1282010-08-13 21:15:58 +00004302fi
4303if test "$withval" = no
4304then
4305 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4306 [Define if you want to use computed gotos in ceval.c.])
4307 AC_MSG_RESULT(no)
4308fi
4309],
4310[AC_MSG_RESULT(no value specified)])
Antoine Pitroub52ec782009-01-25 16:34:23 +00004311
Matthias Kloseb17289e2012-03-15 19:51:34 +01004312AC_MSG_CHECKING(whether $CC supports computed gotos)
4313AC_CACHE_VAL(ac_cv_computed_gotos,
4314AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4315int main(int argc, char **argv)
4316{
4317 static void *targets[1] = { &&LABEL1 };
4318 goto LABEL2;
4319LABEL1:
4320 return 0;
4321LABEL2:
4322 goto *targets[0];
4323 return 1;
4324}
4325]]])],
4326[ac_cv_computed_gotos=yes],
4327[ac_cv_computed_gotos=no],
4328[if test "${with_computed_gotos+set}" = set; then
4329 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4330 else
4331 ac_cv_computed_gotos=no
4332 fi]))
4333AC_MSG_RESULT($ac_cv_computed_gotos)
4334case "$ac_cv_computed_gotos" in yes*)
4335 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4336 [Define if the C compiler supports computed gotos.])
4337esac
4338
R. David Murraye16cda92010-10-15 23:12:57 +00004339case $ac_sys_system in
4340AIX*)
4341 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4342esac
Antoine Pitroub52ec782009-01-25 16:34:23 +00004343
Jesus Cea6a792292010-05-03 21:18:48 +00004344
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004345AC_SUBST(THREADHEADERS)
4346
4347for h in `(cd $srcdir;echo Python/thread_*.h)`
4348do
4349 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4350done
4351
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004352AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004353SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004354AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004355for dir in $SRCDIRS; do
4356 if test ! -d $dir; then
4357 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004358 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004359done
4360AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004361
Stefan Krah1919b7e2012-03-21 18:25:23 +01004362# Availability of -O2:
4363AC_MSG_CHECKING(for -O2)
4364saved_cflags="$CFLAGS"
4365CFLAGS="-O2"
4366AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
4367]])],[have_O2=yes],[have_O2=no])
4368AC_MSG_RESULT($have_O2)
4369CFLAGS="$saved_cflags"
4370
4371# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
4372# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
4373AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug)
4374saved_cflags="$CFLAGS"
4375CFLAGS="-O2 -D_FORTIFY_SOURCE=2"
4376if test "$have_O2" = no; then
4377 CFLAGS=""
4378fi
4379AC_RUN_IFELSE([AC_LANG_SOURCE([[
4380#include <stdio.h>
4381#include <stdlib.h>
4382#include <string.h>
4383void foo(void *p, void *q) { memmove(p, q, 19); }
4384int main() {
4385 char a[32] = "123456789000000000";
4386 foo(&a[9], a);
4387 if (strcmp(a, "123456789123456789000000000") != 0)
4388 return 1;
4389 foo(a, &a[9]);
4390 if (strcmp(a, "123456789000000000") != 0)
4391 return 1;
4392 return 0;
4393}
4394]])],
4395[have_glibc_memmove_bug=no],
4396[have_glibc_memmove_bug=yes],
4397[have_glibc_memmove_bug=undefined])
4398CFLAGS="$saved_cflags"
4399AC_MSG_RESULT($have_glibc_memmove_bug)
4400if test "$have_glibc_memmove_bug" = yes; then
4401 AC_DEFINE(HAVE_GLIBC_MEMMOVE_BUG, 1,
4402 [Define if glibc has incorrect _FORTIFY_SOURCE wrappers
4403 for memmove and bcopy.])
4404fi
4405
4406if test "$have_gcc_asm_for_x87" = yes; then
4407 # Some versions of gcc miscompile inline asm:
4408 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
4409 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
4410 case $CC in
4411 *gcc*)
4412 AC_MSG_CHECKING(for gcc ipa-pure-const bug)
4413 saved_cflags="$CFLAGS"
4414 CFLAGS="-O2"
4415 AC_RUN_IFELSE([AC_LANG_SOURCE([[
4416 __attribute__((noinline)) int
4417 foo(int *p) {
4418 int r;
4419 asm ( "movl \$6, (%1)\n\t"
4420 "xorl %0, %0\n\t"
4421 : "=r" (r) : "r" (p) : "memory"
4422 );
4423 return r;
4424 }
4425 int main() {
4426 int p = 8;
4427 if ((foo(&p) ? : p) != 6)
4428 return 1;
4429 return 0;
4430 }
4431 ]])],
4432 [have_ipa_pure_const_bug=no],
4433 [have_ipa_pure_const_bug=yes],
4434 [have_ipa_pure_const_bug=undefined])
4435 CFLAGS="$saved_cflags"
4436 AC_MSG_RESULT($have_ipa_pure_const_bug)
4437 if test "$have_ipa_pure_const_bug" = yes; then
4438 AC_DEFINE(HAVE_IPA_PURE_CONST_BUG, 1,
4439 [Define if gcc has the ipa-pure-const bug.])
4440 fi
4441 ;;
4442 esac
4443fi
4444
Guido van Rossum627b2d71993-12-24 10:39:16 +00004445# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004446AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrou8e6b4072010-09-10 19:44:44 +00004447AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004448AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004449
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004450echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004451if test ! -f Modules/Setup
4452then
4453 cp $srcdir/Modules/Setup.dist Modules/Setup
4454fi
4455
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004456echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004457if test ! -f Modules/Setup.local
4458then
4459 echo "# Edit this file for local setup changes" >Modules/Setup.local
4460fi
4461
4462echo "creating Makefile"
4463$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4464 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004465 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004466mv config.c Modules