blob: 78bcbe7af768db40908c3261752974d0b3323fc4 [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
Benjamin Peterson076ed002010-10-31 17:11:02 +00002051# Check for support for loadable sqlite extensions
2052AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)
2053AC_ARG_ENABLE(loadable-sqlite-extensions,
2054 AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module]),
2055 [],
2056 [enable_loadable_sqlite_extensions="no"])
2057
2058AC_MSG_RESULT($enable_loadable_sqlite_extensions)
2059
Matthias Klose55708cc2009-04-30 08:06:49 +00002060# Check for --with-dbmliborder
2061AC_MSG_CHECKING(for --with-dbmliborder)
2062AC_ARG_WITH(dbmliborder,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002063 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 +00002064[
2065if test x$with_dbmliborder = xyes
2066then
2067AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2068else
2069 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2070 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2071 then
2072 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2073 fi
2074 done
2075fi])
2076AC_MSG_RESULT($with_dbmliborder)
2077
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002078# Determine if signalmodule should be used.
2079AC_SUBST(USE_SIGNAL_MODULE)
2080AC_SUBST(SIGNAL_OBJS)
2081AC_MSG_CHECKING(for --with-signal-module)
2082AC_ARG_WITH(signal-module,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002083 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002084
2085if test -z "$with_signal_module"
2086then with_signal_module="yes"
2087fi
2088AC_MSG_RESULT($with_signal_module)
2089
2090if test "${with_signal_module}" = "yes"; then
2091 USE_SIGNAL_MODULE=""
2092 SIGNAL_OBJS=""
2093else
2094 USE_SIGNAL_MODULE="#"
2095 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2096fi
2097
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002098# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002099AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002100USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002101
Guido van Rossum54d93d41997-01-22 20:51:58 +00002102AC_SUBST(LDLAST)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002103
Martin v. Löwis11437992002-04-12 09:54:03 +00002104# Templates for things AC_DEFINEd more than once.
2105# For a single AC_DEFINE, no template is needed.
Martin v. Löwis11437992002-04-12 09:54:03 +00002106AH_TEMPLATE(_REENTRANT,
2107 [Define to force use of thread-safe errno, h_errno, and other functions])
2108AH_TEMPLATE(WITH_THREAD,
2109 [Define if you want to compile in rudimentary thread support])
2110
Guido van Rossum54d93d41997-01-22 20:51:58 +00002111AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002112dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002113AC_ARG_WITH(threads,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002114 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002115
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002116# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002117dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002118AC_ARG_WITH(thread,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002119 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002120 [with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002121
2122if test -z "$with_threads"
2123then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002124fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002125AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002126
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002127AC_SUBST(THREADOBJ)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002128if test "$with_threads" = "no"
2129then
2130 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002131elif test "$ac_cv_pthread_is_default" = yes
2132then
2133 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002134 # Defining _REENTRANT on system with POSIX threads should not hurt.
2135 AC_DEFINE(_REENTRANT)
2136 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002137 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002138elif test "$ac_cv_kpthread" = "yes"
2139then
2140 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002141 if test "$ac_cv_cxx_thread" = "yes"; then
2142 CXX="$CXX -Kpthread"
2143 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002144 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002145 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002146 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002147elif test "$ac_cv_kthread" = "yes"
2148then
2149 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002150 if test "$ac_cv_cxx_thread" = "yes"; then
2151 CXX="$CXX -Kthread"
2152 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002153 AC_DEFINE(WITH_THREAD)
2154 posix_threads=yes
2155 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002156elif test "$ac_cv_pthread" = "yes"
2157then
2158 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002159 if test "$ac_cv_cxx_thread" = "yes"; then
2160 CXX="$CXX -pthread"
2161 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002162 AC_DEFINE(WITH_THREAD)
2163 posix_threads=yes
2164 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002165else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002166 if test ! -z "$with_threads" -a -d "$with_threads"
2167 then LDFLAGS="$LDFLAGS -L$with_threads"
2168 fi
2169 if test ! -z "$withval" -a -d "$withval"
2170 then LDFLAGS="$LDFLAGS -L$withval"
2171 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002172
2173 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002174 # define _POSIX_THREADS in unistd.h. Some apparently don't
2175 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002176 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2177 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002178 [
2179#include <unistd.h>
2180#ifdef _POSIX_THREADS
2181yes
2182#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002183 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2184 AC_MSG_RESULT($unistd_defines_pthreads)
2185
Martin v. Löwis130fb172001-07-19 11:00:41 +00002186 AC_DEFINE(_REENTRANT)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002187 # Just looking for pthread_create in libpthread is not enough:
2188 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2189 # So we really have to include pthread.h, and then link.
2190 _libs=$LIBS
2191 LIBS="$LIBS -lpthread"
2192 AC_MSG_CHECKING([for pthread_create in -lpthread])
Matthias Kloseb159a552010-04-25 21:00:44 +00002193 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002194
Matthias Kloseb159a552010-04-25 21:00:44 +00002195void * start_routine (void *arg) { exit (0); }]], [[
2196pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002197 AC_MSG_RESULT(yes)
2198 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002199 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002200 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002201 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002202 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002203 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002204 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002205 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002206 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002207 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002208 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002209 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002210 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002211 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002212 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002213 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002214 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002215 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002216 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002217 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002218 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002219 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002220 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002221 USE_THREAD_MODULE="#"])
Antoine Pitrou37009202011-07-08 23:47:50 +02002222 ])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002223
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002224 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2225 LIBS="$LIBS -lmpc"
2226 THREADOBJ="Python/thread.o"
2227 USE_THREAD_MODULE=""])
2228
2229 if test "$posix_threads" != "yes"; then
2230 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2231 LIBS="$LIBS -lthread"
2232 THREADOBJ="Python/thread.o"
2233 USE_THREAD_MODULE=""])
2234 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002235fi
2236
2237if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002238 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002239 AC_DEFINE(_POSIX_THREADS, 1,
2240 [Define if you have POSIX threads,
2241 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002242 fi
2243
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002244 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2245 case $ac_sys_system/$ac_sys_release in
Charles-François Natali996f6062011-07-21 19:45:31 +02002246 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002247 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002248 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002249 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002250 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002251 ;;
Charles-François Natali996f6062011-07-21 19:45:31 +02002252 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klosec80c93f2010-04-24 17:04:35 +00002253 [Define if the Posix semaphores do not work on your system])
Christian Heimes7b3ce6a2008-01-31 14:31:45 +00002254 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002255 esac
2256
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002257 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2258 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Matthias Kloseb159a552010-04-25 21:00:44 +00002259 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002260 void *foo(void *parm) {
2261 return NULL;
2262 }
2263 main() {
2264 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002265 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002266 if (pthread_attr_init(&attr)) exit(-1);
2267 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002268 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002269 exit(0);
Matthias Kloseb159a552010-04-25 21:00:44 +00002270 }]])],
2271 [ac_cv_pthread_system_supported=yes],
2272 [ac_cv_pthread_system_supported=no],
2273 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002274 ])
2275 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2276 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002277 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002278 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002279 AC_CHECK_FUNCS(pthread_sigmask,
2280 [case $ac_sys_system in
2281 CYGWIN*)
2282 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2283 [Define if pthread_sigmask() does not work on your system.])
2284 ;;
2285 esac])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00002286fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002287
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002288
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002289# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002290AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002291AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002292AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002293[ --enable-ipv6 Enable ipv6 (with ipv4) support
2294 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002295[ case "$enableval" in
2296 no)
2297 AC_MSG_RESULT(no)
2298 ipv6=no
2299 ;;
2300 *) AC_MSG_RESULT(yes)
2301 AC_DEFINE(ENABLE_IPV6)
2302 ipv6=yes
2303 ;;
2304 esac ],
2305
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002306[
2307dnl the check does not work on cross compilation case...
Matthias Kloseb159a552010-04-25 21:00:44 +00002308 AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002309#include <sys/types.h>
2310#include <sys/socket.h>
2311main()
2312{
2313 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2314 exit(1);
2315 else
2316 exit(0);
2317}
Matthias Kloseb159a552010-04-25 21:00:44 +00002318]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002319 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00002320 ipv6=yes
2321],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002322 AC_MSG_RESULT(no)
2323 ipv6=no
Matthias Kloseb159a552010-04-25 21:00:44 +00002324],[
2325 AC_MSG_RESULT(no)
2326 ipv6=no
2327])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002328
2329if test "$ipv6" = "yes"; then
2330 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Kloseb159a552010-04-25 21:00:44 +00002331 AC_COMPILE_IFELSE([
2332 AC_LANG_PROGRAM([[#include <sys/types.h>
2333#include <netinet/in.h>]],
2334 [[struct sockaddr_in6 x;
2335 x.sin6_scope_id;]])
2336 ],[
2337 AC_MSG_RESULT(yes)
2338 ipv6=yes
2339 ],[
2340 AC_MSG_RESULT(no, IPv6 disabled)
2341 ipv6=no
2342 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002343fi
2344
2345if test "$ipv6" = "yes"; then
2346 AC_DEFINE(ENABLE_IPV6)
2347fi
2348])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002349
2350ipv6type=unknown
2351ipv6lib=none
2352ipv6trylibc=no
2353
2354if test "$ipv6" = "yes"; then
2355 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002356 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2357 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002358 case $i in
2359 inria)
2360 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002361 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002362#include <netinet/in.h>
2363#ifdef IPV6_INRIA_VERSION
2364yes
2365#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002366 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002367 ;;
2368 kame)
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 __KAME__
2373yes
2374#endif],
2375 [ipv6type=$i;
2376 ipv6lib=inet6
2377 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002378 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002379 ;;
2380 linux-glibc)
2381 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002382 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002383#include <features.h>
2384#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2385yes
2386#endif],
2387 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002388 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002389 ;;
2390 linux-inet6)
2391 dnl http://www.v6.linux.or.jp/
2392 if test -d /usr/inet6; then
2393 ipv6type=$i
2394 ipv6lib=inet6
2395 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002396 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002397 fi
2398 ;;
2399 solaris)
2400 if test -f /etc/netconfig; then
Antoine Pitrouf3fcd9f2011-01-03 18:53:50 +00002401 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002402 ipv6type=$i
2403 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002404 fi
2405 fi
2406 ;;
2407 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002408 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002409#include <sys/param.h>
2410#ifdef _TOSHIBA_INET6
2411yes
2412#endif],
2413 [ipv6type=$i;
2414 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002415 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002416 ;;
2417 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002418 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002419#include </usr/local/v6/include/sys/v6config.h>
2420#ifdef __V6D__
2421yes
2422#endif],
2423 [ipv6type=$i;
2424 ipv6lib=v6;
2425 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002426 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002427 ;;
2428 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002429 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002430#include <sys/param.h>
2431#ifdef _ZETA_MINAMI_INET6
2432yes
2433#endif],
2434 [ipv6type=$i;
2435 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002436 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002437 ;;
2438 esac
2439 if test "$ipv6type" != "unknown"; then
2440 break
2441 fi
2442 done
2443 AC_MSG_RESULT($ipv6type)
2444fi
2445
2446if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2447 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2448 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2449 echo "using lib$ipv6lib"
2450 else
2451 if test $ipv6trylibc = "yes"; then
2452 echo "using libc"
2453 else
2454 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2455 echo "You need to fetch lib$ipv6lib.a from appropriate"
2456 echo 'ipv6 kit and compile beforehand.'
2457 exit 1
2458 fi
2459 fi
2460fi
2461
Georg Brandl93de2162008-07-16 02:21:06 +00002462AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Kloseb159a552010-04-25 21:00:44 +00002463AC_COMPILE_IFELSE([
2464 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
2465],[
Matthias Klosec80c93f2010-04-24 17:04:35 +00002466 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Kloseb159a552010-04-25 21:00:44 +00002467 AC_MSG_RESULT(yes)
2468],[
Georg Brandl93de2162008-07-16 02:21:06 +00002469 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00002470])
Georg Brandl93de2162008-07-16 02:21:06 +00002471
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002472# Check for --with-doc-strings
2473AC_MSG_CHECKING(for --with-doc-strings)
2474AC_ARG_WITH(doc-strings,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002475 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002476
2477if test -z "$with_doc_strings"
2478then with_doc_strings="yes"
2479fi
2480if test "$with_doc_strings" != "no"
2481then
2482 AC_DEFINE(WITH_DOC_STRINGS, 1,
2483 [Define if you want documentation strings in extension modules])
2484fi
2485AC_MSG_RESULT($with_doc_strings)
2486
Georg Brandl9976a512010-08-02 21:02:36 +00002487# Check if eval loop should use timestamp counter profiling
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002488AC_MSG_CHECKING(for --with-tsc)
2489AC_ARG_WITH(tsc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002490 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002491if test "$withval" != no
2492then
2493 AC_DEFINE(WITH_TSC, 1,
2494 [Define to profile with the Pentium timestamp counter])
2495 AC_MSG_RESULT(yes)
2496else AC_MSG_RESULT(no)
2497fi],
2498[AC_MSG_RESULT(no)])
2499
2500# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002501AC_MSG_CHECKING(for --with-pymalloc)
2502AC_ARG_WITH(pymalloc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00002503 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002504
2505if test -z "$with_pymalloc"
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00002506then
2507 with_pymalloc="yes"
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00002508 ABIFLAGS="${ABIFLAGS}m"
Neil Schemenauer16c22972002-03-22 15:34:49 +00002509fi
2510if test "$with_pymalloc" != "no"
2511then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002512 AC_DEFINE(WITH_PYMALLOC, 1,
2513 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002514fi
2515AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002516
Benjamin Peterson05159c42009-12-03 03:01:27 +00002517# Check for Valgrind support
2518AC_MSG_CHECKING([for --with-valgrind])
2519AC_ARG_WITH([valgrind],
Matthias Klose2b8733f2010-04-25 18:34:36 +00002520 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson05159c42009-12-03 03:01:27 +00002521 with_valgrind=no)
2522AC_MSG_RESULT([$with_valgrind])
2523if test "$with_valgrind" != no; then
2524 AC_CHECK_HEADER([valgrind/valgrind.h],
2525 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2526 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2527 )
Jeffrey Yasskin39370832010-05-03 19:29:34 +00002528 OPT="-DDYNAMIC_ANNOTATIONS_ENABLED=1 $OPT"
Benjamin Peterson05159c42009-12-03 03:01:27 +00002529fi
2530
Guido van Rossum68242b51996-05-28 22:53:03 +00002531# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002532AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002533DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002534
Guido van Rossume97ee181999-12-20 21:27:22 +00002535# the dlopen() function means we might want to use dynload_shlib.o. some
2536# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002537AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002538
2539# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2540# loading of modules.
2541AC_SUBST(DYNLOADFILE)
2542AC_MSG_CHECKING(DYNLOADFILE)
2543if test -z "$DYNLOADFILE"
2544then
2545 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002546 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2547 if test "$ac_cv_func_dlopen" = yes
2548 then DYNLOADFILE="dynload_shlib.o"
2549 else DYNLOADFILE="dynload_aix.o"
2550 fi
2551 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002552 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002553 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2554 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002555 *)
2556 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2557 # out any dynamic loading
2558 if test "$ac_cv_func_dlopen" = yes
2559 then DYNLOADFILE="dynload_shlib.o"
2560 else DYNLOADFILE="dynload_stub.o"
2561 fi
2562 ;;
2563 esac
2564fi
2565AC_MSG_RESULT($DYNLOADFILE)
2566if test "$DYNLOADFILE" != "dynload_stub.o"
2567then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002568 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2569 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002570fi
2571
Jack Jansenc49e5b72001-06-19 15:00:23 +00002572# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2573
2574AC_SUBST(MACHDEP_OBJS)
2575AC_MSG_CHECKING(MACHDEP_OBJS)
2576if test -z "$MACHDEP_OBJS"
2577then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002578 MACHDEP_OBJS=$extra_machdep_objs
2579else
2580 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002581fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002582AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002583
Guido van Rossum627b2d71993-12-24 10:39:16 +00002584# checks for library functions
Antoine Pitroub1c54962010-10-14 15:05:38 +00002585AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
Gregory P. Smith1577cf72012-01-21 18:21:56 -08002586 clock confstr ctermid execv faccessat fchmod fchmodat fchown fchownat \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002587 fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
Ross Lagerwallb0ae53d2011-06-10 07:30:30 +02002588 futimens futimes gai_strerror \
2589 getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis7aed61a2009-11-27 14:09:49 +00002590 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Gregory P. Smith5ed2e772011-05-15 00:26:45 -07002591 if_nameindex \
Antoine Pitrouf0effe62011-11-26 01:11:02 +01002592 initgroups kill killpg lchmod lchown lockf linkat lstat lutimes mmap \
2593 memrchr mbrtowc mkdirat mkfifo \
Charles-François Natalidaafdd52011-05-29 20:07:40 +02002594 mkfifoat mknod mknodat mktime mremap nice openat pathconf pause pipe2 plock poll \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002595 posix_fallocate posix_fadvise pread \
Victor Stinnerb3e72192011-05-08 01:46:11 +02002596 pthread_init pthread_kill putenv pwrite readlink readlinkat readv realpath renameat \
Giampaolo Rodolàc9c2c8b2011-02-25 14:39:16 +00002597 select sem_open sem_timedwait sem_getvalue sem_unlink sendfile setegid seteuid \
Antoine Pitrou061cfb52011-02-28 22:25:22 +00002598 setgid sethostname \
Giampaolo Rodolà18e8bcb2011-02-25 20:57:54 +00002599 setlocale setregid setreuid setresuid setresgid setsid setpgid setpgrp setpriority setuid setvbuf \
Charles-François Nataliea0d5fc2011-09-06 19:03:35 +02002600 sched_get_priority_max sched_setaffinity sched_setscheduler sched_setparam \
2601 sched_rr_get_interval \
Ross Lagerwallbc808222011-06-25 12:13:40 +02002602 sigaction sigaltstack siginterrupt sigpending sigrelse \
2603 sigtimedwait sigwait sigwaitinfo snprintf strftime strlcpy symlinkat sync \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002604 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Ross Lagerwall7807c352011-03-17 20:20:30 +02002605 truncate uname unlinkat unsetenv utimensat utimes waitid waitpid wait3 wait4 \
2606 wcscoll wcsftime wcsxfrm writev _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002607
Gregory P. Smithdf300d52012-01-21 18:20:15 -08002608AC_CHECK_DECL(dirfd,
2609 AC_DEFINE(HAVE_DIRFD, 1,
2610 Define if you have the 'dirfd' function or macro.), ,
2611 [#include <sys/types.h>
2612 #include <dirent.h>])
2613
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002614# For some functions, having a definition is not sufficient, since
2615# we want to take their address.
2616AC_MSG_CHECKING(for chroot)
Matthias Kloseb159a552010-04-25 21:00:44 +00002617AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2618 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2619 AC_MSG_RESULT(yes)],
2620 [AC_MSG_RESULT(no)
2621])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002622AC_MSG_CHECKING(for link)
Matthias Kloseb159a552010-04-25 21:00:44 +00002623AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2624 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2625 AC_MSG_RESULT(yes)],
2626 [AC_MSG_RESULT(no)
2627])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002628AC_MSG_CHECKING(for symlink)
Matthias Kloseb159a552010-04-25 21:00:44 +00002629AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2630 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2631 AC_MSG_RESULT(yes)],
2632 [AC_MSG_RESULT(no)
2633])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002634AC_MSG_CHECKING(for fchdir)
Matthias Kloseb159a552010-04-25 21:00:44 +00002635AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2636 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2637 AC_MSG_RESULT(yes)],
2638 [AC_MSG_RESULT(no)
2639])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002640AC_MSG_CHECKING(for fsync)
Matthias Kloseb159a552010-04-25 21:00:44 +00002641AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2642 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2643 AC_MSG_RESULT(yes)],
2644 [AC_MSG_RESULT(no)
2645])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002646AC_MSG_CHECKING(for fdatasync)
Matthias Kloseb159a552010-04-25 21:00:44 +00002647AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2648 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2649 AC_MSG_RESULT(yes)],
2650 [AC_MSG_RESULT(no)
2651])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002652AC_MSG_CHECKING(for epoll)
Matthias Kloseb159a552010-04-25 21:00:44 +00002653AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2654 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2655 AC_MSG_RESULT(yes)],
2656 [AC_MSG_RESULT(no)
2657])
Benjamin Peterson95c16622011-12-27 15:36:32 -06002658AC_MSG_CHECKING(for epoll_create1)
2659AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create1]])],
2660 [AC_DEFINE(HAVE_EPOLL_CREATE1, 1, Define if you have the 'epoll_create1' function.)
2661 AC_MSG_RESULT(yes)],
2662 [AC_MSG_RESULT(no)
2663])
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002664AC_MSG_CHECKING(for kqueue)
Matthias Kloseb159a552010-04-25 21:00:44 +00002665AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes4fbc72b2008-03-22 00:47:35 +00002666#include <sys/types.h>
2667#include <sys/event.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002668 ]], [[int x=kqueue()]])],
2669 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2670 AC_MSG_RESULT(yes)],
2671 [AC_MSG_RESULT(no)
2672])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002673# On some systems (eg. FreeBSD 5), we would find a definition of the
2674# functions ctermid_r, setgroups in the library, but no prototype
2675# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2676# address to avoid compiler warnings and potential miscompilations
2677# because of the missing prototypes.
2678
2679AC_MSG_CHECKING(for ctermid_r)
Matthias Kloseb159a552010-04-25 21:00:44 +00002680AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002681#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002682]], [[void* p = ctermid_r]])],
2683 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2684 AC_MSG_RESULT(yes)],
2685 [AC_MSG_RESULT(no)
2686])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002687
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00002688AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2689 [AC_COMPILE_IFELSE(
2690 [AC_LANG_PROGRAM(
2691 [#include <sys/file.h>],
2692 [void* p = flock]
2693 )],
2694 [ac_cv_flock_decl=yes],
2695 [ac_cv_flock_decl=no]
2696 )
Matthias Kloseb159a552010-04-25 21:00:44 +00002697])
Antoine Pitroua4e4ae22010-09-10 18:39:00 +00002698if test "x${ac_cv_flock_decl}" = xyes; then
2699 AC_CHECK_FUNCS(flock,,
2700 AC_CHECK_LIB(bsd,flock,
2701 [AC_DEFINE(HAVE_FLOCK)
2702 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2703 ])
2704 )
Antoine Pitroua3000072010-09-07 14:52:42 +00002705fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002706
2707AC_MSG_CHECKING(for getpagesize)
Matthias Kloseb159a552010-04-25 21:00:44 +00002708AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002709#include <unistd.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002710]], [[void* p = getpagesize]])],
2711 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2712 AC_MSG_RESULT(yes)],
2713 [AC_MSG_RESULT(no)
2714])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002715
Victor Stinner984890f2011-11-24 13:53:38 +01002716AC_MSG_CHECKING(for broken unsetenv)
2717AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2718#include <stdlib.h>
2719]], [[int res = unsetenv("DUMMY")]])],
2720 [AC_MSG_RESULT(no)],
2721 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
2722 AC_MSG_RESULT(yes)
2723])
2724
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002725dnl check for true
2726AC_CHECK_PROGS(TRUE, true, /bin/true)
2727
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002728dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2729dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002730AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002731 AC_CHECK_LIB(resolv, inet_aton)
2732)
2733
Christian Heimesd0764e22007-12-04 15:00:33 +00002734# On Tru64, chflags seems to be present, but calling it will
2735# exit Python
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002736AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07002737AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002738#include <sys/stat.h>
2739#include <unistd.h>
2740int main(int argc, char*argv[])
2741{
2742 if(chflags(argv[0], 0) != 0)
2743 return 1;
2744 return 0;
2745}
Ned Deily3eb67d52011-06-28 00:00:28 -07002746]])],
Matthias Kloseb159a552010-04-25 21:00:44 +00002747[ac_cv_have_chflags=yes],
2748[ac_cv_have_chflags=no],
2749[ac_cv_have_chflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002750])
2751if test "$ac_cv_have_chflags" = cross ; then
2752 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2753fi
2754if test "$ac_cv_have_chflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07002755 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002756fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002757
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002758AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily3eb67d52011-06-28 00:00:28 -07002759AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimesd0764e22007-12-04 15:00:33 +00002760#include <sys/stat.h>
2761#include <unistd.h>
2762int main(int argc, char*argv[])
2763{
2764 if(lchflags(argv[0], 0) != 0)
2765 return 1;
2766 return 0;
2767}
Ned Deily3eb67d52011-06-28 00:00:28 -07002768]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Benjamin Petersoned68afa2010-01-30 19:36:43 +00002769])
2770if test "$ac_cv_have_lchflags" = cross ; then
2771 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2772fi
2773if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily3eb67d52011-06-28 00:00:28 -07002774 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002775fi
Christian Heimesd0764e22007-12-04 15:00:33 +00002776
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002777dnl Check if system zlib has *Copy() functions
2778dnl
2779dnl On MacOSX the linker will search for dylibs on the entire linker path
2780dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2781dnl to revert to a more traditional unix behaviour and make it possible to
2782dnl override the system libz with a local static library of libz. Temporarily
2783dnl add that flag to our CFLAGS as well to ensure that we check the version
2784dnl of libz that will be used by setup.py.
2785dnl The -L/usr/local/lib is needed as wel to get the same compilation
2786dnl environment as setup.py (and leaving it out can cause configure to use the
2787dnl wrong version of the library)
2788case $ac_sys_system/$ac_sys_release in
2789Darwin/*)
2790 _CUR_CFLAGS="${CFLAGS}"
2791 _CUR_LDFLAGS="${LDFLAGS}"
2792 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2793 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2794 ;;
2795esac
2796
Matthias Klosec80c93f2010-04-24 17:04:35 +00002797AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Thomas Wouters0e3f5912006-08-11 14:57:12 +00002798
2799case $ac_sys_system/$ac_sys_release in
2800Darwin/*)
2801 CFLAGS="${_CUR_CFLAGS}"
2802 LDFLAGS="${_CUR_LDFLAGS}"
2803 ;;
2804esac
2805
Martin v. Löwise9416172003-05-03 10:12:45 +00002806AC_MSG_CHECKING(for hstrerror)
Matthias Kloseb159a552010-04-25 21:00:44 +00002807AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00002808#include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002809]], [[void* p = hstrerror; hstrerror(0)]])],
2810 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2811 AC_MSG_RESULT(yes)],
2812 [AC_MSG_RESULT(no)
2813])
Martin v. Löwise9416172003-05-03 10:12:45 +00002814
2815AC_MSG_CHECKING(for inet_aton)
Matthias Kloseb159a552010-04-25 21:00:44 +00002816AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00002817#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002818#include <sys/socket.h>
2819#include <netinet/in.h>
2820#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002821]], [[void* p = inet_aton;inet_aton(0,0)]])],
2822 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2823 AC_MSG_RESULT(yes)],
2824 [AC_MSG_RESULT(no)
2825])
Martin v. Löwise9416172003-05-03 10:12:45 +00002826
2827AC_MSG_CHECKING(for inet_pton)
Matthias Kloseb159a552010-04-25 21:00:44 +00002828AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002829#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002830#include <sys/socket.h>
2831#include <netinet/in.h>
2832#include <arpa/inet.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002833]], [[void* p = inet_pton]])],
2834 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2835 AC_MSG_RESULT(yes)],
2836 [AC_MSG_RESULT(no)
2837])
Martin v. Löwise9416172003-05-03 10:12:45 +00002838
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002839# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002840AC_MSG_CHECKING(for setgroups)
Matthias Kloseb159a552010-04-25 21:00:44 +00002841AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002842#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002843#ifdef HAVE_GRP_H
2844#include <grp.h>
2845#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00002846]], [[void* p = setgroups]])],
2847 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2848 AC_MSG_RESULT(yes)],
2849 [AC_MSG_RESULT(no)
2850])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002851
Fred Drake8cef4cf2000-06-28 16:40:38 +00002852# check for openpty and forkpty
2853
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002854AC_CHECK_FUNCS(openpty,,
2855 AC_CHECK_LIB(util,openpty,
2856 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2857 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2858 )
2859)
2860AC_CHECK_FUNCS(forkpty,,
2861 AC_CHECK_LIB(util,forkpty,
2862 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2863 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2864 )
2865)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002866
Christian Heimesb186d002008-03-18 15:15:01 +00002867# Stuff for expat.
2868AC_CHECK_FUNCS(memmove)
2869
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002870# check for long file support functions
2871AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2872
Christian Heimesb186d002008-03-18 15:15:01 +00002873AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002874AC_CHECK_FUNCS(getpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00002875 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
2876 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
2877 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002878)
Jack Jansen150753c2003-03-29 22:07:47 +00002879AC_CHECK_FUNCS(setpgrp,
Matthias Kloseb159a552010-04-25 21:00:44 +00002880 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
2881 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
2882 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002883)
2884AC_CHECK_FUNCS(gettimeofday,
Matthias Kloseb159a552010-04-25 21:00:44 +00002885 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
2886 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
2887 [],
2888 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2889 [Define if gettimeofday() does not have second (timezone) argument
2890 This is the case on Motorola V4 (R40V4.2)])
2891 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002892)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002893
Victor Stinnere0be4232011-10-25 13:06:09 +02002894AC_CHECK_FUNCS(clock_gettime, [], [
2895 AC_CHECK_LIB(rt, clock_gettime, [
2896 AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
2897 AC_DEFINE(TIMEMODULE_LIB, [rt],
2898 [Library needed by timemodule.c: librt may be needed for clock_gettime()])
2899 ])
2900])
2901
2902AC_CHECK_FUNCS(clock_getres, [], [
2903 AC_CHECK_LIB(rt, clock_getres, [
2904 AC_DEFINE(HAVE_CLOCK_GETRES, 1)
2905 ])
2906])
2907
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002908AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Kloseb159a552010-04-25 21:00:44 +00002909AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002910#if defined(MAJOR_IN_MKDEV)
2911#include <sys/mkdev.h>
2912#elif defined(MAJOR_IN_SYSMACROS)
2913#include <sys/sysmacros.h>
2914#else
2915#include <sys/types.h>
2916#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00002917]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002918 makedev(major(0),minor(0));
Matthias Kloseb159a552010-04-25 21:00:44 +00002919]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002920 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2921 [Define to 1 if you have the device macros.])
2922 AC_MSG_RESULT(yes)
2923],[
2924 AC_MSG_RESULT(no)
2925])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002926
2927# On OSF/1 V5.1, getaddrinfo is available, but a define
2928# for [no]getaddrinfo in netdb.h.
2929AC_MSG_CHECKING(for getaddrinfo)
Matthias Kloseb159a552010-04-25 21:00:44 +00002930AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002931#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00002932#include <sys/socket.h>
2933#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00002934#include <stdio.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00002935]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
2936[have_getaddrinfo=yes],
2937[have_getaddrinfo=no])
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002938AC_MSG_RESULT($have_getaddrinfo)
2939if test $have_getaddrinfo = yes
2940then
2941 AC_MSG_CHECKING(getaddrinfo bug)
2942 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00002943 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002944#include <sys/types.h>
2945#include <netdb.h>
2946#include <string.h>
2947#include <sys/socket.h>
2948#include <netinet/in.h>
2949
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00002950int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002951{
2952 int passive, gaierr, inet4 = 0, inet6 = 0;
2953 struct addrinfo hints, *ai, *aitop;
2954 char straddr[INET6_ADDRSTRLEN], strport[16];
2955
2956 for (passive = 0; passive <= 1; passive++) {
2957 memset(&hints, 0, sizeof(hints));
2958 hints.ai_family = AF_UNSPEC;
2959 hints.ai_flags = passive ? AI_PASSIVE : 0;
2960 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00002961 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00002962 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2963 (void)gai_strerror(gaierr);
2964 goto bad;
2965 }
2966 for (ai = aitop; ai; ai = ai->ai_next) {
2967 if (ai->ai_addr == NULL ||
2968 ai->ai_addrlen == 0 ||
2969 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2970 straddr, sizeof(straddr), strport, sizeof(strport),
2971 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2972 goto bad;
2973 }
2974 switch (ai->ai_family) {
2975 case AF_INET:
2976 if (strcmp(strport, "54321") != 0) {
2977 goto bad;
2978 }
2979 if (passive) {
2980 if (strcmp(straddr, "0.0.0.0") != 0) {
2981 goto bad;
2982 }
2983 } else {
2984 if (strcmp(straddr, "127.0.0.1") != 0) {
2985 goto bad;
2986 }
2987 }
2988 inet4++;
2989 break;
2990 case AF_INET6:
2991 if (strcmp(strport, "54321") != 0) {
2992 goto bad;
2993 }
2994 if (passive) {
2995 if (strcmp(straddr, "::") != 0) {
2996 goto bad;
2997 }
2998 } else {
2999 if (strcmp(straddr, "::1") != 0) {
3000 goto bad;
3001 }
3002 }
3003 inet6++;
3004 break;
3005 case AF_UNSPEC:
3006 goto bad;
3007 break;
3008 default:
3009 /* another family support? */
3010 break;
3011 }
3012 }
3013 }
3014
3015 if (!(inet4 == 0 || inet4 == 2))
3016 goto bad;
3017 if (!(inet6 == 0 || inet6 == 2))
3018 goto bad;
3019
3020 if (aitop)
3021 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003022 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003023
3024 bad:
3025 if (aitop)
3026 freeaddrinfo(aitop);
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003027 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003028}
Matthias Kloseb159a552010-04-25 21:00:44 +00003029]]])],
3030[ac_cv_buggy_getaddrinfo=no],
3031[ac_cv_buggy_getaddrinfo=yes],
Matthias Klose96350132012-03-15 20:42:23 +01003032[
3033if test "${enable_ipv6+set}" = set; then
3034 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3035else
3036 ac_cv_buggy_getaddrinfo=yes
3037fi]))
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003038fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003039
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003040AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3041
Mark Dickinson2df5d282009-12-31 21:22:50 +00003042if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003043then
3044 if test $ipv6 = yes
3045 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003046 echo 'Fatal: You must get working getaddrinfo() function.'
3047 echo ' or you can specify "--disable-ipv6"'.
3048 exit 1
3049 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003050else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003051 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003052fi
Benjamin Petersond4694ed2010-11-01 01:44:30 +00003053
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003054AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003055
Guido van Rossum627b2d71993-12-24 10:39:16 +00003056# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003057AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003058AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003059AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003060AC_CHECK_MEMBERS([struct stat.st_rdev])
3061AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003062AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003063AC_CHECK_MEMBERS([struct stat.st_gen])
3064AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003065AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003066
3067AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Kloseb159a552010-04-25 21:00:44 +00003068AC_CACHE_VAL(ac_cv_header_time_altzone,[
3069 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3070 [ac_cv_header_time_altzone=yes],
3071 [ac_cv_header_time_altzone=no])
3072 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003073AC_MSG_RESULT($ac_cv_header_time_altzone)
3074if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003075 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003076fi
3077
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003078was_it_defined=no
3079AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Kloseb159a552010-04-25 21:00:44 +00003080AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003081#include <sys/types.h>
3082#include <sys/select.h>
3083#include <sys/time.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003084]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003085 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3086 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3087 (which you can't on SCO ODT 3.0).])
3088 was_it_defined=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003089],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003090AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003091
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003092AC_MSG_CHECKING(for addrinfo)
3093AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Kloseb159a552010-04-25 21:00:44 +00003094AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3095 [ac_cv_struct_addrinfo=yes],
3096 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003097AC_MSG_RESULT($ac_cv_struct_addrinfo)
3098if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003099 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003100fi
3101
3102AC_MSG_CHECKING(for sockaddr_storage)
3103AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Kloseb159a552010-04-25 21:00:44 +00003104AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003105# include <sys/types.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003106# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3107 [ac_cv_struct_sockaddr_storage=yes],
3108 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003109AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3110if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003111 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003112fi
3113
Guido van Rossum627b2d71993-12-24 10:39:16 +00003114# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003115
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003116AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003117AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003118
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003119works=no
3120AC_MSG_CHECKING(for working volatile)
Matthias Kloseb159a552010-04-25 21:00:44 +00003121AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3122 [works=yes],
3123 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003124)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003125AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003126
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003127works=no
3128AC_MSG_CHECKING(for working signed char)
Matthias Kloseb159a552010-04-25 21:00:44 +00003129AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3130 [works=yes],
3131 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003132)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003133AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003134
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003135have_prototypes=no
3136AC_MSG_CHECKING(for prototypes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003137AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3138 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3139 [Define if your compiler supports function prototype])
3140 have_prototypes=yes],
3141 []
3142)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003143AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003144
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003145works=no
3146AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Kloseb159a552010-04-25 21:00:44 +00003147AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003148#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003149int foo(int x, ...) {
3150 va_list va;
3151 va_start(va, x);
3152 va_arg(va, int);
3153 va_arg(va, char *);
3154 va_arg(va, double);
3155 return 0;
3156}
Matthias Kloseb159a552010-04-25 21:00:44 +00003157]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003158 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3159 [Define if your compiler supports variable length function prototypes
3160 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3161 works=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003162],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003163AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003164
Dave Cole331708b2004-08-09 04:51:41 +00003165# check for socketpair
3166AC_MSG_CHECKING(for socketpair)
Matthias Kloseb159a552010-04-25 21:00:44 +00003167AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003168#include <sys/types.h>
3169#include <sys/socket.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003170]], [[void *x=socketpair]])],
3171 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3172 AC_MSG_RESULT(yes)],
3173 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003174)
3175
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003176# check if sockaddr has sa_len member
3177AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Kloseb159a552010-04-25 21:00:44 +00003178AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3179#include <sys/socket.h>]], [[struct sockaddr x;
3180x.sa_len = 0;]])],
3181 [AC_MSG_RESULT(yes)
3182 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3183 [AC_MSG_RESULT(no)]
3184)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003185
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003186va_list_is_array=no
3187AC_MSG_CHECKING(whether va_list is an array)
Matthias Kloseb159a552010-04-25 21:00:44 +00003188AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003189#ifdef HAVE_STDARG_PROTOTYPES
3190#include <stdarg.h>
3191#else
3192#include <varargs.h>
3193#endif
Matthias Kloseb159a552010-04-25 21:00:44 +00003194]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003195 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3196 va_list_is_array=yes
3197])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003198AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003199
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003200# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003201AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3202 [Define this if you have some version of gethostbyname_r()])
3203
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003204AC_CHECK_FUNC(gethostbyname_r, [
3205 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3206 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3207 OLD_CFLAGS=$CFLAGS
3208 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003209 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003210# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003211 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003212 char *name;
3213 struct hostent *he, *res;
3214 char buffer[2048];
3215 int buflen = 2048;
3216 int h_errnop;
3217
3218 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Kloseb159a552010-04-25 21:00:44 +00003219 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003220 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003221 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3222 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003223 AC_MSG_RESULT(yes)
Matthias Kloseb159a552010-04-25 21:00:44 +00003224 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003225 AC_MSG_RESULT(no)
3226 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Kloseb159a552010-04-25 21:00:44 +00003227 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003228# include <netdb.h>
Matthias Kloseb159a552010-04-25 21:00:44 +00003229 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003230 char *name;
3231 struct hostent *he;
Matthias Kloseb159a552010-04-25 21:00:44 +00003232 char buffer[2048];
3233 int buflen = 2048;
3234 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003235
Matthias Kloseb159a552010-04-25 21:00:44 +00003236 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3237 ]])],
3238 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003239 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Kloseb159a552010-04-25 21:00:44 +00003240 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3241 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003242 AC_MSG_RESULT(yes)
3243 ], [
3244 AC_MSG_RESULT(no)
Matthias Kloseb159a552010-04-25 21:00:44 +00003245 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3246 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3247# include <netdb.h>
3248 ]], [[
3249 char *name;
3250 struct hostent *he;
3251 struct hostent_data data;
3252
3253 (void) gethostbyname_r(name, he, &data);
3254 ]])],
3255 [
3256 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3257 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3258 [Define this if you have the 3-arg version of gethostbyname_r().])
3259 AC_MSG_RESULT(yes)
3260 ], [
3261 AC_MSG_RESULT(no)
3262 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003263 ])
3264 ])
3265 CFLAGS=$OLD_CFLAGS
3266], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003267 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003268])
3269AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3270AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3271AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003272AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003273AC_SUBST(HAVE_GETHOSTBYNAME)
3274
Guido van Rossum627b2d71993-12-24 10:39:16 +00003275# checks for system services
3276# (none yet)
3277
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003278# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003279AC_CHECK_FUNC(__fpu_control,
3280 [],
3281 [AC_CHECK_LIB(ieee, __fpu_control)
3282])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003283
Guido van Rossum93274221997-05-09 02:42:00 +00003284# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003285AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00003286AC_ARG_WITH(fpectl,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003287 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003288[
Guido van Rossum93274221997-05-09 02:42:00 +00003289if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003290then
3291 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3292 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3293 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003294else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003295fi],
3296[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003297
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003298# check for --with-libm=...
3299AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003300case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003301Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003302*) LIBM=-lm
3303esac
Guido van Rossum93274221997-05-09 02:42:00 +00003304AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003305AC_ARG_WITH(libm,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003306 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003307[
Guido van Rossum93274221997-05-09 02:42:00 +00003308if test "$withval" = no
3309then LIBM=
3310 AC_MSG_RESULT(force LIBM empty)
3311elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003312then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003313 AC_MSG_RESULT(set LIBM="$withval")
3314else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003315fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003316[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003317
3318# check for --with-libc=...
3319AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003320AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003321AC_ARG_WITH(libc,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003322 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003323[
Guido van Rossum93274221997-05-09 02:42:00 +00003324if test "$withval" = no
3325then LIBC=
3326 AC_MSG_RESULT(force LIBC empty)
3327elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003328then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003329 AC_MSG_RESULT(set LIBC="$withval")
3330else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003331fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003332[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003333
Stefan Krah1919b7e2012-03-21 18:25:23 +01003334# **************************************
3335# * Check for gcc x64 inline assembler *
3336# **************************************
3337
3338AC_MSG_CHECKING(for x64 gcc inline assembler)
3339AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3340 __asm__ __volatile__ ("movq %rcx, %rax");
3341]])],[have_gcc_asm_for_x64=yes],[have_gcc_asm_for_x64=no])
3342AC_MSG_RESULT($have_gcc_asm_for_x64)
3343if test "$have_gcc_asm_for_x64" = yes
3344then
3345 AC_DEFINE(HAVE_GCC_ASM_FOR_X64, 1,
3346 [Define if we can use x64 gcc inline assembler])
3347fi
3348
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003349# **************************************************
3350# * Check for various properties of floating point *
3351# **************************************************
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003352
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003353AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3354AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003355AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003356#include <string.h>
3357int main() {
3358 double x = 9006104071832581.0;
3359 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3360 return 0;
3361 else
3362 return 1;
3363}
Matthias Kloseb159a552010-04-25 21:00:44 +00003364]])],
3365[ac_cv_little_endian_double=yes],
3366[ac_cv_little_endian_double=no],
3367[ac_cv_little_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003368AC_MSG_RESULT($ac_cv_little_endian_double)
3369if test "$ac_cv_little_endian_double" = yes
3370then
3371 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3372 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3373 with the least significant byte first])
3374fi
3375
3376AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3377AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003378AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003379#include <string.h>
3380int main() {
3381 double x = 9006104071832581.0;
3382 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3383 return 0;
3384 else
3385 return 1;
3386}
Matthias Kloseb159a552010-04-25 21:00:44 +00003387]])],
3388[ac_cv_big_endian_double=yes],
3389[ac_cv_big_endian_double=no],
3390[ac_cv_big_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003391AC_MSG_RESULT($ac_cv_big_endian_double)
3392if test "$ac_cv_big_endian_double" = yes
3393then
3394 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3395 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3396 with the most significant byte first])
3397fi
3398
3399# Some ARM platforms use a mixed-endian representation for doubles.
3400# While Python doesn't currently have full support for these platforms
3401# (see e.g., issue 1762561), we can at least make sure that float <-> string
3402# conversions work.
3403AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3404AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003405AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003406#include <string.h>
3407int main() {
3408 double x = 9006104071832581.0;
3409 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3410 return 0;
3411 else
3412 return 1;
3413}
Matthias Kloseb159a552010-04-25 21:00:44 +00003414]])],
3415[ac_cv_mixed_endian_double=yes],
3416[ac_cv_mixed_endian_double=no],
3417[ac_cv_mixed_endian_double=no])])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003418AC_MSG_RESULT($ac_cv_mixed_endian_double)
3419if test "$ac_cv_mixed_endian_double" = yes
3420then
3421 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3422 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3423 in ARM mixed-endian order (byte order 45670123)])
3424fi
3425
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003426# The short float repr introduced in Python 3.1 requires the
3427# correctly-rounded string <-> double conversion functions from
3428# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3429# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003430# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson7abf8d42009-04-18 20:17:52 +00003431# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003432
3433# This inline assembler syntax may also work for suncc and icc,
3434# so we try it on all platforms.
3435
3436AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Kloseb159a552010-04-25 21:00:44 +00003437AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003438 unsigned short cw;
3439 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3440 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Kloseb159a552010-04-25 21:00:44 +00003441]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003442AC_MSG_RESULT($have_gcc_asm_for_x87)
3443if test "$have_gcc_asm_for_x87" = yes
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003444then
Mark Dickinsonf4243f62009-11-15 13:47:27 +00003445 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3446 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003447fi
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003448
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003449# Detect whether system arithmetic is subject to x87-style double
3450# rounding issues. The result of this test has little meaning on non
3451# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3452# mode is round-to-nearest and double rounding issues are present, and
3453# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3454AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003455# $BASECFLAGS may affect the result
3456ac_save_cc="$CC"
3457CC="$CC $BASECFLAGS"
Matthias Kloseb159a552010-04-25 21:00:44 +00003458AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003459#include <stdlib.h>
3460#include <math.h>
3461int main() {
3462 volatile double x, y, z;
3463 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3464 x = 0.99999999999999989; /* 1-2**-53 */
3465 y = 1./x;
3466 if (y != 1.)
3467 exit(0);
3468 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3469 x = 1e16;
3470 y = 2.99999;
3471 z = x + y;
3472 if (z != 1e16+4.)
3473 exit(0);
3474 /* both tests show evidence of double rounding */
3475 exit(1);
3476}
Matthias Kloseb159a552010-04-25 21:00:44 +00003477]])],
3478[ac_cv_x87_double_rounding=no],
3479[ac_cv_x87_double_rounding=yes],
3480[ac_cv_x87_double_rounding=no])
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003481CC="$ac_save_cc"
Mark Dickinson3dc7c6a2009-01-04 15:09:02 +00003482AC_MSG_RESULT($ac_cv_x87_double_rounding)
3483if test "$ac_cv_x87_double_rounding" = yes
3484then
3485 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3486 [Define if arithmetic is subject to x87-style double rounding issue])
3487fi
3488
Mark Dickinsonb08a53a2009-04-16 19:52:09 +00003489# ************************************
3490# * Check for mathematical functions *
3491# ************************************
3492
3493LIBS_SAVE=$LIBS
3494LIBS="$LIBS $LIBM"
3495
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003496AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
Victor Stinner8f9f8d62011-05-09 12:45:41 +02003497AC_CHECK_FUNCS([hypot lgamma log1p log2 round tgamma])
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003498AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3499
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003500# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3501# -0. on some architectures.
3502AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3503AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003504AC_RUN_IFELSE([AC_LANG_SOURCE([[
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003505#include <math.h>
3506#include <stdlib.h>
3507int main() {
3508 /* return 0 if either negative zeros don't exist
3509 on this platform or if negative zeros exist
3510 and tanh(-0.) == -0. */
3511 if (atan2(0., -1.) == atan2(-0., -1.) ||
3512 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3513 else exit(1);
3514}
Matthias Kloseb159a552010-04-25 21:00:44 +00003515]])],
3516[ac_cv_tanh_preserves_zero_sign=yes],
3517[ac_cv_tanh_preserves_zero_sign=no],
3518[ac_cv_tanh_preserves_zero_sign=no])])
Christian Heimes81ee3ef2008-05-04 22:42:01 +00003519AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3520if test "$ac_cv_tanh_preserves_zero_sign" = yes
3521then
3522 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3523 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3524fi
3525
Mark Dickinson7edecdd2010-11-20 10:09:56 +00003526if test "$ac_cv_func_log1p" = yes
3527then
3528 # On some versions of AIX, log1p(-0.) returns 0. instead of
3529 # -0. See issue #9920.
3530 AC_MSG_CHECKING(whether log1p drops the sign of negative zero)
3531 AC_CACHE_VAL(ac_cv_log1p_drops_zero_sign, [
3532 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3533 #include <math.h>
3534 #include <stdlib.h>
3535 int main() {
3536 /* Fail if the signs of log1p(-0.) and -0. can be
3537 distinguished. */
3538 if (atan2(log1p(-0.), -1.) == atan2(-0., -1.))
3539 return 0;
3540 else
3541 return 1;
3542 }
3543 ]])],
3544 [ac_cv_log1p_drops_zero_sign=no],
3545 [ac_cv_log1p_drops_zero_sign=yes],
3546 [ac_cv_log1p_drops_zero_sign=no])])
3547 AC_MSG_RESULT($ac_cv_log1p_drops_zero_sign)
3548fi
3549if test "$ac_cv_log1p_drops_zero_sign" = yes
3550then
3551 AC_DEFINE(LOG1P_DROPS_ZERO_SIGN, 1,
3552 [Define if log1p(-0.) is 0. rather than -0.])
3553fi
Christian Heimes99170a52007-12-19 02:07:34 +00003554
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00003555LIBS=$LIBS_SAVE
3556
Mark Dickinsona614f042009-11-28 12:48:43 +00003557# For multiprocessing module, check that sem_open
3558# actually works. For FreeBSD versions <= 7.2,
3559# the kernel module that provides POSIX semaphores
3560# isn't loaded by default, so an attempt to call
3561# sem_open results in a 'Signal 12' error.
3562AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3563AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Kloseb159a552010-04-25 21:00:44 +00003564AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsona614f042009-11-28 12:48:43 +00003565#include <unistd.h>
3566#include <fcntl.h>
3567#include <stdio.h>
3568#include <semaphore.h>
3569#include <sys/stat.h>
3570
3571int main(void) {
3572 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3573 if (a == SEM_FAILED) {
3574 perror("sem_open");
3575 return 1;
3576 }
3577 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003578 sem_unlink("/autoconf");
Mark Dickinsona614f042009-11-28 12:48:43 +00003579 return 0;
3580}
Matthias Kloseb159a552010-04-25 21:00:44 +00003581]])],
3582[ac_cv_posix_semaphores_enabled=yes],
3583[ac_cv_posix_semaphores_enabled=no],
3584[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsona614f042009-11-28 12:48:43 +00003585)
3586AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3587if test $ac_cv_posix_semaphores_enabled = no
3588then
3589 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3590 [Define if POSIX semaphores aren't enabled on your system])
3591fi
3592
Mark Dickinson10683072009-04-18 21:18:19 +00003593# Multiprocessing check for broken sem_getvalue
3594AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003595AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Kloseb159a552010-04-25 21:00:44 +00003596AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson10683072009-04-18 21:18:19 +00003597#include <unistd.h>
3598#include <fcntl.h>
3599#include <stdio.h>
3600#include <semaphore.h>
3601#include <sys/stat.h>
3602
3603int main(void){
Mark Dickinsonba79b352009-12-13 21:10:57 +00003604 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Mark Dickinson10683072009-04-18 21:18:19 +00003605 int count;
3606 int res;
3607 if(a==SEM_FAILED){
3608 perror("sem_open");
3609 return 1;
3610
3611 }
3612 res = sem_getvalue(a, &count);
3613 sem_close(a);
Mark Dickinsonba79b352009-12-13 21:10:57 +00003614 sem_unlink("/autocftw");
Mark Dickinson10683072009-04-18 21:18:19 +00003615 return res==-1 ? 1 : 0;
3616}
Matthias Kloseb159a552010-04-25 21:00:44 +00003617]])],
3618[ac_cv_broken_sem_getvalue=no],
3619[ac_cv_broken_sem_getvalue=yes],
3620[ac_cv_broken_sem_getvalue=yes])
Mark Dickinson10683072009-04-18 21:18:19 +00003621)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003622AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3623if test $ac_cv_broken_sem_getvalue = yes
3624then
3625 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3626 [define to 1 if your sem_getvalue is broken.])
3627fi
Mark Dickinson10683072009-04-18 21:18:19 +00003628
Mark Dickinsonbd792642009-03-18 20:06:12 +00003629# determine what size digit to use for Python's longs
3630AC_MSG_CHECKING([digit size for Python's longs])
3631AC_ARG_ENABLE(big-digits,
Matthias Klose2b8733f2010-04-25 18:34:36 +00003632AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonbd792642009-03-18 20:06:12 +00003633[case $enable_big_digits in
3634yes)
3635 enable_big_digits=30 ;;
3636no)
3637 enable_big_digits=15 ;;
3638[15|30])
3639 ;;
3640*)
3641 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3642esac
3643AC_MSG_RESULT($enable_big_digits)
3644AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3645],
3646[AC_MSG_RESULT(no value specified)])
3647
Guido van Rossumef2255b2000-03-10 22:30:29 +00003648# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003649AC_CHECK_HEADER(wchar.h, [
3650 AC_DEFINE(HAVE_WCHAR_H, 1,
3651 [Define if the compiler provides a wchar.h header file.])
3652 wchar_h="yes"
3653],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003654wchar_h="no"
3655)
3656
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003657# determine wchar_t size
3658if test "$wchar_h" = yes
3659then
Guido van Rossum67b26592001-10-20 14:21:45 +00003660 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003661fi
3662
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003663AC_MSG_CHECKING(for UCS-4 tcl)
3664have_ucs4_tcl=no
Matthias Kloseb159a552010-04-25 21:00:44 +00003665AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003666#include <tcl.h>
3667#if TCL_UTF_MAX != 6
3668# error "NOT UCS4_TCL"
Matthias Kloseb159a552010-04-25 21:00:44 +00003669#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003670 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3671 have_ucs4_tcl=yes
Matthias Kloseb159a552010-04-25 21:00:44 +00003672],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003673AC_MSG_RESULT($have_ucs4_tcl)
3674
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003675# check whether wchar_t is signed or not
3676if test "$wchar_h" = yes
3677then
3678 # check whether wchar_t is signed or not
3679 AC_MSG_CHECKING(whether wchar_t is signed)
3680 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003681 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003682 #include <wchar.h>
3683 int main()
3684 {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00003685 /* Success: exit code 0 */
3686 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003687 }
Matthias Kloseb159a552010-04-25 21:00:44 +00003688 ]])],
3689 [ac_cv_wchar_t_signed=yes],
3690 [ac_cv_wchar_t_signed=no],
3691 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003692 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3693fi
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003694
Georg Brandl52d168a2008-01-07 18:10:24 +00003695# wchar_t is only usable if it maps to an unsigned type
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003696if test "$ac_cv_sizeof_wchar_t" -ge 2 \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003697 -a "$ac_cv_wchar_t_signed" = "no"
Georg Brandl52d168a2008-01-07 18:10:24 +00003698then
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003699 HAVE_USABLE_WCHAR_T="yes"
Georg Brandl52d168a2008-01-07 18:10:24 +00003700 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3701 [Define if you have a useable wchar_t type defined in wchar.h; useable
3702 means wchar_t must be an unsigned type with at least 16 bits. (see
3703 Include/unicodeobject.h).])
Georg Brandl52d168a2008-01-07 18:10:24 +00003704else
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003705 HAVE_USABLE_WCHAR_T="no usable wchar_t found"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003706fi
Martin v. Löwisd63a3b82011-09-28 07:41:54 +02003707AC_MSG_RESULT($HAVE_USABLE_WCHAR_T)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003708
3709# check for endianness
3710AC_C_BIGENDIAN
3711
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003712# ABI version string for Python extension modules. This appears between the
3713# periods in shared library file names, e.g. foo.<SOABI>.so. It is calculated
3714# from the following attributes which affect the ABI of this Python build (in
3715# this order):
3716#
3717# * The Python implementation (always 'cpython-' for us)
3718# * The major and minor version numbers
3719# * --with-pydebug (adds a 'd')
3720# * --with-pymalloc (adds a 'm')
3721# * --with-wide-unicode (adds a 'u')
3722#
3723# Thus for example, Python 3.2 built with wide unicode, pydebug, and pymalloc,
Georg Brandlde7d8342010-09-03 22:19:07 +00003724# would get a shared library ABI version tag of 'cpython-32dmu' and shared
3725# libraries would be named 'foo.cpython-32dmu.so'.
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003726AC_SUBST(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003727AC_MSG_CHECKING(ABIFLAGS)
3728AC_MSG_RESULT($ABIFLAGS)
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003729AC_MSG_CHECKING(SOABI)
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003730SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003731AC_MSG_RESULT($SOABI)
3732
Barry Warsaw8cf4eae2010-10-16 01:04:07 +00003733AC_MSG_CHECKING(LDVERSION)
3734LDVERSION='$(VERSION)$(ABIFLAGS)'
3735AC_MSG_RESULT($LDVERSION)
3736
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003737# SO is the extension of shared libraries `(including the dot!)
3738# -- usually .so, .sl on HP-UX, .dll on Cygwin
3739AC_MSG_CHECKING(SO)
3740if test -z "$SO"
3741then
3742 case $ac_sys_system in
3743 hp*|HP*)
3744 case `uname -m` in
3745 ia64) SO=.so;;
3746 *) SO=.sl;;
3747 esac
3748 ;;
3749 CYGWIN*) SO=.dll;;
Matthias Klose3fbfea12010-10-14 15:24:22 +00003750 Linux*|GNU*)
3751 SO=.${SOABI}.so;;
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003752 *) SO=.so;;
3753 esac
3754else
3755 # this might also be a termcap variable, see #610332
Georg Brandlde7d8342010-09-03 22:19:07 +00003756 echo
3757 echo '====================================================================='
3758 echo '+ +'
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003759 echo '+ WARNING: You have set SO in your environment. +'
Georg Brandlde7d8342010-09-03 22:19:07 +00003760 echo '+ Do you really mean to change the extension for shared libraries? +'
3761 echo '+ Continuing in 10 seconds to let you to ponder. +'
3762 echo '+ +'
3763 echo '====================================================================='
Barry Warsaw35f3a2c2010-09-03 18:30:30 +00003764 sleep 10
3765fi
3766AC_MSG_RESULT($SO)
3767
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003768# Check whether right shifting a negative integer extends the sign bit
3769# or fills with zeros (like the Cray J90, according to Tim Peters).
3770AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003771AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003772AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003773int main()
3774{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003775 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003776}
Matthias Kloseb159a552010-04-25 21:00:44 +00003777]])],
3778[ac_cv_rshift_extends_sign=yes],
3779[ac_cv_rshift_extends_sign=no],
3780[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003781AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3782if test "$ac_cv_rshift_extends_sign" = no
3783then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003784 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3785 [Define if i>>j for signed int i does not extend the sign bit
3786 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003787fi
3788
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003789# check for getc_unlocked and related locking functions
3790AC_MSG_CHECKING(for getc_unlocked() and friends)
3791AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003792AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003793 FILE *f = fopen("/dev/null", "r");
3794 flockfile(f);
3795 getc_unlocked(f);
3796 funlockfile(f);
Matthias Kloseb159a552010-04-25 21:00:44 +00003797]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003798AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3799if test "$ac_cv_have_getc_unlocked" = yes
3800then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003801 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3802 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003803fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003804
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003805# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003806# save the value of LIBS so we don't actually link Python with readline
3807LIBS_no_readline=$LIBS
Gregory P. Smith18820942008-09-07 06:24:49 +00003808
3809# On some systems we need to link readline to a termcap compatible
3810# library. NOTE: Keep the precedence of listed libraries synchronised
3811# with setup.py.
3812py_cv_lib_readline=no
3813AC_MSG_CHECKING([how to link readline libs])
3814for py_libtermcap in "" ncursesw ncurses curses termcap; do
3815 if test -z "$py_libtermcap"; then
3816 READLINE_LIBS="-lreadline"
3817 else
3818 READLINE_LIBS="-lreadline -l$py_libtermcap"
3819 fi
3820 LIBS="$READLINE_LIBS $LIBS_no_readline"
3821 AC_LINK_IFELSE(
3822 [AC_LANG_CALL([],[readline])],
3823 [py_cv_lib_readline=yes])
3824 if test $py_cv_lib_readline = yes; then
3825 break
3826 fi
3827done
3828# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3829#AC_SUBST([READLINE_LIBS])
Gregory P. Smith97515912008-09-07 19:23:19 +00003830if test $py_cv_lib_readline = no; then
Gregory P. Smith18820942008-09-07 06:24:49 +00003831 AC_MSG_RESULT([none])
3832else
3833 AC_MSG_RESULT([$READLINE_LIBS])
3834 AC_DEFINE(HAVE_LIBREADLINE, 1,
3835 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003836fi
3837
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003838# check for readline 2.1
3839AC_CHECK_LIB(readline, rl_callback_handler_install,
3840 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003841 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003842
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003843# check for readline 2.2
Matthias Kloseb159a552010-04-25 21:00:44 +00003844AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3845 [have_readline=yes],
3846 [have_readline=no]
3847)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003848if test $have_readline = yes
3849then
3850 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3851 [readline/readline.h],
3852 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3853 [Define if you have readline 2.2]), )
Antoine Pitroud5131772009-10-26 19:22:14 +00003854 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3855 [readline/readline.h],
3856 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3857 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003858fi
3859
Martin v. Löwis0daad592001-09-30 21:09:59 +00003860# check for readline 4.0
3861AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003862 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003863 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003864
Thomas Wouters89d996e2007-09-08 17:39:28 +00003865# also in 4.0
3866AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3867 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003868 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Thomas Wouters89d996e2007-09-08 17:39:28 +00003869
Guido van Rossum353ae582001-07-10 16:45:32 +00003870# check for readline 4.2
3871AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003872 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smith18820942008-09-07 06:24:49 +00003873 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003874
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003875# also in readline 4.2
Matthias Kloseb159a552010-04-25 21:00:44 +00003876AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3877 [have_readline=yes],
3878 [have_readline=no]
3879)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003880if test $have_readline = yes
3881then
3882 AC_EGREP_HEADER([extern int rl_catch_signals;],
3883 [readline/readline.h],
3884 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3885 [Define if you can turn off readline's signal handling.]), )
3886fi
3887
Martin v. Löwis82bca632006-02-10 20:49:30 +00003888# End of readline checks: restore LIBS
3889LIBS=$LIBS_no_readline
3890
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003891AC_MSG_CHECKING(for broken nice())
3892AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003893AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003894int main()
3895{
3896 int val1 = nice(1);
3897 if (val1 != -1 && val1 == nice(2))
3898 exit(0);
3899 exit(1);
3900}
Matthias Kloseb159a552010-04-25 21:00:44 +00003901]])],
3902[ac_cv_broken_nice=yes],
3903[ac_cv_broken_nice=no],
3904[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003905AC_MSG_RESULT($ac_cv_broken_nice)
3906if test "$ac_cv_broken_nice" = yes
3907then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003908 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3909 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003910fi
3911
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003912AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00003913AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Kloseb159a552010-04-25 21:00:44 +00003914AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003915#include <poll.h>
3916
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003917int main()
3918{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003919 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003920 int poll_test;
3921
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003922 close (42);
3923
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003924 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003925 if (poll_test < 0)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003926 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003927 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003928 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003929 else
Alexandre Vassalottiaee170a2009-07-17 06:24:33 +00003930 return 1;
3931}
Matthias Kloseb159a552010-04-25 21:00:44 +00003932]])],
3933[ac_cv_broken_poll=yes],
3934[ac_cv_broken_poll=no],
3935[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003936AC_MSG_RESULT($ac_cv_broken_poll)
3937if test "$ac_cv_broken_poll" = yes
3938then
3939 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3940 [Define if poll() sets errno on invalid file descriptors.])
3941fi
3942
Brett Cannon43802422005-02-10 20:48:03 +00003943# Before we can test tzset, we need to check if struct tm has a tm_zone
3944# (which is not required by ISO C or UNIX spec) and/or if we support
3945# tzname[]
3946AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003947
Brett Cannon43802422005-02-10 20:48:03 +00003948# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003949AC_MSG_CHECKING(for working tzset())
3950AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Kloseb159a552010-04-25 21:00:44 +00003951AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003952#include <stdlib.h>
3953#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003954#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003955
3956#if HAVE_TZNAME
3957extern char *tzname[];
3958#endif
3959
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003960int main()
3961{
Brett Cannon18367812003-09-19 00:59:16 +00003962 /* Note that we need to ensure that not only does tzset(3)
3963 do 'something' with localtime, but it works as documented
3964 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003965 This includes making sure that tzname is set properly if
3966 tm->tm_zone does not exist since it is the alternative way
3967 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003968
3969 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003970 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003971 */
3972
Brett Cannon43802422005-02-10 20:48:03 +00003973 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003974 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3975
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003976 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003977 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003978 if (localtime(&groundhogday)->tm_hour != 0)
3979 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003980#if HAVE_TZNAME
3981 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3982 if (strcmp(tzname[0], "UTC") ||
3983 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3984 exit(1);
3985#endif
Brett Cannon18367812003-09-19 00:59:16 +00003986
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003987 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003988 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003989 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003990 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003991#if HAVE_TZNAME
3992 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3993 exit(1);
3994#endif
Brett Cannon18367812003-09-19 00:59:16 +00003995
3996 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3997 tzset();
3998 if (localtime(&groundhogday)->tm_hour != 11)
3999 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004000#if HAVE_TZNAME
4001 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4002 exit(1);
4003#endif
4004
4005#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004006 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4007 exit(1);
4008 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4009 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004010#endif
Brett Cannon18367812003-09-19 00:59:16 +00004011
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004012 exit(0);
4013}
Matthias Kloseb159a552010-04-25 21:00:44 +00004014]])],
4015[ac_cv_working_tzset=yes],
4016[ac_cv_working_tzset=no],
4017[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004018AC_MSG_RESULT($ac_cv_working_tzset)
4019if test "$ac_cv_working_tzset" = yes
4020then
4021 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4022 [Define if tzset() actually switches the local timezone in a meaningful way.])
4023fi
4024
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004025# Look for subsecond timestamps in struct stat
4026AC_MSG_CHECKING(for tv_nsec in struct stat)
4027AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Kloseb159a552010-04-25 21:00:44 +00004028AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004029struct stat st;
4030st.st_mtim.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004031]])],
4032[ac_cv_stat_tv_nsec=yes],
4033[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004034AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4035if test "$ac_cv_stat_tv_nsec" = yes
4036then
4037 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4038 [Define if you have struct stat.st_mtim.tv_nsec])
4039fi
4040
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004041# Look for BSD style subsecond timestamps in struct stat
4042AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4043AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Kloseb159a552010-04-25 21:00:44 +00004044AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004045struct stat st;
4046st.st_mtimespec.tv_nsec = 1;
Matthias Kloseb159a552010-04-25 21:00:44 +00004047]])],
4048[ac_cv_stat_tv_nsec2=yes],
4049[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004050AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4051if test "$ac_cv_stat_tv_nsec2" = yes
4052then
4053 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4054 [Define if you have struct stat.st_mtimensec])
4055fi
4056
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004057# On HP/UX 11.0, mvwdelch is a block with a return statement
4058AC_MSG_CHECKING(whether mvwdelch is an expression)
4059AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Kloseb159a552010-04-25 21:00:44 +00004060AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004061 int rtn;
4062 rtn = mvwdelch(0,0,0);
Matthias Kloseb159a552010-04-25 21:00:44 +00004063]])],
4064[ac_cv_mvwdelch_is_expression=yes],
4065[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004066AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4067
4068if test "$ac_cv_mvwdelch_is_expression" = yes
4069then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004070 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4071 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004072fi
4073
4074AC_MSG_CHECKING(whether WINDOW has _flags)
4075AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Kloseb159a552010-04-25 21:00:44 +00004076AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004077 WINDOW *w;
4078 w->_flags = 0;
Matthias Kloseb159a552010-04-25 21:00:44 +00004079]])],
4080[ac_cv_window_has_flags=yes],
4081[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004082AC_MSG_RESULT($ac_cv_window_has_flags)
4083
4084
4085if test "$ac_cv_window_has_flags" = yes
4086then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004087 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4088 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004089fi
4090
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004091AC_MSG_CHECKING(for is_term_resized)
Matthias Kloseb159a552010-04-25 21:00:44 +00004092AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4093 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4094 AC_MSG_RESULT(yes)],
4095 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004096)
Martin v. Löwis24a880b2002-12-31 12:55:15 +00004097
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004098AC_MSG_CHECKING(for resize_term)
Matthias Kloseb159a552010-04-25 21:00:44 +00004099AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4100 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4101 AC_MSG_RESULT(yes)],
4102 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004103)
4104
4105AC_MSG_CHECKING(for resizeterm)
Matthias Kloseb159a552010-04-25 21:00:44 +00004106AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4107 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4108 AC_MSG_RESULT(yes)],
4109 [AC_MSG_RESULT(no)]
Thomas Wouters0e3f5912006-08-11 14:57:12 +00004110)
4111
Thomas Wouters89f507f2006-12-13 04:49:30 +00004112AC_MSG_CHECKING(for /dev/ptmx)
4113
4114if test -r /dev/ptmx
4115then
4116 AC_MSG_RESULT(yes)
4117 AC_DEFINE(HAVE_DEV_PTMX, 1,
4118 [Define if we have /dev/ptmx.])
4119else
4120 AC_MSG_RESULT(no)
4121fi
4122
4123AC_MSG_CHECKING(for /dev/ptc)
4124
4125if test -r /dev/ptc
4126then
4127 AC_MSG_RESULT(yes)
4128 AC_DEFINE(HAVE_DEV_PTC, 1,
4129 [Define if we have /dev/ptc.])
4130else
4131 AC_MSG_RESULT(no)
4132fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004133
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004134if test "$have_long_long" = yes
4135then
4136 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4137 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Kloseb159a552010-04-25 21:00:44 +00004138 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004139 #include <stdio.h>
4140 #include <stddef.h>
4141 #include <string.h>
4142
4143 #ifdef HAVE_SYS_TYPES_H
4144 #include <sys/types.h>
4145 #endif
4146
4147 int main()
4148 {
4149 char buffer[256];
4150
4151 if (sprintf(buffer, "%lld", (long long)123) < 0)
4152 return 1;
4153 if (strcmp(buffer, "123"))
4154 return 1;
4155
4156 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4157 return 1;
4158 if (strcmp(buffer, "-123"))
4159 return 1;
4160
4161 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4162 return 1;
4163 if (strcmp(buffer, "123"))
4164 return 1;
4165
4166 return 0;
4167 }
Matthias Kloseb159a552010-04-25 21:00:44 +00004168 ]]])],
4169 [ac_cv_have_long_long_format=yes],
4170 [ac_cv_have_long_long_format=no],
Matthias Klose3b739b12012-03-15 19:31:06 +01004171 [ac_cv_have_long_long_format="cross -- assuming no"
4172 if test x$GCC = xyes; then
4173 save_CFLAGS=$CFLAGS
4174 CFLAGS="$CFLAGS -Werror -Wformat"
4175 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4176 #include <stdio.h>
4177 #include <stddef.h>
4178 ]], [[
4179 char *buffer;
4180 sprintf(buffer, "%lld", (long long)123);
4181 sprintf(buffer, "%lld", (long long)-123);
4182 sprintf(buffer, "%llu", (unsigned long long)123);
4183 ]])],
4184 ac_cv_have_long_long_format=yes
4185 )
4186 CFLAGS=$save_CFLAGS
4187 fi])
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004188 )
4189 AC_MSG_RESULT($ac_cv_have_long_long_format)
4190fi
4191
Mark Dickinson89d7d412009-12-31 20:50:59 +00004192if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004193then
4194 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4195 [Define to printf format modifier for long long type])
4196fi
4197
Ronald Oussoren3c1928a2009-11-19 17:15:31 +00004198if test $ac_sys_system = Darwin
4199then
4200 LIBS="$LIBS -framework CoreFoundation"
4201fi
Mark Dickinson6ce4a9a2009-11-16 17:00:11 +00004202
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004203AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Kloseb159a552010-04-25 21:00:44 +00004204AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie5091f62009-07-17 06:41:02 +00004205#include <stdio.h>
Thomas Wouters477c8d52006-05-27 19:21:47 +00004206#include <stddef.h>
4207#include <string.h>
4208
Christian Heimes2c181612007-12-17 20:04:13 +00004209#ifdef HAVE_SYS_TYPES_H
4210#include <sys/types.h>
4211#endif
Thomas Wouters89f507f2006-12-13 04:49:30 +00004212
4213#ifdef HAVE_SSIZE_T
4214typedef ssize_t Py_ssize_t;
4215#elif SIZEOF_VOID_P == SIZEOF_LONG
4216typedef long Py_ssize_t;
4217#else
4218typedef int Py_ssize_t;
4219#endif
Thomas Wouters477c8d52006-05-27 19:21:47 +00004220
Christian Heimes2c181612007-12-17 20:04:13 +00004221int main()
4222{
4223 char buffer[256];
4224
Thomas Wouters477c8d52006-05-27 19:21:47 +00004225 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4226 return 1;
4227
Thomas Wouters89f507f2006-12-13 04:49:30 +00004228 if (strcmp(buffer, "123"))
Thomas Wouters477c8d52006-05-27 19:21:47 +00004229 return 1;
Thomas Wouters89f507f2006-12-13 04:49:30 +00004230
4231 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4232 return 1;
4233
4234 if (strcmp(buffer, "-123"))
4235 return 1;
4236
Thomas Wouters477c8d52006-05-27 19:21:47 +00004237 return 0;
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004238}
Matthias Kloseb159a552010-04-25 21:00:44 +00004239]])],
4240 [ac_cv_have_size_t_format=yes],
4241 [ac_cv_have_size_t_format=no],
4242 [ac_cv_have_size_t_format="cross -- assuming yes"
4243])])
Benjamin Peterson8f326b22009-12-13 02:10:36 +00004244if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004245 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4246 [Define to printf format modifier for Py_ssize_t])
4247fi
Thomas Wouters477c8d52006-05-27 19:21:47 +00004248
Martin v. Löwis01c04012002-11-11 14:58:44 +00004249AC_CHECK_TYPE(socklen_t,,
4250 AC_DEFINE(socklen_t,int,
Matthias Klosec80c93f2010-04-24 17:04:35 +00004251 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004252#ifdef HAVE_SYS_TYPES_H
4253#include <sys/types.h>
4254#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004255#ifdef HAVE_SYS_SOCKET_H
4256#include <sys/socket.h>
4257#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004258])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004259
Antoine Pitroufff95302008-09-03 18:58:51 +00004260AC_MSG_CHECKING(for broken mbstowcs)
Alexandre Vassalotti7b0c1c72009-07-17 06:00:34 +00004261AC_CACHE_VAL(ac_cv_broken_mbstowcs,
Matthias Kloseb159a552010-04-25 21:00:44 +00004262AC_RUN_IFELSE([AC_LANG_SOURCE([[
Antoine Pitroufff95302008-09-03 18:58:51 +00004263#include<stdlib.h>
4264int main() {
4265 size_t len = -1;
4266 const char *str = "text";
4267 len = mbstowcs(NULL, str, 0);
4268 return (len != 4);
4269}
Matthias Kloseb159a552010-04-25 21:00:44 +00004270]])],
4271[ac_cv_broken_mbstowcs=no],
4272[ac_cv_broken_mbstowcs=yes],
4273[ac_cv_broken_mbstowcs=no]))
Antoine Pitroufff95302008-09-03 18:58:51 +00004274AC_MSG_RESULT($ac_cv_broken_mbstowcs)
4275if test "$ac_cv_broken_mbstowcs" = yes
4276then
4277 AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4278 [Define if mbstowcs(NULL, "text", 0) does not return the number of
4279 wide chars that would be converted.])
4280fi
4281
Antoine Pitroub52ec782009-01-25 16:34:23 +00004282# Check for --with-computed-gotos
4283AC_MSG_CHECKING(for --with-computed-gotos)
4284AC_ARG_WITH(computed-gotos,
Antoine Pitrou042b1282010-08-13 21:15:58 +00004285 AS_HELP_STRING([--with(out)-computed-gotos],
4286 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
Antoine Pitroub52ec782009-01-25 16:34:23 +00004287[
Antoine Pitrou042b1282010-08-13 21:15:58 +00004288if test "$withval" = yes
Antoine Pitroub52ec782009-01-25 16:34:23 +00004289then
4290 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4291 [Define if you want to use computed gotos in ceval.c.])
4292 AC_MSG_RESULT(yes)
Antoine Pitrou042b1282010-08-13 21:15:58 +00004293fi
4294if test "$withval" = no
4295then
4296 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4297 [Define if you want to use computed gotos in ceval.c.])
4298 AC_MSG_RESULT(no)
4299fi
4300],
4301[AC_MSG_RESULT(no value specified)])
Antoine Pitroub52ec782009-01-25 16:34:23 +00004302
Matthias Kloseb17289e2012-03-15 19:51:34 +01004303AC_MSG_CHECKING(whether $CC supports computed gotos)
4304AC_CACHE_VAL(ac_cv_computed_gotos,
4305AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4306int main(int argc, char **argv)
4307{
4308 static void *targets[1] = { &&LABEL1 };
4309 goto LABEL2;
4310LABEL1:
4311 return 0;
4312LABEL2:
4313 goto *targets[0];
4314 return 1;
4315}
4316]]])],
4317[ac_cv_computed_gotos=yes],
4318[ac_cv_computed_gotos=no],
4319[if test "${with_computed_gotos+set}" = set; then
4320 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4321 else
4322 ac_cv_computed_gotos=no
4323 fi]))
4324AC_MSG_RESULT($ac_cv_computed_gotos)
4325case "$ac_cv_computed_gotos" in yes*)
4326 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4327 [Define if the C compiler supports computed gotos.])
4328esac
4329
R. David Murraye16cda92010-10-15 23:12:57 +00004330case $ac_sys_system in
4331AIX*)
4332 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4333esac
Antoine Pitroub52ec782009-01-25 16:34:23 +00004334
Jesus Cea6a792292010-05-03 21:18:48 +00004335
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004336AC_SUBST(THREADHEADERS)
4337
4338for h in `(cd $srcdir;echo Python/thread_*.h)`
4339do
4340 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4341done
4342
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004343AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004344SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004345AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004346for dir in $SRCDIRS; do
4347 if test ! -d $dir; then
4348 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004349 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004350done
4351AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004352
Stefan Krah1919b7e2012-03-21 18:25:23 +01004353# Availability of -O2:
4354AC_MSG_CHECKING(for -O2)
4355saved_cflags="$CFLAGS"
4356CFLAGS="-O2"
4357AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
4358]])],[have_O2=yes],[have_O2=no])
4359AC_MSG_RESULT($have_O2)
4360CFLAGS="$saved_cflags"
4361
4362# _FORTIFY_SOURCE wrappers for memmove and bcopy are incorrect:
4363# http://sourceware.org/ml/libc-alpha/2010-12/msg00009.html
4364AC_MSG_CHECKING(for glibc _FORTIFY_SOURCE/memmove bug)
4365saved_cflags="$CFLAGS"
4366CFLAGS="-O2 -D_FORTIFY_SOURCE=2"
4367if test "$have_O2" = no; then
4368 CFLAGS=""
4369fi
4370AC_RUN_IFELSE([AC_LANG_SOURCE([[
4371#include <stdio.h>
4372#include <stdlib.h>
4373#include <string.h>
4374void foo(void *p, void *q) { memmove(p, q, 19); }
4375int main() {
4376 char a[32] = "123456789000000000";
4377 foo(&a[9], a);
4378 if (strcmp(a, "123456789123456789000000000") != 0)
4379 return 1;
4380 foo(a, &a[9]);
4381 if (strcmp(a, "123456789000000000") != 0)
4382 return 1;
4383 return 0;
4384}
4385]])],
4386[have_glibc_memmove_bug=no],
4387[have_glibc_memmove_bug=yes],
4388[have_glibc_memmove_bug=undefined])
4389CFLAGS="$saved_cflags"
4390AC_MSG_RESULT($have_glibc_memmove_bug)
4391if test "$have_glibc_memmove_bug" = yes; then
4392 AC_DEFINE(HAVE_GLIBC_MEMMOVE_BUG, 1,
4393 [Define if glibc has incorrect _FORTIFY_SOURCE wrappers
4394 for memmove and bcopy.])
4395fi
4396
4397if test "$have_gcc_asm_for_x87" = yes; then
4398 # Some versions of gcc miscompile inline asm:
4399 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46491
4400 # http://gcc.gnu.org/ml/gcc/2010-11/msg00366.html
4401 case $CC in
4402 *gcc*)
4403 AC_MSG_CHECKING(for gcc ipa-pure-const bug)
4404 saved_cflags="$CFLAGS"
4405 CFLAGS="-O2"
4406 AC_RUN_IFELSE([AC_LANG_SOURCE([[
4407 __attribute__((noinline)) int
4408 foo(int *p) {
4409 int r;
4410 asm ( "movl \$6, (%1)\n\t"
4411 "xorl %0, %0\n\t"
4412 : "=r" (r) : "r" (p) : "memory"
4413 );
4414 return r;
4415 }
4416 int main() {
4417 int p = 8;
4418 if ((foo(&p) ? : p) != 6)
4419 return 1;
4420 return 0;
4421 }
4422 ]])],
4423 [have_ipa_pure_const_bug=no],
4424 [have_ipa_pure_const_bug=yes],
4425 [have_ipa_pure_const_bug=undefined])
4426 CFLAGS="$saved_cflags"
4427 AC_MSG_RESULT($have_ipa_pure_const_bug)
4428 if test "$have_ipa_pure_const_bug" = yes; then
4429 AC_DEFINE(HAVE_IPA_PURE_CONST_BUG, 1,
4430 [Define if gcc has the ipa-pure-const bug.])
4431 fi
4432 ;;
4433 esac
4434fi
4435
Guido van Rossum627b2d71993-12-24 10:39:16 +00004436# generate output files
Antoine Pitrou20327222009-05-24 20:39:11 +00004437AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrou8e6b4072010-09-10 19:44:44 +00004438AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004439AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004440
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004441echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004442if test ! -f Modules/Setup
4443then
4444 cp $srcdir/Modules/Setup.dist Modules/Setup
4445fi
4446
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00004447echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004448if test ! -f Modules/Setup.local
4449then
4450 echo "# Edit this file for local setup changes" >Modules/Setup.local
4451fi
4452
4453echo "creating Makefile"
4454$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4455 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004456 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00004457mv config.c Modules