blob: 4def2d42b899b5a5e82f8ad0e2a37eb5eb51fe2a [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Benjamin Peterson98b1b022008-11-30 14:43:23 +00004dnl NOTE: autoconf 2.64 doesn't seem to work (use 2.61).
Martin v. Löwis88afe662002-10-26 13:47:44 +00005
6# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00007m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00008
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009dnl Some m4 magic to ensure that the configure script is generated
10dnl by the correct autoconf version.
11m4_define([version_required],
12[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0,
13 [],
14 [m4_fatal([Autoconf version $1 is required for Python], 63)])
15])
16version_required(2.61)
17
Guido van Rossum76be6ed1995-01-02 18:33:54 +000018AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000019AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000020AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000021AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000022
Georg Brandlbcd64a32009-03-31 21:45:18 +000023dnl Ensure that if prefix is specified, it does not end in a slash. If
24dnl it does, we get path names containing '//' which is both ugly and
25dnl can cause trouble.
26
27dnl Last slash shouldn't be stripped if prefix=/
28if test "$prefix" != "/"; then
29 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
30fi
31
Martin v. Löwis8316feb2003-06-14 07:48:07 +000032dnl This is for stuff that absolutely must end up in pyconfig.h.
33dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000034AH_TOP([
35#ifndef Py_PYCONFIG_H
36#define Py_PYCONFIG_H
37])
Martin v. Löwis11437992002-04-12 09:54:03 +000038AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000039/* Define the macros needed if on a UnixWare 7.x system. */
40#if defined(__USLC__) && defined(__SCO_VERSION__)
41#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
42#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000043
44#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000045])
46
Martin v. Löwis8316feb2003-06-14 07:48:07 +000047# We don't use PACKAGE_ variables, and they cause conflicts
48# with other autoconf-based packages that include Python.h
49grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
50rm confdefs.h
51mv confdefs.h.new confdefs.h
52
Guido van Rossum642b6781997-07-19 19:35:41 +000053AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000054VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000055
Martin v. Löwis1142de32002-03-29 16:28:31 +000056AC_SUBST(SOVERSION)
57SOVERSION=1.0
58
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000059# The later defininition of _XOPEN_SOURCE disables certain features
60# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
61AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
62
Martin v. Löwisbcd93962003-05-03 10:32:18 +000063# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
64# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
65# them.
66AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
67
Andrew MacIntyreabccf412003-07-02 13:53:25 +000068# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
69# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
70# them.
71AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
72
Martin v. Löwisd6320502004-08-12 13:45:08 +000073# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
74# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
75AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
76
Ronald Oussoren5640ce22008-06-05 12:58:24 +000077# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
78# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
79# them.
80AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
81
82
Martin v. Löwise981a4e2002-11-11 13:26:51 +000083define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000084
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000085# Arguments passed to configure.
86AC_SUBST(CONFIG_ARGS)
87CONFIG_ARGS="$ac_configure_args"
88
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000089AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +000090AC_ARG_ENABLE(universalsdk,
Matthias Klose5183ebd2010-04-24 16:38:36 +000091 AC_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +000092[
93 case $enableval in
94 yes)
95 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +000096 if test ! -d "${enableval}"
97 then
98 enableval=/
99 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000100 ;;
101 esac
102 case $enableval in
103 no)
104 UNIVERSALSDK=
105 enable_universalsdk=
106 ;;
107 *)
108 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000109 if test ! -d "${UNIVERSALSDK}"
110 then
111 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
112 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000113 ;;
114 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000115
Ronald Oussoren988117f2006-04-29 11:31:35 +0000116],[
117 UNIVERSALSDK=
118 enable_universalsdk=
119])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000120if test -n "${UNIVERSALSDK}"
121then
122 AC_MSG_RESULT(${UNIVERSALSDK})
123else
124 AC_MSG_RESULT(no)
125fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000126AC_SUBST(UNIVERSALSDK)
127
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000128AC_SUBST(ARCH_RUN_32BIT)
129
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000130UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000131AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000132AC_MSG_CHECKING(for --with-universal-archs)
133AC_ARG_WITH(universal-archs,
Matthias Klose5183ebd2010-04-24 16:38:36 +0000134 AC_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 +0000135[
136 AC_MSG_RESULT($withval)
137 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000138 if test "${enable_universalsdk}" ; then
139 :
140 else
141 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
142 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000143],
144[
145 AC_MSG_RESULT(32-bit)
146])
147
148
149
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000150AC_ARG_WITH(framework-name,
Matthias Klose5183ebd2010-04-24 16:38:36 +0000151 AC_HELP_STRING([--with-framework-name=FRAMEWORK],
152 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000153[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000154 if test "${enable_framework}"; then
155 :
156 else
157 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
158 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000159 PYTHONFRAMEWORK=${withval}
160 PYTHONFRAMEWORKDIR=${withval}.framework
161 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
162 ],[
163 PYTHONFRAMEWORK=Python
164 PYTHONFRAMEWORKDIR=Python.framework
165 PYTHONFRAMEWORKIDENTIFIER=org.python.python
166])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000167dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000168AC_ARG_ENABLE(framework,
Matthias Klose5183ebd2010-04-24 16:38:36 +0000169 AC_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000170[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000171 case $enableval in
172 yes)
173 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000174 esac
175 case $enableval in
176 no)
177 PYTHONFRAMEWORK=
178 PYTHONFRAMEWORKDIR=no-framework
179 PYTHONFRAMEWORKPREFIX=
180 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000181 FRAMEWORKINSTALLFIRST=
182 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000183 FRAMEWORKALTINSTALLFIRST=
184 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000185 if test "x${prefix}" = "xNONE"; then
186 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
187 else
188 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
189 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000190 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000191 ;;
192 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000193 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000194 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000195 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000196 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000197 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
198 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000199 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000200
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000201 if test "x${prefix}" = "xNONE" ; then
202 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000203
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000204 else
205 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
206 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000207
208 case "${enableval}" in
209 /System*)
210 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
211 if test "${prefix}" = "NONE" ; then
212 # See below
213 FRAMEWORKUNIXTOOLSPREFIX="/usr"
214 fi
215 ;;
216
217 /Library*)
218 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
219 ;;
220
221 */Library/Frameworks)
222 MDIR="`dirname "${enableval}"`"
223 MDIR="`dirname "${MDIR}"`"
224 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
225
226 if test "${prefix}" = "NONE"; then
227 # User hasn't specified the
228 # --prefix option, but wants to install
229 # the framework in a non-default location,
230 # ensure that the compatibility links get
231 # installed relative to that prefix as well
232 # instead of in /usr/local.
233 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
234 fi
235 ;;
236
237 *)
238 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
239 ;;
240 esac
241
Jack Jansen127e56e2001-09-11 14:41:54 +0000242 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000243
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000244 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000245 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000246 AC_CONFIG_FILES(Mac/Makefile)
247 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
248 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000249 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
250 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000251 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000252 ],[
253 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000254 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000255 PYTHONFRAMEWORKPREFIX=
256 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000257 FRAMEWORKINSTALLFIRST=
258 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000259 FRAMEWORKALTINSTALLFIRST=
260 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000261 if test "x${prefix}" = "xNONE" ; then
262 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
263 else
264 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
265 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000266 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000267
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000268])
269AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000270AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000271AC_SUBST(PYTHONFRAMEWORKDIR)
272AC_SUBST(PYTHONFRAMEWORKPREFIX)
273AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000274AC_SUBST(FRAMEWORKINSTALLFIRST)
275AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000276AC_SUBST(FRAMEWORKALTINSTALLFIRST)
277AC_SUBST(FRAMEWORKALTINSTALLLAST)
278AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000279AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000280
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000281##AC_ARG_WITH(dyld,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000282## AC_HELP_STRING(--with-dyld,
283## Use (OpenStep|Rhapsody) dynamic linker))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000284##
Guido van Rossumb418f891996-07-30 18:06:02 +0000285# Set name for machine-dependent library files
286AC_SUBST(MACHDEP)
287AC_MSG_CHECKING(MACHDEP)
288if test -z "$MACHDEP"
289then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000290 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000291 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000292 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000293 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000294 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000295 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000296 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000297 ac_md_system=`echo $ac_sys_system |
298 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
299 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +0000300 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +0000301 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000302
Guido van Rossumbcd91e01997-03-20 20:46:29 +0000303 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000304 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000305 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000306 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000307 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000308 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000309 esac
310fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000311
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000312# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
313# disable features if it is defined, without any means to access these
314# features as extensions. For these systems, we skip the definition of
315# _XOPEN_SOURCE. Before adding a system to the list to gain access to
316# some feature, make sure there is no alternative way to access this
317# feature. Also, when using wildcards, make sure you have verified the
318# need for not defining _XOPEN_SOURCE on all systems matching the
319# wildcard, and that the wildcard does not include future systems
320# (which may remove their limitations).
321dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
322case $ac_sys_system/$ac_sys_release in
323 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
324 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000325 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000326 # In addition, Stefan Krah confirms that issue #1244610 exists through
327 # OpenBSD 4.6, but is fixed in 4.7.
328 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000329 define_xopen_source=no
330 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
331 # also defined. This can be overridden by defining _BSD_SOURCE
332 # As this has a different meaning on Linux, only define it on OpenBSD
333 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
334 ;;
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000335 OpenBSD/4.@<:@789@:>@)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000336 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
337 # also defined. This can be overridden by defining _BSD_SOURCE
338 # As this has a different meaning on Linux, only define it on OpenBSD
339 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
340 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000341 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
342 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
343 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000344 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 +0000345 define_xopen_source=no;;
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000346 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
347 # of union __?sigval. Reported by Stuart Bishop.
348 SunOS/5.6)
349 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000350 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
351 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000352 # Reconfirmed for 7.1.4 by Martin v. Loewis.
353 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000354 define_xopen_source=no;;
355 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000356 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000357 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000358 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000359 # On FreeBSD 4, the math functions C89 does not cover are never defined
360 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
361 FreeBSD/4.*)
362 define_xopen_source=no;;
363 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
364 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
365 # identifies itself as Darwin/7.*
366 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
367 # disables platform specific features beyond repair.
368 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
369 # has no effect, don't bother defining them
370 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000371 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000372 Darwin/1@<:@0-9@:>@.*)
373 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000374 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
375 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
376 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000377 AIX/4)
378 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000379 AIX/5)
380 if test `uname -r` -eq 1; then
381 define_xopen_source=no
382 fi
383 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000384 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
385 # defining NI_NUMERICHOST.
386 QNX/6.3.2)
387 define_xopen_source=no
388 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000389
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000390esac
391
392if test $define_xopen_source = yes
393then
Skip Montanarof0d5f792004-08-15 14:08:23 +0000394 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
395 # defined precisely as g++ defines it
Martin v. Löwis7dece662005-11-26 11:38:24 +0000396 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
397 # compiler
Skip Montanarof0d5f792004-08-15 14:08:23 +0000398 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis7dece662005-11-26 11:38:24 +0000399 SunOS/5.8|SunOS/5.9|SunOS/5.10)
Skip Montanarof0d5f792004-08-15 14:08:23 +0000400 AC_DEFINE(_XOPEN_SOURCE, 500,
401 Define to the level of X/Open that your system supports)
402 ;;
403 *)
404 AC_DEFINE(_XOPEN_SOURCE, 600,
405 Define to the level of X/Open that your system supports)
406 ;;
407 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000408
409 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
410 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
411 # several APIs are not declared. Since this is also needed in some
412 # cases for HP-UX, we define it globally.
Martin v. Löwis7dece662005-11-26 11:38:24 +0000413 # except for Solaris 10, where it must not be defined,
414 # as it implies XPG4.2
415 case $ac_sys_system/$ac_sys_release in
416 SunOS/5.10)
417 ;;
418 *)
419 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
420 Define to activate Unix95-and-earlier features)
421 ;;
422 esac
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000423
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000424 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
425
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000426fi
427
Guido van Rossum91922671997-10-09 20:24:13 +0000428#
429# SGI compilers allow the specification of the both the ABI and the
430# ISA on the command line. Depending on the values of these switches,
431# different and often incompatable code will be generated.
432#
433# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
434# thus supply support for various ABI/ISA combinations. The MACHDEP
435# variable is also adjusted.
436#
437AC_SUBST(SGI_ABI)
438if test ! -z "$SGI_ABI"
439then
440 CC="cc $SGI_ABI"
441 LDFLAGS="$SGI_ABI $LDFLAGS"
442 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
443fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000444AC_MSG_RESULT($MACHDEP)
445
Jack Jansen83f898c2002-12-30 22:23:40 +0000446# And add extra plat-mac for darwin
447AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000448AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000449AC_MSG_CHECKING(EXTRAPLATDIR)
450if test -z "$EXTRAPLATDIR"
451then
452 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000453 darwin)
454 EXTRAPLATDIR="\$(PLATMACDIRS)"
455 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
456 ;;
457 *)
458 EXTRAPLATDIR=""
459 EXTRAMACHDEPPATH=""
460 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000461 esac
462fi
463AC_MSG_RESULT($EXTRAPLATDIR)
464
Jack Jansen6b08a402004-06-03 12:41:45 +0000465# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
466# it may influence the way we can build extensions, so distutils
467# needs to check it
468AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000469AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000470CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000471EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000472
Mark Dickinson65134662008-04-25 16:11:04 +0000473AC_MSG_CHECKING(machine type as reported by uname -m)
474ac_sys_machine=`uname -m`
475AC_MSG_RESULT($ac_sys_machine)
476
Guido van Rossum627b2d71993-12-24 10:39:16 +0000477# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000478
479# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
480# for debug/optimization stuff. BASECFLAGS is for flags that are required
481# just to get things to compile and link. Users are free to override OPT
482# when running configure or make. The build should not break if they do.
483# BASECFLAGS should generally not be messed with, however.
484
485# XXX shouldn't some/most/all of this code be merged with the stuff later
486# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000487AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000488AC_ARG_WITH(gcc,
489 AC_HELP_STRING(--without-gcc,never use gcc),
490[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000491 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000492 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000493 without_gcc=yes;;
494 yes) CC=gcc
495 without_gcc=no;;
496 *) CC=$withval
497 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000498 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000499 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000500 AIX*) CC=cc_r
501 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000502 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000503 case $BE_HOST_CPU in
504 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000505 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000506 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000507 BASECFLAGS="$BASECFLAGS -export pragma"
508 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000509 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000510 ;;
511 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000512 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000513 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000514 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000515 ;;
516 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000517 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000518 ;;
519 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000520 AR="\$(srcdir)/Modules/ar_beos"
521 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000522 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000523 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000524 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000525AC_MSG_RESULT($without_gcc)
526
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000527# If the user switches compilers, we can't believe the cache
528if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
529then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000530 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
531(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000532fi
533
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000534# If the user set CFLAGS, use this instead of the automatically
535# determined setting
536preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000537AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000538if test ! -z "$preset_cflags"
539then
540 CFLAGS=$preset_cflags
541fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000542
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000543AC_SUBST(CXX)
544AC_SUBST(MAINCC)
545AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
546AC_ARG_WITH(cxx_main,
547 AC_HELP_STRING([--with-cxx-main=<compiler>],
548 [compile main() and link python executable with C++ compiler]),
549[
550
551 case $withval in
552 no) with_cxx_main=no
553 MAINCC='$(CC)';;
554 yes) with_cxx_main=yes
555 MAINCC='$(CXX)';;
556 *) with_cxx_main=yes
557 MAINCC=$withval
558 if test -z "$CXX"
559 then
560 CXX=$withval
561 fi;;
562 esac], [
563 with_cxx_main=no
564 MAINCC='$(CC)'
565])
566AC_MSG_RESULT($with_cxx_main)
567
568preset_cxx="$CXX"
569if test -z "$CXX"
570then
571 case "$CC" in
572 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
573 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
574 esac
575 if test "$CXX" = "notfound"
576 then
577 CXX=""
578 fi
579fi
580if test -z "$CXX"
581then
582 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
583 if test "$CXX" = "notfound"
584 then
585 CXX=""
586 fi
587fi
588if test "$preset_cxx" != "$CXX"
589then
590 AC_MSG_WARN([
591
592 By default, distutils will build C++ extension modules with "$CXX".
593 If this is not intended, then set CXX on the configure command line.
594 ])
595fi
596
597
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000598# checks for UNIX variants that set C preprocessor variables
599AC_AIX
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000600
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000601# Check for unsupported systems
602case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000603atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000604 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
605 echo See README for details.
606 exit 1;;
607esac
608
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000609AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000610AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000611AC_ARG_WITH(suffix,
612 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
613[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000614 case $withval in
615 no) EXEEXT=;;
616 yes) EXEEXT=.exe;;
617 *) EXEEXT=$withval;;
618 esac])
619AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000620
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000621# Test whether we're running on a non-case-sensitive system, in which
622# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000623AC_SUBST(BUILDEXEEXT)
624AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000625if test ! -d CaseSensitiveTestDir; then
626mkdir CaseSensitiveTestDir
627fi
628
629if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000630then
Jack Jansen1999ef42001-12-06 21:47:20 +0000631 AC_MSG_RESULT(yes)
632 BUILDEXEEXT=.exe
633else
634 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000635 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000636fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000637rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000638
Guido van Rossumdd997f71998-10-07 19:58:26 +0000639case $MACHDEP in
640bsdos*)
641 case $CC in
642 gcc) CC="$CC -D_HAVE_BSDI";;
643 esac;;
644esac
645
Guido van Rossum84561611997-08-21 00:08:11 +0000646case $ac_sys_system in
647hp*|HP*)
648 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000649 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000650 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000651SunOS*)
652 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000653 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000654 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000655esac
656
Martin v. Löwise8964d42001-03-06 12:09:07 +0000657
Neil Schemenauer61c51152001-01-26 16:18:16 +0000658AC_SUBST(LIBRARY)
659AC_MSG_CHECKING(LIBRARY)
660if test -z "$LIBRARY"
661then
662 LIBRARY='libpython$(VERSION).a'
663fi
664AC_MSG_RESULT($LIBRARY)
665
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000666# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000667# name of the library into which to insert object files). BLDLIBRARY is also
668# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
669# is blank as the main program is not linked directly against LDLIBRARY.
670# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
671# systems without shared libraries, LDLIBRARY is the same as LIBRARY
672# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
673# DLLLIBRARY is the shared (i.e., DLL) library.
674#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000675# RUNSHARED is used to run shared python without installed libraries
676#
677# INSTSONAME is the name of the shared library that will be use to install
678# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000679AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000680AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000681AC_SUBST(BLDLIBRARY)
682AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000683AC_SUBST(INSTSONAME)
684AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000685LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000686BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000687INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000688DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000689LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000690RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000691
Guido van Rossumfb842551997-08-06 23:42:07 +0000692# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000693# If CXX is set, and if it is needed to link a main function that was
694# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
695# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000696# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000697# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000698AC_SUBST(LINKCC)
699AC_MSG_CHECKING(LINKCC)
700if test -z "$LINKCC"
701then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000702 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000703 case $ac_sys_system in
704 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000705 exp_extra="\"\""
706 if test $ac_sys_release -ge 5 -o \
707 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
708 exp_extra="."
709 fi
710 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000711 QNX*)
712 # qcc must be used because the other compilers do not
713 # support -N.
714 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000715 esac
716fi
717AC_MSG_RESULT($LINKCC)
718
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000719# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
720# make sure we default having it set to "no": this is used by
721# distutils.unixccompiler to know if it should add --enable-new-dtags
722# to linker command lines, and failing to detect GNU ld simply results
723# in the same bahaviour as before.
724AC_SUBST(GNULD)
725AC_MSG_CHECKING(for GNU ld)
726ac_prog=ld
727if test "$GCC" = yes; then
728 ac_prog=`$CC -print-prog-name=ld`
729fi
730case `"$ac_prog" -V 2>&1 < /dev/null` in
731 *GNU*)
732 GNULD=yes;;
733 *)
734 GNULD=no;;
735esac
736AC_MSG_RESULT($GNULD)
737
Martin v. Löwis1142de32002-03-29 16:28:31 +0000738AC_MSG_CHECKING(for --enable-shared)
739AC_ARG_ENABLE(shared,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000740 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000741
Martin v. Löwis1142de32002-03-29 16:28:31 +0000742if test -z "$enable_shared"
743then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000744 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000745 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000746 enable_shared="yes";;
747 *)
748 enable_shared="no";;
749 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000750fi
751AC_MSG_RESULT($enable_shared)
752
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000753AC_MSG_CHECKING(for --enable-profiling)
754AC_ARG_ENABLE(profiling,
755 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
756[ac_save_cc="$CC"
757 CC="$CC -pg"
758 AC_TRY_RUN([int main() { return 0; }],
759 ac_enable_profiling="yes",
760 ac_enable_profiling="no",
761 ac_enable_profiling="no")
762 CC="$ac_save_cc"])
763AC_MSG_RESULT($ac_enable_profiling)
764
765case "$ac_enable_profiling" in
766 "yes")
767 BASECFLAGS="-pg $BASECFLAGS"
768 LDFLAGS="-pg $LDFLAGS"
769 ;;
770esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000771
772AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000773
Guido van Rossumb8552162001-09-05 14:58:11 +0000774# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
775# library that we build, but we do not want to link against it (we
776# will find it with a -framework option). For this reason there is an
777# extra variable BLDLIBRARY against which Python and the extension
778# modules are linked, BLDLIBRARY. This is normally the same as
779# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000780if test "$enable_framework"
781then
782 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen66b84832003-07-04 12:14:39 +0000783 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000784 BLDLIBRARY=''
785else
786 BLDLIBRARY='$(LDLIBRARY)'
787fi
788
Martin v. Löwis1142de32002-03-29 16:28:31 +0000789# Other platforms follow
790if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000791 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000792 case $ac_sys_system in
793 BeOS*)
794 LDLIBRARY='libpython$(VERSION).so'
795 ;;
796 CYGWIN*)
797 LDLIBRARY='libpython$(VERSION).dll.a'
798 DLLLIBRARY='libpython$(VERSION).dll'
799 ;;
800 SunOS*)
801 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000802 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000803 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000804 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000805 ;;
Martin v. Löwis86d66262006-02-17 08:40:11 +0000806 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000807 LDLIBRARY='libpython$(VERSION).so'
808 BLDLIBRARY='-L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000809 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000810 case $ac_sys_system in
811 FreeBSD*)
812 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
813 ;;
814 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000815 INSTSONAME="$LDLIBRARY".$SOVERSION
816 ;;
817 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000818 case `uname -m` in
819 ia64)
820 LDLIBRARY='libpython$(VERSION).so'
821 ;;
822 *)
823 LDLIBRARY='libpython$(VERSION).sl'
824 ;;
825 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000826 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000827 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000828 ;;
829 OSF*)
830 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000831 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
Martin v. Löwisfc9b75f2003-08-09 09:06:52 +0000832 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000833 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000834 atheos*)
835 LDLIBRARY='libpython$(VERSION).so'
836 BLDLIBRARY='-L. -lpython$(VERSION)'
837 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
838 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000839 Darwin*)
840 LDLIBRARY='libpython$(VERSION).dylib'
841 BLDLIBRARY='-L. -lpython$(VERSION)'
842 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
843 ;;
844
Martin v. Löwis1142de32002-03-29 16:28:31 +0000845 esac
Jason Tishler30765592003-09-04 11:04:06 +0000846else # shared is disabled
847 case $ac_sys_system in
848 CYGWIN*)
849 BLDLIBRARY='$(LIBRARY)'
850 LDLIBRARY='libpython$(VERSION).dll.a'
851 ;;
852 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000853fi
854
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000855AC_MSG_RESULT($LDLIBRARY)
856
Guido van Rossum627b2d71993-12-24 10:39:16 +0000857AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000858AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000859AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000860
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000861# tweak ARFLAGS only if the user didn't set it on the command line
862AC_SUBST(ARFLAGS)
863if test -z "$ARFLAGS"
864then
865 ARFLAGS="rc"
866fi
867
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000868AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000869AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000870if test $SVNVERSION = found
871then
872 SVNVERSION="svnversion \$(srcdir)"
873else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000874 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000875fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000876
Neil Schemenauera42c8272001-03-31 00:01:55 +0000877case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000878bsdos*|hp*|HP*)
879 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000880 if test -z "$INSTALL"
881 then
882 INSTALL="${srcdir}/install-sh -c"
883 fi
884esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000885AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000886
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000887# Not every filesystem supports hard links
888AC_SUBST(LN)
889if test -z "$LN" ; then
890 case $ac_sys_system in
891 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000892 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000893 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000894 *) LN=ln;;
895 esac
896fi
897
Fred Drake9f715822001-07-11 06:27:00 +0000898# Check for --with-pydebug
899AC_MSG_CHECKING(for --with-pydebug)
900AC_ARG_WITH(pydebug,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000901 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
902[
Fred Drake9f715822001-07-11 06:27:00 +0000903if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000904then
905 AC_DEFINE(Py_DEBUG, 1,
906 [Define if you want to build an interpreter with many run-time checks.])
907 AC_MSG_RESULT(yes);
908 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +0000909else AC_MSG_RESULT(no); Py_DEBUG='false'
910fi],
911[AC_MSG_RESULT(no)])
912
Skip Montanarodecc6a42003-01-01 20:07:49 +0000913# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
914# merged with this chunk of code?
915
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000916# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +0000917# ------------------------
918# (The following bit of code is complicated enough - please keep things
919# indented properly. Just pretend you're editing Python code. ;-)
920
921# There are two parallel sets of case statements below, one that checks to
922# see if OPT was set and one that does BASECFLAGS setting based upon
923# compiler and platform. BASECFLAGS tweaks need to be made even if the
924# user set OPT.
925
926# tweak OPT based on compiler and platform, only if the user didn't set
927# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +0000928AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +0000929if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +0000930then
Skip Montanarodecc6a42003-01-01 20:07:49 +0000931 case $GCC in
932 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000933 if test "$CC" != 'g++' ; then
934 STRICT_PROTO="-Wstrict-prototypes"
935 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +0000936 # For gcc 4.x we need to use -fwrapv so lets check if its supported
937 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
938 WRAP="-fwrapv"
939 fi
Skip Montanarodecc6a42003-01-01 20:07:49 +0000940 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000941 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000942 if test "$Py_DEBUG" = 'true' ; then
943 # Optimization messes up debuggers, so turn it off for
944 # debug builds.
Skip Montanaro288a5be2006-04-13 02:00:56 +0000945 OPT="-g -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +0000946 else
Guido van Rossum7c862f82007-12-13 20:50:10 +0000947 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000948 fi
949 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000950 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +0000951 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +0000952 ;;
Fred Drake9f715822001-07-11 06:27:00 +0000953 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000954 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +0000955 SCO_SV*) OPT="$OPT -m486 -DSCO5"
956 ;;
957 esac
Fred Drake9f715822001-07-11 06:27:00 +0000958 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +0000959
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000960 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +0000961 OPT="-O"
962 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000963 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000964fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000965
Skip Montanarodecc6a42003-01-01 20:07:49 +0000966AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000967
968# The -arch flags for universal builds on OSX
969UNIVERSAL_ARCH_FLAGS=
970AC_SUBST(UNIVERSAL_ARCH_FLAGS)
971
Skip Montanarodecc6a42003-01-01 20:07:49 +0000972# tweak BASECFLAGS based on compiler and platform
973case $GCC in
974yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000975 # Python violates C99 rules, by casting between incompatible
976 # pointer types. GCC may generate bad code as a result of that,
977 # so use -fno-strict-aliasing if supported.
978 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
979 ac_save_cc="$CC"
980 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +0000981 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +0000982 AC_TRY_COMPILE([],[int main() { return 0; }],
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000983 ac_cv_no_strict_aliasing_ok=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +0000984 ac_cv_no_strict_aliasing_ok=no))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +0000985 CC="$ac_save_cc"
986 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
987 if test $ac_cv_no_strict_aliasing_ok = yes
988 then
989 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
990 fi
Mark Dickinson65134662008-04-25 16:11:04 +0000991
992 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
993 # support. Without this, treatment of subnormals doesn't follow
994 # the standard.
995 case $ac_sys_machine in
996 alpha*)
997 BASECFLAGS="$BASECFLAGS -mieee"
998 ;;
999 esac
1000
Skip Montanarodecc6a42003-01-01 20:07:49 +00001001 case $ac_sys_system in
1002 SCO_SV*)
1003 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1004 ;;
1005 # is there any other compiler on Darwin besides gcc?
1006 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001007 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1008 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001009 if test "${CC}" = gcc
1010 then
1011 AC_MSG_CHECKING(which compiler should be used)
1012 case "${UNIVERSALSDK}" in
1013 */MacOSX10.4u.sdk)
1014 # Build using 10.4 SDK, force usage of gcc when the
1015 # compiler is gcc, otherwise the user will get very
1016 # confusing error messages when building on OSX 10.6
1017 CC=gcc-4.0
1018 CPP=cpp-4.0
1019 ;;
1020 esac
1021 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001022 fi
1023
Benjamin Peterson4347c442008-07-17 15:59:24 +00001024 # Calculate the right deployment target for this build.
1025 #
1026 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1027 if test ${cur_target} '>' 10.2; then
1028 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001029 if test ${enable_universalsdk}; then
1030 if test "${UNIVERSAL_ARCHS}" = "all"; then
1031 # Ensure that the default platform for a
1032 # 4-way universal build is OSX 10.5,
1033 # that's the first OS release where
1034 # 4-way builds make sense.
1035 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001036
1037 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1038 cur_target='10.5'
1039
1040 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1041 cur_target='10.5'
1042
1043 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1044 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001045 fi
1046 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001047 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001048 # On Intel macs default to a deployment
1049 # target of 10.4, that's the first OSX
1050 # release with Intel support.
1051 cur_target="10.4"
1052 fi
1053 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001054 fi
1055 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1056
1057 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1058 # environment with a value that is the same as what we'll use
1059 # in the Makefile to ensure that we'll get the same compiler
1060 # environment during configure and build time.
1061 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1062 export MACOSX_DEPLOYMENT_TARGET
1063 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1064
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001065 if test "${enable_universalsdk}"; then
1066 UNIVERSAL_ARCH_FLAGS=""
1067 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1068 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1069 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001070 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001071
1072 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1073 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1074 LIPO_32BIT_FLAGS=""
1075 ARCH_RUN_32BIT="true"
1076
1077 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1078 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1079 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001080 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001081
1082 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1083 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1084 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001085 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001086
1087 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1088 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1089 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001090 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001091
1092 else
1093 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1094
1095 fi
1096
1097
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001098 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1099 if test "${UNIVERSALSDK}" != "/"
1100 then
1101 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1102 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1103 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001104 fi
1105
1106 fi
1107
1108
Skip Montanarodecc6a42003-01-01 20:07:49 +00001109 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001110 OSF*)
1111 BASECFLAGS="$BASECFLAGS -mieee"
1112 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001113 esac
1114 ;;
1115
1116*)
1117 case $ac_sys_system in
1118 OpenUNIX*|UnixWare*)
1119 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1120 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001121 OSF*)
1122 BASECFLAGS="$BASECFLAGS -ieee -std"
1123 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001124 SCO_SV*)
1125 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1126 ;;
1127 esac
1128 ;;
1129esac
1130
Fred Drakee1ceaa02001-12-04 20:55:47 +00001131if test "$Py_DEBUG" = 'true'; then
1132 :
1133else
1134 OPT="-DNDEBUG $OPT"
1135fi
1136
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001137if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001138then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001139 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001140fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001141
Neal Norwitz020c46a2006-01-07 21:39:28 +00001142# disable check for icc since it seems to pass, but generates a warning
1143if test "$CC" = icc
1144then
1145 ac_cv_opt_olimit_ok=no
1146fi
1147
Guido van Rossum91922671997-10-09 20:24:13 +00001148AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1149AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1150[ac_save_cc="$CC"
1151CC="$CC -OPT:Olimit=0"
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001152AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossum91922671997-10-09 20:24:13 +00001153 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001154 ac_cv_opt_olimit_ok=no,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001155 )
Guido van Rossum91922671997-10-09 20:24:13 +00001156CC="$ac_save_cc"])
1157AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001158if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001159 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001160 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1161 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1162 # environment?
1163 Darwin*)
1164 ;;
1165 *)
1166 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1167 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001168 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001169else
1170 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1171 AC_CACHE_VAL(ac_cv_olimit_ok,
1172 [ac_save_cc="$CC"
1173 CC="$CC -Olimit 1500"
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001174 AC_TRY_COMPILE([],[int main() { return 0; }],
Guido van Rossumf8678121998-07-07 21:05:09 +00001175 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +00001176 ac_cv_olimit_ok=no,
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001177 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001178 CC="$ac_save_cc"])
1179 AC_MSG_RESULT($ac_cv_olimit_ok)
1180 if test $ac_cv_olimit_ok = yes; then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001181 BASECFLAGS="$BASECFLAGS -Olimit 1500"
Guido van Rossumf8678121998-07-07 21:05:09 +00001182 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001183fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001184
Martin v. Löwisaac13162006-10-19 10:58:46 +00001185# Check whether GCC supports PyArg_ParseTuple format
1186if test "$GCC" = "yes"
1187then
1188 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1189 save_CFLAGS=$CFLAGS
1190 CFLAGS="$CFLAGS -Werror"
1191 AC_TRY_COMPILE([
1192 void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1193 ],,
1194 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1195 AC_MSG_RESULT(yes),
1196 AC_MSG_RESULT(no)
1197 )
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001198 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001199fi
1200
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001201# On some compilers, pthreads are available without further options
1202# (e.g. MacOS X). On some of these systems, the compiler will not
1203# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1204# So we have to see first whether pthreads are available without
1205# options before we can check whether -Kpthread improves anything.
1206AC_MSG_CHECKING(whether pthreads are available without options)
1207AC_CACHE_VAL(ac_cv_pthread_is_default,
1208[AC_TRY_RUN([
1209#include <pthread.h>
1210
1211void* routine(void* p){return NULL;}
1212
1213int main(){
1214 pthread_t p;
1215 if(pthread_create(&p,NULL,routine,NULL)!=0)
1216 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001217 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001218 return 0;
1219}
1220],
Skip Montanarod8d39a02003-07-10 20:44:10 +00001221[
1222 ac_cv_pthread_is_default=yes
1223 ac_cv_kthread=no
1224 ac_cv_pthread=no
1225],
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001226 ac_cv_pthread_is_default=no,
1227 ac_cv_pthread_is_default=no)
1228])
1229AC_MSG_RESULT($ac_cv_pthread_is_default)
1230
1231
1232if test $ac_cv_pthread_is_default = yes
1233then
1234 ac_cv_kpthread=no
1235else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001236# -Kpthread, if available, provides the right #defines
1237# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001238# Some compilers won't report that they do not support -Kpthread,
1239# so we need to run a program to see whether it really made the
1240# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001241AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1242AC_CACHE_VAL(ac_cv_kpthread,
1243[ac_save_cc="$CC"
1244CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001245AC_TRY_RUN([
1246#include <pthread.h>
1247
1248void* routine(void* p){return NULL;}
1249
1250int main(){
1251 pthread_t p;
1252 if(pthread_create(&p,NULL,routine,NULL)!=0)
1253 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001254 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001255 return 0;
1256}
1257],
Martin v. Löwis130fb172001-07-19 11:00:41 +00001258 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001259 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +00001260 ac_cv_kpthread=no)
1261CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001262AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001263fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001264
Skip Montanarod8d39a02003-07-10 20:44:10 +00001265if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001266then
1267# -Kthread, if available, provides the right #defines
1268# and linker options to make pthread_create available
1269# Some compilers won't report that they do not support -Kthread,
1270# so we need to run a program to see whether it really made the
1271# function available.
1272AC_MSG_CHECKING(whether $CC accepts -Kthread)
1273AC_CACHE_VAL(ac_cv_kthread,
1274[ac_save_cc="$CC"
1275CC="$CC -Kthread"
1276AC_TRY_RUN([
1277#include <pthread.h>
1278
1279void* routine(void* p){return NULL;}
1280
1281int main(){
1282 pthread_t p;
1283 if(pthread_create(&p,NULL,routine,NULL)!=0)
1284 return 1;
1285 (void)pthread_detach(p);
1286 return 0;
1287}
1288],
1289 ac_cv_kthread=yes,
1290 ac_cv_kthread=no,
1291 ac_cv_kthread=no)
1292CC="$ac_save_cc"])
1293AC_MSG_RESULT($ac_cv_kthread)
1294fi
1295
Skip Montanarod8d39a02003-07-10 20:44:10 +00001296if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001297then
1298# -pthread, if available, provides the right #defines
1299# and linker options to make pthread_create available
1300# Some compilers won't report that they do not support -pthread,
1301# so we need to run a program to see whether it really made the
1302# function available.
1303AC_MSG_CHECKING(whether $CC accepts -pthread)
1304AC_CACHE_VAL(ac_cv_thread,
1305[ac_save_cc="$CC"
1306CC="$CC -pthread"
1307AC_TRY_RUN([
1308#include <pthread.h>
1309
1310void* routine(void* p){return NULL;}
1311
1312int main(){
1313 pthread_t p;
1314 if(pthread_create(&p,NULL,routine,NULL)!=0)
1315 return 1;
1316 (void)pthread_detach(p);
1317 return 0;
1318}
1319],
1320 ac_cv_pthread=yes,
1321 ac_cv_pthread=no,
1322 ac_cv_pthread=no)
1323CC="$ac_save_cc"])
1324AC_MSG_RESULT($ac_cv_pthread)
1325fi
1326
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001327# If we have set a CC compiler flag for thread support then
1328# check if it works for CXX, too.
1329ac_cv_cxx_thread=no
1330if test ! -z "$CXX"
1331then
1332AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1333ac_save_cxx="$CXX"
1334
1335if test "$ac_cv_kpthread" = "yes"
1336then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001337 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001338 ac_cv_cxx_thread=yes
1339elif test "$ac_cv_kthread" = "yes"
1340then
1341 CXX="$CXX -Kthread"
1342 ac_cv_cxx_thread=yes
1343elif test "$ac_cv_pthread" = "yes"
1344then
1345 CXX="$CXX -pthread"
1346 ac_cv_cxx_thread=yes
1347fi
1348
1349if test $ac_cv_cxx_thread = yes
1350then
1351 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1352 $CXX -c conftest.$ac_ext 2>&5
1353 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1354 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1355 then
1356 ac_cv_cxx_thread=yes
1357 else
1358 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001359 fi
1360 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001361fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001362AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001363fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001364CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001365
Fred Drakece81d592000-07-09 14:39:29 +00001366dnl # check for ANSI or K&R ("traditional") preprocessor
1367dnl AC_MSG_CHECKING(for C preprocessor type)
1368dnl AC_TRY_COMPILE([
1369dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1370dnl int foo;
1371dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1372dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1373dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001374
Guido van Rossum627b2d71993-12-24 10:39:16 +00001375# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001376AC_HEADER_STDC
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001377AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1378fcntl.h grp.h \
Neal Norwitz9fdfaaf2008-03-28 05:34:59 +00001379ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001380shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001381unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001382sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1383sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001384sys/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 +00001385sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001386sys/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 +00001387sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001388bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001389AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001390AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001391
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001392# On Solaris, term.h requires curses.h
Martin v. Löwisfd1c69e2004-11-30 22:09:37 +00001393AC_CHECK_HEADERS(term.h,,,[
Martin v. Löwis5d52e782004-09-18 10:07:03 +00001394#ifdef HAVE_CURSES_H
1395#include <curses.h>
1396#endif
1397])
Martin v. Löwisae2830c2004-09-18 09:54:52 +00001398
Martin v. Löwis11017b12006-01-14 18:12:57 +00001399# On Linux, netlink.h requires asm/types.h
1400AC_CHECK_HEADERS(linux/netlink.h,,,[
1401#ifdef HAVE_ASM_TYPES_H
1402#include <asm/types.h>
1403#endif
1404#ifdef HAVE_SYS_SOCKET_H
1405#include <sys/socket.h>
1406#endif
1407])
1408
Guido van Rossum627b2d71993-12-24 10:39:16 +00001409# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001410was_it_defined=no
1411AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001412AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1413 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1414])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001415AC_MSG_RESULT($was_it_defined)
1416
Neal Norwitz11690112002-07-30 01:08:28 +00001417# Check whether using makedev requires defining _OSF_SOURCE
1418AC_MSG_CHECKING(for makedev)
Jesus Cea616de772010-04-28 10:32:30 +00001419AC_TRY_LINK([
1420#if defined(MAJOR_IN_MKDEV)
1421#include <sys/mkdev.h>
1422#elif defined(MAJOR_IN_SYSMACROS)
1423#include <sys/sysmacros.h>
1424#else
1425#include <sys/types.h>
1426#endif ],
Neal Norwitz11690112002-07-30 01:08:28 +00001427 [ makedev(0, 0) ],
1428 ac_cv_has_makedev=yes,
1429 ac_cv_has_makedev=no)
1430if test "$ac_cv_has_makedev" = "no"; then
1431 # we didn't link, try if _OSF_SOURCE will allow us to link
1432 AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001433#define _OSF_SOURCE 1
1434#include <sys/types.h>
Neal Norwitz11690112002-07-30 01:08:28 +00001435 ],
1436 [ makedev(0, 0) ],
1437 ac_cv_has_makedev=yes,
1438 ac_cv_has_makedev=no)
1439 if test "$ac_cv_has_makedev" = "yes"; then
1440 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1441 fi
1442fi
1443AC_MSG_RESULT($ac_cv_has_makedev)
1444if test "$ac_cv_has_makedev" = "yes"; then
1445 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1446fi
1447
Martin v. Löwis399a6892002-10-04 10:22:02 +00001448# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1449# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1450# defined, but the compiler does not support pragma redefine_extname,
1451# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1452# structures (such as rlimit64) without declaring them. As a
1453# work-around, disable LFS on such configurations
1454
1455use_lfs=yes
1456AC_MSG_CHECKING(Solaris LFS bug)
1457AC_TRY_COMPILE([
1458#define _LARGEFILE_SOURCE 1
1459#define _FILE_OFFSET_BITS 64
1460#include <sys/resource.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00001461],[struct rlimit foo;],sol_lfs_bug=no,sol_lfs_bug=yes)
Martin v. Löwis399a6892002-10-04 10:22:02 +00001462AC_MSG_RESULT($sol_lfs_bug)
1463if test "$sol_lfs_bug" = "yes"; then
1464 use_lfs=no
1465fi
1466
1467if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001468# Two defines needed to enable largefile support on various platforms
1469# These may affect some typedefs
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
1487AC_TYPE_SIGNAL
1488AC_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
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001511AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1512 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1513 have_long_long=yes
1514])
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
1522AC_TRY_COMPILE([], [long double x; x = (long double)0.;], [
1523 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1524 have_long_double=yes
1525])
1526AC_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
1533AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1534 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1535 have_c99_bool=yes
1536])
1537AC_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>
1546 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001547
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001548AC_CHECK_SIZEOF(off_t, [], [
1549#ifdef HAVE_SYS_TYPES_H
1550#include <sys/types.h>
1551#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001552])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001553
1554AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001555if test "$have_long_long" = yes
1556then
1557if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001558 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001559 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1560 [Defined to enable large file support when an off_t is bigger than a long
1561 and long long is available and at least as big as an off_t. You may need
1562 to add some flags for configuration and compilation to enable this mode.
1563 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001564 AC_MSG_RESULT(yes)
1565else
1566 AC_MSG_RESULT(no)
1567fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001568else
1569 AC_MSG_RESULT(no)
1570fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001571
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001572AC_CHECK_SIZEOF(time_t, [], [
1573#ifdef HAVE_SYS_TYPES_H
1574#include <sys/types.h>
1575#endif
1576#ifdef HAVE_TIME_H
1577#include <time.h>
1578#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001579])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001580
Trent Mick635f6fb2000-08-23 21:33:05 +00001581# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001582ac_save_cc="$CC"
1583if test "$ac_cv_kpthread" = "yes"
1584then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001585elif test "$ac_cv_kthread" = "yes"
1586then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001587elif test "$ac_cv_pthread" = "yes"
1588then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001589fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001590AC_MSG_CHECKING(for pthread_t)
1591have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +00001592AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +00001593AC_MSG_RESULT($have_pthread_t)
1594if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001595 AC_CHECK_SIZEOF(pthread_t, [], [
1596#ifdef HAVE_PTHREAD_H
1597#include <pthread.h>
1598#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001599 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001600fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001601CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001602
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001603AC_MSG_CHECKING(for --enable-toolbox-glue)
1604AC_ARG_ENABLE(toolbox-glue,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001605 AC_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001606
1607if test -z "$enable_toolbox_glue"
1608then
1609 case $ac_sys_system/$ac_sys_release in
1610 Darwin/*)
1611 enable_toolbox_glue="yes";;
1612 *)
1613 enable_toolbox_glue="no";;
1614 esac
1615fi
1616case "$enable_toolbox_glue" in
1617yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001618 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001619 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001620 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1621 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001622 ;;
1623*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001624 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001625 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001626 ;;
1627esac
1628AC_MSG_RESULT($enable_toolbox_glue)
1629
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001630
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001631AC_SUBST(OTHER_LIBTOOL_OPT)
1632case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001633 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001634 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1635 ;;
1636 Darwin/*)
1637 OTHER_LIBTOOL_OPT=""
1638 ;;
1639esac
1640
Ronald Oussoren25967582009-09-06 10:00:26 +00001641
1642ARCH_RUN_32BIT=""
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001643AC_SUBST(LIBTOOL_CRUFT)
1644case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001645 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001646 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1647 if test "${enable_universalsdk}"; then
1648 :
1649 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001650 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001651 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001652 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001653 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001654 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001655 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001656 if test ${gcc_version} '<' 4.0
1657 then
1658 LIBTOOL_CRUFT="-lcc_dynamic"
1659 else
1660 LIBTOOL_CRUFT=""
1661 fi
Ronald Oussoren23d92532009-09-07 06:12:00 +00001662 AC_TRY_RUN([
Ronald Oussoren25967582009-09-06 10:00:26 +00001663 #include <unistd.h>
1664 int main(int argc, char*argv[])
1665 {
1666 if (sizeof(long) == 4) {
1667 return 0;
1668 } else {
1669 return 1;
1670 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001671 }
Ronald Oussoren23d92532009-09-07 06:12:00 +00001672 ], ac_osx_32bit=yes,
Ronald Oussoren25967582009-09-06 10:00:26 +00001673 ac_osx_32bit=no,
Ronald Oussoren23d92532009-09-07 06:12:00 +00001674 ac_osx_32bit=yes)
Ronald Oussoren25967582009-09-06 10:00:26 +00001675
1676 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001677 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001678 i386)
1679 MACOSX_DEFAULT_ARCH="i386"
1680 ;;
1681 ppc)
1682 MACOSX_DEFAULT_ARCH="ppc"
1683 ;;
1684 *)
1685 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1686 ;;
1687 esac
1688 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001689 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001690 i386)
1691 MACOSX_DEFAULT_ARCH="x86_64"
1692 ;;
1693 ppc)
1694 MACOSX_DEFAULT_ARCH="ppc64"
1695 ;;
1696 *)
1697 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1698 ;;
1699 esac
1700
1701 #ARCH_RUN_32BIT="true"
1702 fi
1703
1704 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001705 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001706 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001707esac
1708
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001709AC_MSG_CHECKING(for --enable-framework)
1710if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001711then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001712 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001713 # -F. is needed to allow linking to the framework while
1714 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001715 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1716 [Define if you want to produce an OpenStep/Rhapsody framework
1717 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001718 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001719 if test $enable_shared = "yes"
1720 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001721 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 +00001722 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001723else
1724 AC_MSG_RESULT(no)
1725fi
1726
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001727AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001728case $ac_sys_system/$ac_sys_release in
1729 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001730 AC_DEFINE(WITH_DYLD, 1,
1731 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1732 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1733 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001734 AC_MSG_RESULT(always on for Darwin)
1735 ;;
1736 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001737 AC_MSG_RESULT(no)
1738 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001739esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001740
Guido van Rossumac405f61994-09-12 10:56:06 +00001741# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001742AC_SUBST(SO)
1743AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001744AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001745AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001746AC_SUBST(CCSHARED)
1747AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001748# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001749# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001750AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001751if test -z "$SO"
1752then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001753 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001754 hp*|HP*)
1755 case `uname -m` in
1756 ia64) SO=.so;;
1757 *) SO=.sl;;
1758 esac
1759 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001760 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001761 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001762 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001763else
1764 # this might also be a termcap variable, see #610332
1765 echo
1766 echo '====================================================================='
1767 echo '+ +'
1768 echo '+ WARNING: You have set SO in your environment. +'
1769 echo '+ Do you really mean to change the extension for shared libraries? +'
1770 echo '+ Continuing in 10 seconds to let you to ponder. +'
1771 echo '+ +'
1772 echo '====================================================================='
1773 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001774fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001775AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001776
Neal Norwitz58e28882006-05-19 07:00:58 +00001777AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001778# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001779# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001780# (Shared libraries in this instance are shared modules to be loaded into
1781# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001782AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001783if test -z "$LDSHARED"
1784then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001785 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001786 AIX*)
1787 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001788 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001789 ;;
1790 BeOS*)
1791 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001792 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001793 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001794 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001795 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001796 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001797 if test "$GCC" = "yes" ; then
1798 LDSHARED='$(CC) -shared'
1799 LDCXXSHARED='$(CXX) -shared'
1800 else
1801 LDSHARED='$(CC) -G'
1802 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001803 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001804 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001805 if test "$GCC" = "yes" ; then
1806 LDSHARED='$(CC) -shared'
1807 LDCXXSHARED='$(CXX) -shared'
1808 else
1809 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001810 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001811 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001812 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +00001813 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001814 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001815 if test "$enable_framework" ; then
1816 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001817 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1818 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001819 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001820 else
1821 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001822 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001823 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001824 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001825 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001826 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001827 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001828 if test "$enable_framework" ; then
1829 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001830 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1831 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001832 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001833 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001834 # No framework, use the Python app as bundle-loader
1835 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001836 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001837 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001838 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001839 Darwin/*)
1840 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1841 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001842
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001843 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001844 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001845 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001846 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001847 fi
Jack Jansen6b08a402004-06-03 12:41:45 +00001848 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Tarek Ziadé00002952010-04-03 08:37:59 +00001849 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00001850 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00001851 else
1852 LDSHARED='$(CC) $(LDFLAGS) -bundle'
Tarek Ziadé00002952010-04-03 08:37:59 +00001853 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00001854 if test "$enable_framework" ; then
1855 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001856 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1857 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001858 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001859 else
1860 # No framework, use the Python app as bundle-loader
1861 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1862 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001863 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00001864 fi
1865 fi
1866 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001867 Linux*|GNU*|QNX*)
1868 LDSHARED='$(CC) -shared'
1869 LDCXXSHARED='$(CXX) -shared';;
1870 BSD/OS*/4*)
1871 LDSHARED="gcc -shared"
1872 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001873 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00001874 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00001875 then
Benjamin Peterson3b2abe92010-03-14 15:06:14 +00001876 LDSHARED='$(CC) -shared ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001877 LDCXXSHARED='$(CXX) -shared ${LDFLAGS}'
Guido van Rossum0286ae82000-08-29 15:06:49 +00001878 else
1879 LDSHARED="ld -Bshareable ${LDFLAGS}"
1880 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00001881 OpenBSD*)
1882 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1883 then
1884 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001885 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001886 else
1887 case `uname -r` in
1888 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1889 LDSHARED="ld -Bshareable ${LDFLAGS}"
1890 ;;
1891 *)
1892 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
Tarek Ziadé00002952010-04-03 08:37:59 +00001893 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
Martin v. Löwis222c5152006-06-03 07:37:13 +00001894 ;;
1895 esac
1896 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001897 NetBSD*|DragonFly*)
1898 LDSHARED="cc -shared ${LDFLAGS}"
1899 LDCXXSHARED="c++ -shared ${LDFLAGS}";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001900 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001901 if test "$GCC" = "yes" ; then
1902 LDSHARED='$(CC) -shared'
1903 LDCXXSHARED='$(CXX) -shared'
1904 else
1905 LDSHARED='$(CC) -G'
1906 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00001907 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00001908 SCO_SV*)
1909 LDSHARED='$(CC) -Wl,-G,-Bexport'
1910 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1911 CYGWIN*)
1912 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1913 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
1914 atheos*)
1915 LDSHARED="gcc -shared"
1916 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001917 *) LDSHARED="ld";;
1918 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001919fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001920AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001921LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001922BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00001923# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001924# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001925AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001926if test -z "$CCSHARED"
1927then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001928 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00001929 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00001930 then CCSHARED="-fPIC";
1931 elif test `uname -p` = sparc;
1932 then CCSHARED="-xcode=pic32";
1933 else CCSHARED="-Kpic";
1934 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00001935 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00001936 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00001937 else CCSHARED="+z";
1938 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001939 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001940 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001941 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001942 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00001943 if test "$GCC" = "yes"
1944 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001945 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00001946 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001947 SCO_SV*)
1948 if test "$GCC" = "yes"
1949 then CCSHARED="-fPIC"
1950 else CCSHARED="-Kpic -belf"
1951 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001952 IRIX*/6*) case $CC in
1953 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00001954 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001955 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001956 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00001957 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00001958fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001959AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001960# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00001961# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001962AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001963if test -z "$LINKFORSHARED"
1964then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001965 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001966 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00001967 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00001968 LINKFORSHARED="-Wl,-E -Wl,+s";;
1969# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00001970 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001971 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001972 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001973 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001974 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1975 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001976 # not used by the core itself but which needs to be in the core so
1977 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00001978 # -prebind is no longer used, because it actually seems to give a
1979 # slowdown in stead of a speedup, maybe due to the large number of
1980 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001981
1982 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001983 if test "$enable_framework"
1984 then
Jack Jansenda49e192005-01-07 13:08:22 +00001985 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001986 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001987 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00001988 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001989 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00001990 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00001991 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00001992 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1993 then
1994 LINKFORSHARED="-Wl,--export-dynamic"
1995 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00001996 SunOS/5*) case $CC in
1997 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00001998 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00001999 then
2000 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002001 fi;;
2002 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002003 CYGWIN*)
2004 if test $enable_shared = "no"
2005 then
2006 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2007 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002008 QNX*)
2009 # -Wl,-E causes the symbols to be added to the dynamic
2010 # symbol table so that they can be found when a module
2011 # is loaded. -N 2048K causes the stack size to be set
2012 # to 2048 kilobytes so that the stack doesn't overflow
2013 # when running test_compile.py.
2014 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002015 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002016fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002017AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002018
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002019
Neil Schemenauer61c51152001-01-26 16:18:16 +00002020AC_SUBST(CFLAGSFORSHARED)
2021AC_MSG_CHECKING(CFLAGSFORSHARED)
2022if test ! "$LIBRARY" = "$LDLIBRARY"
2023then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002024 case $ac_sys_system in
2025 CYGWIN*)
2026 # Cygwin needs CCSHARED when building extension DLLs
2027 # but not when building the interpreter DLL.
2028 CFLAGSFORSHARED='';;
2029 *)
2030 CFLAGSFORSHARED='$(CCSHARED)'
2031 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002032fi
2033AC_MSG_RESULT($CFLAGSFORSHARED)
2034
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002035# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2036# library (with --enable-shared).
2037# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002038# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2039# if it is not required, since it creates a dependency of the shared library
2040# to LIBS. This, in turn, means that applications linking the shared libpython
2041# don't need to link LIBS explicitly. The default should be only changed
2042# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002043AC_SUBST(SHLIBS)
2044AC_MSG_CHECKING(SHLIBS)
2045case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002046 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002047 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002048esac
2049AC_MSG_RESULT($SHLIBS)
2050
2051
Guido van Rossum627b2d71993-12-24 10:39:16 +00002052# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002053AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2054AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002055
Skip Montanaro4d756af2008-12-01 01:55:22 +00002056# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002057if test "$with_threads" = "yes" -o -z "$with_threads"; then
2058 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2059 # posix4 on Solaris 2.6
2060 # pthread (first!) on Linux
2061fi
2062
Martin v. Löwis19d17342003-06-14 21:03:05 +00002063# check if we need libintl for locale functions
2064AC_CHECK_LIB(intl, textdomain,
2065 AC_DEFINE(WITH_LIBINTL, 1,
2066 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002067
2068# checks for system dependent C++ extensions support
2069case "$ac_sys_system" in
2070 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
2071 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
2072 [loadAndInit("", 0, "")],
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002073 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
2074 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2075 and you want support for AIX C++ shared extension modules.])
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002076 AC_MSG_RESULT(yes)],
2077 [AC_MSG_RESULT(no)]);;
2078 *) ;;
2079esac
2080
Guido van Rossum70c7f481998-03-26 18:44:10 +00002081# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002082# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002083AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002084AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002085
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002086case "$ac_sys_system" in
2087BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002088AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2089;;
2090esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002091
Guido van Rossumc5a39031996-07-31 17:35:03 +00002092AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002093AC_ARG_WITH(libs,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002094 AC_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002095[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002096AC_MSG_RESULT($withval)
2097LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002098],
2099[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002100
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002101AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2102
Benjamin Peterson2c196742009-12-31 03:17:18 +00002103# Check for use of the system expat library
2104AC_MSG_CHECKING(for --with-system-expat)
2105AC_ARG_WITH(system_expat,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002106 AC_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]))
Benjamin Peterson2c196742009-12-31 03:17:18 +00002107
2108AC_MSG_RESULT($with_system_expat)
2109
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002110# Check for use of the system libffi library
2111AC_MSG_CHECKING(for --with-system-ffi)
2112AC_ARG_WITH(system_ffi,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002113 AC_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]))
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002114
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002115if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002116 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2117else
2118 LIBFFI_INCLUDEDIR=""
2119fi
2120AC_SUBST(LIBFFI_INCLUDEDIR)
2121
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002122AC_MSG_RESULT($with_system_ffi)
2123
Matthias Klose10cbe482009-04-29 17:18:19 +00002124# Check for --with-dbmliborder
2125AC_MSG_CHECKING(for --with-dbmliborder)
2126AC_ARG_WITH(dbmliborder,
Matthias Klose51c614e2009-04-29 19:52:49 +00002127 AC_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 +00002128[
2129if test x$with_dbmliborder = xyes
2130then
2131AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2132else
2133 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2134 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2135 then
2136 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2137 fi
2138 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002139fi])
2140AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002141
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002142# Determine if signalmodule should be used.
2143AC_SUBST(USE_SIGNAL_MODULE)
2144AC_SUBST(SIGNAL_OBJS)
2145AC_MSG_CHECKING(for --with-signal-module)
2146AC_ARG_WITH(signal-module,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002147 AC_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002148
2149if test -z "$with_signal_module"
2150then with_signal_module="yes"
2151fi
2152AC_MSG_RESULT($with_signal_module)
2153
2154if test "${with_signal_module}" = "yes"; then
2155 USE_SIGNAL_MODULE=""
2156 SIGNAL_OBJS=""
2157else
2158 USE_SIGNAL_MODULE="#"
2159 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2160fi
2161
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002162# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002163AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002164USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002165
Guido van Rossum54d93d41997-01-22 20:51:58 +00002166AC_MSG_CHECKING(for --with-dec-threads)
2167AC_SUBST(LDLAST)
2168AC_ARG_WITH(dec-threads,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002169 AC_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002170[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002171AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002172LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002173if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002174 with_thread="$withval";
2175fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002176[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002177
Martin v. Löwis11437992002-04-12 09:54:03 +00002178# Templates for things AC_DEFINEd more than once.
2179# For a single AC_DEFINE, no template is needed.
2180AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2181AH_TEMPLATE(_REENTRANT,
2182 [Define to force use of thread-safe errno, h_errno, and other functions])
2183AH_TEMPLATE(WITH_THREAD,
2184 [Define if you want to compile in rudimentary thread support])
2185
Guido van Rossum54d93d41997-01-22 20:51:58 +00002186AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002187dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002188AC_ARG_WITH(threads,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002189 AC_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002190
Barry Warsawc0d24d82000-06-29 16:12:00 +00002191# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002192dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002193AC_ARG_WITH(thread,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002194 AC_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002195 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002196
2197if test -z "$with_threads"
2198then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002199fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002200AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002201
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002202AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002203if test "$with_threads" = "no"
2204then
2205 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002206elif test "$ac_cv_pthread_is_default" = yes
2207then
2208 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002209 # Defining _REENTRANT on system with POSIX threads should not hurt.
2210 AC_DEFINE(_REENTRANT)
2211 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002212 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002213elif test "$ac_cv_kpthread" = "yes"
2214then
2215 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002216 if test "$ac_cv_cxx_thread" = "yes"; then
2217 CXX="$CXX -Kpthread"
2218 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002219 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002220 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002221 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002222elif test "$ac_cv_kthread" = "yes"
2223then
2224 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002225 if test "$ac_cv_cxx_thread" = "yes"; then
2226 CXX="$CXX -Kthread"
2227 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002228 AC_DEFINE(WITH_THREAD)
2229 posix_threads=yes
2230 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002231elif test "$ac_cv_pthread" = "yes"
2232then
2233 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002234 if test "$ac_cv_cxx_thread" = "yes"; then
2235 CXX="$CXX -pthread"
2236 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002237 AC_DEFINE(WITH_THREAD)
2238 posix_threads=yes
2239 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002240else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002241 if test ! -z "$with_threads" -a -d "$with_threads"
2242 then LDFLAGS="$LDFLAGS -L$with_threads"
2243 fi
2244 if test ! -z "$withval" -a -d "$withval"
2245 then LDFLAGS="$LDFLAGS -L$withval"
2246 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002247
2248 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002249 # define _POSIX_THREADS in unistd.h. Some apparently don't
2250 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002251 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2252 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002253 [
2254#include <unistd.h>
2255#ifdef _POSIX_THREADS
2256yes
2257#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002258 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2259 AC_MSG_RESULT($unistd_defines_pthreads)
2260
Martin v. Löwis130fb172001-07-19 11:00:41 +00002261 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002262 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2263 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002264 AC_DEFINE(HURD_C_THREADS, 1,
2265 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002266 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002267 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002268 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2269 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002270 AC_DEFINE(MACH_C_THREADS, 1,
2271 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002272 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002273 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002274 AC_ARG_WITH([pth],
Matthias Klose5183ebd2010-04-24 16:38:36 +00002275 AC_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002276 [AC_MSG_RESULT($withval)
2277 AC_DEFINE([WITH_THREAD])
2278 AC_DEFINE([HAVE_PTH], 1,
2279 [Define if you have GNU PTH threads.])
2280 LIBS="-lpth $LIBS"
2281 THREADOBJ="Python/thread.o"],
2282 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002283
2284 # Just looking for pthread_create in libpthread is not enough:
2285 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2286 # So we really have to include pthread.h, and then link.
2287 _libs=$LIBS
2288 LIBS="$LIBS -lpthread"
2289 AC_MSG_CHECKING([for pthread_create in -lpthread])
2290 AC_TRY_LINK([#include <pthread.h>
2291
2292void * start_routine (void *arg) { exit (0); }], [
2293pthread_create (NULL, NULL, start_routine, NULL)], [
2294 AC_MSG_RESULT(yes)
2295 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002296 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002297 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002298 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002299 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002300 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002301 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002302 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2303 AC_DEFINE(ATHEOS_THREADS, 1,
2304 [Define this if you have AtheOS threads.])
2305 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002306 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002307 AC_DEFINE(BEOS_THREADS, 1,
2308 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002309 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002310 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002311 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002312 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002313 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002314 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002315 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002316 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002317 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002318 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002319 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002320 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002321 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002322 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002323 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002324 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002325 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002326 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002327 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002328
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002329 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2330 LIBS="$LIBS -lmpc"
2331 THREADOBJ="Python/thread.o"
2332 USE_THREAD_MODULE=""])
2333
2334 if test "$posix_threads" != "yes"; then
2335 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2336 LIBS="$LIBS -lthread"
2337 THREADOBJ="Python/thread.o"
2338 USE_THREAD_MODULE=""])
2339 fi
2340
2341 if test "$USE_THREAD_MODULE" != "#"
2342 then
2343 # If the above checks didn't disable threads, (at least) OSF1
2344 # needs this '-threads' argument during linking.
2345 case $ac_sys_system in
2346 OSF1) LDLAST=-threads;;
2347 esac
2348 fi
2349fi
2350
2351if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002352 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002353 AC_DEFINE(_POSIX_THREADS, 1,
2354 [Define if you have POSIX threads,
2355 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002356 fi
2357
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002358 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2359 case $ac_sys_system/$ac_sys_release in
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002360 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002361 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002362 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002363 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002364 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002365 ;;
Christian Heimescba36bb2008-01-30 22:54:18 +00002366 AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002367 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002368 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002369 esac
2370
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002371 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2372 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2373 [AC_TRY_RUN([#include <pthread.h>
2374 void *foo(void *parm) {
2375 return NULL;
2376 }
2377 main() {
2378 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002379 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002380 if (pthread_attr_init(&attr)) exit(-1);
2381 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002382 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002383 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00002384 }],
2385 ac_cv_pthread_system_supported=yes,
2386 ac_cv_pthread_system_supported=no,
2387 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002388 ])
2389 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2390 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002391 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002392 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002393 AC_CHECK_FUNCS(pthread_sigmask,
2394 [case $ac_sys_system in
2395 CYGWIN*)
2396 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2397 [Define if pthread_sigmask() does not work on your system.])
2398 ;;
2399 esac])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002400fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002401
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002402
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002403# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002404AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002405AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002406AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002407[ --enable-ipv6 Enable ipv6 (with ipv4) support
2408 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002409[ case "$enableval" in
2410 no)
2411 AC_MSG_RESULT(no)
2412 ipv6=no
2413 ;;
2414 *) AC_MSG_RESULT(yes)
2415 AC_DEFINE(ENABLE_IPV6)
2416 ipv6=yes
2417 ;;
2418 esac ],
2419
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002420[
2421dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002422 AC_TRY_RUN([ /* AF_INET6 available check */
2423#include <sys/types.h>
2424#include <sys/socket.h>
2425main()
2426{
2427 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2428 exit(1);
2429 else
2430 exit(0);
2431}
2432],
2433 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002434 ipv6=yes,
2435 AC_MSG_RESULT(no)
2436 ipv6=no,
2437 AC_MSG_RESULT(no)
2438 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002439)
2440
2441if test "$ipv6" = "yes"; then
2442 AC_MSG_CHECKING(if RFC2553 API is available)
2443 AC_TRY_COMPILE([#include <sys/types.h>
2444#include <netinet/in.h>],
2445 [struct sockaddr_in6 x;
2446x.sin6_scope_id;],
2447 AC_MSG_RESULT(yes)
2448 ipv6=yes,
2449 AC_MSG_RESULT(no, IPv6 disabled)
2450 ipv6=no)
2451fi
2452
2453if test "$ipv6" = "yes"; then
2454 AC_DEFINE(ENABLE_IPV6)
2455fi
2456])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002457
2458ipv6type=unknown
2459ipv6lib=none
2460ipv6trylibc=no
2461
2462if test "$ipv6" = "yes"; then
2463 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002464 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2465 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002466 case $i in
2467 inria)
2468 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002469 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002470#include <netinet/in.h>
2471#ifdef IPV6_INRIA_VERSION
2472yes
2473#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002474 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002475 ;;
2476 kame)
2477 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002478 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002479#include <netinet/in.h>
2480#ifdef __KAME__
2481yes
2482#endif],
2483 [ipv6type=$i;
2484 ipv6lib=inet6
2485 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002486 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002487 ;;
2488 linux-glibc)
2489 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002490 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002491#include <features.h>
2492#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2493yes
2494#endif],
2495 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002496 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002497 ;;
2498 linux-inet6)
2499 dnl http://www.v6.linux.or.jp/
2500 if test -d /usr/inet6; then
2501 ipv6type=$i
2502 ipv6lib=inet6
2503 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002504 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002505 fi
2506 ;;
2507 solaris)
2508 if test -f /etc/netconfig; then
2509 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2510 ipv6type=$i
2511 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002512 fi
2513 fi
2514 ;;
2515 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002516 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002517#include <sys/param.h>
2518#ifdef _TOSHIBA_INET6
2519yes
2520#endif],
2521 [ipv6type=$i;
2522 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002523 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002524 ;;
2525 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002526 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002527#include </usr/local/v6/include/sys/v6config.h>
2528#ifdef __V6D__
2529yes
2530#endif],
2531 [ipv6type=$i;
2532 ipv6lib=v6;
2533 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002534 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002535 ;;
2536 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002537 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002538#include <sys/param.h>
2539#ifdef _ZETA_MINAMI_INET6
2540yes
2541#endif],
2542 [ipv6type=$i;
2543 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002544 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002545 ;;
2546 esac
2547 if test "$ipv6type" != "unknown"; then
2548 break
2549 fi
2550 done
2551 AC_MSG_RESULT($ipv6type)
2552fi
2553
2554if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2555 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2556 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2557 echo "using lib$ipv6lib"
2558 else
2559 if test $ipv6trylibc = "yes"; then
2560 echo "using libc"
2561 else
2562 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2563 echo "You need to fetch lib$ipv6lib.a from appropriate"
2564 echo 'ipv6 kit and compile beforehand.'
2565 exit 1
2566 fi
2567 fi
2568fi
2569
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002570AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2571AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002572 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002573 AC_MSG_RESULT(yes),
2574 AC_MSG_RESULT(no)
2575)
2576
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002577# Check for --with-doc-strings
2578AC_MSG_CHECKING(for --with-doc-strings)
2579AC_ARG_WITH(doc-strings,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002580 AC_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002581
2582if test -z "$with_doc_strings"
2583then with_doc_strings="yes"
2584fi
2585if test "$with_doc_strings" != "no"
2586then
2587 AC_DEFINE(WITH_DOC_STRINGS, 1,
2588 [Define if you want documentation strings in extension modules])
2589fi
2590AC_MSG_RESULT($with_doc_strings)
2591
Neil Schemenauera35c6882001-02-27 04:45:05 +00002592# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002593AC_MSG_CHECKING(for --with-tsc)
2594AC_ARG_WITH(tsc,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002595 AC_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002596if test "$withval" != no
2597then
2598 AC_DEFINE(WITH_TSC, 1,
2599 [Define to profile with the Pentium timestamp counter])
2600 AC_MSG_RESULT(yes)
2601else AC_MSG_RESULT(no)
2602fi],
2603[AC_MSG_RESULT(no)])
2604
2605# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002606AC_MSG_CHECKING(for --with-pymalloc)
2607AC_ARG_WITH(pymalloc,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002608 AC_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002609
2610if test -z "$with_pymalloc"
2611then with_pymalloc="yes"
2612fi
2613if test "$with_pymalloc" != "no"
2614then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002615 AC_DEFINE(WITH_PYMALLOC, 1,
2616 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002617fi
2618AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002619
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002620# Check for Valgrind support
2621AC_MSG_CHECKING([for --with-valgrind])
2622AC_ARG_WITH([valgrind],
2623 AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2624 with_valgrind=no)
2625AC_MSG_RESULT([$with_valgrind])
2626if test "$with_valgrind" != no; then
2627 AC_CHECK_HEADER([valgrind/valgrind.h],
2628 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2629 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2630 )
2631fi
2632
Barry Warsawef82cd72000-06-30 16:21:01 +00002633# Check for --with-wctype-functions
2634AC_MSG_CHECKING(for --with-wctype-functions)
2635AC_ARG_WITH(wctype-functions,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002636 AC_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002637[
Barry Warsawef82cd72000-06-30 16:21:01 +00002638if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002639then
2640 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2641 [Define if you want wctype.h functions to be used instead of the
2642 one supplied by Python itself. (see Include/unicodectype.h).])
2643 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002644else AC_MSG_RESULT(no)
2645fi],
2646[AC_MSG_RESULT(no)])
2647
Guido van Rossum68242b51996-05-28 22:53:03 +00002648# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002649AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002650DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002651
Guido van Rossume97ee181999-12-20 21:27:22 +00002652# the dlopen() function means we might want to use dynload_shlib.o. some
2653# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002654AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002655
2656# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2657# loading of modules.
2658AC_SUBST(DYNLOADFILE)
2659AC_MSG_CHECKING(DYNLOADFILE)
2660if test -z "$DYNLOADFILE"
2661then
2662 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002663 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2664 if test "$ac_cv_func_dlopen" = yes
2665 then DYNLOADFILE="dynload_shlib.o"
2666 else DYNLOADFILE="dynload_aix.o"
2667 fi
2668 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002669 BeOS*) DYNLOADFILE="dynload_beos.o";;
2670 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002671 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2672 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002673 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002674 *)
2675 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2676 # out any dynamic loading
2677 if test "$ac_cv_func_dlopen" = yes
2678 then DYNLOADFILE="dynload_shlib.o"
2679 else DYNLOADFILE="dynload_stub.o"
2680 fi
2681 ;;
2682 esac
2683fi
2684AC_MSG_RESULT($DYNLOADFILE)
2685if test "$DYNLOADFILE" != "dynload_stub.o"
2686then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002687 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2688 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002689fi
2690
Jack Jansenc49e5b72001-06-19 15:00:23 +00002691# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2692
2693AC_SUBST(MACHDEP_OBJS)
2694AC_MSG_CHECKING(MACHDEP_OBJS)
2695if test -z "$MACHDEP_OBJS"
2696then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002697 MACHDEP_OBJS=$extra_machdep_objs
2698else
2699 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002700fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002701AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002702
Guido van Rossum627b2d71993-12-24 10:39:16 +00002703# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002704AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2705 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002706 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002707 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Antoine Pitrou30b3b352009-12-02 20:37:54 +00002708 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002709 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002710 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002711 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2712 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002713 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002714 setlocale setregid setreuid setresuid setresgid \
2715 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002716 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002717 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002718 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002719
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002720# For some functions, having a definition is not sufficient, since
2721# we want to take their address.
2722AC_MSG_CHECKING(for chroot)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002723AC_TRY_COMPILE([#include <unistd.h>], [void *x=chroot],
2724 AC_DEFINE(HAVE_CHROOT, 1, [Define if you have the 'chroot' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002725 AC_MSG_RESULT(yes),
2726 AC_MSG_RESULT(no)
2727)
2728AC_MSG_CHECKING(for link)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002729AC_TRY_COMPILE([#include <unistd.h>], [void *x=link],
2730 AC_DEFINE(HAVE_LINK, 1, [Define if you have the 'link' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002731 AC_MSG_RESULT(yes),
2732 AC_MSG_RESULT(no)
2733)
2734AC_MSG_CHECKING(for symlink)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002735AC_TRY_COMPILE([#include <unistd.h>], [void *x=symlink],
2736 AC_DEFINE(HAVE_SYMLINK, 1, [Define if you have the 'symlink' function.])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002737 AC_MSG_RESULT(yes),
2738 AC_MSG_RESULT(no)
2739)
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002740AC_MSG_CHECKING(for fchdir)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002741AC_TRY_COMPILE([#include <unistd.h>], [void *x=fchdir],
2742 AC_DEFINE(HAVE_FCHDIR, 1, [Define if you have the 'fchdir' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002743 AC_MSG_RESULT(yes),
2744 AC_MSG_RESULT(no)
2745)
2746AC_MSG_CHECKING(for fsync)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002747AC_TRY_COMPILE([#include <unistd.h>], [void *x=fsync],
2748 AC_DEFINE(HAVE_FSYNC, 1, [Define if you have the 'fsync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002749 AC_MSG_RESULT(yes),
2750 AC_MSG_RESULT(no)
2751)
2752AC_MSG_CHECKING(for fdatasync)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002753AC_TRY_COMPILE([#include <unistd.h>], [void *x=fdatasync],
2754 AC_DEFINE(HAVE_FDATASYNC, 1, [Define if you have the 'fdatasync' function.])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002755 AC_MSG_RESULT(yes),
2756 AC_MSG_RESULT(no)
2757)
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002758AC_MSG_CHECKING(for epoll)
Matthias Klose5183ebd2010-04-24 16:38:36 +00002759AC_TRY_COMPILE([#include <sys/epoll.h>], [void *x=epoll_create],
2760 AC_DEFINE(HAVE_EPOLL, 1, [Define if you have the 'epoll' functions.])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002761 AC_MSG_RESULT(yes),
2762 AC_MSG_RESULT(no)
2763)
2764AC_MSG_CHECKING(for kqueue)
2765AC_TRY_COMPILE([
2766#include <sys/types.h>
2767#include <sys/event.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002768 ], [int x=kqueue()],
2769 AC_DEFINE(HAVE_KQUEUE, 1, [Define if you have the 'kqueue' functions.])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002770 AC_MSG_RESULT(yes),
2771 AC_MSG_RESULT(no)
2772)
Martin v. Löwisd5843682002-11-21 20:41:28 +00002773# On some systems (eg. FreeBSD 5), we would find a definition of the
2774# functions ctermid_r, setgroups in the library, but no prototype
2775# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2776# address to avoid compiler warnings and potential miscompilations
2777# because of the missing prototypes.
2778
2779AC_MSG_CHECKING(for ctermid_r)
2780AC_TRY_COMPILE([
2781#include "confdefs.h"
2782#include <stdio.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002783], [void* p = ctermid_r],
2784 AC_DEFINE(HAVE_CTERMID_R, 1, [Define if you have the 'ctermid_r' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002785 AC_MSG_RESULT(yes),
2786 AC_MSG_RESULT(no)
2787)
2788
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002789AC_MSG_CHECKING(for flock)
2790AC_TRY_COMPILE([
2791#include "confdefs.h"
2792#include <sys/file.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002793], [void* p = flock],
2794 AC_DEFINE(HAVE_FLOCK, 1, [Define if you have the 'flock' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002795 AC_MSG_RESULT(yes),
2796 AC_MSG_RESULT(no)
2797)
2798
2799AC_MSG_CHECKING(for getpagesize)
2800AC_TRY_COMPILE([
2801#include "confdefs.h"
2802#include <unistd.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002803], [void* p = getpagesize],
2804 AC_DEFINE(HAVE_GETPAGESIZE, 1, [Define if you have the 'getpagesize' function.])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002805 AC_MSG_RESULT(yes),
2806 AC_MSG_RESULT(no)
2807)
2808
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002809dnl check for true
2810AC_CHECK_PROGS(TRUE, true, /bin/true)
2811
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002812dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2813dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002814AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002815 AC_CHECK_LIB(resolv, inet_aton)
2816)
2817
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002818# On Tru64, chflags seems to be present, but calling it will
2819# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00002820AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002821AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002822#include <sys/stat.h>
2823#include <unistd.h>
2824int main(int argc, char*argv[])
2825{
2826 if(chflags(argv[0], 0) != 0)
2827 return 1;
2828 return 0;
2829}
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002830]], ac_cv_have_chflags=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002831 ac_cv_have_chflags=no,
Gregory P. Smithbb213892009-11-02 01:37:37 +00002832 ac_cv_have_chflags=cross)
2833])
2834if test "$ac_cv_have_chflags" = cross ; then
2835 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2836fi
2837if test "$ac_cv_have_chflags" = yes ; then
Matthias Klose5183ebd2010-04-24 16:38:36 +00002838 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the `chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002839fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002840
Gregory P. Smithbb213892009-11-02 01:37:37 +00002841AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002842AC_TRY_RUN([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002843#include <sys/stat.h>
2844#include <unistd.h>
2845int main(int argc, char*argv[])
2846{
2847 if(lchflags(argv[0], 0) != 0)
2848 return 1;
2849 return 0;
2850}
Alexandre Vassalotti30267d62009-07-17 06:10:06 +00002851]], ac_cv_have_lchflags=yes,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002852 ac_cv_have_lchflags=no,
Gregory P. Smithbb213892009-11-02 01:37:37 +00002853 ac_cv_have_lchflags=cross)
2854])
2855if test "$ac_cv_have_lchflags" = cross ; then
2856 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2857fi
2858if test "$ac_cv_have_lchflags" = yes ; then
Matthias Klose5183ebd2010-04-24 16:38:36 +00002859 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the `lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00002860fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00002861
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002862dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00002863dnl
2864dnl On MacOSX the linker will search for dylibs on the entire linker path
2865dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2866dnl to revert to a more traditional unix behaviour and make it possible to
2867dnl override the system libz with a local static library of libz. Temporarily
2868dnl add that flag to our CFLAGS as well to ensure that we check the version
2869dnl of libz that will be used by setup.py.
2870dnl The -L/usr/local/lib is needed as wel to get the same compilation
2871dnl environment as setup.py (and leaving it out can cause configure to use the
2872dnl wrong version of the library)
2873case $ac_sys_system/$ac_sys_release in
2874Darwin/*)
2875 _CUR_CFLAGS="${CFLAGS}"
2876 _CUR_LDFLAGS="${LDFLAGS}"
2877 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2878 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2879 ;;
2880esac
2881
Matthias Klose5183ebd2010-04-24 16:38:36 +00002882AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00002883
Ronald Oussorenf8752642006-07-06 10:13:35 +00002884case $ac_sys_system/$ac_sys_release in
2885Darwin/*)
2886 CFLAGS="${_CUR_CFLAGS}"
2887 LDFLAGS="${_CUR_LDFLAGS}"
2888 ;;
2889esac
2890
Martin v. Löwise9416172003-05-03 10:12:45 +00002891AC_MSG_CHECKING(for hstrerror)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002892AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002893#include "confdefs.h"
2894#include <netdb.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002895], [void* p = hstrerror; hstrerror(0)],
2896 AC_DEFINE(HAVE_HSTRERROR, 1, [Define if you have the 'hstrerror' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002897 AC_MSG_RESULT(yes),
2898 AC_MSG_RESULT(no)
2899)
2900
2901AC_MSG_CHECKING(for inet_aton)
Martin v. Löwis95c419b2003-05-03 12:10:48 +00002902AC_TRY_LINK([
Martin v. Löwise9416172003-05-03 10:12:45 +00002903#include "confdefs.h"
Martin v. Löwis86d66262006-02-17 08:40:11 +00002904#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002905#include <sys/socket.h>
2906#include <netinet/in.h>
2907#include <arpa/inet.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002908], [void* p = inet_aton;inet_aton(0,0)],
2909 AC_DEFINE(HAVE_INET_ATON, 1, [Define if you have the 'inet_aton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002910 AC_MSG_RESULT(yes),
2911 AC_MSG_RESULT(no)
2912)
2913
2914AC_MSG_CHECKING(for inet_pton)
2915AC_TRY_COMPILE([
2916#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002917#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00002918#include <sys/socket.h>
2919#include <netinet/in.h>
2920#include <arpa/inet.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00002921], [void* p = inet_pton],
2922 AC_DEFINE(HAVE_INET_PTON, 1, [Define if you have the 'inet_pton' function.])
Martin v. Löwise9416172003-05-03 10:12:45 +00002923 AC_MSG_RESULT(yes),
2924 AC_MSG_RESULT(no)
2925)
2926
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002927# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00002928AC_MSG_CHECKING(for setgroups)
2929AC_TRY_COMPILE([
2930#include "confdefs.h"
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00002931#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00002932#ifdef HAVE_GRP_H
2933#include <grp.h>
2934#endif
Martin v. Löwisd5843682002-11-21 20:41:28 +00002935],
Matthias Klose5183ebd2010-04-24 16:38:36 +00002936[void* p = setgroups],
2937 AC_DEFINE(HAVE_SETGROUPS, 1, [Define if you have the 'setgroups' function.])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002938 AC_MSG_RESULT(yes),
2939 AC_MSG_RESULT(no)
2940)
2941
Fred Drake8cef4cf2000-06-28 16:40:38 +00002942# check for openpty and forkpty
2943
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00002944AC_CHECK_FUNCS(openpty,,
2945 AC_CHECK_LIB(util,openpty,
2946 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2947 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2948 )
2949)
2950AC_CHECK_FUNCS(forkpty,,
2951 AC_CHECK_LIB(util,forkpty,
2952 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2953 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2954 )
2955)
Fred Drake8cef4cf2000-06-28 16:40:38 +00002956
Brett Cannonaa5778d2008-03-18 04:09:00 +00002957# Stuff for expat.
2958AC_CHECK_FUNCS(memmove)
2959
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002960# check for long file support functions
2961AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2962
Brett Cannonaa5778d2008-03-18 04:09:00 +00002963AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002964AC_CHECK_FUNCS(getpgrp,
2965 AC_TRY_COMPILE([#include <unistd.h>],
2966 [getpgrp(0);],
2967 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2968 [Define if getpgrp() must be called as getpgrp(0).])
2969 )
2970)
Jack Jansen150753c2003-03-29 22:07:47 +00002971AC_CHECK_FUNCS(setpgrp,
2972 AC_TRY_COMPILE([#include <unistd.h>],
2973 [setpgrp(0,0);],
2974 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2975 [Define if setpgrp() must be called as setpgrp(0, 0).])
2976 )
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002977)
2978AC_CHECK_FUNCS(gettimeofday,
2979 AC_TRY_COMPILE([#include <sys/time.h>],
2980 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2981 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2982 [Define if gettimeofday() does not have second (timezone) argument
2983 This is the case on Motorola V4 (R40V4.2)])
2984 )
2985)
Guido van Rossum627b2d71993-12-24 10:39:16 +00002986
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002987AC_MSG_CHECKING(for major, minor, and makedev)
Martin v. Löwise3271202002-11-07 07:42:30 +00002988AC_TRY_LINK([
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002989#if defined(MAJOR_IN_MKDEV)
2990#include <sys/mkdev.h>
2991#elif defined(MAJOR_IN_SYSMACROS)
2992#include <sys/sysmacros.h>
2993#else
2994#include <sys/types.h>
2995#endif
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00002996],[
2997 makedev(major(0),minor(0));
2998],[
2999 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3000 [Define to 1 if you have the device macros.])
3001 AC_MSG_RESULT(yes)
3002],[
3003 AC_MSG_RESULT(no)
3004])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003005
3006# On OSF/1 V5.1, getaddrinfo is available, but a define
3007# for [no]getaddrinfo in netdb.h.
3008AC_MSG_CHECKING(for getaddrinfo)
3009AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003010#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003011#include <sys/socket.h>
3012#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003013#include <stdio.h>
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003014], [getaddrinfo(NULL, NULL, NULL, NULL);],
3015have_getaddrinfo=yes,
3016have_getaddrinfo=no)
3017AC_MSG_RESULT($have_getaddrinfo)
3018if test $have_getaddrinfo = yes
3019then
3020 AC_MSG_CHECKING(getaddrinfo bug)
3021 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
3022 AC_TRY_RUN([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003023#include <sys/types.h>
3024#include <netdb.h>
3025#include <string.h>
3026#include <sys/socket.h>
3027#include <netinet/in.h>
3028
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003029int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003030{
3031 int passive, gaierr, inet4 = 0, inet6 = 0;
3032 struct addrinfo hints, *ai, *aitop;
3033 char straddr[INET6_ADDRSTRLEN], strport[16];
3034
3035 for (passive = 0; passive <= 1; passive++) {
3036 memset(&hints, 0, sizeof(hints));
3037 hints.ai_family = AF_UNSPEC;
3038 hints.ai_flags = passive ? AI_PASSIVE : 0;
3039 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003040 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003041 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3042 (void)gai_strerror(gaierr);
3043 goto bad;
3044 }
3045 for (ai = aitop; ai; ai = ai->ai_next) {
3046 if (ai->ai_addr == NULL ||
3047 ai->ai_addrlen == 0 ||
3048 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3049 straddr, sizeof(straddr), strport, sizeof(strport),
3050 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3051 goto bad;
3052 }
3053 switch (ai->ai_family) {
3054 case AF_INET:
3055 if (strcmp(strport, "54321") != 0) {
3056 goto bad;
3057 }
3058 if (passive) {
3059 if (strcmp(straddr, "0.0.0.0") != 0) {
3060 goto bad;
3061 }
3062 } else {
3063 if (strcmp(straddr, "127.0.0.1") != 0) {
3064 goto bad;
3065 }
3066 }
3067 inet4++;
3068 break;
3069 case AF_INET6:
3070 if (strcmp(strport, "54321") != 0) {
3071 goto bad;
3072 }
3073 if (passive) {
3074 if (strcmp(straddr, "::") != 0) {
3075 goto bad;
3076 }
3077 } else {
3078 if (strcmp(straddr, "::1") != 0) {
3079 goto bad;
3080 }
3081 }
3082 inet6++;
3083 break;
3084 case AF_UNSPEC:
3085 goto bad;
3086 break;
3087 default:
3088 /* another family support? */
3089 break;
3090 }
3091 }
3092 }
3093
3094 if (!(inet4 == 0 || inet4 == 2))
3095 goto bad;
3096 if (!(inet6 == 0 || inet6 == 2))
3097 goto bad;
3098
3099 if (aitop)
3100 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003101 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003102
3103 bad:
3104 if (aitop)
3105 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003106 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003107}
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003108]], ac_cv_buggy_getaddrinfo=no,
3109 ac_cv_buggy_getaddrinfo=yes,
3110 ac_cv_buggy_getaddrinfo=yes))
3111fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003112
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003113if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003114then
3115 if test $ipv6 = yes
3116 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003117 echo 'Fatal: You must get working getaddrinfo() function.'
3118 echo ' or you can specify "--disable-ipv6"'.
3119 exit 1
3120 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003121else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003122 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003123fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003124AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003125
Guido van Rossum627b2d71993-12-24 10:39:16 +00003126# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003127AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003128AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003129AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003130AC_CHECK_MEMBERS([struct stat.st_rdev])
3131AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003132AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003133AC_CHECK_MEMBERS([struct stat.st_gen])
3134AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003135AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003136
3137AC_MSG_CHECKING(for time.h that defines altzone)
3138AC_CACHE_VAL(ac_cv_header_time_altzone,
3139[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
3140 ac_cv_header_time_altzone=yes,
3141 ac_cv_header_time_altzone=no)])
3142AC_MSG_RESULT($ac_cv_header_time_altzone)
3143if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003144 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003145fi
3146
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003147was_it_defined=no
3148AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003149AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003150#include <sys/types.h>
3151#include <sys/select.h>
3152#include <sys/time.h>
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003153], [;], [
3154 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3155 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3156 (which you can't on SCO ODT 3.0).])
3157 was_it_defined=yes
3158])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003159AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003160
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003161AC_MSG_CHECKING(for addrinfo)
3162AC_CACHE_VAL(ac_cv_struct_addrinfo,
3163AC_TRY_COMPILE([
3164# include <netdb.h>],
3165 [struct addrinfo a],
3166 ac_cv_struct_addrinfo=yes,
3167 ac_cv_struct_addrinfo=no))
3168AC_MSG_RESULT($ac_cv_struct_addrinfo)
3169if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003170 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003171fi
3172
3173AC_MSG_CHECKING(for sockaddr_storage)
3174AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
3175AC_TRY_COMPILE([
3176# include <sys/types.h>
3177# include <sys/socket.h>],
3178 [struct sockaddr_storage s],
3179 ac_cv_struct_sockaddr_storage=yes,
3180 ac_cv_struct_sockaddr_storage=no))
3181AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3182if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003183 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003184fi
3185
Guido van Rossum627b2d71993-12-24 10:39:16 +00003186# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003187
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003188AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003189AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003190
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003191works=no
3192AC_MSG_CHECKING(for working volatile)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003193AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
3194 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3195)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003196AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003197
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003198works=no
3199AC_MSG_CHECKING(for working signed char)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003200AC_TRY_COMPILE([], [signed char c;], works=yes,
3201 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3202)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003203AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003204
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003205have_prototypes=no
3206AC_MSG_CHECKING(for prototypes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003207AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3208 AC_DEFINE(HAVE_PROTOTYPES, 1,
3209 [Define if your compiler supports function prototype])
3210 have_prototypes=yes
3211])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003212AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003213
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003214works=no
3215AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003216AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003217#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003218int foo(int x, ...) {
3219 va_list va;
3220 va_start(va, x);
3221 va_arg(va, int);
3222 va_arg(va, char *);
3223 va_arg(va, double);
3224 return 0;
3225}
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003226], [return foo(10, "", 3.14);], [
3227 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3228 [Define if your compiler supports variable length function prototypes
3229 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3230 works=yes
3231])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003232AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003233
Dave Cole331708b2004-08-09 04:51:41 +00003234# check for socketpair
3235AC_MSG_CHECKING(for socketpair)
3236AC_TRY_COMPILE([
3237#include <sys/types.h>
3238#include <sys/socket.h>
Matthias Klose5183ebd2010-04-24 16:38:36 +00003239], [void *x=socketpair],
3240 AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
Dave Cole331708b2004-08-09 04:51:41 +00003241 AC_MSG_RESULT(yes),
3242 AC_MSG_RESULT(no)
3243)
3244
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003245# check if sockaddr has sa_len member
3246AC_MSG_CHECKING(if sockaddr has sa_len member)
3247AC_TRY_COMPILE([#include <sys/types.h>
3248#include <sys/socket.h>],
3249[struct sockaddr x;
3250x.sa_len = 0;],
3251 AC_MSG_RESULT(yes)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003252 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003253 AC_MSG_RESULT(no))
3254
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003255va_list_is_array=no
3256AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003257AC_TRY_COMPILE([
3258#ifdef HAVE_STDARG_PROTOTYPES
3259#include <stdarg.h>
3260#else
3261#include <varargs.h>
3262#endif
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003263], [va_list list1, list2; list1 = list2;], , [
3264 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3265 va_list_is_array=yes
3266])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003267AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003268
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003269# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003270AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3271 [Define this if you have some version of gethostbyname_r()])
3272
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003273AC_CHECK_FUNC(gethostbyname_r, [
3274 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3275 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3276 OLD_CFLAGS=$CFLAGS
3277 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3278 AC_TRY_COMPILE([
3279# include <netdb.h>
3280 ], [
3281 char *name;
3282 struct hostent *he, *res;
3283 char buffer[2048];
3284 int buflen = 2048;
3285 int h_errnop;
3286
3287 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3288 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003289 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003290 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3291 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003292 AC_MSG_RESULT(yes)
3293 ], [
3294 AC_MSG_RESULT(no)
3295 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3296 AC_TRY_COMPILE([
3297# include <netdb.h>
3298 ], [
3299 char *name;
3300 struct hostent *he;
3301 char buffer[2048];
3302 int buflen = 2048;
3303 int h_errnop;
3304
3305 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3306 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003307 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003308 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3309 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003310 AC_MSG_RESULT(yes)
3311 ], [
3312 AC_MSG_RESULT(no)
3313 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3314 AC_TRY_COMPILE([
3315# include <netdb.h>
3316 ], [
3317 char *name;
3318 struct hostent *he;
3319 struct hostent_data data;
3320
3321 (void) gethostbyname_r(name, he, &data);
3322 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003323 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003324 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3325 [Define this if you have the 3-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003326 AC_MSG_RESULT(yes)
3327 ], [
3328 AC_MSG_RESULT(no)
3329 ])
3330 ])
3331 ])
3332 CFLAGS=$OLD_CFLAGS
3333], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003334 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003335])
3336AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3337AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3338AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003339AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003340AC_SUBST(HAVE_GETHOSTBYNAME)
3341
Guido van Rossum627b2d71993-12-24 10:39:16 +00003342# checks for system services
3343# (none yet)
3344
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003345# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003346AC_CHECK_FUNC(__fpu_control,
3347 [],
3348 [AC_CHECK_LIB(ieee, __fpu_control)
3349])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003350
Guido van Rossum93274221997-05-09 02:42:00 +00003351# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003352AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003353AC_ARG_WITH(fpectl,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003354 AC_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003355[
Guido van Rossum93274221997-05-09 02:42:00 +00003356if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003357then
3358 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3359 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3360 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003361else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003362fi],
3363[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003364
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003365# check for --with-libm=...
3366AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003367case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003368Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003369BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003370*) LIBM=-lm
3371esac
Guido van Rossum93274221997-05-09 02:42:00 +00003372AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003373AC_ARG_WITH(libm,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003374 AC_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003375[
Guido van Rossum93274221997-05-09 02:42:00 +00003376if test "$withval" = no
3377then LIBM=
3378 AC_MSG_RESULT(force LIBM empty)
3379elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003380then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003381 AC_MSG_RESULT(set LIBM="$withval")
3382else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003383fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003384[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003385
3386# check for --with-libc=...
3387AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003388AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003389AC_ARG_WITH(libc,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003390 AC_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003391[
Guido van Rossum93274221997-05-09 02:42:00 +00003392if test "$withval" = no
3393then LIBC=
3394 AC_MSG_RESULT(force LIBC empty)
3395elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003396then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003397 AC_MSG_RESULT(set LIBC="$withval")
3398else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003399fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003400[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003401
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003402# **************************************************
3403# * Check for various properties of floating point *
3404# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003405
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003406AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3407AC_CACHE_VAL(ac_cv_little_endian_double, [
3408AC_TRY_RUN([
3409#include <string.h>
3410int main() {
3411 double x = 9006104071832581.0;
3412 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3413 return 0;
3414 else
3415 return 1;
3416}
3417],
3418ac_cv_little_endian_double=yes,
3419ac_cv_little_endian_double=no,
3420ac_cv_little_endian_double=no)])
3421AC_MSG_RESULT($ac_cv_little_endian_double)
3422if test "$ac_cv_little_endian_double" = yes
3423then
3424 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3425 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3426 with the least significant byte first])
3427fi
3428
3429AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3430AC_CACHE_VAL(ac_cv_big_endian_double, [
3431AC_TRY_RUN([
3432#include <string.h>
3433int main() {
3434 double x = 9006104071832581.0;
3435 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3436 return 0;
3437 else
3438 return 1;
3439}
3440],
3441ac_cv_big_endian_double=yes,
3442ac_cv_big_endian_double=no,
3443ac_cv_big_endian_double=no)])
3444AC_MSG_RESULT($ac_cv_big_endian_double)
3445if test "$ac_cv_big_endian_double" = yes
3446then
3447 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3448 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3449 with the most significant byte first])
3450fi
3451
3452# Some ARM platforms use a mixed-endian representation for doubles.
3453# While Python doesn't currently have full support for these platforms
3454# (see e.g., issue 1762561), we can at least make sure that float <-> string
3455# conversions work.
3456AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3457AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3458AC_TRY_RUN([
3459#include <string.h>
3460int main() {
3461 double x = 9006104071832581.0;
3462 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3463 return 0;
3464 else
3465 return 1;
3466}
3467],
3468ac_cv_mixed_endian_double=yes,
3469ac_cv_mixed_endian_double=no,
3470ac_cv_mixed_endian_double=no)])
3471AC_MSG_RESULT($ac_cv_mixed_endian_double)
3472if test "$ac_cv_mixed_endian_double" = yes
3473then
3474 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3475 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3476 in ARM mixed-endian order (byte order 45670123)])
3477fi
3478
3479# The short float repr introduced in Python 3.1 requires the
3480# correctly-rounded string <-> double conversion functions from
3481# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3482# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003483# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003484# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003485
3486# This inline assembler syntax may also work for suncc and icc,
3487# so we try it on all platforms.
3488
3489AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3490AC_TRY_COMPILE([], [
3491 unsigned short cw;
3492 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3493 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3494],
3495[have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3496AC_MSG_RESULT($have_gcc_asm_for_x87)
3497if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003498then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003499 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3500 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003501fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003502
Mark Dickinson04b27232009-01-04 12:29:36 +00003503# Detect whether system arithmetic is subject to x87-style double
3504# rounding issues. The result of this test has little meaning on non
3505# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3506# mode is round-to-nearest and double rounding issues are present, and
3507# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3508AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003509# $BASECFLAGS may affect the result
3510ac_save_cc="$CC"
3511CC="$CC $BASECFLAGS"
Mark Dickinson04b27232009-01-04 12:29:36 +00003512AC_TRY_RUN([
3513#include <stdlib.h>
3514#include <math.h>
3515int main() {
3516 volatile double x, y, z;
3517 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3518 x = 0.99999999999999989; /* 1-2**-53 */
3519 y = 1./x;
3520 if (y != 1.)
3521 exit(0);
3522 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3523 x = 1e16;
3524 y = 2.99999;
3525 z = x + y;
3526 if (z != 1e16+4.)
3527 exit(0);
3528 /* both tests show evidence of double rounding */
3529 exit(1);
3530}
3531],
3532ac_cv_x87_double_rounding=no,
3533ac_cv_x87_double_rounding=yes,
Mark Dickinson99abd142009-10-24 13:44:16 +00003534ac_cv_x87_double_rounding=no)
3535CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003536AC_MSG_RESULT($ac_cv_x87_double_rounding)
3537if test "$ac_cv_x87_double_rounding" = yes
3538then
3539 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3540 [Define if arithmetic is subject to x87-style double rounding issue])
3541fi
3542
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003543# ************************************
3544# * Check for mathematical functions *
3545# ************************************
3546
3547LIBS_SAVE=$LIBS
3548LIBS="$LIBS $LIBM"
3549
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003550# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3551# -0. on some architectures.
3552AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3553AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3554AC_TRY_RUN([
3555#include <math.h>
3556#include <stdlib.h>
3557int main() {
3558 /* return 0 if either negative zeros don't exist
3559 on this platform or if negative zeros exist
3560 and tanh(-0.) == -0. */
3561 if (atan2(0., -1.) == atan2(-0., -1.) ||
3562 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3563 else exit(1);
3564}
3565],
3566ac_cv_tanh_preserves_zero_sign=yes,
3567ac_cv_tanh_preserves_zero_sign=no,
3568ac_cv_tanh_preserves_zero_sign=no)])
3569AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3570if test "$ac_cv_tanh_preserves_zero_sign" = yes
3571then
3572 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3573 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3574fi
3575
3576AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3577AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3578AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3579
3580LIBS=$LIBS_SAVE
3581
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003582# For multiprocessing module, check that sem_open
3583# actually works. For FreeBSD versions <= 7.2,
3584# the kernel module that provides POSIX semaphores
3585# isn't loaded by default, so an attempt to call
3586# sem_open results in a 'Signal 12' error.
3587AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3588AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3589AC_TRY_RUN([
3590#include <unistd.h>
3591#include <fcntl.h>
3592#include <stdio.h>
3593#include <semaphore.h>
3594#include <sys/stat.h>
3595
3596int main(void) {
3597 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3598 if (a == SEM_FAILED) {
3599 perror("sem_open");
3600 return 1;
3601 }
3602 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003603 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003604 return 0;
3605}
3606], ac_cv_posix_semaphores_enabled=yes,
3607 ac_cv_posix_semaphores_enabled=no,
3608 ac_cv_posix_semaphores_enabled=yes)
3609)
3610AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3611if test $ac_cv_posix_semaphores_enabled = no
3612then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003613 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3614 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003615fi
3616
Jesse Noller355b1262009-04-02 00:03:28 +00003617# Multiprocessing check for broken sem_getvalue
3618AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003619AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Jesse Noller355b1262009-04-02 00:03:28 +00003620AC_TRY_RUN([
3621#include <unistd.h>
3622#include <fcntl.h>
3623#include <stdio.h>
3624#include <semaphore.h>
3625#include <sys/stat.h>
3626
3627int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003628 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003629 int count;
3630 int res;
3631 if(a==SEM_FAILED){
3632 perror("sem_open");
3633 return 1;
3634
3635 }
3636 res = sem_getvalue(a, &count);
3637 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003638 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003639 return res==-1 ? 1 : 0;
3640}
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003641], ac_cv_broken_sem_getvalue=no,
3642 ac_cv_broken_sem_getvalue=yes,
3643 ac_cv_broken_sem_getvalue=yes)
Jesse Noller355b1262009-04-02 00:03:28 +00003644)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003645AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3646if test $ac_cv_broken_sem_getvalue = yes
3647then
3648 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3649 [define to 1 if your sem_getvalue is broken.])
3650fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003651
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003652# determine what size digit to use for Python's longs
3653AC_MSG_CHECKING([digit size for Python's longs])
3654AC_ARG_ENABLE(big-digits,
3655AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3656[case $enable_big_digits in
3657yes)
3658 enable_big_digits=30 ;;
3659no)
3660 enable_big_digits=15 ;;
3661[15|30])
3662 ;;
3663*)
3664 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3665esac
3666AC_MSG_RESULT($enable_big_digits)
3667AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3668],
3669[AC_MSG_RESULT(no value specified)])
3670
Guido van Rossumef2255b2000-03-10 22:30:29 +00003671# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003672AC_CHECK_HEADER(wchar.h, [
3673 AC_DEFINE(HAVE_WCHAR_H, 1,
3674 [Define if the compiler provides a wchar.h header file.])
3675 wchar_h="yes"
3676],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003677wchar_h="no"
3678)
3679
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003680# determine wchar_t size
3681if test "$wchar_h" = yes
3682then
Guido van Rossum67b26592001-10-20 14:21:45 +00003683 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003684fi
3685
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003686AC_MSG_CHECKING(for UCS-4 tcl)
3687have_ucs4_tcl=no
3688AC_TRY_COMPILE([
3689#include <tcl.h>
3690#if TCL_UTF_MAX != 6
3691# error "NOT UCS4_TCL"
3692#endif], [], [
3693 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3694 have_ucs4_tcl=yes
3695])
3696AC_MSG_RESULT($have_ucs4_tcl)
3697
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003698# check whether wchar_t is signed or not
3699if test "$wchar_h" = yes
3700then
3701 # check whether wchar_t is signed or not
3702 AC_MSG_CHECKING(whether wchar_t is signed)
3703 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3704 AC_TRY_RUN([
3705 #include <wchar.h>
3706 int main()
3707 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003708 /* Success: exit code 0 */
3709 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003710 }
3711 ],
3712 ac_cv_wchar_t_signed=yes,
3713 ac_cv_wchar_t_signed=no,
3714 ac_cv_wchar_t_signed=yes)])
3715 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3716fi
3717
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003718AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003719dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003720AC_ARG_ENABLE(unicode,
Matthias Klose5183ebd2010-04-24 16:38:36 +00003721 AC_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is yes)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003722 [],
3723 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003724
3725if test $enable_unicode = yes
3726then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003727 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003728 case "$have_ucs4_tcl" in
3729 yes) enable_unicode="ucs4"
3730 ;;
3731 *) enable_unicode="ucs2"
3732 ;;
3733 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003734fi
3735
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003736AH_TEMPLATE(Py_UNICODE_SIZE,
3737 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003738case "$enable_unicode" in
3739ucs2) unicode_size="2"
3740 AC_DEFINE(Py_UNICODE_SIZE,2)
3741 ;;
3742ucs4) unicode_size="4"
3743 AC_DEFINE(Py_UNICODE_SIZE,4)
3744 ;;
Ezio Melotti5820efb2010-02-27 00:05:42 +00003745*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003746esac
3747
Martin v. Löwis11437992002-04-12 09:54:03 +00003748AH_TEMPLATE(PY_UNICODE_TYPE,
3749 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003750
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003751AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003752if test "$enable_unicode" = "no"
3753then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003754 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003755 AC_MSG_RESULT(not used)
3756else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003757 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003758 AC_DEFINE(Py_USING_UNICODE, 1,
3759 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003760
3761 # wchar_t is only usable if it maps to an unsigned type
3762 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003763 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003764 then
3765 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003766 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3767 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003768 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003769 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003770 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3771 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3772 then
3773 PY_UNICODE_TYPE="unsigned short"
3774 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3775 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3776 then
3777 PY_UNICODE_TYPE="unsigned long"
3778 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3779 else
3780 PY_UNICODE_TYPE="no type found"
3781 fi
3782 AC_MSG_RESULT($PY_UNICODE_TYPE)
3783fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003784
3785# check for endianness
3786AC_C_BIGENDIAN
3787
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003788# Check whether right shifting a negative integer extends the sign bit
3789# or fills with zeros (like the Cray J90, according to Tim Peters).
3790AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00003791AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003792AC_TRY_RUN([
3793int main()
3794{
Vladimir Marangozova6180282000-07-12 05:05:06 +00003795 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003796}
Guido van Rossum3065c942001-09-17 04:03:14 +00003797],
3798ac_cv_rshift_extends_sign=yes,
3799ac_cv_rshift_extends_sign=no,
3800ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003801AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3802if test "$ac_cv_rshift_extends_sign" = no
3803then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003804 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3805 [Define if i>>j for signed int i does not extend the sign bit
3806 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00003807fi
3808
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003809# check for getc_unlocked and related locking functions
3810AC_MSG_CHECKING(for getc_unlocked() and friends)
3811AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3812AC_TRY_LINK([#include <stdio.h>],[
3813 FILE *f = fopen("/dev/null", "r");
3814 flockfile(f);
3815 getc_unlocked(f);
3816 funlockfile(f);
3817], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3818AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3819if test "$ac_cv_have_getc_unlocked" = yes
3820then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003821 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3822 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00003823fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00003824
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003825# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00003826# save the value of LIBS so we don't actually link Python with readline
3827LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003828
3829# On some systems we need to link readline to a termcap compatible
3830# library. NOTE: Keep the precedence of listed libraries synchronised
3831# with setup.py.
3832py_cv_lib_readline=no
3833AC_MSG_CHECKING([how to link readline libs])
3834for py_libtermcap in "" ncursesw ncurses curses termcap; do
3835 if test -z "$py_libtermcap"; then
3836 READLINE_LIBS="-lreadline"
3837 else
3838 READLINE_LIBS="-lreadline -l$py_libtermcap"
3839 fi
3840 LIBS="$READLINE_LIBS $LIBS_no_readline"
3841 AC_LINK_IFELSE(
3842 [AC_LANG_CALL([],[readline])],
3843 [py_cv_lib_readline=yes])
3844 if test $py_cv_lib_readline = yes; then
3845 break
3846 fi
3847done
3848# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3849#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00003850if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00003851 AC_MSG_RESULT([none])
3852else
3853 AC_MSG_RESULT([$READLINE_LIBS])
3854 AC_DEFINE(HAVE_LIBREADLINE, 1,
3855 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00003856fi
3857
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003858# check for readline 2.1
3859AC_CHECK_LIB(readline, rl_callback_handler_install,
3860 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003861 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003862
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003863# check for readline 2.2
3864AC_TRY_CPP([#include <readline/readline.h>],
3865have_readline=yes, have_readline=no)
3866if test $have_readline = yes
3867then
3868 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3869 [readline/readline.h],
3870 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3871 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00003872 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3873 [readline/readline.h],
3874 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3875 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00003876fi
3877
Martin v. Löwis0daad592001-09-30 21:09:59 +00003878# check for readline 4.0
3879AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003880 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003881 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00003882
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003883# also in 4.0
3884AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3885 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003886 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00003887
Guido van Rossum353ae582001-07-10 16:45:32 +00003888# check for readline 4.2
3889AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003890 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00003891 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00003892
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00003893# also in readline 4.2
3894AC_TRY_CPP([#include <readline/readline.h>],
3895have_readline=yes, have_readline=no)
3896if test $have_readline = yes
3897then
3898 AC_EGREP_HEADER([extern int rl_catch_signals;],
3899 [readline/readline.h],
3900 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3901 [Define if you can turn off readline's signal handling.]), )
3902fi
3903
Martin v. Löwis82bca632006-02-10 20:49:30 +00003904# End of readline checks: restore LIBS
3905LIBS=$LIBS_no_readline
3906
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003907AC_MSG_CHECKING(for broken nice())
3908AC_CACHE_VAL(ac_cv_broken_nice, [
3909AC_TRY_RUN([
3910int main()
3911{
3912 int val1 = nice(1);
3913 if (val1 != -1 && val1 == nice(2))
3914 exit(0);
3915 exit(1);
3916}
Guido van Rossum3065c942001-09-17 04:03:14 +00003917],
3918ac_cv_broken_nice=yes,
3919ac_cv_broken_nice=no,
3920ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003921AC_MSG_RESULT($ac_cv_broken_nice)
3922if test "$ac_cv_broken_nice" = yes
3923then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003924 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3925 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00003926fi
3927
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003928AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003929AC_CACHE_VAL(ac_cv_broken_poll,
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003930AC_TRY_RUN([
3931#include <poll.h>
3932
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003933int main()
3934{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003935 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003936 int poll_test;
3937
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003938 close (42);
3939
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003940 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003941 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003942 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003943 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003944 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003945 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00003946 return 1;
3947}
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003948],
3949ac_cv_broken_poll=yes,
3950ac_cv_broken_poll=no,
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003951ac_cv_broken_poll=no))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003952AC_MSG_RESULT($ac_cv_broken_poll)
3953if test "$ac_cv_broken_poll" = yes
3954then
3955 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3956 [Define if poll() sets errno on invalid file descriptors.])
3957fi
3958
Brett Cannon43802422005-02-10 20:48:03 +00003959# Before we can test tzset, we need to check if struct tm has a tm_zone
3960# (which is not required by ISO C or UNIX spec) and/or if we support
3961# tzname[]
3962AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00003963
Brett Cannon43802422005-02-10 20:48:03 +00003964# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003965AC_MSG_CHECKING(for working tzset())
3966AC_CACHE_VAL(ac_cv_working_tzset, [
3967AC_TRY_RUN([
3968#include <stdlib.h>
3969#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00003970#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00003971
3972#if HAVE_TZNAME
3973extern char *tzname[];
3974#endif
3975
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003976int main()
3977{
Brett Cannon18367812003-09-19 00:59:16 +00003978 /* Note that we need to ensure that not only does tzset(3)
3979 do 'something' with localtime, but it works as documented
3980 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00003981 This includes making sure that tzname is set properly if
3982 tm->tm_zone does not exist since it is the alternative way
3983 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00003984
3985 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00003986 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00003987 */
3988
Brett Cannon43802422005-02-10 20:48:03 +00003989 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00003990 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3991
Neal Norwitz7f2588c2003-04-11 15:35:53 +00003992 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00003993 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00003994 if (localtime(&groundhogday)->tm_hour != 0)
3995 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00003996#if HAVE_TZNAME
3997 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3998 if (strcmp(tzname[0], "UTC") ||
3999 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4000 exit(1);
4001#endif
Brett Cannon18367812003-09-19 00:59:16 +00004002
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004003 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004004 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004005 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004006 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004007#if HAVE_TZNAME
4008 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4009 exit(1);
4010#endif
Brett Cannon18367812003-09-19 00:59:16 +00004011
4012 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4013 tzset();
4014 if (localtime(&groundhogday)->tm_hour != 11)
4015 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004016#if HAVE_TZNAME
4017 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4018 exit(1);
4019#endif
4020
4021#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004022 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4023 exit(1);
4024 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4025 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004026#endif
Brett Cannon18367812003-09-19 00:59:16 +00004027
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004028 exit(0);
4029}
4030],
4031ac_cv_working_tzset=yes,
4032ac_cv_working_tzset=no,
4033ac_cv_working_tzset=no)])
4034AC_MSG_RESULT($ac_cv_working_tzset)
4035if test "$ac_cv_working_tzset" = yes
4036then
4037 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4038 [Define if tzset() actually switches the local timezone in a meaningful way.])
4039fi
4040
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004041# Look for subsecond timestamps in struct stat
4042AC_MSG_CHECKING(for tv_nsec in struct stat)
4043AC_CACHE_VAL(ac_cv_stat_tv_nsec,
4044AC_TRY_COMPILE([#include <sys/stat.h>], [
4045struct stat st;
4046st.st_mtim.tv_nsec = 1;
4047],
Martin v. Löwisa32c9942002-09-09 16:17:47 +00004048ac_cv_stat_tv_nsec=yes,
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004049ac_cv_stat_tv_nsec=no,
4050ac_cv_stat_tv_nsec=no))
4051AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4052if test "$ac_cv_stat_tv_nsec" = yes
4053then
4054 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4055 [Define if you have struct stat.st_mtim.tv_nsec])
4056fi
4057
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004058# Look for BSD style subsecond timestamps in struct stat
4059AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4060AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
4061AC_TRY_COMPILE([#include <sys/stat.h>], [
4062struct stat st;
4063st.st_mtimespec.tv_nsec = 1;
4064],
4065ac_cv_stat_tv_nsec2=yes,
4066ac_cv_stat_tv_nsec2=no,
4067ac_cv_stat_tv_nsec2=no))
4068AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4069if test "$ac_cv_stat_tv_nsec2" = yes
4070then
4071 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4072 [Define if you have struct stat.st_mtimensec])
4073fi
4074
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004075# On HP/UX 11.0, mvwdelch is a block with a return statement
4076AC_MSG_CHECKING(whether mvwdelch is an expression)
4077AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
4078AC_TRY_COMPILE([#include <curses.h>], [
4079 int rtn;
4080 rtn = mvwdelch(0,0,0);
4081], ac_cv_mvwdelch_is_expression=yes,
4082 ac_cv_mvwdelch_is_expression=no,
4083 ac_cv_mvwdelch_is_expression=yes))
4084AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4085
4086if test "$ac_cv_mvwdelch_is_expression" = yes
4087then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004088 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4089 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004090fi
4091
4092AC_MSG_CHECKING(whether WINDOW has _flags)
4093AC_CACHE_VAL(ac_cv_window_has_flags,
4094AC_TRY_COMPILE([#include <curses.h>], [
4095 WINDOW *w;
4096 w->_flags = 0;
4097], ac_cv_window_has_flags=yes,
4098 ac_cv_window_has_flags=no,
4099 ac_cv_window_has_flags=no))
4100AC_MSG_RESULT($ac_cv_window_has_flags)
4101
4102
4103if test "$ac_cv_window_has_flags" = yes
4104then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004105 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4106 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004107fi
4108
Walter Dörwald4994d952006-06-19 08:07:50 +00004109AC_MSG_CHECKING(for is_term_resized)
Matthias Klose5183ebd2010-04-24 16:38:36 +00004110AC_TRY_COMPILE([#include <curses.h>], [void *x=is_term_resized],
4111 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, [Define if you have the 'is_term_resized' function.])
Walter Dörwald4994d952006-06-19 08:07:50 +00004112 AC_MSG_RESULT(yes),
4113 AC_MSG_RESULT(no)
4114)
4115
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004116AC_MSG_CHECKING(for resize_term)
Matthias Klose5183ebd2010-04-24 16:38:36 +00004117AC_TRY_COMPILE([#include <curses.h>], [void *x=resize_term],
4118 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, [Define if you have the 'resize_term' function.])
Walter Dörwald4994d952006-06-19 08:07:50 +00004119 AC_MSG_RESULT(yes),
4120 AC_MSG_RESULT(no)
4121)
4122
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004123AC_MSG_CHECKING(for resizeterm)
Matthias Klose5183ebd2010-04-24 16:38:36 +00004124AC_TRY_COMPILE([#include <curses.h>], [void *x=resizeterm],
4125 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, [Define if you have the 'resizeterm' function.])
Walter Dörwald4994d952006-06-19 08:07:50 +00004126 AC_MSG_RESULT(yes),
4127 AC_MSG_RESULT(no)
4128)
4129
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004130AC_MSG_CHECKING(for /dev/ptmx)
4131
4132if test -r /dev/ptmx
4133then
4134 AC_MSG_RESULT(yes)
4135 AC_DEFINE(HAVE_DEV_PTMX, 1,
4136 [Define if we have /dev/ptmx.])
4137else
4138 AC_MSG_RESULT(no)
4139fi
4140
4141AC_MSG_CHECKING(for /dev/ptc)
4142
4143if test -r /dev/ptc
4144then
4145 AC_MSG_RESULT(yes)
4146 AC_DEFINE(HAVE_DEV_PTC, 1,
4147 [Define if we have /dev/ptc.])
4148else
4149 AC_MSG_RESULT(no)
4150fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004151
Mark Dickinson82864d12009-11-15 16:18:58 +00004152if test "$have_long_long" = yes
4153then
4154 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4155 AC_CACHE_VAL(ac_cv_have_long_long_format,
4156 AC_TRY_RUN([[
4157 #include <stdio.h>
4158 #include <stddef.h>
4159 #include <string.h>
4160
4161 #ifdef HAVE_SYS_TYPES_H
4162 #include <sys/types.h>
4163 #endif
4164
4165 int main()
4166 {
4167 char buffer[256];
4168
4169 if (sprintf(buffer, "%lld", (long long)123) < 0)
4170 return 1;
4171 if (strcmp(buffer, "123"))
4172 return 1;
4173
4174 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4175 return 1;
4176 if (strcmp(buffer, "-123"))
4177 return 1;
4178
4179 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4180 return 1;
4181 if (strcmp(buffer, "123"))
4182 return 1;
4183
4184 return 0;
4185 }
4186 ]], ac_cv_have_long_long_format=yes,
4187 ac_cv_have_long_long_format=no,
4188 ac_cv_have_long_long_format=no)
4189 )
4190 AC_MSG_RESULT($ac_cv_have_long_long_format)
4191fi
4192
Mark Dickinson5ce84742009-12-31 20:48:04 +00004193if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004194then
4195 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4196 [Define to printf format modifier for long long type])
4197fi
4198
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004199if test $ac_sys_system = Darwin
4200then
4201 LIBS="$LIBS -framework CoreFoundation"
4202fi
4203
Mark Dickinson82864d12009-11-15 16:18:58 +00004204
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004205AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4206AC_TRY_RUN([
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004207#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004208#include <stddef.h>
4209#include <string.h>
4210
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004211#ifdef HAVE_SYS_TYPES_H
4212#include <sys/types.h>
4213#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004214
4215#ifdef HAVE_SSIZE_T
4216typedef ssize_t Py_ssize_t;
4217#elif SIZEOF_VOID_P == SIZEOF_LONG
4218typedef long Py_ssize_t;
4219#else
4220typedef int Py_ssize_t;
4221#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004222
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004223int main()
4224{
4225 char buffer[256];
4226
Brett Cannon09d12362006-05-11 05:11:33 +00004227 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4228 return 1;
4229
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004230 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004231 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004232
4233 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4234 return 1;
4235
4236 if (strcmp(buffer, "-123"))
4237 return 1;
4238
Brett Cannon09d12362006-05-11 05:11:33 +00004239 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004240}
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004241], ac_cv_have_size_t_format=yes,
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004242 ac_cv_have_size_t_format=no,
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004243 [ac_cv_have_size_t_format="cross -- assuming yes"]
4244)])
4245if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004246 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4247 [Define to printf format modifier for Py_ssize_t])
4248fi
Brett Cannon09d12362006-05-11 05:11:33 +00004249
Martin v. Löwis01c04012002-11-11 14:58:44 +00004250AC_CHECK_TYPE(socklen_t,,
4251 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004252 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004253#ifdef HAVE_SYS_TYPES_H
4254#include <sys/types.h>
4255#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004256#ifdef HAVE_SYS_SOCKET_H
4257#include <sys/socket.h>
4258#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004259])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004260
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004261AC_SUBST(THREADHEADERS)
4262
4263for h in `(cd $srcdir;echo Python/thread_*.h)`
4264do
4265 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4266done
4267
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004268AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004269SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004270AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004271for dir in $SRCDIRS; do
4272 if test ! -d $dir; then
4273 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004274 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004275done
4276AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004277
Guido van Rossum627b2d71993-12-24 10:39:16 +00004278# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004279AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Martin v. Löwis88afe662002-10-26 13:47:44 +00004280AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004281
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004282echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004283if test ! -f Modules/Setup
4284then
4285 cp $srcdir/Modules/Setup.dist Modules/Setup
4286fi
4287
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004288echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004289if test ! -f Modules/Setup.local
4290then
4291 echo "# Edit this file for local setup changes" >Modules/Setup.local
4292fi
4293
4294echo "creating Makefile"
4295$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4296 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004297 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004298
4299case $ac_sys_system in
4300BeOS)
4301 AC_MSG_WARN([
4302
4303 Support for BeOS is deprecated as of Python 2.6.
4304 See PEP 11 for the gory details.
4305 ])
4306 ;;
4307*) ;;
4308esac
4309
Neil Schemenauer66252162001-02-19 04:47:42 +00004310mv config.c Modules