blob: ec7538c1970705e35405bfa2cea0dab482fec883 [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000011AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
Georg Brandlbcd64a32009-03-31 21:45:18 +000015dnl Ensure that if prefix is specified, it does not end in a slash. If
16dnl it does, we get path names containing '//' which is both ugly and
17dnl can cause trouble.
18
19dnl Last slash shouldn't be stripped if prefix=/
20if test "$prefix" != "/"; then
21 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
22fi
23
Martin v. Löwis8316feb2003-06-14 07:48:07 +000024dnl This is for stuff that absolutely must end up in pyconfig.h.
25dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000026AH_TOP([
27#ifndef Py_PYCONFIG_H
28#define Py_PYCONFIG_H
29])
Martin v. Löwis11437992002-04-12 09:54:03 +000030AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000031/* Define the macros needed if on a UnixWare 7.x system. */
32#if defined(__USLC__) && defined(__SCO_VERSION__)
33#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
34#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000035
36#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000037])
38
Martin v. Löwis8316feb2003-06-14 07:48:07 +000039# We don't use PACKAGE_ variables, and they cause conflicts
40# with other autoconf-based packages that include Python.h
41grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
42rm confdefs.h
43mv confdefs.h.new confdefs.h
44
Guido van Rossum642b6781997-07-19 19:35:41 +000045AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000046VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000047
Martin v. Löwis1142de32002-03-29 16:28:31 +000048AC_SUBST(SOVERSION)
49SOVERSION=1.0
50
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000051# The later defininition of _XOPEN_SOURCE disables certain features
52# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
53AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
54
Martin v. Löwisbcd93962003-05-03 10:32:18 +000055# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
56# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
57# them.
58AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
59
Andrew MacIntyreabccf412003-07-02 13:53:25 +000060# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
61# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
62# them.
63AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
64
Martin v. Löwisd6320502004-08-12 13:45:08 +000065# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
66# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
67AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
68
Ronald Oussoren5640ce22008-06-05 12:58:24 +000069# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
70# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
71# them.
72AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
73
74
Martin v. Löwise981a4e2002-11-11 13:26:51 +000075define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000076
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000077# Arguments passed to configure.
78AC_SUBST(CONFIG_ARGS)
79CONFIG_ARGS="$ac_configure_args"
80
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000081AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +000082AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +000083 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +000084[
85 case $enableval in
86 yes)
87 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000088 if test ! -d "${enableval}"
89 then
90 enableval=/
91 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +000092 ;;
93 esac
94 case $enableval in
95 no)
96 UNIVERSALSDK=
97 enable_universalsdk=
98 ;;
99 *)
100 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000101 if test ! -d "${UNIVERSALSDK}"
102 then
103 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
104 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000105 ;;
106 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000107
Ronald Oussoren988117f2006-04-29 11:31:35 +0000108],[
109 UNIVERSALSDK=
110 enable_universalsdk=
111])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000112if test -n "${UNIVERSALSDK}"
113then
114 AC_MSG_RESULT(${UNIVERSALSDK})
115else
116 AC_MSG_RESULT(no)
117fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000118AC_SUBST(UNIVERSALSDK)
119
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000120AC_SUBST(ARCH_RUN_32BIT)
121
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000122UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000123AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000124AC_MSG_CHECKING(for --with-universal-archs)
125AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000126 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000127[
128 AC_MSG_RESULT($withval)
129 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000130 if test "${enable_universalsdk}" ; then
131 :
132 else
133 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
134 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000135],
136[
137 AC_MSG_RESULT(32-bit)
138])
139
140
141
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000142AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000143 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000144 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000145[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000146 if test "${enable_framework}"; then
147 :
148 else
149 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
150 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000151 PYTHONFRAMEWORK=${withval}
152 PYTHONFRAMEWORKDIR=${withval}.framework
153 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
154 ],[
155 PYTHONFRAMEWORK=Python
156 PYTHONFRAMEWORKDIR=Python.framework
157 PYTHONFRAMEWORKIDENTIFIER=org.python.python
158])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000159dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000160AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000161 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000162[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000163 case $enableval in
164 yes)
165 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000166 esac
167 case $enableval in
168 no)
169 PYTHONFRAMEWORK=
170 PYTHONFRAMEWORKDIR=no-framework
171 PYTHONFRAMEWORKPREFIX=
172 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000173 FRAMEWORKINSTALLFIRST=
174 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000175 FRAMEWORKALTINSTALLFIRST=
176 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000177 if test "x${prefix}" = "xNONE"; then
178 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
179 else
180 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
181 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000182 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000183 ;;
184 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000185 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000186 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000187 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000188 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000189 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
190 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000191 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000192
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000193 if test "x${prefix}" = "xNONE" ; then
194 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000195
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000196 else
197 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
198 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000199
200 case "${enableval}" in
201 /System*)
202 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
203 if test "${prefix}" = "NONE" ; then
204 # See below
205 FRAMEWORKUNIXTOOLSPREFIX="/usr"
206 fi
207 ;;
208
209 /Library*)
210 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
211 ;;
212
213 */Library/Frameworks)
214 MDIR="`dirname "${enableval}"`"
215 MDIR="`dirname "${MDIR}"`"
216 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
217
218 if test "${prefix}" = "NONE"; then
219 # User hasn't specified the
220 # --prefix option, but wants to install
221 # the framework in a non-default location,
222 # ensure that the compatibility links get
223 # installed relative to that prefix as well
224 # instead of in /usr/local.
225 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
226 fi
227 ;;
228
229 *)
230 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
231 ;;
232 esac
233
Jack Jansen127e56e2001-09-11 14:41:54 +0000234 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000235
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000236 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000237 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000238 AC_CONFIG_FILES(Mac/Makefile)
239 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
240 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000241 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
242 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000243 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000244 ],[
245 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000246 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000247 PYTHONFRAMEWORKPREFIX=
248 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000249 FRAMEWORKINSTALLFIRST=
250 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000251 FRAMEWORKALTINSTALLFIRST=
252 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000253 if test "x${prefix}" = "xNONE" ; then
254 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
255 else
256 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
257 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000258 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000259
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000260])
261AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000262AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000263AC_SUBST(PYTHONFRAMEWORKDIR)
264AC_SUBST(PYTHONFRAMEWORKPREFIX)
265AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000266AC_SUBST(FRAMEWORKINSTALLFIRST)
267AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000268AC_SUBST(FRAMEWORKALTINSTALLFIRST)
269AC_SUBST(FRAMEWORKALTINSTALLLAST)
270AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000271AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000272
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000273##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000274## AS_HELP_STRING([--with-dyld],
275## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000276##
Guido van Rossumb418f891996-07-30 18:06:02 +0000277# Set name for machine-dependent library files
278AC_SUBST(MACHDEP)
279AC_MSG_CHECKING(MACHDEP)
280if test -z "$MACHDEP"
281then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000282 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000283 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000284 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000285 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000286 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000287 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000288 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000289 ac_md_system=`echo $ac_sys_system |
290 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
291 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000292 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000293 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000294
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000295 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200296 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000297 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000298 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000299 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000300 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000301 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000302 esac
303fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000304
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000305# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
306# disable features if it is defined, without any means to access these
307# features as extensions. For these systems, we skip the definition of
308# _XOPEN_SOURCE. Before adding a system to the list to gain access to
309# some feature, make sure there is no alternative way to access this
310# feature. Also, when using wildcards, make sure you have verified the
311# need for not defining _XOPEN_SOURCE on all systems matching the
312# wildcard, and that the wildcard does not include future systems
313# (which may remove their limitations).
314dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
315case $ac_sys_system/$ac_sys_release in
316 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
317 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000318 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000319 # In addition, Stefan Krah confirms that issue #1244610 exists through
320 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200321 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000322 define_xopen_source=no
323 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
324 # also defined. This can be overridden by defining _BSD_SOURCE
325 # As this has a different meaning on Linux, only define it on OpenBSD
326 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
327 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200328 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000329 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
330 # also defined. This can be overridden by defining _BSD_SOURCE
331 # As this has a different meaning on Linux, only define it on OpenBSD
332 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
333 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000334 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
335 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
336 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000337 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000338 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000339 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
340 # request to enable features supported by the standard as a request
341 # to disable features not supported by the standard. The best way
342 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
343 # entirely and define __EXTENSIONS__ instead.
344 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000345 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000346 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
347 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000348 # Reconfirmed for 7.1.4 by Martin v. Loewis.
349 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000350 define_xopen_source=no;;
351 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000352 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000353 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000354 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000355 # On FreeBSD 4, the math functions C89 does not cover are never defined
356 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
357 FreeBSD/4.*)
358 define_xopen_source=no;;
359 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
360 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
361 # identifies itself as Darwin/7.*
362 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
363 # disables platform specific features beyond repair.
364 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
365 # has no effect, don't bother defining them
366 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000367 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000368 Darwin/1@<:@0-9@:>@.*)
369 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000370 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
371 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
372 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000373 AIX/4)
374 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000375 AIX/5)
376 if test `uname -r` -eq 1; then
377 define_xopen_source=no
378 fi
379 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000380 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
381 # defining NI_NUMERICHOST.
382 QNX/6.3.2)
383 define_xopen_source=no
384 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000385
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000386esac
387
388if test $define_xopen_source = yes
389then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000390 AC_DEFINE(_XOPEN_SOURCE, 600,
391 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000392
393 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
394 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
395 # several APIs are not declared. Since this is also needed in some
396 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000397 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
398 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000399
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000400 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
401
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000402fi
403
Guido van Rossum91922671997-10-09 20:24:13 +0000404#
405# SGI compilers allow the specification of the both the ABI and the
406# ISA on the command line. Depending on the values of these switches,
407# different and often incompatable code will be generated.
408#
409# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
410# thus supply support for various ABI/ISA combinations. The MACHDEP
411# variable is also adjusted.
412#
413AC_SUBST(SGI_ABI)
414if test ! -z "$SGI_ABI"
415then
416 CC="cc $SGI_ABI"
417 LDFLAGS="$SGI_ABI $LDFLAGS"
418 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
419fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000420AC_MSG_RESULT($MACHDEP)
421
Jack Jansen83f898c2002-12-30 22:23:40 +0000422# And add extra plat-mac for darwin
423AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000424AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000425AC_MSG_CHECKING(EXTRAPLATDIR)
426if test -z "$EXTRAPLATDIR"
427then
428 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000429 darwin)
430 EXTRAPLATDIR="\$(PLATMACDIRS)"
431 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
432 ;;
433 *)
434 EXTRAPLATDIR=""
435 EXTRAMACHDEPPATH=""
436 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000437 esac
438fi
439AC_MSG_RESULT($EXTRAPLATDIR)
440
Jack Jansen6b08a402004-06-03 12:41:45 +0000441# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
442# it may influence the way we can build extensions, so distutils
443# needs to check it
444AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000445AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000446CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000447EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000448
Mark Dickinson65134662008-04-25 16:11:04 +0000449AC_MSG_CHECKING(machine type as reported by uname -m)
450ac_sys_machine=`uname -m`
451AC_MSG_RESULT($ac_sys_machine)
452
Guido van Rossum627b2d71993-12-24 10:39:16 +0000453# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000454
455# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
456# for debug/optimization stuff. BASECFLAGS is for flags that are required
457# just to get things to compile and link. Users are free to override OPT
458# when running configure or make. The build should not break if they do.
459# BASECFLAGS should generally not be messed with, however.
460
461# XXX shouldn't some/most/all of this code be merged with the stuff later
462# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000463AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000464AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000465 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000466[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000467 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000468 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000469 without_gcc=yes;;
470 yes) CC=gcc
471 without_gcc=no;;
472 *) CC=$withval
473 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000474 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000475 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000476 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000477 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000478 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000479 case $BE_HOST_CPU in
480 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000481 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000482 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000483 BASECFLAGS="$BASECFLAGS -export pragma"
484 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000485 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000486 ;;
487 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000488 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000489 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000490 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000491 ;;
492 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000493 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000494 ;;
495 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000496 AR="\$(srcdir)/Modules/ar_beos"
497 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000498 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000499 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000500 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000501AC_MSG_RESULT($without_gcc)
502
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000503# If the user switches compilers, we can't believe the cache
504if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
505then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000506 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
507(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000508fi
509
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000510# If the user set CFLAGS, use this instead of the automatically
511# determined setting
512preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000513AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000514if test ! -z "$preset_cflags"
515then
516 CFLAGS=$preset_cflags
517fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000518
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000519AC_SUBST(CXX)
520AC_SUBST(MAINCC)
521AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
522AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000523 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000524 [compile main() and link python executable with C++ compiler]),
525[
526
527 case $withval in
528 no) with_cxx_main=no
529 MAINCC='$(CC)';;
530 yes) with_cxx_main=yes
531 MAINCC='$(CXX)';;
532 *) with_cxx_main=yes
533 MAINCC=$withval
534 if test -z "$CXX"
535 then
536 CXX=$withval
537 fi;;
538 esac], [
539 with_cxx_main=no
540 MAINCC='$(CC)'
541])
542AC_MSG_RESULT($with_cxx_main)
543
544preset_cxx="$CXX"
545if test -z "$CXX"
546then
547 case "$CC" in
548 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
549 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
550 esac
551 if test "$CXX" = "notfound"
552 then
553 CXX=""
554 fi
555fi
556if test -z "$CXX"
557then
558 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
559 if test "$CXX" = "notfound"
560 then
561 CXX=""
562 fi
563fi
564if test "$preset_cxx" != "$CXX"
565then
566 AC_MSG_WARN([
567
568 By default, distutils will build C++ extension modules with "$CXX".
569 If this is not intended, then set CXX on the configure command line.
570 ])
571fi
572
573
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000574# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000575AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000576
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000577# Check for unsupported systems
578case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000579atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000580 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
581 echo See README for details.
582 exit 1;;
583esac
584
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000585AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000586AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000587AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000588 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000589[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000590 case $withval in
591 no) EXEEXT=;;
592 yes) EXEEXT=.exe;;
593 *) EXEEXT=$withval;;
594 esac])
595AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000596
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000597# Test whether we're running on a non-case-sensitive system, in which
598# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000599AC_SUBST(BUILDEXEEXT)
600AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000601if test ! -d CaseSensitiveTestDir; then
602mkdir CaseSensitiveTestDir
603fi
604
605if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000606then
Jack Jansen1999ef42001-12-06 21:47:20 +0000607 AC_MSG_RESULT(yes)
608 BUILDEXEEXT=.exe
609else
610 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000611 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000612fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000613rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000614
Guido van Rossumdd997f71998-10-07 19:58:26 +0000615case $MACHDEP in
616bsdos*)
617 case $CC in
618 gcc) CC="$CC -D_HAVE_BSDI";;
619 esac;;
620esac
621
Guido van Rossum84561611997-08-21 00:08:11 +0000622case $ac_sys_system in
623hp*|HP*)
624 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000625 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000626 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000627SunOS*)
628 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000629 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000630 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000631esac
632
Martin v. Löwise8964d42001-03-06 12:09:07 +0000633
Neil Schemenauer61c51152001-01-26 16:18:16 +0000634AC_SUBST(LIBRARY)
635AC_MSG_CHECKING(LIBRARY)
636if test -z "$LIBRARY"
637then
638 LIBRARY='libpython$(VERSION).a'
639fi
640AC_MSG_RESULT($LIBRARY)
641
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000642# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000643# name of the library into which to insert object files). BLDLIBRARY is also
644# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
645# is blank as the main program is not linked directly against LDLIBRARY.
646# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
647# systems without shared libraries, LDLIBRARY is the same as LIBRARY
648# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
649# DLLLIBRARY is the shared (i.e., DLL) library.
650#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000651# RUNSHARED is used to run shared python without installed libraries
652#
653# INSTSONAME is the name of the shared library that will be use to install
654# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000655AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000656AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000657AC_SUBST(BLDLIBRARY)
658AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000659AC_SUBST(INSTSONAME)
660AC_SUBST(RUNSHARED)
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=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000667
Guido van Rossumfb842551997-08-06 23:42:07 +0000668# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000669# If CXX is set, and if it is needed to link a main function that was
670# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
671# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000672# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000673# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000674AC_SUBST(LINKCC)
675AC_MSG_CHECKING(LINKCC)
676if test -z "$LINKCC"
677then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000678 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000679 case $ac_sys_system in
680 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000681 exp_extra="\"\""
682 if test $ac_sys_release -ge 5 -o \
683 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
684 exp_extra="."
685 fi
686 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000687 QNX*)
688 # qcc must be used because the other compilers do not
689 # support -N.
690 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000691 esac
692fi
693AC_MSG_RESULT($LINKCC)
694
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000695# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
696# make sure we default having it set to "no": this is used by
697# distutils.unixccompiler to know if it should add --enable-new-dtags
698# to linker command lines, and failing to detect GNU ld simply results
699# in the same bahaviour as before.
700AC_SUBST(GNULD)
701AC_MSG_CHECKING(for GNU ld)
702ac_prog=ld
703if test "$GCC" = yes; then
704 ac_prog=`$CC -print-prog-name=ld`
705fi
706case `"$ac_prog" -V 2>&1 < /dev/null` in
707 *GNU*)
708 GNULD=yes;;
709 *)
710 GNULD=no;;
711esac
712AC_MSG_RESULT($GNULD)
713
Martin v. Löwis1142de32002-03-29 16:28:31 +0000714AC_MSG_CHECKING(for --enable-shared)
715AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000716 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000717
Martin v. Löwis1142de32002-03-29 16:28:31 +0000718if test -z "$enable_shared"
719then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000720 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000721 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000722 enable_shared="yes";;
723 *)
724 enable_shared="no";;
725 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000726fi
727AC_MSG_RESULT($enable_shared)
728
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000729AC_MSG_CHECKING(for --enable-profiling)
730AC_ARG_ENABLE(profiling,
Matthias Klose22520ea2010-05-08 10:14:46 +0000731 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000732[ac_save_cc="$CC"
733 CC="$CC -pg"
Matthias Klosec511b472010-05-08 11:01:39 +0000734 AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
735 [ac_enable_profiling="yes"],
736 [ac_enable_profiling="no"],
737 [ac_enable_profiling="no"])
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000738 CC="$ac_save_cc"])
739AC_MSG_RESULT($ac_enable_profiling)
740
741case "$ac_enable_profiling" in
742 "yes")
743 BASECFLAGS="-pg $BASECFLAGS"
744 LDFLAGS="-pg $LDFLAGS"
745 ;;
746esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000747
748AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000749
Guido van Rossumb8552162001-09-05 14:58:11 +0000750# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
751# library that we build, but we do not want to link against it (we
752# will find it with a -framework option). For this reason there is an
753# extra variable BLDLIBRARY against which Python and the extension
754# modules are linked, BLDLIBRARY. This is normally the same as
755# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000756if test "$enable_framework"
757then
758 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000759 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000760 BLDLIBRARY=''
761else
762 BLDLIBRARY='$(LDLIBRARY)'
763fi
764
Martin v. Löwis1142de32002-03-29 16:28:31 +0000765# Other platforms follow
766if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000767 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000768 case $ac_sys_system in
769 BeOS*)
770 LDLIBRARY='libpython$(VERSION).so'
771 ;;
772 CYGWIN*)
773 LDLIBRARY='libpython$(VERSION).dll.a'
774 DLLLIBRARY='libpython$(VERSION).dll'
775 ;;
776 SunOS*)
777 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000778 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000779 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000780 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000781 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200782 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000783 LDLIBRARY='libpython$(VERSION).so'
784 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000785 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000786 case $ac_sys_system in
787 FreeBSD*)
788 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
789 ;;
790 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000791 INSTSONAME="$LDLIBRARY".$SOVERSION
792 ;;
793 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000794 case `uname -m` in
795 ia64)
796 LDLIBRARY='libpython$(VERSION).so'
797 ;;
798 *)
799 LDLIBRARY='libpython$(VERSION).sl'
800 ;;
801 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000802 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000803 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000804 ;;
805 OSF*)
806 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000807 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000808 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000809 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000810 atheos*)
811 LDLIBRARY='libpython$(VERSION).so'
812 BLDLIBRARY='-L. -lpython$(VERSION)'
813 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
814 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000815 Darwin*)
816 LDLIBRARY='libpython$(VERSION).dylib'
817 BLDLIBRARY='-L. -lpython$(VERSION)'
818 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
819 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000820 AIX*)
821 LDLIBRARY='libpython$(VERSION).so'
822 RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
823 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000824
Martin v. Löwis1142de32002-03-29 16:28:31 +0000825 esac
Jason Tishler30765592003-09-04 11:04:06 +0000826else # shared is disabled
827 case $ac_sys_system in
828 CYGWIN*)
829 BLDLIBRARY='$(LIBRARY)'
830 LDLIBRARY='libpython$(VERSION).dll.a'
831 ;;
832 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000833fi
834
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000835AC_MSG_RESULT($LDLIBRARY)
836
Guido van Rossum627b2d71993-12-24 10:39:16 +0000837AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000838AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000839AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000840
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000841# tweak ARFLAGS only if the user didn't set it on the command line
842AC_SUBST(ARFLAGS)
843if test -z "$ARFLAGS"
844then
845 ARFLAGS="rc"
846fi
847
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000848AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000849AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000850if test $SVNVERSION = found
851then
852 SVNVERSION="svnversion \$(srcdir)"
853else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000854 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000855fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000856
Georg Brandl3a5508e2011-03-06 10:42:21 +0100857AC_SUBST(HGVERSION)
858AC_SUBST(HGTAG)
859AC_SUBST(HGBRANCH)
860AC_CHECK_PROG(HAS_HG, hg, found, not-found)
861if test $HAS_HG = found
862then
863 HGVERSION="hg id -i \$(srcdir)"
864 HGTAG="hg id -t \$(srcdir)"
865 HGBRANCH="hg id -b \$(srcdir)"
866else
867 HGVERSION=""
868 HGTAG=""
869 HGBRANCH=""
870fi
871
Neil Schemenauera42c8272001-03-31 00:01:55 +0000872case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000873bsdos*|hp*|HP*)
874 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000875 if test -z "$INSTALL"
876 then
877 INSTALL="${srcdir}/install-sh -c"
878 fi
879esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000880AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +0000881AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +0000882
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000883# Not every filesystem supports hard links
884AC_SUBST(LN)
885if test -z "$LN" ; then
886 case $ac_sys_system in
887 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000888 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000889 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000890 *) LN=ln;;
891 esac
892fi
893
Fred Drake9f715822001-07-11 06:27:00 +0000894# Check for --with-pydebug
895AC_MSG_CHECKING(for --with-pydebug)
896AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +0000897 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000898[
Fred Drake9f715822001-07-11 06:27:00 +0000899if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000900then
901 AC_DEFINE(Py_DEBUG, 1,
902 [Define if you want to build an interpreter with many run-time checks.])
903 AC_MSG_RESULT(yes);
904 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000905else AC_MSG_RESULT(no); Py_DEBUG='false'
906fi],
907[AC_MSG_RESULT(no)])
908
Skip Montanarodecc6a42003-01-01 20:07:49 +0000909# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
910# merged with this chunk of code?
911
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000912# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000913# ------------------------
914# (The following bit of code is complicated enough - please keep things
915# indented properly. Just pretend you're editing Python code. ;-)
916
917# There are two parallel sets of case statements below, one that checks to
918# see if OPT was set and one that does BASECFLAGS setting based upon
919# compiler and platform. BASECFLAGS tweaks need to be made even if the
920# user set OPT.
921
922# tweak OPT based on compiler and platform, only if the user didn't set
923# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000924AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +0000925if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000926then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000927 case $GCC in
928 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000929 if test "$CC" != 'g++' ; then
930 STRICT_PROTO="-Wstrict-prototypes"
931 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +0000932 # For gcc 4.x we need to use -fwrapv so lets check if its supported
933 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
934 WRAP="-fwrapv"
935 fi
Stefan Krah503e5e12011-09-14 15:19:42 +0200936
937 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +0100938 case $CC in
939 *clang*) WRAP="-fwrapv"
940 ;;
941 esac
Stefan Krah503e5e12011-09-14 15:19:42 +0200942
Skip Montanarodecc6a42003-01-01 20:07:49 +0000943 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000944 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000945 if test "$Py_DEBUG" = 'true' ; then
946 # Optimization messes up debuggers, so turn it off for
947 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +0000948 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000949 else
Guido van Rossum7c862f82007-12-13 20:50:10 +0000950 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000951 fi
952 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000953 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000954 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000955 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000956 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000957 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000958 SCO_SV*) OPT="$OPT -m486 -DSCO5"
959 ;;
960 esac
Fred Drake9f715822001-07-11 06:27:00 +0000961 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000962
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000963 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000964 OPT="-O"
965 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000966 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000967fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000968
Skip Montanarodecc6a42003-01-01 20:07:49 +0000969AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000970
971# The -arch flags for universal builds on OSX
972UNIVERSAL_ARCH_FLAGS=
973AC_SUBST(UNIVERSAL_ARCH_FLAGS)
974
Skip Montanarodecc6a42003-01-01 20:07:49 +0000975# tweak BASECFLAGS based on compiler and platform
976case $GCC in
977yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000978 # Python violates C99 rules, by casting between incompatible
979 # pointer types. GCC may generate bad code as a result of that,
980 # so use -fno-strict-aliasing if supported.
981 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
982 ac_save_cc="$CC"
983 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +0000984 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +0000985 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +0000986 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +0000987 [ac_cv_no_strict_aliasing_ok=yes],
988 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000989 CC="$ac_save_cc"
990 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
991 if test $ac_cv_no_strict_aliasing_ok = yes
992 then
993 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
994 fi
Mark Dickinson65134662008-04-25 16:11:04 +0000995
996 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
997 # support. Without this, treatment of subnormals doesn't follow
998 # the standard.
999 case $ac_sys_machine in
1000 alpha*)
1001 BASECFLAGS="$BASECFLAGS -mieee"
1002 ;;
1003 esac
1004
Skip Montanarodecc6a42003-01-01 20:07:49 +00001005 case $ac_sys_system in
1006 SCO_SV*)
1007 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1008 ;;
1009 # is there any other compiler on Darwin besides gcc?
1010 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001011 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1012 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001013 if test "${CC}" = gcc
1014 then
1015 AC_MSG_CHECKING(which compiler should be used)
1016 case "${UNIVERSALSDK}" in
1017 */MacOSX10.4u.sdk)
1018 # Build using 10.4 SDK, force usage of gcc when the
1019 # compiler is gcc, otherwise the user will get very
1020 # confusing error messages when building on OSX 10.6
1021 CC=gcc-4.0
1022 CPP=cpp-4.0
1023 ;;
1024 esac
1025 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001026 fi
1027
Benjamin Peterson4347c442008-07-17 15:59:24 +00001028 # Calculate the right deployment target for this build.
1029 #
1030 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1031 if test ${cur_target} '>' 10.2; then
1032 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001033 if test ${enable_universalsdk}; then
1034 if test "${UNIVERSAL_ARCHS}" = "all"; then
1035 # Ensure that the default platform for a
1036 # 4-way universal build is OSX 10.5,
1037 # that's the first OS release where
1038 # 4-way builds make sense.
1039 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001040
1041 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1042 cur_target='10.5'
1043
1044 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1045 cur_target='10.5'
1046
1047 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1048 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001049 fi
1050 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001051 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001052 # On Intel macs default to a deployment
1053 # target of 10.4, that's the first OSX
1054 # release with Intel support.
1055 cur_target="10.4"
1056 fi
1057 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001058 fi
1059 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1060
1061 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1062 # environment with a value that is the same as what we'll use
1063 # in the Makefile to ensure that we'll get the same compiler
1064 # environment during configure and build time.
1065 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1066 export MACOSX_DEPLOYMENT_TARGET
1067 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1068
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001069 if test "${enable_universalsdk}"; then
1070 UNIVERSAL_ARCH_FLAGS=""
1071 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1072 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1073 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001074 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001075
1076 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1077 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1078 LIPO_32BIT_FLAGS=""
1079 ARCH_RUN_32BIT="true"
1080
1081 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1082 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1083 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001084 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001085
1086 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1087 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1088 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001089 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001090
1091 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1092 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1093 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001094 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001095
1096 else
1097 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1098
1099 fi
1100
1101
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001102 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1103 if test "${UNIVERSALSDK}" != "/"
1104 then
1105 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1106 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1107 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001108 fi
1109
1110 fi
1111
1112
Skip Montanarodecc6a42003-01-01 20:07:49 +00001113 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001114 OSF*)
1115 BASECFLAGS="$BASECFLAGS -mieee"
1116 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001117 esac
1118 ;;
1119
1120*)
1121 case $ac_sys_system in
1122 OpenUNIX*|UnixWare*)
1123 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1124 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001125 OSF*)
1126 BASECFLAGS="$BASECFLAGS -ieee -std"
1127 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001128 SCO_SV*)
1129 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1130 ;;
1131 esac
1132 ;;
1133esac
1134
Fred Drakee1ceaa02001-12-04 20:55:47 +00001135if test "$Py_DEBUG" = 'true'; then
1136 :
1137else
1138 OPT="-DNDEBUG $OPT"
1139fi
1140
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001141if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001142then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001143 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001144fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001145
Neal Norwitz020c46a2006-01-07 21:39:28 +00001146# disable check for icc since it seems to pass, but generates a warning
1147if test "$CC" = icc
1148then
1149 ac_cv_opt_olimit_ok=no
1150fi
1151
Guido van Rossum91922671997-10-09 20:24:13 +00001152AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1153AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1154[ac_save_cc="$CC"
1155CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001156AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001157 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001158 [ac_cv_opt_olimit_ok=yes],
1159 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001160 )
Guido van Rossum91922671997-10-09 20:24:13 +00001161CC="$ac_save_cc"])
1162AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001163if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001164 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001165 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1166 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1167 # environment?
1168 Darwin*)
1169 ;;
1170 *)
1171 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1172 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001173 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001174else
1175 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1176 AC_CACHE_VAL(ac_cv_olimit_ok,
1177 [ac_save_cc="$CC"
1178 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001179 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001180 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001181 [ac_cv_olimit_ok=yes],
1182 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001183 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001184 CC="$ac_save_cc"])
1185 AC_MSG_RESULT($ac_cv_olimit_ok)
1186 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001187 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001188 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001189fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001190
Martin v. Löwisaac13162006-10-19 10:58:46 +00001191# Check whether GCC supports PyArg_ParseTuple format
1192if test "$GCC" = "yes"
1193then
1194 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1195 save_CFLAGS=$CFLAGS
1196 CFLAGS="$CFLAGS -Werror"
Matthias Klosec511b472010-05-08 11:01:39 +00001197 AC_COMPILE_IFELSE([
1198 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1199 ],[
1200 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1201 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1202 AC_MSG_RESULT(yes)
1203 ],[
1204 AC_MSG_RESULT(no)
1205 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001206 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001207fi
1208
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001209# On some compilers, pthreads are available without further options
1210# (e.g. MacOS X). On some of these systems, the compiler will not
1211# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1212# So we have to see first whether pthreads are available without
1213# options before we can check whether -Kpthread improves anything.
1214AC_MSG_CHECKING(whether pthreads are available without options)
1215AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001216[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001217#include <pthread.h>
1218
1219void* routine(void* p){return NULL;}
1220
1221int main(){
1222 pthread_t p;
1223 if(pthread_create(&p,NULL,routine,NULL)!=0)
1224 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001225 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001226 return 0;
1227}
Matthias Klosec511b472010-05-08 11:01:39 +00001228]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001229 ac_cv_pthread_is_default=yes
1230 ac_cv_kthread=no
1231 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001232],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001233])
1234AC_MSG_RESULT($ac_cv_pthread_is_default)
1235
1236
1237if test $ac_cv_pthread_is_default = yes
1238then
1239 ac_cv_kpthread=no
1240else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001241# -Kpthread, if available, provides the right #defines
1242# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001243# Some compilers won't report that they do not support -Kpthread,
1244# so we need to run a program to see whether it really made the
1245# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001246AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1247AC_CACHE_VAL(ac_cv_kpthread,
1248[ac_save_cc="$CC"
1249CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001250AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001251#include <pthread.h>
1252
1253void* routine(void* p){return NULL;}
1254
1255int main(){
1256 pthread_t p;
1257 if(pthread_create(&p,NULL,routine,NULL)!=0)
1258 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001259 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001260 return 0;
1261}
Matthias Klosec511b472010-05-08 11:01:39 +00001262]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001263CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001264AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001265fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001266
Skip Montanarod8d39a02003-07-10 20:44:10 +00001267if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001268then
1269# -Kthread, if available, provides the right #defines
1270# and linker options to make pthread_create available
1271# Some compilers won't report that they do not support -Kthread,
1272# so we need to run a program to see whether it really made the
1273# function available.
1274AC_MSG_CHECKING(whether $CC accepts -Kthread)
1275AC_CACHE_VAL(ac_cv_kthread,
1276[ac_save_cc="$CC"
1277CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001278AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001279#include <pthread.h>
1280
1281void* routine(void* p){return NULL;}
1282
1283int main(){
1284 pthread_t p;
1285 if(pthread_create(&p,NULL,routine,NULL)!=0)
1286 return 1;
1287 (void)pthread_detach(p);
1288 return 0;
1289}
Matthias Klosec511b472010-05-08 11:01:39 +00001290]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001291CC="$ac_save_cc"])
1292AC_MSG_RESULT($ac_cv_kthread)
1293fi
1294
Skip Montanarod8d39a02003-07-10 20:44:10 +00001295if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001296then
1297# -pthread, if available, provides the right #defines
1298# and linker options to make pthread_create available
1299# Some compilers won't report that they do not support -pthread,
1300# so we need to run a program to see whether it really made the
1301# function available.
1302AC_MSG_CHECKING(whether $CC accepts -pthread)
1303AC_CACHE_VAL(ac_cv_thread,
1304[ac_save_cc="$CC"
1305CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001306AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001307#include <pthread.h>
1308
1309void* routine(void* p){return NULL;}
1310
1311int main(){
1312 pthread_t p;
1313 if(pthread_create(&p,NULL,routine,NULL)!=0)
1314 return 1;
1315 (void)pthread_detach(p);
1316 return 0;
1317}
Matthias Klosec511b472010-05-08 11:01:39 +00001318]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001319CC="$ac_save_cc"])
1320AC_MSG_RESULT($ac_cv_pthread)
1321fi
1322
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001323# If we have set a CC compiler flag for thread support then
1324# check if it works for CXX, too.
1325ac_cv_cxx_thread=no
1326if test ! -z "$CXX"
1327then
1328AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1329ac_save_cxx="$CXX"
1330
1331if test "$ac_cv_kpthread" = "yes"
1332then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001333 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001334 ac_cv_cxx_thread=yes
1335elif test "$ac_cv_kthread" = "yes"
1336then
1337 CXX="$CXX -Kthread"
1338 ac_cv_cxx_thread=yes
1339elif test "$ac_cv_pthread" = "yes"
1340then
1341 CXX="$CXX -pthread"
1342 ac_cv_cxx_thread=yes
1343fi
1344
1345if test $ac_cv_cxx_thread = yes
1346then
1347 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1348 $CXX -c conftest.$ac_ext 2>&5
1349 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1350 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1351 then
1352 ac_cv_cxx_thread=yes
1353 else
1354 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001355 fi
1356 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001357fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001358AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001359fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001360CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001361
Fred Drakece81d592000-07-09 14:39:29 +00001362dnl # check for ANSI or K&R ("traditional") preprocessor
1363dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001364dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001365dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1366dnl int foo;
1367dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001368dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001369dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001370
Guido van Rossum627b2d71993-12-24 10:39:16 +00001371# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001372AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001373AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1374fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001375ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001376shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001377unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001378sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1379sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001380sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001381sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001382sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis0347a9a2006-10-27 07:06:52 +00001383sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001384bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001385AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001386AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001387
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001388# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001389AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001390#ifdef HAVE_CURSES_H
1391#include <curses.h>
1392#endif
1393])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001394
Martin v. Löwis11017b12006-01-14 18:12:57 +00001395# On Linux, netlink.h requires asm/types.h
1396AC_CHECK_HEADERS(linux/netlink.h,,,[
1397#ifdef HAVE_ASM_TYPES_H
1398#include <asm/types.h>
1399#endif
1400#ifdef HAVE_SYS_SOCKET_H
1401#include <sys/socket.h>
1402#endif
1403])
1404
Guido van Rossum627b2d71993-12-24 10:39:16 +00001405# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001406was_it_defined=no
1407AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001408AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1409 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1410])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001411AC_MSG_RESULT($was_it_defined)
1412
Neal Norwitz11690112002-07-30 01:08:28 +00001413# Check whether using makedev requires defining _OSF_SOURCE
1414AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001415AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001416#if defined(MAJOR_IN_MKDEV)
1417#include <sys/mkdev.h>
1418#elif defined(MAJOR_IN_SYSMACROS)
1419#include <sys/sysmacros.h>
1420#else
1421#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001422#endif ]], [[ makedev(0, 0) ]])],
1423[ac_cv_has_makedev=yes],
1424[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001425if test "$ac_cv_has_makedev" = "no"; then
1426 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001427 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001428#define _OSF_SOURCE 1
1429#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001430 ]], [[ makedev(0, 0) ]])],
1431[ac_cv_has_makedev=yes],
1432[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001433 if test "$ac_cv_has_makedev" = "yes"; then
1434 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1435 fi
1436fi
1437AC_MSG_RESULT($ac_cv_has_makedev)
1438if test "$ac_cv_has_makedev" = "yes"; then
1439 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1440fi
1441
Martin v. Löwis399a6892002-10-04 10:22:02 +00001442# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1443# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1444# defined, but the compiler does not support pragma redefine_extname,
1445# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1446# structures (such as rlimit64) without declaring them. As a
1447# work-around, disable LFS on such configurations
1448
1449use_lfs=yes
1450AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001451AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001452#define _LARGEFILE_SOURCE 1
1453#define _FILE_OFFSET_BITS 64
1454#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001455]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001456AC_MSG_RESULT($sol_lfs_bug)
1457if test "$sol_lfs_bug" = "yes"; then
1458 use_lfs=no
1459fi
1460
1461if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001462# Two defines needed to enable largefile support on various platforms
1463# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001464case $ac_sys_system/$ac_sys_release in
1465AIX*)
1466 AC_DEFINE(_LARGE_FILES, 1,
1467 [This must be defined on AIX systems to enable large file support.])
1468 ;;
1469esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001470AC_DEFINE(_LARGEFILE_SOURCE, 1,
1471[This must be defined on some systems to enable large file support.])
1472AC_DEFINE(_FILE_OFFSET_BITS, 64,
1473[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001474fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001475
Guido van Rossum300fda71996-08-19 21:58:16 +00001476# Add some code to confdefs.h so that the test for off_t works on SCO
1477cat >> confdefs.h <<\EOF
1478#if defined(SCO_DS)
1479#undef _OFF_T
1480#endif
1481EOF
1482
Guido van Rossumef2255b2000-03-10 22:30:29 +00001483# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001484AC_TYPE_MODE_T
1485AC_TYPE_OFF_T
1486AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001487AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001488AC_TYPE_SIZE_T
1489AC_TYPE_UID_T
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001490AC_TYPE_UINT32_T
1491AC_TYPE_UINT64_T
1492AC_TYPE_INT32_T
1493AC_TYPE_INT64_T
Christian Heimes951cc0f2008-01-31 23:08:23 +00001494AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001495 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001496
Guido van Rossumef2255b2000-03-10 22:30:29 +00001497# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001498# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001499AC_CHECK_SIZEOF(int, 4)
1500AC_CHECK_SIZEOF(long, 4)
1501AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001502AC_CHECK_SIZEOF(short, 2)
1503AC_CHECK_SIZEOF(float, 4)
1504AC_CHECK_SIZEOF(double, 8)
1505AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001506AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001507AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001508
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001509AC_MSG_CHECKING(for long long support)
1510have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001511AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001512 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1513 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001514],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001515AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001516if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001517AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001518fi
1519
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001520AC_MSG_CHECKING(for long double support)
1521have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001522AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001523 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1524 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001525],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001526AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001527if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001528AC_CHECK_SIZEOF(long double, 12)
1529fi
1530
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001531AC_MSG_CHECKING(for _Bool support)
1532have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001533AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001534 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1535 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001536],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001537AC_MSG_RESULT($have_c99_bool)
1538if test "$have_c99_bool" = yes ; then
1539AC_CHECK_SIZEOF(_Bool, 1)
1540fi
1541
Martin v. Löwisebe26702006-10-02 14:55:51 +00001542AC_CHECK_TYPES(uintptr_t,
1543 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001544 [], [#ifdef HAVE_STDINT_H
1545 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001546 #endif
1547 #ifdef HAVE_INTTYPES_H
1548 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001549 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001550
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001551AC_CHECK_SIZEOF(off_t, [], [
1552#ifdef HAVE_SYS_TYPES_H
1553#include <sys/types.h>
1554#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001555])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001556
1557AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001558if test "$have_long_long" = yes
1559then
1560if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001561 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001562 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1563 [Defined to enable large file support when an off_t is bigger than a long
1564 and long long is available and at least as big as an off_t. You may need
1565 to add some flags for configuration and compilation to enable this mode.
1566 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001567 AC_MSG_RESULT(yes)
1568else
1569 AC_MSG_RESULT(no)
1570fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001571else
1572 AC_MSG_RESULT(no)
1573fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001574
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001575AC_CHECK_SIZEOF(time_t, [], [
1576#ifdef HAVE_SYS_TYPES_H
1577#include <sys/types.h>
1578#endif
1579#ifdef HAVE_TIME_H
1580#include <time.h>
1581#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001582])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001583
Trent Mick635f6fb2000-08-23 21:33:05 +00001584# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001585ac_save_cc="$CC"
1586if test "$ac_cv_kpthread" = "yes"
1587then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001588elif test "$ac_cv_kthread" = "yes"
1589then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001590elif test "$ac_cv_pthread" = "yes"
1591then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001592fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001593AC_MSG_CHECKING(for pthread_t)
1594have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001595AC_COMPILE_IFELSE([
1596 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1597],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001598AC_MSG_RESULT($have_pthread_t)
1599if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001600 AC_CHECK_SIZEOF(pthread_t, [], [
1601#ifdef HAVE_PTHREAD_H
1602#include <pthread.h>
1603#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001604 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001605fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001606CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001607
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001608AC_MSG_CHECKING(for --enable-toolbox-glue)
1609AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001610 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001611
1612if test -z "$enable_toolbox_glue"
1613then
1614 case $ac_sys_system/$ac_sys_release in
1615 Darwin/*)
1616 enable_toolbox_glue="yes";;
1617 *)
1618 enable_toolbox_glue="no";;
1619 esac
1620fi
1621case "$enable_toolbox_glue" in
1622yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001623 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001624 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001625 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1626 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001627 ;;
1628*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001629 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001630 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001631 ;;
1632esac
1633AC_MSG_RESULT($enable_toolbox_glue)
1634
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001635
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001636AC_SUBST(OTHER_LIBTOOL_OPT)
1637case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001638 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001639 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1640 ;;
1641 Darwin/*)
1642 OTHER_LIBTOOL_OPT=""
1643 ;;
1644esac
1645
Ronald Oussoren25967582009-09-06 10:00:26 +00001646
1647ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001648AC_SUBST(LIBTOOL_CRUFT)
1649case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001650 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001651 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1652 if test "${enable_universalsdk}"; then
1653 :
1654 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001655 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001656 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001657 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001658 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001659 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001660 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001661 if test ${gcc_version} '<' 4.0
1662 then
1663 LIBTOOL_CRUFT="-lcc_dynamic"
1664 else
1665 LIBTOOL_CRUFT=""
1666 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001667 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001668 #include <unistd.h>
1669 int main(int argc, char*argv[])
1670 {
1671 if (sizeof(long) == 4) {
1672 return 0;
1673 } else {
1674 return 1;
1675 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001676 }
Matthias Klosec511b472010-05-08 11:01:39 +00001677 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001678
1679 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001680 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001681 i386)
1682 MACOSX_DEFAULT_ARCH="i386"
1683 ;;
1684 ppc)
1685 MACOSX_DEFAULT_ARCH="ppc"
1686 ;;
1687 *)
1688 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1689 ;;
1690 esac
1691 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001692 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001693 i386)
1694 MACOSX_DEFAULT_ARCH="x86_64"
1695 ;;
1696 ppc)
1697 MACOSX_DEFAULT_ARCH="ppc64"
1698 ;;
1699 *)
1700 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1701 ;;
1702 esac
1703
1704 #ARCH_RUN_32BIT="true"
1705 fi
1706
1707 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001708 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001709 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001710esac
1711
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001712AC_MSG_CHECKING(for --enable-framework)
1713if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001714then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001715 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001716 # -F. is needed to allow linking to the framework while
1717 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001718 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1719 [Define if you want to produce an OpenStep/Rhapsody framework
1720 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001721 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001722 if test $enable_shared = "yes"
1723 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001724 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
Ronald Oussoren450d5612009-06-08 21:12:41 +00001725 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001726else
1727 AC_MSG_RESULT(no)
1728fi
1729
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001730AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001731case $ac_sys_system/$ac_sys_release in
1732 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001733 AC_DEFINE(WITH_DYLD, 1,
1734 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1735 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1736 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001737 AC_MSG_RESULT(always on for Darwin)
1738 ;;
1739 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001740 AC_MSG_RESULT(no)
1741 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001742esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001743
Guido van Rossumac405f61994-09-12 10:56:06 +00001744# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001745AC_SUBST(SO)
1746AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001747AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001748AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001749AC_SUBST(CCSHARED)
1750AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001751# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001752# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001753AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001754if test -z "$SO"
1755then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001756 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001757 hp*|HP*)
1758 case `uname -m` in
1759 ia64) SO=.so;;
1760 *) SO=.sl;;
1761 esac
1762 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001763 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001764 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001765 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001766else
1767 # this might also be a termcap variable, see #610332
1768 echo
1769 echo '====================================================================='
1770 echo '+ +'
1771 echo '+ WARNING: You have set SO in your environment. +'
1772 echo '+ Do you really mean to change the extension for shared libraries? +'
1773 echo '+ Continuing in 10 seconds to let you to ponder. +'
1774 echo '+ +'
1775 echo '====================================================================='
1776 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001777fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001778AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001779
Neal Norwitz58e28882006-05-19 07:00:58 +00001780AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001781# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001782# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001783# (Shared libraries in this instance are shared modules to be loaded into
1784# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001785AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001786if test -z "$LDSHARED"
1787then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001788 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001789 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001790 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001791 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001792 ;;
1793 BeOS*)
1794 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001795 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001796 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001797 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001798 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001799 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001800 if test "$GCC" = "yes" ; then
1801 LDSHARED='$(CC) -shared'
1802 LDCXXSHARED='$(CXX) -shared'
1803 else
1804 LDSHARED='$(CC) -G'
1805 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001806 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001807 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001808 if test "$GCC" = "yes" ; then
1809 LDSHARED='$(CC) -shared'
1810 LDCXXSHARED='$(CXX) -shared'
1811 else
1812 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001813 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001814 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001815 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001816 LDSHARED='$(CC) -bundle'
1817 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001818 if test "$enable_framework" ; then
1819 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001820 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1821 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001822 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001823 else
1824 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001825 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001826 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001827 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001828 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001829 LDSHARED='$(CC) -bundle'
1830 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001831 if test "$enable_framework" ; then
1832 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001833 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1834 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001835 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001836 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001837 # No framework, use the Python app as bundle-loader
1838 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001839 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001840 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001841 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001842 Darwin/*)
1843 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1844 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001845
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001846 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001847 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001848 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001849 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001850 fi
Stefan Krah3a3e2032010-11-28 15:30:05 +00001851 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
1852 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001853 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001854 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00001855 LDSHARED='$(CC) -bundle'
1856 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001857 if test "$enable_framework" ; then
1858 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001859 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1860 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001861 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001862 else
1863 # No framework, use the Python app as bundle-loader
1864 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1865 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001866 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001867 fi
1868 fi
1869 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001870 Linux*|GNU*|QNX*)
1871 LDSHARED='$(CC) -shared'
1872 LDCXXSHARED='$(CXX) -shared';;
1873 BSD/OS*/4*)
1874 LDSHARED="gcc -shared"
1875 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001876 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001877 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001878 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00001879 LDSHARED='$(CC) -shared'
1880 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001881 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00001882 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00001883 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001884 OpenBSD*)
1885 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1886 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00001887 LDSHARED='$(CC) -shared $(CCSHARED)'
1888 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001889 else
1890 case `uname -r` in
1891 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1892 LDSHARED="ld -Bshareable ${LDFLAGS}"
1893 ;;
1894 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001895 LDSHARED='$(CC) -shared $(CCSHARED)'
1896 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001897 ;;
1898 esac
1899 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001900 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00001901 LDSHARED='$(CC) -shared'
1902 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001903 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001904 if test "$GCC" = "yes" ; then
1905 LDSHARED='$(CC) -shared'
1906 LDCXXSHARED='$(CXX) -shared'
1907 else
1908 LDSHARED='$(CC) -G'
1909 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001910 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001911 SCO_SV*)
1912 LDSHARED='$(CC) -Wl,-G,-Bexport'
1913 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1914 CYGWIN*)
1915 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1916 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
1917 atheos*)
1918 LDSHARED="gcc -shared"
1919 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001920 *) LDSHARED="ld";;
1921 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001922fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001923AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001924LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001925BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001926# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001927# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001928AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001929if test -z "$CCSHARED"
1930then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001931 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001932 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00001933 then CCSHARED="-fPIC";
1934 elif test `uname -p` = sparc;
1935 then CCSHARED="-xcode=pic32";
1936 else CCSHARED="-Kpic";
1937 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001938 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001939 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001940 else CCSHARED="+z";
1941 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001942 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001943 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001944 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001945 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001946 if test "$GCC" = "yes"
1947 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001948 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001949 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001950 SCO_SV*)
1951 if test "$GCC" = "yes"
1952 then CCSHARED="-fPIC"
1953 else CCSHARED="-Kpic -belf"
1954 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001955 IRIX*/6*) case $CC in
1956 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001957 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001958 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001959 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001960 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001961fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001962AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001963# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001964# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001965AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001966if test -z "$LINKFORSHARED"
1967then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001968 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001969 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001970 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001971 LINKFORSHARED="-Wl,-E -Wl,+s";;
1972# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001973 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001974 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001975 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001976 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001977 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1978 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001979 # not used by the core itself but which needs to be in the core so
1980 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001981 # -prebind is no longer used, because it actually seems to give a
1982 # slowdown in stead of a speedup, maybe due to the large number of
1983 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001984
1985 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001986 if test "$enable_framework"
1987 then
Jack Jansenda49e192005-01-07 13:08:22 +00001988 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001989 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001990 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001991 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001992 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001993 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001994 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001995 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1996 then
1997 LINKFORSHARED="-Wl,--export-dynamic"
1998 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001999 SunOS/5*) case $CC in
2000 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002001 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002002 then
2003 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002004 fi;;
2005 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002006 CYGWIN*)
2007 if test $enable_shared = "no"
2008 then
2009 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2010 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002011 QNX*)
2012 # -Wl,-E causes the symbols to be added to the dynamic
2013 # symbol table so that they can be found when a module
2014 # is loaded. -N 2048K causes the stack size to be set
2015 # to 2048 kilobytes so that the stack doesn't overflow
2016 # when running test_compile.py.
2017 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002018 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002019fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002020AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002021
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002022
Neil Schemenauer61c51152001-01-26 16:18:16 +00002023AC_SUBST(CFLAGSFORSHARED)
2024AC_MSG_CHECKING(CFLAGSFORSHARED)
2025if test ! "$LIBRARY" = "$LDLIBRARY"
2026then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002027 case $ac_sys_system in
2028 CYGWIN*)
2029 # Cygwin needs CCSHARED when building extension DLLs
2030 # but not when building the interpreter DLL.
2031 CFLAGSFORSHARED='';;
2032 *)
2033 CFLAGSFORSHARED='$(CCSHARED)'
2034 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002035fi
2036AC_MSG_RESULT($CFLAGSFORSHARED)
2037
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002038# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2039# library (with --enable-shared).
2040# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002041# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2042# if it is not required, since it creates a dependency of the shared library
2043# to LIBS. This, in turn, means that applications linking the shared libpython
2044# don't need to link LIBS explicitly. The default should be only changed
2045# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002046AC_SUBST(SHLIBS)
2047AC_MSG_CHECKING(SHLIBS)
2048case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002049 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002050 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002051esac
2052AC_MSG_RESULT($SHLIBS)
2053
2054
Guido van Rossum627b2d71993-12-24 10:39:16 +00002055# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002056AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2057AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002058
Skip Montanaro4d756af2008-12-01 01:55:22 +00002059# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002060if test "$with_threads" = "yes" -o -z "$with_threads"; then
2061 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2062 # posix4 on Solaris 2.6
2063 # pthread (first!) on Linux
2064fi
2065
Martin v. Löwis19d17342003-06-14 21:03:05 +00002066# check if we need libintl for locale functions
2067AC_CHECK_LIB(intl, textdomain,
2068 AC_DEFINE(WITH_LIBINTL, 1,
2069 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002070
2071# checks for system dependent C++ extensions support
2072case "$ac_sys_system" in
2073 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002074 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002075 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002076 [[loadAndInit("", 0, "")]])
2077 ],[
2078 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002079 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2080 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002081 AC_MSG_RESULT(yes)
2082 ],[
2083 AC_MSG_RESULT(no)
2084 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002085 *) ;;
2086esac
2087
Guido van Rossum70c7f481998-03-26 18:44:10 +00002088# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002089# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002090AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002091AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002092
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002093case "$ac_sys_system" in
2094BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002095AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2096;;
2097esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002098
Guido van Rossumc5a39031996-07-31 17:35:03 +00002099AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002100AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002101 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002102[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002103AC_MSG_RESULT($withval)
2104LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002105],
2106[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002107
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002108AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2109
Benjamin Peterson2c196742009-12-31 03:17:18 +00002110# Check for use of the system expat library
2111AC_MSG_CHECKING(for --with-system-expat)
2112AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002113 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2114 [],
2115 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002116
2117AC_MSG_RESULT($with_system_expat)
2118
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002119# Check for use of the system libffi library
2120AC_MSG_CHECKING(for --with-system-ffi)
2121AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002122 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2123 [],
2124 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002125
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002126if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002127 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2128else
2129 LIBFFI_INCLUDEDIR=""
2130fi
2131AC_SUBST(LIBFFI_INCLUDEDIR)
2132
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002133AC_MSG_RESULT($with_system_ffi)
2134
Matthias Klose10cbe482009-04-29 17:18:19 +00002135# Check for --with-dbmliborder
2136AC_MSG_CHECKING(for --with-dbmliborder)
2137AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002138 AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
Matthias Klose10cbe482009-04-29 17:18:19 +00002139[
2140if test x$with_dbmliborder = xyes
2141then
2142AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2143else
2144 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2145 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2146 then
2147 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2148 fi
2149 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002150fi])
2151AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002152
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002153# Determine if signalmodule should be used.
2154AC_SUBST(USE_SIGNAL_MODULE)
2155AC_SUBST(SIGNAL_OBJS)
2156AC_MSG_CHECKING(for --with-signal-module)
2157AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002158 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002159
2160if test -z "$with_signal_module"
2161then with_signal_module="yes"
2162fi
2163AC_MSG_RESULT($with_signal_module)
2164
2165if test "${with_signal_module}" = "yes"; then
2166 USE_SIGNAL_MODULE=""
2167 SIGNAL_OBJS=""
2168else
2169 USE_SIGNAL_MODULE="#"
2170 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2171fi
2172
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002173# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002174AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002175USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002176
Guido van Rossum54d93d41997-01-22 20:51:58 +00002177AC_MSG_CHECKING(for --with-dec-threads)
2178AC_SUBST(LDLAST)
2179AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002180 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002181[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002182AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002183LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002184if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002185 with_thread="$withval";
2186fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002187[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002188
Martin v. Löwis11437992002-04-12 09:54:03 +00002189# Templates for things AC_DEFINEd more than once.
2190# For a single AC_DEFINE, no template is needed.
2191AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2192AH_TEMPLATE(_REENTRANT,
2193 [Define to force use of thread-safe errno, h_errno, and other functions])
2194AH_TEMPLATE(WITH_THREAD,
2195 [Define if you want to compile in rudimentary thread support])
2196
Guido van Rossum54d93d41997-01-22 20:51:58 +00002197AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002198dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002199AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002200 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002201
Barry Warsawc0d24d82000-06-29 16:12:00 +00002202# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002203dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002204AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002205 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002206 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002207
2208if test -z "$with_threads"
2209then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002210fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002211AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002212
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002213AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002214if test "$with_threads" = "no"
2215then
2216 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002217elif test "$ac_cv_pthread_is_default" = yes
2218then
2219 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002220 # Defining _REENTRANT on system with POSIX threads should not hurt.
2221 AC_DEFINE(_REENTRANT)
2222 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002223 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002224elif test "$ac_cv_kpthread" = "yes"
2225then
2226 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002227 if test "$ac_cv_cxx_thread" = "yes"; then
2228 CXX="$CXX -Kpthread"
2229 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002230 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002231 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002232 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002233elif test "$ac_cv_kthread" = "yes"
2234then
2235 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002236 if test "$ac_cv_cxx_thread" = "yes"; then
2237 CXX="$CXX -Kthread"
2238 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002239 AC_DEFINE(WITH_THREAD)
2240 posix_threads=yes
2241 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002242elif test "$ac_cv_pthread" = "yes"
2243then
2244 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002245 if test "$ac_cv_cxx_thread" = "yes"; then
2246 CXX="$CXX -pthread"
2247 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002248 AC_DEFINE(WITH_THREAD)
2249 posix_threads=yes
2250 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002251else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002252 if test ! -z "$with_threads" -a -d "$with_threads"
2253 then LDFLAGS="$LDFLAGS -L$with_threads"
2254 fi
2255 if test ! -z "$withval" -a -d "$withval"
2256 then LDFLAGS="$LDFLAGS -L$withval"
2257 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002258
2259 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002260 # define _POSIX_THREADS in unistd.h. Some apparently don't
2261 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002262 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2263 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002264 [
2265#include <unistd.h>
2266#ifdef _POSIX_THREADS
2267yes
2268#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002269 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2270 AC_MSG_RESULT($unistd_defines_pthreads)
2271
Martin v. Löwis130fb172001-07-19 11:00:41 +00002272 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002273 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2274 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002275 AC_DEFINE(HURD_C_THREADS, 1,
2276 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002277 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002278 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002279 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2280 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002281 AC_DEFINE(MACH_C_THREADS, 1,
2282 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002283 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002284 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002285 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002286 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002287 [AC_MSG_RESULT($withval)
2288 AC_DEFINE([WITH_THREAD])
2289 AC_DEFINE([HAVE_PTH], 1,
2290 [Define if you have GNU PTH threads.])
2291 LIBS="-lpth $LIBS"
2292 THREADOBJ="Python/thread.o"],
2293 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002294
2295 # Just looking for pthread_create in libpthread is not enough:
2296 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2297 # So we really have to include pthread.h, and then link.
2298 _libs=$LIBS
2299 LIBS="$LIBS -lpthread"
2300 AC_MSG_CHECKING([for pthread_create in -lpthread])
Matthias Klosec511b472010-05-08 11:01:39 +00002301 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002302
Matthias Klosec511b472010-05-08 11:01:39 +00002303void * start_routine (void *arg) { exit (0); }]], [[
2304pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002305 AC_MSG_RESULT(yes)
2306 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002307 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002308 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002309 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002310 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002311 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002312 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002313 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2314 AC_DEFINE(ATHEOS_THREADS, 1,
2315 [Define this if you have AtheOS threads.])
2316 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002317 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002318 AC_DEFINE(BEOS_THREADS, 1,
2319 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002320 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002321 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002322 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002323 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002324 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002325 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002326 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002327 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002328 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002329 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002330 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002331 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002332 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002333 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002334 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002335 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002336 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002337 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002338 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002339
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002340 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2341 LIBS="$LIBS -lmpc"
2342 THREADOBJ="Python/thread.o"
2343 USE_THREAD_MODULE=""])
2344
2345 if test "$posix_threads" != "yes"; then
2346 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2347 LIBS="$LIBS -lthread"
2348 THREADOBJ="Python/thread.o"
2349 USE_THREAD_MODULE=""])
2350 fi
2351
2352 if test "$USE_THREAD_MODULE" != "#"
2353 then
2354 # If the above checks didn't disable threads, (at least) OSF1
2355 # needs this '-threads' argument during linking.
2356 case $ac_sys_system in
2357 OSF1) LDLAST=-threads;;
2358 esac
2359 fi
2360fi
2361
2362if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002363 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002364 AC_DEFINE(_POSIX_THREADS, 1,
2365 [Define if you have POSIX threads,
2366 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002367 fi
2368
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002369 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2370 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002371 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002372 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002373 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002374 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002375 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002376 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002377 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002378 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002379 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002380 esac
2381
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002382 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2383 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Matthias Klosec511b472010-05-08 11:01:39 +00002384 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002385 void *foo(void *parm) {
2386 return NULL;
2387 }
2388 main() {
2389 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002390 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002391 if (pthread_attr_init(&attr)) exit(-1);
2392 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002393 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002394 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002395 }]])],
2396 [ac_cv_pthread_system_supported=yes],
2397 [ac_cv_pthread_system_supported=no],
2398 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002399 ])
2400 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2401 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002402 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002403 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002404 AC_CHECK_FUNCS(pthread_sigmask,
2405 [case $ac_sys_system in
2406 CYGWIN*)
2407 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2408 [Define if pthread_sigmask() does not work on your system.])
2409 ;;
2410 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002411fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002412
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002413
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002414# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002415AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002416AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002417AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002418[ --enable-ipv6 Enable ipv6 (with ipv4) support
2419 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002420[ case "$enableval" in
2421 no)
2422 AC_MSG_RESULT(no)
2423 ipv6=no
2424 ;;
2425 *) AC_MSG_RESULT(yes)
2426 AC_DEFINE(ENABLE_IPV6)
2427 ipv6=yes
2428 ;;
2429 esac ],
2430
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002431[
2432dnl the check does not work on cross compilation case...
Matthias Klosec511b472010-05-08 11:01:39 +00002433 AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002434#include <sys/types.h>
2435#include <sys/socket.h>
2436main()
2437{
2438 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2439 exit(1);
2440 else
2441 exit(0);
2442}
Matthias Klosec511b472010-05-08 11:01:39 +00002443]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002444 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002445 ipv6=yes
2446],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002447 AC_MSG_RESULT(no)
2448 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002449],[
2450 AC_MSG_RESULT(no)
2451 ipv6=no
2452])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002453
2454if test "$ipv6" = "yes"; then
2455 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002456 AC_COMPILE_IFELSE([
2457 AC_LANG_PROGRAM([[#include <sys/types.h>
2458#include <netinet/in.h>]],
2459 [[struct sockaddr_in6 x;
2460 x.sin6_scope_id;]])
2461 ],[
2462 AC_MSG_RESULT(yes)
2463 ipv6=yes
2464 ],[
2465 AC_MSG_RESULT(no, IPv6 disabled)
2466 ipv6=no
2467 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002468fi
2469
2470if test "$ipv6" = "yes"; then
2471 AC_DEFINE(ENABLE_IPV6)
2472fi
2473])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002474
2475ipv6type=unknown
2476ipv6lib=none
2477ipv6trylibc=no
2478
2479if test "$ipv6" = "yes"; then
2480 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002481 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2482 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002483 case $i in
2484 inria)
2485 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002486 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002487#include <netinet/in.h>
2488#ifdef IPV6_INRIA_VERSION
2489yes
2490#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002491 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002492 ;;
2493 kame)
2494 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002495 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002496#include <netinet/in.h>
2497#ifdef __KAME__
2498yes
2499#endif],
2500 [ipv6type=$i;
2501 ipv6lib=inet6
2502 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002503 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002504 ;;
2505 linux-glibc)
2506 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002507 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002508#include <features.h>
2509#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2510yes
2511#endif],
2512 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002513 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002514 ;;
2515 linux-inet6)
2516 dnl http://www.v6.linux.or.jp/
2517 if test -d /usr/inet6; then
2518 ipv6type=$i
2519 ipv6lib=inet6
2520 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002521 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002522 fi
2523 ;;
2524 solaris)
2525 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002526 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002527 ipv6type=$i
2528 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002529 fi
2530 fi
2531 ;;
2532 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002533 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002534#include <sys/param.h>
2535#ifdef _TOSHIBA_INET6
2536yes
2537#endif],
2538 [ipv6type=$i;
2539 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002540 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002541 ;;
2542 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002543 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002544#include </usr/local/v6/include/sys/v6config.h>
2545#ifdef __V6D__
2546yes
2547#endif],
2548 [ipv6type=$i;
2549 ipv6lib=v6;
2550 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002551 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002552 ;;
2553 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002554 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002555#include <sys/param.h>
2556#ifdef _ZETA_MINAMI_INET6
2557yes
2558#endif],
2559 [ipv6type=$i;
2560 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002561 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002562 ;;
2563 esac
2564 if test "$ipv6type" != "unknown"; then
2565 break
2566 fi
2567 done
2568 AC_MSG_RESULT($ipv6type)
2569fi
2570
2571if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2572 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2573 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2574 echo "using lib$ipv6lib"
2575 else
2576 if test $ipv6trylibc = "yes"; then
2577 echo "using libc"
2578 else
2579 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2580 echo "You need to fetch lib$ipv6lib.a from appropriate"
2581 echo 'ipv6 kit and compile beforehand.'
2582 exit 1
2583 fi
2584 fi
2585fi
2586
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002587AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002588AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002589 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002590],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002591 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002592 AC_MSG_RESULT(yes)
2593],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002594 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002595])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002596
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002597# Check for --with-doc-strings
2598AC_MSG_CHECKING(for --with-doc-strings)
2599AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002600 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002601
2602if test -z "$with_doc_strings"
2603then with_doc_strings="yes"
2604fi
2605if test "$with_doc_strings" != "no"
2606then
2607 AC_DEFINE(WITH_DOC_STRINGS, 1,
2608 [Define if you want documentation strings in extension modules])
2609fi
2610AC_MSG_RESULT($with_doc_strings)
2611
Neil Schemenauera35c6882001-02-27 04:45:05 +00002612# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002613AC_MSG_CHECKING(for --with-tsc)
2614AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002615 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002616if test "$withval" != no
2617then
2618 AC_DEFINE(WITH_TSC, 1,
2619 [Define to profile with the Pentium timestamp counter])
2620 AC_MSG_RESULT(yes)
2621else AC_MSG_RESULT(no)
2622fi],
2623[AC_MSG_RESULT(no)])
2624
2625# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002626AC_MSG_CHECKING(for --with-pymalloc)
2627AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002628 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002629
2630if test -z "$with_pymalloc"
2631then with_pymalloc="yes"
2632fi
2633if test "$with_pymalloc" != "no"
2634then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002635 AC_DEFINE(WITH_PYMALLOC, 1,
2636 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002637fi
2638AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002639
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002640# Check for Valgrind support
2641AC_MSG_CHECKING([for --with-valgrind])
2642AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002643 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002644 with_valgrind=no)
2645AC_MSG_RESULT([$with_valgrind])
2646if test "$with_valgrind" != no; then
2647 AC_CHECK_HEADER([valgrind/valgrind.h],
2648 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2649 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2650 )
2651fi
2652
Barry Warsawef82cd72000-06-30 16:21:01 +00002653# Check for --with-wctype-functions
2654AC_MSG_CHECKING(for --with-wctype-functions)
2655AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002656 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002657[
Barry Warsawef82cd72000-06-30 16:21:01 +00002658if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002659then
2660 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2661 [Define if you want wctype.h functions to be used instead of the
2662 one supplied by Python itself. (see Include/unicodectype.h).])
2663 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002664else AC_MSG_RESULT(no)
2665fi],
2666[AC_MSG_RESULT(no)])
2667
Guido van Rossum68242b51996-05-28 22:53:03 +00002668# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002669AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002670DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002671
Guido van Rossume97ee181999-12-20 21:27:22 +00002672# the dlopen() function means we might want to use dynload_shlib.o. some
2673# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002674AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002675
2676# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2677# loading of modules.
2678AC_SUBST(DYNLOADFILE)
2679AC_MSG_CHECKING(DYNLOADFILE)
2680if test -z "$DYNLOADFILE"
2681then
2682 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002683 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2684 if test "$ac_cv_func_dlopen" = yes
2685 then DYNLOADFILE="dynload_shlib.o"
2686 else DYNLOADFILE="dynload_aix.o"
2687 fi
2688 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002689 BeOS*) DYNLOADFILE="dynload_beos.o";;
2690 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002691 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2692 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002693 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002694 *)
2695 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2696 # out any dynamic loading
2697 if test "$ac_cv_func_dlopen" = yes
2698 then DYNLOADFILE="dynload_shlib.o"
2699 else DYNLOADFILE="dynload_stub.o"
2700 fi
2701 ;;
2702 esac
2703fi
2704AC_MSG_RESULT($DYNLOADFILE)
2705if test "$DYNLOADFILE" != "dynload_stub.o"
2706then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002707 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2708 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002709fi
2710
Jack Jansenc49e5b72001-06-19 15:00:23 +00002711# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2712
2713AC_SUBST(MACHDEP_OBJS)
2714AC_MSG_CHECKING(MACHDEP_OBJS)
2715if test -z "$MACHDEP_OBJS"
2716then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002717 MACHDEP_OBJS=$extra_machdep_objs
2718else
2719 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002720fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002721AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002722
Guido van Rossum627b2d71993-12-24 10:39:16 +00002723# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002724AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2725 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002726 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002727 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitrou30b3b352009-12-02 20:37:54 +00002728 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002729 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002730 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002731 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2732 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002733 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002734 setlocale setregid setreuid setresuid setresgid \
2735 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002736 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002737 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002738 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002739
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002740# For some functions, having a definition is not sufficient, since
2741# we want to take their address.
2742AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002743AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2744 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2745 AC_MSG_RESULT(yes)],
2746 [AC_MSG_RESULT(no)
2747])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002748AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002749AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2750 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2751 AC_MSG_RESULT(yes)],
2752 [AC_MSG_RESULT(no)
2753])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002754AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002755AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2756 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2757 AC_MSG_RESULT(yes)],
2758 [AC_MSG_RESULT(no)
2759])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002760AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002761AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2762 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2763 AC_MSG_RESULT(yes)],
2764 [AC_MSG_RESULT(no)
2765])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002766AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002767AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2768 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2769 AC_MSG_RESULT(yes)],
2770 [AC_MSG_RESULT(no)
2771])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002772AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002773AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2774 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2775 AC_MSG_RESULT(yes)],
2776 [AC_MSG_RESULT(no)
2777])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002778AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002779AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2780 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2781 AC_MSG_RESULT(yes)],
2782 [AC_MSG_RESULT(no)
2783])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002784AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002785AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002786#include <sys/types.h>
2787#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002788 ]], [[int x=kqueue()]])],
2789 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2790 AC_MSG_RESULT(yes)],
2791 [AC_MSG_RESULT(no)
2792])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002793# On some systems (eg. FreeBSD 5), we would find a definition of the
2794# functions ctermid_r, setgroups in the library, but no prototype
2795# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2796# address to avoid compiler warnings and potential miscompilations
2797# because of the missing prototypes.
2798
2799AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002800AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002801#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002802]], [[void* p = ctermid_r]])],
2803 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2804 AC_MSG_RESULT(yes)],
2805 [AC_MSG_RESULT(no)
2806])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002807
Antoine Pitroub170f172010-09-10 18:47:36 +00002808AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2809 [AC_COMPILE_IFELSE(
2810 [AC_LANG_PROGRAM(
2811 [#include <sys/file.h>],
2812 [void* p = flock]
2813 )],
2814 [ac_cv_flock_decl=yes],
2815 [ac_cv_flock_decl=no]
2816 )
Matthias Klosec511b472010-05-08 11:01:39 +00002817])
Antoine Pitroub170f172010-09-10 18:47:36 +00002818if test "x${ac_cv_flock_decl}" = xyes; then
2819 AC_CHECK_FUNCS(flock,,
2820 AC_CHECK_LIB(bsd,flock,
2821 [AC_DEFINE(HAVE_FLOCK)
2822 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2823 ])
2824 )
Antoine Pitrou85729812010-09-07 14:55:24 +00002825fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002826
2827AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00002828AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002829#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002830]], [[void* p = getpagesize]])],
2831 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2832 AC_MSG_RESULT(yes)],
2833 [AC_MSG_RESULT(no)
2834])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002835
Charles-François Natali93a11752011-11-27 13:01:35 +01002836AC_MSG_CHECKING(for broken unsetenv)
2837AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2838#include <stdlib.h>
2839]], [[int res = unsetenv("DUMMY")]])],
2840 [AC_MSG_RESULT(no)],
2841 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
2842 AC_MSG_RESULT(yes)
2843])
2844
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002845dnl check for true
2846AC_CHECK_PROGS(TRUE, true, /bin/true)
2847
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002848dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2849dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002850AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002851 AC_CHECK_LIB(resolv, inet_aton)
2852)
2853
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002854# On Tru64, chflags seems to be present, but calling it will
2855# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00002856AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07002857AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002858#include <sys/stat.h>
2859#include <unistd.h>
2860int main(int argc, char*argv[])
2861{
2862 if(chflags(argv[0], 0) != 0)
2863 return 1;
2864 return 0;
2865}
Ned Deily43e10542011-06-27 23:41:53 -07002866]])],
Matthias Klosec511b472010-05-08 11:01:39 +00002867[ac_cv_have_chflags=yes],
2868[ac_cv_have_chflags=no],
2869[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00002870])
2871if test "$ac_cv_have_chflags" = cross ; then
2872 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2873fi
2874if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07002875 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002876fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002877
Gregory P. Smithbb213892009-11-02 01:37:37 +00002878AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07002879AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002880#include <sys/stat.h>
2881#include <unistd.h>
2882int main(int argc, char*argv[])
2883{
2884 if(lchflags(argv[0], 0) != 0)
2885 return 1;
2886 return 0;
2887}
Ned Deily43e10542011-06-27 23:41:53 -07002888]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00002889])
2890if test "$ac_cv_have_lchflags" = cross ; then
2891 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2892fi
2893if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07002894 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002895fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002896
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002897dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00002898dnl
2899dnl On MacOSX the linker will search for dylibs on the entire linker path
2900dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2901dnl to revert to a more traditional unix behaviour and make it possible to
2902dnl override the system libz with a local static library of libz. Temporarily
2903dnl add that flag to our CFLAGS as well to ensure that we check the version
2904dnl of libz that will be used by setup.py.
2905dnl The -L/usr/local/lib is needed as wel to get the same compilation
2906dnl environment as setup.py (and leaving it out can cause configure to use the
2907dnl wrong version of the library)
2908case $ac_sys_system/$ac_sys_release in
2909Darwin/*)
2910 _CUR_CFLAGS="${CFLAGS}"
2911 _CUR_LDFLAGS="${LDFLAGS}"
2912 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2913 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2914 ;;
2915esac
2916
Matthias Klose5183ebd2010-04-24 16:38:36 +00002917AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002918
Ronald Oussorenf8752642006-07-06 10:13:35 +00002919case $ac_sys_system/$ac_sys_release in
2920Darwin/*)
2921 CFLAGS="${_CUR_CFLAGS}"
2922 LDFLAGS="${_CUR_LDFLAGS}"
2923 ;;
2924esac
2925
Martin v. Löwise9416172003-05-03 10:12:45 +00002926AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00002927AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00002928#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002929]], [[void* p = hstrerror; hstrerror(0)]])],
2930 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2931 AC_MSG_RESULT(yes)],
2932 [AC_MSG_RESULT(no)
2933])
Martin v. Löwise9416172003-05-03 10:12:45 +00002934
2935AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00002936AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00002937#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002938#include <sys/socket.h>
2939#include <netinet/in.h>
2940#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002941]], [[void* p = inet_aton;inet_aton(0,0)]])],
2942 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2943 AC_MSG_RESULT(yes)],
2944 [AC_MSG_RESULT(no)
2945])
Martin v. Löwise9416172003-05-03 10:12:45 +00002946
2947AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00002948AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002949#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002950#include <sys/socket.h>
2951#include <netinet/in.h>
2952#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002953]], [[void* p = inet_pton]])],
2954 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2955 AC_MSG_RESULT(yes)],
2956 [AC_MSG_RESULT(no)
2957])
Martin v. Löwise9416172003-05-03 10:12:45 +00002958
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002959# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002960AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00002961AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002962#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002963#ifdef HAVE_GRP_H
2964#include <grp.h>
2965#endif
Matthias Klosec511b472010-05-08 11:01:39 +00002966]], [[void* p = setgroups]])],
2967 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2968 AC_MSG_RESULT(yes)],
2969 [AC_MSG_RESULT(no)
2970])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002971
Fred Drake8cef4cf2000-06-28 16:40:38 +00002972# check for openpty and forkpty
2973
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002974AC_CHECK_FUNCS(openpty,,
2975 AC_CHECK_LIB(util,openpty,
2976 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2977 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2978 )
2979)
2980AC_CHECK_FUNCS(forkpty,,
2981 AC_CHECK_LIB(util,forkpty,
2982 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2983 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2984 )
2985)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002986
Brett Cannonaa5778d2008-03-18 04:09:00 +00002987# Stuff for expat.
2988AC_CHECK_FUNCS(memmove)
2989
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002990# check for long file support functions
2991AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2992
Brett Cannonaa5778d2008-03-18 04:09:00 +00002993AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002994AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00002995 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
2996 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
2997 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002998)
Jack Jansen150753c2003-03-29 22:07:47 +00002999AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003000 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3001 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3002 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003003)
3004AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003005 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3006 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3007 [],
3008 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3009 [Define if gettimeofday() does not have second (timezone) argument
3010 This is the case on Motorola V4 (R40V4.2)])
3011 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003012)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003013
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003014AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003015AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003016#if defined(MAJOR_IN_MKDEV)
3017#include <sys/mkdev.h>
3018#elif defined(MAJOR_IN_SYSMACROS)
3019#include <sys/sysmacros.h>
3020#else
3021#include <sys/types.h>
3022#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003023]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003024 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003025]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003026 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3027 [Define to 1 if you have the device macros.])
3028 AC_MSG_RESULT(yes)
3029],[
3030 AC_MSG_RESULT(no)
3031])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003032
3033# On OSF/1 V5.1, getaddrinfo is available, but a define
3034# for [no]getaddrinfo in netdb.h.
3035AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003036AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003037#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003038#include <sys/socket.h>
3039#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003040#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003041]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3042[have_getaddrinfo=yes],
3043[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003044AC_MSG_RESULT($have_getaddrinfo)
3045if test $have_getaddrinfo = yes
3046then
3047 AC_MSG_CHECKING(getaddrinfo bug)
3048 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003049 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003050#include <sys/types.h>
3051#include <netdb.h>
3052#include <string.h>
3053#include <sys/socket.h>
3054#include <netinet/in.h>
3055
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003056int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003057{
3058 int passive, gaierr, inet4 = 0, inet6 = 0;
3059 struct addrinfo hints, *ai, *aitop;
3060 char straddr[INET6_ADDRSTRLEN], strport[16];
3061
3062 for (passive = 0; passive <= 1; passive++) {
3063 memset(&hints, 0, sizeof(hints));
3064 hints.ai_family = AF_UNSPEC;
3065 hints.ai_flags = passive ? AI_PASSIVE : 0;
3066 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003067 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003068 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3069 (void)gai_strerror(gaierr);
3070 goto bad;
3071 }
3072 for (ai = aitop; ai; ai = ai->ai_next) {
3073 if (ai->ai_addr == NULL ||
3074 ai->ai_addrlen == 0 ||
3075 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3076 straddr, sizeof(straddr), strport, sizeof(strport),
3077 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3078 goto bad;
3079 }
3080 switch (ai->ai_family) {
3081 case AF_INET:
3082 if (strcmp(strport, "54321") != 0) {
3083 goto bad;
3084 }
3085 if (passive) {
3086 if (strcmp(straddr, "0.0.0.0") != 0) {
3087 goto bad;
3088 }
3089 } else {
3090 if (strcmp(straddr, "127.0.0.1") != 0) {
3091 goto bad;
3092 }
3093 }
3094 inet4++;
3095 break;
3096 case AF_INET6:
3097 if (strcmp(strport, "54321") != 0) {
3098 goto bad;
3099 }
3100 if (passive) {
3101 if (strcmp(straddr, "::") != 0) {
3102 goto bad;
3103 }
3104 } else {
3105 if (strcmp(straddr, "::1") != 0) {
3106 goto bad;
3107 }
3108 }
3109 inet6++;
3110 break;
3111 case AF_UNSPEC:
3112 goto bad;
3113 break;
3114 default:
3115 /* another family support? */
3116 break;
3117 }
3118 }
3119 }
3120
3121 if (!(inet4 == 0 || inet4 == 2))
3122 goto bad;
3123 if (!(inet6 == 0 || inet6 == 2))
3124 goto bad;
3125
3126 if (aitop)
3127 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003128 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003129
3130 bad:
3131 if (aitop)
3132 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003133 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003134}
Matthias Klosec511b472010-05-08 11:01:39 +00003135]]])],
3136[ac_cv_buggy_getaddrinfo=no],
3137[ac_cv_buggy_getaddrinfo=yes],
3138[ac_cv_buggy_getaddrinfo=yes]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003139fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003140
Benjamin Peterson75fed812010-11-01 01:47:19 +00003141AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3142
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003143if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003144then
3145 if test $ipv6 = yes
3146 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003147 echo 'Fatal: You must get working getaddrinfo() function.'
3148 echo ' or you can specify "--disable-ipv6"'.
3149 exit 1
3150 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003151else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003152 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003153fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003154
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003155AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003156
Guido van Rossum627b2d71993-12-24 10:39:16 +00003157# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003158AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003159AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003160AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003161AC_CHECK_MEMBERS([struct stat.st_rdev])
3162AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003163AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003164AC_CHECK_MEMBERS([struct stat.st_gen])
3165AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003166AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003167
3168AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003169AC_CACHE_VAL(ac_cv_header_time_altzone,[
3170 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3171 [ac_cv_header_time_altzone=yes],
3172 [ac_cv_header_time_altzone=no])
3173 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003174AC_MSG_RESULT($ac_cv_header_time_altzone)
3175if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003176 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003177fi
3178
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003179was_it_defined=no
3180AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003181AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003182#include <sys/types.h>
3183#include <sys/select.h>
3184#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003185]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003186 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3187 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3188 (which you can't on SCO ODT 3.0).])
3189 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003190],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003191AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003192
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003193AC_MSG_CHECKING(for addrinfo)
3194AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003195AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3196 [ac_cv_struct_addrinfo=yes],
3197 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003198AC_MSG_RESULT($ac_cv_struct_addrinfo)
3199if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003200 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003201fi
3202
3203AC_MSG_CHECKING(for sockaddr_storage)
3204AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003205AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003206# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003207# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3208 [ac_cv_struct_sockaddr_storage=yes],
3209 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003210AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3211if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003212 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003213fi
3214
Guido van Rossum627b2d71993-12-24 10:39:16 +00003215# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003216
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003217AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003218AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003219
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003220works=no
3221AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003222AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3223 [works=yes],
3224 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003225)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003226AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003227
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003228works=no
3229AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003230AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3231 [works=yes],
3232 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003233)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003234AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003235
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003236have_prototypes=no
3237AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003238AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3239 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3240 [Define if your compiler supports function prototype])
3241 have_prototypes=yes],
3242 []
3243)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003244AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003245
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003246works=no
3247AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003248AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003249#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003250int foo(int x, ...) {
3251 va_list va;
3252 va_start(va, x);
3253 va_arg(va, int);
3254 va_arg(va, char *);
3255 va_arg(va, double);
3256 return 0;
3257}
Matthias Klosec511b472010-05-08 11:01:39 +00003258]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003259 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3260 [Define if your compiler supports variable length function prototypes
3261 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3262 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003263],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003264AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003265
Dave Cole331708b2004-08-09 04:51:41 +00003266# check for socketpair
3267AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003268AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003269#include <sys/types.h>
3270#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003271]], [[void *x=socketpair]])],
3272 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3273 AC_MSG_RESULT(yes)],
3274 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003275)
3276
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003277# check if sockaddr has sa_len member
3278AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003279AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3280#include <sys/socket.h>]], [[struct sockaddr x;
3281x.sa_len = 0;]])],
3282 [AC_MSG_RESULT(yes)
3283 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3284 [AC_MSG_RESULT(no)]
3285)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003286
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003287va_list_is_array=no
3288AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003289AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003290#ifdef HAVE_STDARG_PROTOTYPES
3291#include <stdarg.h>
3292#else
3293#include <varargs.h>
3294#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003295]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003296 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3297 va_list_is_array=yes
3298])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003299AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003300
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003301# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003302AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3303 [Define this if you have some version of gethostbyname_r()])
3304
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003305AC_CHECK_FUNC(gethostbyname_r, [
3306 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3307 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3308 OLD_CFLAGS=$CFLAGS
3309 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003311# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003312 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003313 char *name;
3314 struct hostent *he, *res;
3315 char buffer[2048];
3316 int buflen = 2048;
3317 int h_errnop;
3318
3319 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003320 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003321 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003322 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3323 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003324 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003325 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003326 AC_MSG_RESULT(no)
3327 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003328 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003329# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003330 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003331 char *name;
3332 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003333 char buffer[2048];
3334 int buflen = 2048;
3335 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003336
Matthias Klosec511b472010-05-08 11:01:39 +00003337 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3338 ]])],
3339 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003340 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003341 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3342 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003343 AC_MSG_RESULT(yes)
3344 ], [
3345 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003346 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3347 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3348# include <netdb.h>
3349 ]], [[
3350 char *name;
3351 struct hostent *he;
3352 struct hostent_data data;
3353
3354 (void) gethostbyname_r(name, he, &data);
3355 ]])],
3356 [
3357 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3358 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3359 [Define this if you have the 3-arg version of gethostbyname_r().])
3360 AC_MSG_RESULT(yes)
3361 ], [
3362 AC_MSG_RESULT(no)
3363 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003364 ])
3365 ])
3366 CFLAGS=$OLD_CFLAGS
3367], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003368 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003369])
3370AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3371AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3372AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003373AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003374AC_SUBST(HAVE_GETHOSTBYNAME)
3375
Guido van Rossum627b2d71993-12-24 10:39:16 +00003376# checks for system services
3377# (none yet)
3378
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003379# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003380AC_CHECK_FUNC(__fpu_control,
3381 [],
3382 [AC_CHECK_LIB(ieee, __fpu_control)
3383])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003384
Guido van Rossum93274221997-05-09 02:42:00 +00003385# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003386AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003387AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003388 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003389[
Guido van Rossum93274221997-05-09 02:42:00 +00003390if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003391then
3392 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3393 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3394 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003395else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003396fi],
3397[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003398
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003399# check for --with-libm=...
3400AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003401case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003402Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003403BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003404*) LIBM=-lm
3405esac
Guido van Rossum93274221997-05-09 02:42:00 +00003406AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003407AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003408 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003409[
Guido van Rossum93274221997-05-09 02:42:00 +00003410if test "$withval" = no
3411then LIBM=
3412 AC_MSG_RESULT(force LIBM empty)
3413elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003414then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003415 AC_MSG_RESULT(set LIBM="$withval")
3416else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003417fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003418[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003419
3420# check for --with-libc=...
3421AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003422AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003423AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003424 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003425[
Guido van Rossum93274221997-05-09 02:42:00 +00003426if test "$withval" = no
3427then LIBC=
3428 AC_MSG_RESULT(force LIBC empty)
3429elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003430then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003431 AC_MSG_RESULT(set LIBC="$withval")
3432else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003433fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003434[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003435
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003436# **************************************************
3437# * Check for various properties of floating point *
3438# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003439
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003440AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3441AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003442AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003443#include <string.h>
3444int main() {
3445 double x = 9006104071832581.0;
3446 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3447 return 0;
3448 else
3449 return 1;
3450}
Matthias Klosec511b472010-05-08 11:01:39 +00003451]])],
3452[ac_cv_little_endian_double=yes],
3453[ac_cv_little_endian_double=no],
3454[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003455AC_MSG_RESULT($ac_cv_little_endian_double)
3456if test "$ac_cv_little_endian_double" = yes
3457then
3458 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3459 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3460 with the least significant byte first])
3461fi
3462
3463AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3464AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003465AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003466#include <string.h>
3467int main() {
3468 double x = 9006104071832581.0;
3469 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3470 return 0;
3471 else
3472 return 1;
3473}
Matthias Klosec511b472010-05-08 11:01:39 +00003474]])],
3475[ac_cv_big_endian_double=yes],
3476[ac_cv_big_endian_double=no],
3477[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003478AC_MSG_RESULT($ac_cv_big_endian_double)
3479if test "$ac_cv_big_endian_double" = yes
3480then
3481 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3482 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3483 with the most significant byte first])
3484fi
3485
3486# Some ARM platforms use a mixed-endian representation for doubles.
3487# While Python doesn't currently have full support for these platforms
3488# (see e.g., issue 1762561), we can at least make sure that float <-> string
3489# conversions work.
3490AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3491AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003492AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003493#include <string.h>
3494int main() {
3495 double x = 9006104071832581.0;
3496 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3497 return 0;
3498 else
3499 return 1;
3500}
Matthias Klosec511b472010-05-08 11:01:39 +00003501]])],
3502[ac_cv_mixed_endian_double=yes],
3503[ac_cv_mixed_endian_double=no],
3504[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003505AC_MSG_RESULT($ac_cv_mixed_endian_double)
3506if test "$ac_cv_mixed_endian_double" = yes
3507then
3508 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3509 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3510 in ARM mixed-endian order (byte order 45670123)])
3511fi
3512
3513# The short float repr introduced in Python 3.1 requires the
3514# correctly-rounded string <-> double conversion functions from
3515# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3516# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003517# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003518# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003519
3520# This inline assembler syntax may also work for suncc and icc,
3521# so we try it on all platforms.
3522
3523AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003524AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003525 unsigned short cw;
3526 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3527 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003528]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003529AC_MSG_RESULT($have_gcc_asm_for_x87)
3530if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003531then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003532 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3533 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003534fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003535
Mark Dickinson04b27232009-01-04 12:29:36 +00003536# Detect whether system arithmetic is subject to x87-style double
3537# rounding issues. The result of this test has little meaning on non
3538# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3539# mode is round-to-nearest and double rounding issues are present, and
3540# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3541AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003542# $BASECFLAGS may affect the result
3543ac_save_cc="$CC"
3544CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003545AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003546#include <stdlib.h>
3547#include <math.h>
3548int main() {
3549 volatile double x, y, z;
3550 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3551 x = 0.99999999999999989; /* 1-2**-53 */
3552 y = 1./x;
3553 if (y != 1.)
3554 exit(0);
3555 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3556 x = 1e16;
3557 y = 2.99999;
3558 z = x + y;
3559 if (z != 1e16+4.)
3560 exit(0);
3561 /* both tests show evidence of double rounding */
3562 exit(1);
3563}
Matthias Klosec511b472010-05-08 11:01:39 +00003564]])],
3565[ac_cv_x87_double_rounding=no],
3566[ac_cv_x87_double_rounding=yes],
3567[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003568CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003569AC_MSG_RESULT($ac_cv_x87_double_rounding)
3570if test "$ac_cv_x87_double_rounding" = yes
3571then
3572 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3573 [Define if arithmetic is subject to x87-style double rounding issue])
3574fi
3575
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003576# ************************************
3577# * Check for mathematical functions *
3578# ************************************
3579
3580LIBS_SAVE=$LIBS
3581LIBS="$LIBS $LIBM"
3582
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003583# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3584# -0. on some architectures.
3585AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3586AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003587AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003588#include <math.h>
3589#include <stdlib.h>
3590int main() {
3591 /* return 0 if either negative zeros don't exist
3592 on this platform or if negative zeros exist
3593 and tanh(-0.) == -0. */
3594 if (atan2(0., -1.) == atan2(-0., -1.) ||
3595 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3596 else exit(1);
3597}
Matthias Klosec511b472010-05-08 11:01:39 +00003598]])],
3599[ac_cv_tanh_preserves_zero_sign=yes],
3600[ac_cv_tanh_preserves_zero_sign=no],
3601[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003602AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3603if test "$ac_cv_tanh_preserves_zero_sign" = yes
3604then
3605 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3606 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3607fi
3608
3609AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3610AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3611AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3612
3613LIBS=$LIBS_SAVE
3614
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003615# For multiprocessing module, check that sem_open
3616# actually works. For FreeBSD versions <= 7.2,
3617# the kernel module that provides POSIX semaphores
3618# isn't loaded by default, so an attempt to call
3619# sem_open results in a 'Signal 12' error.
3620AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3621AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003622AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003623#include <unistd.h>
3624#include <fcntl.h>
3625#include <stdio.h>
3626#include <semaphore.h>
3627#include <sys/stat.h>
3628
3629int main(void) {
3630 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3631 if (a == SEM_FAILED) {
3632 perror("sem_open");
3633 return 1;
3634 }
3635 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003636 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003637 return 0;
3638}
Matthias Klosec511b472010-05-08 11:01:39 +00003639]])],
3640[ac_cv_posix_semaphores_enabled=yes],
3641[ac_cv_posix_semaphores_enabled=no],
3642[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003643)
3644AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3645if test $ac_cv_posix_semaphores_enabled = no
3646then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003647 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3648 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003649fi
3650
Jesse Noller355b1262009-04-02 00:03:28 +00003651# Multiprocessing check for broken sem_getvalue
3652AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003653AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003654AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003655#include <unistd.h>
3656#include <fcntl.h>
3657#include <stdio.h>
3658#include <semaphore.h>
3659#include <sys/stat.h>
3660
3661int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003662 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003663 int count;
3664 int res;
3665 if(a==SEM_FAILED){
3666 perror("sem_open");
3667 return 1;
3668
3669 }
3670 res = sem_getvalue(a, &count);
3671 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003672 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003673 return res==-1 ? 1 : 0;
3674}
Matthias Klosec511b472010-05-08 11:01:39 +00003675]])],
3676[ac_cv_broken_sem_getvalue=no],
3677[ac_cv_broken_sem_getvalue=yes],
3678[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003679)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003680AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3681if test $ac_cv_broken_sem_getvalue = yes
3682then
3683 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3684 [define to 1 if your sem_getvalue is broken.])
3685fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003686
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003687# determine what size digit to use for Python's longs
3688AC_MSG_CHECKING([digit size for Python's longs])
3689AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003690AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003691[case $enable_big_digits in
3692yes)
3693 enable_big_digits=30 ;;
3694no)
3695 enable_big_digits=15 ;;
3696[15|30])
3697 ;;
3698*)
3699 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3700esac
3701AC_MSG_RESULT($enable_big_digits)
3702AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3703],
3704[AC_MSG_RESULT(no value specified)])
3705
Guido van Rossumef2255b2000-03-10 22:30:29 +00003706# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003707AC_CHECK_HEADER(wchar.h, [
3708 AC_DEFINE(HAVE_WCHAR_H, 1,
3709 [Define if the compiler provides a wchar.h header file.])
3710 wchar_h="yes"
3711],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003712wchar_h="no"
3713)
3714
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003715# determine wchar_t size
3716if test "$wchar_h" = yes
3717then
Guido van Rossum67b26592001-10-20 14:21:45 +00003718 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003719fi
3720
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003721AC_MSG_CHECKING(for UCS-4 tcl)
3722have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003723AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003724#include <tcl.h>
3725#if TCL_UTF_MAX != 6
3726# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003727#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003728 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3729 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003730],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003731AC_MSG_RESULT($have_ucs4_tcl)
3732
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003733# check whether wchar_t is signed or not
3734if test "$wchar_h" = yes
3735then
3736 # check whether wchar_t is signed or not
3737 AC_MSG_CHECKING(whether wchar_t is signed)
3738 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003739 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003740 #include <wchar.h>
3741 int main()
3742 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003743 /* Success: exit code 0 */
3744 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003745 }
Matthias Klosec511b472010-05-08 11:01:39 +00003746 ]])],
3747 [ac_cv_wchar_t_signed=yes],
3748 [ac_cv_wchar_t_signed=no],
3749 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003750 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3751fi
3752
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003753AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003754dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003755AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003756 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003757 [],
3758 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003759
3760if test $enable_unicode = yes
3761then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003762 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003763 case "$have_ucs4_tcl" in
3764 yes) enable_unicode="ucs4"
3765 ;;
3766 *) enable_unicode="ucs2"
3767 ;;
3768 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003769fi
3770
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003771AH_TEMPLATE(Py_UNICODE_SIZE,
3772 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003773case "$enable_unicode" in
3774ucs2) unicode_size="2"
3775 AC_DEFINE(Py_UNICODE_SIZE,2)
3776 ;;
3777ucs4) unicode_size="4"
3778 AC_DEFINE(Py_UNICODE_SIZE,4)
3779 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003780no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003781*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003782esac
3783
Martin v. Löwis11437992002-04-12 09:54:03 +00003784AH_TEMPLATE(PY_UNICODE_TYPE,
3785 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003786
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003787AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003788if test "$enable_unicode" = "no"
3789then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003790 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003791 AC_MSG_RESULT(not used)
3792else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003793 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003794 AC_DEFINE(Py_USING_UNICODE, 1,
3795 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003796
3797 # wchar_t is only usable if it maps to an unsigned type
3798 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003799 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003800 then
3801 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003802 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3803 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003804 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003805 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003806 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3807 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3808 then
3809 PY_UNICODE_TYPE="unsigned short"
3810 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3811 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3812 then
3813 PY_UNICODE_TYPE="unsigned long"
3814 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3815 else
3816 PY_UNICODE_TYPE="no type found"
3817 fi
3818 AC_MSG_RESULT($PY_UNICODE_TYPE)
3819fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003820
3821# check for endianness
3822AC_C_BIGENDIAN
3823
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003824# Check whether right shifting a negative integer extends the sign bit
3825# or fills with zeros (like the Cray J90, according to Tim Peters).
3826AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003827AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003828AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003829int main()
3830{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003831 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003832}
Matthias Klosec511b472010-05-08 11:01:39 +00003833]])],
3834[ac_cv_rshift_extends_sign=yes],
3835[ac_cv_rshift_extends_sign=no],
3836[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003837AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3838if test "$ac_cv_rshift_extends_sign" = no
3839then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003840 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3841 [Define if i>>j for signed int i does not extend the sign bit
3842 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003843fi
3844
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003845# check for getc_unlocked and related locking functions
3846AC_MSG_CHECKING(for getc_unlocked() and friends)
3847AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00003848AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003849 FILE *f = fopen("/dev/null", "r");
3850 flockfile(f);
3851 getc_unlocked(f);
3852 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00003853]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003854AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3855if test "$ac_cv_have_getc_unlocked" = yes
3856then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003857 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3858 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003859fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003860
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003861# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003862# save the value of LIBS so we don't actually link Python with readline
3863LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003864
3865# On some systems we need to link readline to a termcap compatible
3866# library. NOTE: Keep the precedence of listed libraries synchronised
3867# with setup.py.
3868py_cv_lib_readline=no
3869AC_MSG_CHECKING([how to link readline libs])
3870for py_libtermcap in "" ncursesw ncurses curses termcap; do
3871 if test -z "$py_libtermcap"; then
3872 READLINE_LIBS="-lreadline"
3873 else
3874 READLINE_LIBS="-lreadline -l$py_libtermcap"
3875 fi
3876 LIBS="$READLINE_LIBS $LIBS_no_readline"
3877 AC_LINK_IFELSE(
3878 [AC_LANG_CALL([],[readline])],
3879 [py_cv_lib_readline=yes])
3880 if test $py_cv_lib_readline = yes; then
3881 break
3882 fi
3883done
3884# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3885#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00003886if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003887 AC_MSG_RESULT([none])
3888else
3889 AC_MSG_RESULT([$READLINE_LIBS])
3890 AC_DEFINE(HAVE_LIBREADLINE, 1,
3891 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003892fi
3893
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003894# check for readline 2.1
3895AC_CHECK_LIB(readline, rl_callback_handler_install,
3896 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003897 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003898
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003899# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00003900AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3901 [have_readline=yes],
3902 [have_readline=no]
3903)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003904if test $have_readline = yes
3905then
3906 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3907 [readline/readline.h],
3908 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3909 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00003910 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3911 [readline/readline.h],
3912 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3913 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003914fi
3915
Martin v. Löwis0daad592001-09-30 21:09:59 +00003916# check for readline 4.0
3917AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003918 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003919 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003920
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003921# also in 4.0
3922AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3923 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003924 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003925
Guido van Rossum353ae582001-07-10 16:45:32 +00003926# check for readline 4.2
3927AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003928 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003929 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003930
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003931# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00003932AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3933 [have_readline=yes],
3934 [have_readline=no]
3935)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003936if test $have_readline = yes
3937then
3938 AC_EGREP_HEADER([extern int rl_catch_signals;],
3939 [readline/readline.h],
3940 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3941 [Define if you can turn off readline's signal handling.]), )
3942fi
3943
Martin v. Löwis82bca632006-02-10 20:49:30 +00003944# End of readline checks: restore LIBS
3945LIBS=$LIBS_no_readline
3946
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003947AC_MSG_CHECKING(for broken nice())
3948AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00003949AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003950int main()
3951{
3952 int val1 = nice(1);
3953 if (val1 != -1 && val1 == nice(2))
3954 exit(0);
3955 exit(1);
3956}
Matthias Klosec511b472010-05-08 11:01:39 +00003957]])],
3958[ac_cv_broken_nice=yes],
3959[ac_cv_broken_nice=no],
3960[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003961AC_MSG_RESULT($ac_cv_broken_nice)
3962if test "$ac_cv_broken_nice" = yes
3963then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003964 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3965 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003966fi
3967
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003968AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003969AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00003970AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003971#include <poll.h>
3972
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003973int main()
3974{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003975 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003976 int poll_test;
3977
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003978 close (42);
3979
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003980 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003981 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003982 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003983 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003984 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003985 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003986 return 1;
3987}
Matthias Klosec511b472010-05-08 11:01:39 +00003988]])],
3989[ac_cv_broken_poll=yes],
3990[ac_cv_broken_poll=no],
3991[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003992AC_MSG_RESULT($ac_cv_broken_poll)
3993if test "$ac_cv_broken_poll" = yes
3994then
3995 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3996 [Define if poll() sets errno on invalid file descriptors.])
3997fi
3998
Brett Cannon43802422005-02-10 20:48:03 +00003999# Before we can test tzset, we need to check if struct tm has a tm_zone
4000# (which is not required by ISO C or UNIX spec) and/or if we support
4001# tzname[]
4002AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004003
Brett Cannon43802422005-02-10 20:48:03 +00004004# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004005AC_MSG_CHECKING(for working tzset())
4006AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004007AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004008#include <stdlib.h>
4009#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004010#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004011
4012#if HAVE_TZNAME
4013extern char *tzname[];
4014#endif
4015
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004016int main()
4017{
Brett Cannon18367812003-09-19 00:59:16 +00004018 /* Note that we need to ensure that not only does tzset(3)
4019 do 'something' with localtime, but it works as documented
4020 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004021 This includes making sure that tzname is set properly if
4022 tm->tm_zone does not exist since it is the alternative way
4023 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004024
4025 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004026 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004027 */
4028
Brett Cannon43802422005-02-10 20:48:03 +00004029 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004030 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4031
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004032 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004033 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004034 if (localtime(&groundhogday)->tm_hour != 0)
4035 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004036#if HAVE_TZNAME
4037 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4038 if (strcmp(tzname[0], "UTC") ||
4039 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4040 exit(1);
4041#endif
Brett Cannon18367812003-09-19 00:59:16 +00004042
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004043 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004044 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004045 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004046 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004047#if HAVE_TZNAME
4048 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4049 exit(1);
4050#endif
Brett Cannon18367812003-09-19 00:59:16 +00004051
4052 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4053 tzset();
4054 if (localtime(&groundhogday)->tm_hour != 11)
4055 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004056#if HAVE_TZNAME
4057 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4058 exit(1);
4059#endif
4060
4061#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004062 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4063 exit(1);
4064 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4065 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004066#endif
Brett Cannon18367812003-09-19 00:59:16 +00004067
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004068 exit(0);
4069}
Matthias Klosec511b472010-05-08 11:01:39 +00004070]])],
4071[ac_cv_working_tzset=yes],
4072[ac_cv_working_tzset=no],
4073[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004074AC_MSG_RESULT($ac_cv_working_tzset)
4075if test "$ac_cv_working_tzset" = yes
4076then
4077 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4078 [Define if tzset() actually switches the local timezone in a meaningful way.])
4079fi
4080
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004081# Look for subsecond timestamps in struct stat
4082AC_MSG_CHECKING(for tv_nsec in struct stat)
4083AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004084AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004085struct stat st;
4086st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004087]])],
4088[ac_cv_stat_tv_nsec=yes],
4089[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004090AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4091if test "$ac_cv_stat_tv_nsec" = yes
4092then
4093 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4094 [Define if you have struct stat.st_mtim.tv_nsec])
4095fi
4096
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004097# Look for BSD style subsecond timestamps in struct stat
4098AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4099AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004100AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004101struct stat st;
4102st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004103]])],
4104[ac_cv_stat_tv_nsec2=yes],
4105[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004106AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4107if test "$ac_cv_stat_tv_nsec2" = yes
4108then
4109 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4110 [Define if you have struct stat.st_mtimensec])
4111fi
4112
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004113# On HP/UX 11.0, mvwdelch is a block with a return statement
4114AC_MSG_CHECKING(whether mvwdelch is an expression)
4115AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004116AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004117 int rtn;
4118 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004119]])],
4120[ac_cv_mvwdelch_is_expression=yes],
4121[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004122AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4123
4124if test "$ac_cv_mvwdelch_is_expression" = yes
4125then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004126 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4127 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004128fi
4129
4130AC_MSG_CHECKING(whether WINDOW has _flags)
4131AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004132AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004133 WINDOW *w;
4134 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004135]])],
4136[ac_cv_window_has_flags=yes],
4137[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004138AC_MSG_RESULT($ac_cv_window_has_flags)
4139
4140
4141if test "$ac_cv_window_has_flags" = yes
4142then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004143 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4144 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004145fi
4146
Walter Dörwald4994d952006-06-19 08:07:50 +00004147AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004148AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4149 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4150 AC_MSG_RESULT(yes)],
4151 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004152)
4153
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004154AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004155AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4156 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4157 AC_MSG_RESULT(yes)],
4158 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004159)
4160
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004161AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004162AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4163 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4164 AC_MSG_RESULT(yes)],
4165 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004166)
4167
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004168AC_MSG_CHECKING(for /dev/ptmx)
4169
4170if test -r /dev/ptmx
4171then
4172 AC_MSG_RESULT(yes)
4173 AC_DEFINE(HAVE_DEV_PTMX, 1,
4174 [Define if we have /dev/ptmx.])
4175else
4176 AC_MSG_RESULT(no)
4177fi
4178
4179AC_MSG_CHECKING(for /dev/ptc)
4180
4181if test -r /dev/ptc
4182then
4183 AC_MSG_RESULT(yes)
4184 AC_DEFINE(HAVE_DEV_PTC, 1,
4185 [Define if we have /dev/ptc.])
4186else
4187 AC_MSG_RESULT(no)
4188fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004189
Mark Dickinson82864d12009-11-15 16:18:58 +00004190if test "$have_long_long" = yes
4191then
4192 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4193 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004194 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004195 #include <stdio.h>
4196 #include <stddef.h>
4197 #include <string.h>
4198
4199 #ifdef HAVE_SYS_TYPES_H
4200 #include <sys/types.h>
4201 #endif
4202
4203 int main()
4204 {
4205 char buffer[256];
4206
4207 if (sprintf(buffer, "%lld", (long long)123) < 0)
4208 return 1;
4209 if (strcmp(buffer, "123"))
4210 return 1;
4211
4212 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4213 return 1;
4214 if (strcmp(buffer, "-123"))
4215 return 1;
4216
4217 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4218 return 1;
4219 if (strcmp(buffer, "123"))
4220 return 1;
4221
4222 return 0;
4223 }
Matthias Klosec511b472010-05-08 11:01:39 +00004224 ]]])],
4225 [ac_cv_have_long_long_format=yes],
4226 [ac_cv_have_long_long_format=no],
4227 [ac_cv_have_long_long_format=no])
Mark Dickinson82864d12009-11-15 16:18:58 +00004228 )
4229 AC_MSG_RESULT($ac_cv_have_long_long_format)
4230fi
4231
Mark Dickinson5ce84742009-12-31 20:48:04 +00004232if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004233then
4234 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4235 [Define to printf format modifier for long long type])
4236fi
4237
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004238if test $ac_sys_system = Darwin
4239then
4240 LIBS="$LIBS -framework CoreFoundation"
4241fi
4242
Mark Dickinson82864d12009-11-15 16:18:58 +00004243
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004244AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004245AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004246#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004247#include <stddef.h>
4248#include <string.h>
4249
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004250#ifdef HAVE_SYS_TYPES_H
4251#include <sys/types.h>
4252#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004253
4254#ifdef HAVE_SSIZE_T
4255typedef ssize_t Py_ssize_t;
4256#elif SIZEOF_VOID_P == SIZEOF_LONG
4257typedef long Py_ssize_t;
4258#else
4259typedef int Py_ssize_t;
4260#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004261
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004262int main()
4263{
4264 char buffer[256];
4265
Brett Cannon09d12362006-05-11 05:11:33 +00004266 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4267 return 1;
4268
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004269 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004270 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004271
4272 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4273 return 1;
4274
4275 if (strcmp(buffer, "-123"))
4276 return 1;
4277
Brett Cannon09d12362006-05-11 05:11:33 +00004278 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004279}
Matthias Klosec511b472010-05-08 11:01:39 +00004280]])],
4281[ac_cv_have_size_t_format=yes],
4282[ac_cv_have_size_t_format=no],
4283[ac_cv_have_size_t_format="cross -- assuming yes"
4284])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004285if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004286 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4287 [Define to printf format modifier for Py_ssize_t])
4288fi
Brett Cannon09d12362006-05-11 05:11:33 +00004289
Martin v. Löwis01c04012002-11-11 14:58:44 +00004290AC_CHECK_TYPE(socklen_t,,
4291 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004292 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004293#ifdef HAVE_SYS_TYPES_H
4294#include <sys/types.h>
4295#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004296#ifdef HAVE_SYS_SOCKET_H
4297#include <sys/socket.h>
4298#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004299])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004300
R. David Murray1d9d16e2010-10-16 00:43:13 +00004301case $ac_sys_system in
4302AIX*)
4303 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4304esac
4305
4306
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004307AC_SUBST(THREADHEADERS)
4308
4309for h in `(cd $srcdir;echo Python/thread_*.h)`
4310do
4311 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4312done
4313
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004314AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004315SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004316AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004317for dir in $SRCDIRS; do
4318 if test ! -d $dir; then
4319 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004320 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004321done
4322AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004323
Guido van Rossum627b2d71993-12-24 10:39:16 +00004324# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004325AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004326AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004327AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004328
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004329echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004330if test ! -f Modules/Setup
4331then
4332 cp $srcdir/Modules/Setup.dist Modules/Setup
4333fi
4334
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004335echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004336if test ! -f Modules/Setup.local
4337then
4338 echo "# Edit this file for local setup changes" >Modules/Setup.local
4339fi
4340
4341echo "creating Makefile"
4342$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4343 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004344 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004345
4346case $ac_sys_system in
4347BeOS)
4348 AC_MSG_WARN([
4349
4350 Support for BeOS is deprecated as of Python 2.6.
4351 See PEP 11 for the gory details.
4352 ])
4353 ;;
4354*) ;;
4355esac
4356
Neil Schemenauer66252162001-02-19 04:47:42 +00004357mv config.c Modules