blob: ee7e5fcd07c4e96f1ceb37f5020c4d681c017855 [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000011AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
doko@python.orgd65e2ba2013-01-31 23:52:03 +010015AC_CANONICAL_HOST
16AC_SUBST(build)
17AC_SUBST(host)
18
19if test "$cross_compiling" = yes; then
20 AC_MSG_CHECKING([for python interpreter for cross build])
21 if test -z "$PYTHON_FOR_BUILD"; then
22 for interp in python$PACKAGE_VERSION python2 python; do
23 which $interp >/dev/null 2>&1 || continue
24 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
25 break
26 fi
27 interp=
28 done
29 if test x$interp = x; then
30 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
31 fi
32 AC_MSG_RESULT($interp)
33 PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
34 fi
35elif test "$cross_compiling" = maybe; then
36 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
37else
38 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
39fi
40AC_SUBST(PYTHON_FOR_BUILD)
41
Georg Brandlbcd64a32009-03-31 21:45:18 +000042dnl Ensure that if prefix is specified, it does not end in a slash. If
43dnl it does, we get path names containing '//' which is both ugly and
44dnl can cause trouble.
45
46dnl Last slash shouldn't be stripped if prefix=/
47if test "$prefix" != "/"; then
48 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
49fi
50
Martin v. Löwis8316feb2003-06-14 07:48:07 +000051dnl This is for stuff that absolutely must end up in pyconfig.h.
52dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000053AH_TOP([
54#ifndef Py_PYCONFIG_H
55#define Py_PYCONFIG_H
56])
Martin v. Löwis11437992002-04-12 09:54:03 +000057AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000058/* Define the macros needed if on a UnixWare 7.x system. */
59#if defined(__USLC__) && defined(__SCO_VERSION__)
60#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
61#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000062
63#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000064])
65
Martin v. Löwis8316feb2003-06-14 07:48:07 +000066# We don't use PACKAGE_ variables, and they cause conflicts
67# with other autoconf-based packages that include Python.h
68grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
69rm confdefs.h
70mv confdefs.h.new confdefs.h
71
Guido van Rossum642b6781997-07-19 19:35:41 +000072AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000073VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000074
Martin v. Löwis1142de32002-03-29 16:28:31 +000075AC_SUBST(SOVERSION)
76SOVERSION=1.0
77
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000078# The later defininition of _XOPEN_SOURCE disables certain features
79# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
80AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
81
Martin v. Löwisbcd93962003-05-03 10:32:18 +000082# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
83# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
84# them.
85AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
86
Andrew MacIntyreabccf412003-07-02 13:53:25 +000087# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
88# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
89# them.
90AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
91
Martin v. Löwisd6320502004-08-12 13:45:08 +000092# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
93# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
94AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
95
Ronald Oussoren5640ce22008-06-05 12:58:24 +000096# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
97# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
98# them.
99AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
100
101
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000102define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000103
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000104# Arguments passed to configure.
105AC_SUBST(CONFIG_ARGS)
106CONFIG_ARGS="$ac_configure_args"
107
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000108AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +0000109AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +0000110 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000111[
112 case $enableval in
113 yes)
114 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000115 if test ! -d "${enableval}"
116 then
117 enableval=/
118 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000119 ;;
120 esac
121 case $enableval in
122 no)
123 UNIVERSALSDK=
124 enable_universalsdk=
125 ;;
126 *)
127 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000128 if test ! -d "${UNIVERSALSDK}"
129 then
130 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
131 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000132 ;;
133 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000134
Ronald Oussoren988117f2006-04-29 11:31:35 +0000135],[
136 UNIVERSALSDK=
137 enable_universalsdk=
138])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000139if test -n "${UNIVERSALSDK}"
140then
141 AC_MSG_RESULT(${UNIVERSALSDK})
142else
143 AC_MSG_RESULT(no)
144fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000145AC_SUBST(UNIVERSALSDK)
146
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000147AC_SUBST(ARCH_RUN_32BIT)
Ned Deily8e60f6e2013-05-30 00:14:29 -0700148ARCH_RUN_32BIT=""
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000149
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000150UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000151AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000152AC_MSG_CHECKING(for --with-universal-archs)
153AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000154 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000155[
156 AC_MSG_RESULT($withval)
157 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000158 if test "${enable_universalsdk}" ; then
159 :
160 else
161 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
162 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000163],
164[
165 AC_MSG_RESULT(32-bit)
166])
167
168
169
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000170AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000171 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000172 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000173[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000174 if test "${enable_framework}"; then
175 :
176 else
177 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
178 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000179 PYTHONFRAMEWORK=${withval}
180 PYTHONFRAMEWORKDIR=${withval}.framework
181 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
182 ],[
183 PYTHONFRAMEWORK=Python
184 PYTHONFRAMEWORKDIR=Python.framework
185 PYTHONFRAMEWORKIDENTIFIER=org.python.python
186])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000187dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000188AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000189 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000190[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000191 case $enableval in
192 yes)
193 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000194 esac
195 case $enableval in
196 no)
197 PYTHONFRAMEWORK=
198 PYTHONFRAMEWORKDIR=no-framework
199 PYTHONFRAMEWORKPREFIX=
200 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000201 FRAMEWORKINSTALLFIRST=
202 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000203 FRAMEWORKALTINSTALLFIRST=
204 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000205 if test "x${prefix}" = "xNONE"; then
206 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
207 else
208 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
209 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000210 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000211 ;;
212 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000213 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000214 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000215 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000216 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000217 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
218 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000219 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000220
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000221 if test "x${prefix}" = "xNONE" ; then
222 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000223
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000224 else
225 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
226 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000227
228 case "${enableval}" in
229 /System*)
230 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
231 if test "${prefix}" = "NONE" ; then
232 # See below
233 FRAMEWORKUNIXTOOLSPREFIX="/usr"
234 fi
235 ;;
236
237 /Library*)
238 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
239 ;;
240
241 */Library/Frameworks)
242 MDIR="`dirname "${enableval}"`"
243 MDIR="`dirname "${MDIR}"`"
244 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
245
246 if test "${prefix}" = "NONE"; then
247 # User hasn't specified the
248 # --prefix option, but wants to install
249 # the framework in a non-default location,
250 # ensure that the compatibility links get
251 # installed relative to that prefix as well
252 # instead of in /usr/local.
253 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
254 fi
255 ;;
256
257 *)
258 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
259 ;;
260 esac
261
Jack Jansen127e56e2001-09-11 14:41:54 +0000262 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000263
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000264 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000265 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000266 AC_CONFIG_FILES(Mac/Makefile)
267 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
268 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000269 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
270 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000271 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000272 ],[
273 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000274 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000275 PYTHONFRAMEWORKPREFIX=
276 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000277 FRAMEWORKINSTALLFIRST=
278 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000279 FRAMEWORKALTINSTALLFIRST=
280 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000281 if test "x${prefix}" = "xNONE" ; then
282 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
283 else
284 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
285 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000286 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000287
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000288])
289AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000290AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000291AC_SUBST(PYTHONFRAMEWORKDIR)
292AC_SUBST(PYTHONFRAMEWORKPREFIX)
293AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000294AC_SUBST(FRAMEWORKINSTALLFIRST)
295AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000296AC_SUBST(FRAMEWORKALTINSTALLFIRST)
297AC_SUBST(FRAMEWORKALTINSTALLLAST)
298AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000299AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000300
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000301##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000302## AS_HELP_STRING([--with-dyld],
303## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000304##
Guido van Rossumb418f891996-07-30 18:06:02 +0000305# Set name for machine-dependent library files
306AC_SUBST(MACHDEP)
307AC_MSG_CHECKING(MACHDEP)
308if test -z "$MACHDEP"
309then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100310 # avoid using uname for cross builds
311 if test "$cross_compiling" = yes; then
312 # ac_sys_system and ac_sys_release are only used for setting
313 # `define_xopen_source' in the case statement below. For the
314 # current supported cross builds, this macro is not adjusted.
315 case "$host" in
316 *-*-linux*)
317 ac_sys_system=Linux
318 ;;
319 *-*-cygwin*)
320 ac_sys_system=Cygwin
321 ;;
322 *)
323 # for now, limit cross builds to known configurations
324 MACHDEP="unknown"
325 AC_MSG_ERROR([cross build not supported for $host])
326 esac
327 ac_sys_release=
328 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000329 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000330 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000331 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000332 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000333 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000334 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000335 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100336 fi
337 ac_md_system=`echo $ac_sys_system |
338 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
339 ac_md_release=`echo $ac_sys_release |
340 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
341 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000342
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100343 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200344 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000345 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000346 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000347 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000348 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000349 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100350 esac
351fi
352
353AC_SUBST(_PYTHON_HOST_PLATFORM)
354if test "$cross_compiling" = yes; then
355 case "$host" in
356 *-*-linux*)
357 case "$host_cpu" in
358 arm*)
359 _host_cpu=arm
360 ;;
361 *)
362 _host_cpu=$host_cpu
363 esac
364 ;;
365 *-*-cygwin*)
366 _host_cpu=
367 ;;
368 *)
369 # for now, limit cross builds to known configurations
370 MACHDEP="unknown"
371 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000372 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100373 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000374fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000375
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000376# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
377# disable features if it is defined, without any means to access these
378# features as extensions. For these systems, we skip the definition of
379# _XOPEN_SOURCE. Before adding a system to the list to gain access to
380# some feature, make sure there is no alternative way to access this
381# feature. Also, when using wildcards, make sure you have verified the
382# need for not defining _XOPEN_SOURCE on all systems matching the
383# wildcard, and that the wildcard does not include future systems
384# (which may remove their limitations).
385dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
386case $ac_sys_system/$ac_sys_release in
387 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
388 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000389 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000390 # In addition, Stefan Krah confirms that issue #1244610 exists through
391 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200392 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000393 define_xopen_source=no
394 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
395 # also defined. This can be overridden by defining _BSD_SOURCE
396 # As this has a different meaning on Linux, only define it on OpenBSD
397 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
398 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200399 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000400 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
401 # also defined. This can be overridden by defining _BSD_SOURCE
402 # As this has a different meaning on Linux, only define it on OpenBSD
403 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
404 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000405 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
406 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
407 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000408 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 +0000409 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000410 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
411 # request to enable features supported by the standard as a request
412 # to disable features not supported by the standard. The best way
413 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
414 # entirely and define __EXTENSIONS__ instead.
415 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000416 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000417 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
418 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000419 # Reconfirmed for 7.1.4 by Martin v. Loewis.
420 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000421 define_xopen_source=no;;
422 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000423 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000424 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000425 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000426 # On FreeBSD 4, the math functions C89 does not cover are never defined
427 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
428 FreeBSD/4.*)
429 define_xopen_source=no;;
430 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
431 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
432 # identifies itself as Darwin/7.*
433 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
434 # disables platform specific features beyond repair.
435 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
436 # has no effect, don't bother defining them
437 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000438 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000439 Darwin/1@<:@0-9@:>@.*)
440 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000441 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
442 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
443 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000444 AIX/4)
445 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000446 AIX/5)
447 if test `uname -r` -eq 1; then
448 define_xopen_source=no
449 fi
450 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000451 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
452 # defining NI_NUMERICHOST.
453 QNX/6.3.2)
454 define_xopen_source=no
455 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000456
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000457esac
458
459if test $define_xopen_source = yes
460then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000461 AC_DEFINE(_XOPEN_SOURCE, 600,
462 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000463
464 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
465 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
466 # several APIs are not declared. Since this is also needed in some
467 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000468 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
469 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000470
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000471 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
472
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000473fi
474
Guido van Rossum91922671997-10-09 20:24:13 +0000475#
476# SGI compilers allow the specification of the both the ABI and the
477# ISA on the command line. Depending on the values of these switches,
478# different and often incompatable code will be generated.
479#
480# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
481# thus supply support for various ABI/ISA combinations. The MACHDEP
482# variable is also adjusted.
483#
484AC_SUBST(SGI_ABI)
485if test ! -z "$SGI_ABI"
486then
487 CC="cc $SGI_ABI"
488 LDFLAGS="$SGI_ABI $LDFLAGS"
489 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
490fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000491AC_MSG_RESULT($MACHDEP)
492
Jack Jansen83f898c2002-12-30 22:23:40 +0000493# And add extra plat-mac for darwin
494AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000495AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000496AC_MSG_CHECKING(EXTRAPLATDIR)
497if test -z "$EXTRAPLATDIR"
498then
499 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000500 darwin)
501 EXTRAPLATDIR="\$(PLATMACDIRS)"
502 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
503 ;;
504 *)
505 EXTRAPLATDIR=""
506 EXTRAMACHDEPPATH=""
507 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000508 esac
509fi
510AC_MSG_RESULT($EXTRAPLATDIR)
511
Jack Jansen6b08a402004-06-03 12:41:45 +0000512# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
513# it may influence the way we can build extensions, so distutils
514# needs to check it
515AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000516AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000517CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000518EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000519
Guido van Rossum627b2d71993-12-24 10:39:16 +0000520# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000521
522# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
523# for debug/optimization stuff. BASECFLAGS is for flags that are required
524# just to get things to compile and link. Users are free to override OPT
525# when running configure or make. The build should not break if they do.
526# BASECFLAGS should generally not be messed with, however.
527
528# XXX shouldn't some/most/all of this code be merged with the stuff later
529# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000530AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000531AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000532 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000533[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000534 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000535 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000536 without_gcc=yes;;
537 yes) CC=gcc
538 without_gcc=no;;
539 *) CC=$withval
540 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000541 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000542 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000543 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000544 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000545 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000546 case $BE_HOST_CPU in
547 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000548 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000549 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000550 BASECFLAGS="$BASECFLAGS -export pragma"
551 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000552 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000553 ;;
554 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000555 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000556 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000557 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000558 ;;
559 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000560 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000561 ;;
562 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000563 AR="\$(srcdir)/Modules/ar_beos"
564 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000565 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000566 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000567 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000568AC_MSG_RESULT($without_gcc)
569
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000570# If the user switches compilers, we can't believe the cache
571if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
572then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000573 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
574(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000575fi
576
Trent Nelson15daa352012-12-13 06:46:39 +0000577if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
578 # Normally, MIPSpro CC treats #error directives as warnings, which means
579 # a successful exit code is returned (0). This is a problem because IRIX
580 # has a bunch of system headers with this guard at the top:
581 #
582 # #ifndef __c99
583 # #error This header file is to be used only for c99 mode compilations
584 # #else
585 #
586 # When autoconf tests for such a header, like stdint.h, this happens:
587 #
588 # configure:4619: cc -c conftest.c >&5
589 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
590 # #error directive: This header file is to be used only for c99 mode
591 # compilations
592 #
593 # #error This header file is to be used only for c99 mode compilations
594 # ^
595 #
596 # configure:4619: $? = 0
597 # configure:4619: result: yes
598 #
599 # Therefore, we use `-diag_error 1035` to have the compiler treat the
600 # warning as an error, which causes cc to return a non-zero result,
601 # which autoconf can interpret correctly.
602 CFLAGS="$CFLAGS -diag_error 1035"
603 # Whilst we're here, we might as well make sure CXX defaults to something
604 # sensible if we're not using gcc.
605 if test -z "$CXX"; then
606 CXX="CC"
607 fi
608fi
609
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000610# If the user set CFLAGS, use this instead of the automatically
611# determined setting
612preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000613AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000614if test ! -z "$preset_cflags"
615then
616 CFLAGS=$preset_cflags
617fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000618
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000619AC_SUBST(CXX)
620AC_SUBST(MAINCC)
621AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
622AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000623 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000624 [compile main() and link python executable with C++ compiler]),
625[
626
627 case $withval in
628 no) with_cxx_main=no
629 MAINCC='$(CC)';;
630 yes) with_cxx_main=yes
631 MAINCC='$(CXX)';;
632 *) with_cxx_main=yes
633 MAINCC=$withval
634 if test -z "$CXX"
635 then
636 CXX=$withval
637 fi;;
638 esac], [
639 with_cxx_main=no
640 MAINCC='$(CC)'
641])
642AC_MSG_RESULT($with_cxx_main)
643
644preset_cxx="$CXX"
645if test -z "$CXX"
646then
647 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100648 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
649 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000650 esac
651 if test "$CXX" = "notfound"
652 then
653 CXX=""
654 fi
655fi
656if test -z "$CXX"
657then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100658 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000659 if test "$CXX" = "notfound"
660 then
661 CXX=""
662 fi
663fi
664if test "$preset_cxx" != "$CXX"
665then
666 AC_MSG_WARN([
667
668 By default, distutils will build C++ extension modules with "$CXX".
669 If this is not intended, then set CXX on the configure command line.
670 ])
671fi
672
doko@python.org4e63fbe2013-01-25 13:08:27 +0100673MULTIARCH=$($CC --print-multiarch 2>/dev/null)
674AC_SUBST(MULTIARCH)
675
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000676
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000677# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000678AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000679
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000680# Check for unsupported systems
681case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000682atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000683 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
684 echo See README for details.
685 exit 1;;
686esac
687
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000688AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000689AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000690AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000691 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000692[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000693 case $withval in
694 no) EXEEXT=;;
695 yes) EXEEXT=.exe;;
696 *) EXEEXT=$withval;;
697 esac])
698AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000699
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000700# Test whether we're running on a non-case-sensitive system, in which
701# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000702AC_SUBST(BUILDEXEEXT)
703AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000704if test ! -d CaseSensitiveTestDir; then
705mkdir CaseSensitiveTestDir
706fi
707
708if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000709then
Jack Jansen1999ef42001-12-06 21:47:20 +0000710 AC_MSG_RESULT(yes)
711 BUILDEXEEXT=.exe
712else
713 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000714 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000715fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000716rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000717
Guido van Rossumdd997f71998-10-07 19:58:26 +0000718case $MACHDEP in
719bsdos*)
720 case $CC in
721 gcc) CC="$CC -D_HAVE_BSDI";;
722 esac;;
723esac
724
Guido van Rossum84561611997-08-21 00:08:11 +0000725case $ac_sys_system in
726hp*|HP*)
727 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000728 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000729 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000730SunOS*)
731 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000732 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000733 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000734esac
735
Martin v. Löwise8964d42001-03-06 12:09:07 +0000736
Neil Schemenauer61c51152001-01-26 16:18:16 +0000737AC_SUBST(LIBRARY)
738AC_MSG_CHECKING(LIBRARY)
739if test -z "$LIBRARY"
740then
741 LIBRARY='libpython$(VERSION).a'
742fi
743AC_MSG_RESULT($LIBRARY)
744
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000745# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000746# name of the library into which to insert object files). BLDLIBRARY is also
747# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
748# is blank as the main program is not linked directly against LDLIBRARY.
749# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
750# systems without shared libraries, LDLIBRARY is the same as LIBRARY
751# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
752# DLLLIBRARY is the shared (i.e., DLL) library.
753#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000754# RUNSHARED is used to run shared python without installed libraries
755#
756# INSTSONAME is the name of the shared library that will be use to install
757# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000758AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000759AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000760AC_SUBST(BLDLIBRARY)
761AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000762AC_SUBST(INSTSONAME)
763AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000764LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000765BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000766INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000767DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000768LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000769RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000770
Guido van Rossumfb842551997-08-06 23:42:07 +0000771# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000772# If CXX is set, and if it is needed to link a main function that was
773# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
774# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000775# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000776# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000777AC_SUBST(LINKCC)
778AC_MSG_CHECKING(LINKCC)
779if test -z "$LINKCC"
780then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000781 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000782 case $ac_sys_system in
783 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000784 exp_extra="\"\""
785 if test $ac_sys_release -ge 5 -o \
786 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
787 exp_extra="."
788 fi
789 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000790 QNX*)
791 # qcc must be used because the other compilers do not
792 # support -N.
793 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000794 esac
795fi
796AC_MSG_RESULT($LINKCC)
797
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000798# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
799# make sure we default having it set to "no": this is used by
800# distutils.unixccompiler to know if it should add --enable-new-dtags
801# to linker command lines, and failing to detect GNU ld simply results
802# in the same bahaviour as before.
803AC_SUBST(GNULD)
804AC_MSG_CHECKING(for GNU ld)
805ac_prog=ld
806if test "$GCC" = yes; then
807 ac_prog=`$CC -print-prog-name=ld`
808fi
809case `"$ac_prog" -V 2>&1 < /dev/null` in
810 *GNU*)
811 GNULD=yes;;
812 *)
813 GNULD=no;;
814esac
815AC_MSG_RESULT($GNULD)
816
Martin v. Löwis1142de32002-03-29 16:28:31 +0000817AC_MSG_CHECKING(for --enable-shared)
818AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000819 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000820
Martin v. Löwis1142de32002-03-29 16:28:31 +0000821if test -z "$enable_shared"
822then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000823 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000824 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000825 enable_shared="yes";;
826 *)
827 enable_shared="no";;
828 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000829fi
830AC_MSG_RESULT($enable_shared)
831
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000832AC_MSG_CHECKING(for --enable-profiling)
833AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100834 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
835if test "x$enable_profiling" = xyes; then
836 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400837 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100838 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
839 [],
840 [enable_profiling=no])
841 CC="$ac_save_cc"
842else
843 enable_profiling=no
844fi
845AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000846
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100847if test "x$enable_profiling" = xyes; then
848 BASECFLAGS="-pg $BASECFLAGS"
849 LDFLAGS="-pg $LDFLAGS"
850fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000851
852AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000853
Guido van Rossumb8552162001-09-05 14:58:11 +0000854# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
855# library that we build, but we do not want to link against it (we
856# will find it with a -framework option). For this reason there is an
857# extra variable BLDLIBRARY against which Python and the extension
858# modules are linked, BLDLIBRARY. This is normally the same as
859# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000860if test "$enable_framework"
861then
862 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200863 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000864 BLDLIBRARY=''
865else
866 BLDLIBRARY='$(LDLIBRARY)'
867fi
868
Martin v. Löwis1142de32002-03-29 16:28:31 +0000869# Other platforms follow
870if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000871 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000872 case $ac_sys_system in
873 BeOS*)
874 LDLIBRARY='libpython$(VERSION).so'
875 ;;
876 CYGWIN*)
877 LDLIBRARY='libpython$(VERSION).dll.a'
878 DLLLIBRARY='libpython$(VERSION).dll'
879 ;;
880 SunOS*)
881 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000882 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200883 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000884 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000885 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200886 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000887 LDLIBRARY='libpython$(VERSION).so'
888 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200889 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000890 case $ac_sys_system in
891 FreeBSD*)
892 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
893 ;;
894 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000895 INSTSONAME="$LDLIBRARY".$SOVERSION
896 ;;
897 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000898 case `uname -m` in
899 ia64)
900 LDLIBRARY='libpython$(VERSION).so'
901 ;;
902 *)
903 LDLIBRARY='libpython$(VERSION).sl'
904 ;;
905 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000906 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200907 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000908 ;;
909 OSF*)
910 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000911 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200912 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000913 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000914 atheos*)
915 LDLIBRARY='libpython$(VERSION).so'
916 BLDLIBRARY='-L. -lpython$(VERSION)'
917 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
918 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000919 Darwin*)
920 LDLIBRARY='libpython$(VERSION).dylib'
921 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200922 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000923 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000924 AIX*)
925 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200926 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000927 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000928
Martin v. Löwis1142de32002-03-29 16:28:31 +0000929 esac
Jason Tishler30765592003-09-04 11:04:06 +0000930else # shared is disabled
931 case $ac_sys_system in
932 CYGWIN*)
933 BLDLIBRARY='$(LIBRARY)'
934 LDLIBRARY='libpython$(VERSION).dll.a'
935 ;;
936 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000937fi
938
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100939if test "$cross_compiling" = yes; then
940 RUNSHARED=
941fi
942
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000943AC_MSG_RESULT($LDLIBRARY)
944
Guido van Rossum627b2d71993-12-24 10:39:16 +0000945AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000946AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100947AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000948
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000949# tweak ARFLAGS only if the user didn't set it on the command line
950AC_SUBST(ARFLAGS)
951if test -z "$ARFLAGS"
952then
953 ARFLAGS="rc"
954fi
955
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000956AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000957AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000958if test $SVNVERSION = found
959then
960 SVNVERSION="svnversion \$(srcdir)"
961else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000962 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000963fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000964
Trent Nelsond86ceec2012-10-16 09:42:45 -0400965AC_SUBST(BASECPPFLAGS)
Trent Nelsonabf20512012-10-17 04:32:49 -0400966if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelsond86ceec2012-10-16 09:42:45 -0400967 # If we're building out-of-tree make sure Include (in the current dir)
968 # gets picked up before its $srcdir counterpart in order for Python-ast.h
969 # and graminit.h to get picked up from the correct directory.
970 # (A side effect of this is that these resources will automatically be
971 # regenerated when building out-of-tree, regardless of whether or not
972 # the $srcdir counterpart is up-to-date. This is an acceptable trade
973 # off.)
974 BASECPPFLAGS="-IInclude"
975else
976 BASECPPFLAGS=""
977fi
978
Georg Brandl3a5508e2011-03-06 10:42:21 +0100979AC_SUBST(HGVERSION)
980AC_SUBST(HGTAG)
981AC_SUBST(HGBRANCH)
982AC_CHECK_PROG(HAS_HG, hg, found, not-found)
983if test $HAS_HG = found
984then
985 HGVERSION="hg id -i \$(srcdir)"
986 HGTAG="hg id -t \$(srcdir)"
987 HGBRANCH="hg id -b \$(srcdir)"
988else
989 HGVERSION=""
990 HGTAG=""
991 HGBRANCH=""
992fi
993
Neil Schemenauera42c8272001-03-31 00:01:55 +0000994case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000995bsdos*|hp*|HP*)
996 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000997 if test -z "$INSTALL"
998 then
999 INSTALL="${srcdir}/install-sh -c"
1000 fi
1001esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001002AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001003AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001004
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001005# Not every filesystem supports hard links
1006AC_SUBST(LN)
1007if test -z "$LN" ; then
1008 case $ac_sys_system in
1009 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001010 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001011 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001012 *) LN=ln;;
1013 esac
1014fi
1015
Fred Drake9f715822001-07-11 06:27:00 +00001016# Check for --with-pydebug
1017AC_MSG_CHECKING(for --with-pydebug)
1018AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001019 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001020[
Fred Drake9f715822001-07-11 06:27:00 +00001021if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001022then
1023 AC_DEFINE(Py_DEBUG, 1,
1024 [Define if you want to build an interpreter with many run-time checks.])
1025 AC_MSG_RESULT(yes);
1026 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001027else AC_MSG_RESULT(no); Py_DEBUG='false'
1028fi],
1029[AC_MSG_RESULT(no)])
1030
Skip Montanarodecc6a42003-01-01 20:07:49 +00001031# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1032# merged with this chunk of code?
1033
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001034# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001035# ------------------------
1036# (The following bit of code is complicated enough - please keep things
1037# indented properly. Just pretend you're editing Python code. ;-)
1038
1039# There are two parallel sets of case statements below, one that checks to
1040# see if OPT was set and one that does BASECFLAGS setting based upon
1041# compiler and platform. BASECFLAGS tweaks need to be made even if the
1042# user set OPT.
1043
1044# tweak OPT based on compiler and platform, only if the user didn't set
1045# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001046AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001047if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001048then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001049 case $GCC in
1050 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001051 if test "$CC" != 'g++' ; then
1052 STRICT_PROTO="-Wstrict-prototypes"
1053 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001054 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1055 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1056 WRAP="-fwrapv"
1057 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001058
1059 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001060 case $CC in
1061 *clang*) WRAP="-fwrapv"
1062 ;;
1063 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001064
Skip Montanarodecc6a42003-01-01 20:07:49 +00001065 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001066 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001067 if test "$Py_DEBUG" = 'true' ; then
1068 # Optimization messes up debuggers, so turn it off for
1069 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001070 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001071 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001072 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001073 fi
1074 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001075 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001076 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001077 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001078 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001079 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001080 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1081 ;;
1082 esac
Fred Drake9f715822001-07-11 06:27:00 +00001083 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001084
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001085 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001086 OPT="-O"
1087 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001088 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001089fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001090
Skip Montanarodecc6a42003-01-01 20:07:49 +00001091AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001092
1093# The -arch flags for universal builds on OSX
1094UNIVERSAL_ARCH_FLAGS=
1095AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1096
Skip Montanarodecc6a42003-01-01 20:07:49 +00001097# tweak BASECFLAGS based on compiler and platform
1098case $GCC in
1099yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001100 # Python violates C99 rules, by casting between incompatible
1101 # pointer types. GCC may generate bad code as a result of that,
1102 # so use -fno-strict-aliasing if supported.
1103 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1104 ac_save_cc="$CC"
1105 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001106 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001107 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001108 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001109 [ac_cv_no_strict_aliasing_ok=yes],
1110 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001111 CC="$ac_save_cc"
1112 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1113 if test $ac_cv_no_strict_aliasing_ok = yes
1114 then
1115 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1116 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001117
1118 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1119 # support. Without this, treatment of subnormals doesn't follow
1120 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001121 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001122 alpha*)
1123 BASECFLAGS="$BASECFLAGS -mieee"
1124 ;;
1125 esac
1126
Skip Montanarodecc6a42003-01-01 20:07:49 +00001127 case $ac_sys_system in
1128 SCO_SV*)
1129 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1130 ;;
1131 # is there any other compiler on Darwin besides gcc?
1132 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001133 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1134 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001135 if test "${CC}" = gcc
1136 then
1137 AC_MSG_CHECKING(which compiler should be used)
1138 case "${UNIVERSALSDK}" in
1139 */MacOSX10.4u.sdk)
1140 # Build using 10.4 SDK, force usage of gcc when the
1141 # compiler is gcc, otherwise the user will get very
1142 # confusing error messages when building on OSX 10.6
1143 CC=gcc-4.0
1144 CPP=cpp-4.0
1145 ;;
1146 esac
1147 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001148 fi
1149
Benjamin Peterson4347c442008-07-17 15:59:24 +00001150 # Calculate the right deployment target for this build.
1151 #
1152 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1153 if test ${cur_target} '>' 10.2; then
1154 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001155 if test ${enable_universalsdk}; then
1156 if test "${UNIVERSAL_ARCHS}" = "all"; then
1157 # Ensure that the default platform for a
1158 # 4-way universal build is OSX 10.5,
1159 # that's the first OS release where
1160 # 4-way builds make sense.
1161 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001162
1163 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1164 cur_target='10.5'
1165
1166 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1167 cur_target='10.5'
1168
1169 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1170 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001171 fi
1172 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001173 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001174 # On Intel macs default to a deployment
1175 # target of 10.4, that's the first OSX
1176 # release with Intel support.
1177 cur_target="10.4"
1178 fi
1179 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001180 fi
1181 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1182
1183 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1184 # environment with a value that is the same as what we'll use
1185 # in the Makefile to ensure that we'll get the same compiler
1186 # environment during configure and build time.
1187 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1188 export MACOSX_DEPLOYMENT_TARGET
1189 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1190
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001191 if test "${enable_universalsdk}"; then
1192 UNIVERSAL_ARCH_FLAGS=""
1193 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1194 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1195 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001196 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001197
1198 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1199 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1200 LIPO_32BIT_FLAGS=""
1201 ARCH_RUN_32BIT="true"
1202
1203 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1204 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1205 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001206 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001207
1208 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1209 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1210 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001211 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001212
1213 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1214 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1215 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001216 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001217
1218 else
1219 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1220
1221 fi
1222
1223
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001224 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1225 if test "${UNIVERSALSDK}" != "/"
1226 then
1227 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1228 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1229 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001230 fi
1231
1232 fi
1233
1234
Skip Montanarodecc6a42003-01-01 20:07:49 +00001235 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001236 OSF*)
1237 BASECFLAGS="$BASECFLAGS -mieee"
1238 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001239 esac
1240 ;;
1241
1242*)
1243 case $ac_sys_system in
1244 OpenUNIX*|UnixWare*)
1245 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1246 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001247 OSF*)
1248 BASECFLAGS="$BASECFLAGS -ieee -std"
1249 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001250 SCO_SV*)
1251 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1252 ;;
1253 esac
1254 ;;
1255esac
1256
Fred Drakee1ceaa02001-12-04 20:55:47 +00001257if test "$Py_DEBUG" = 'true'; then
1258 :
1259else
1260 OPT="-DNDEBUG $OPT"
1261fi
1262
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001263if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001264then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001265 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001266fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001267
Neal Norwitz020c46a2006-01-07 21:39:28 +00001268# disable check for icc since it seems to pass, but generates a warning
1269if test "$CC" = icc
1270then
1271 ac_cv_opt_olimit_ok=no
1272fi
1273
Guido van Rossum91922671997-10-09 20:24:13 +00001274AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1275AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1276[ac_save_cc="$CC"
1277CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001278AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001279 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001280 [ac_cv_opt_olimit_ok=yes],
1281 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001282 )
Guido van Rossum91922671997-10-09 20:24:13 +00001283CC="$ac_save_cc"])
1284AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001285if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001286 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001287 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1288 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1289 # environment?
1290 Darwin*)
1291 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001292 # XXX thankfully this useless troublemaker of a flag has been
1293 # eradicated in the 3.x line. For now, make sure it isn't picked
1294 # up by any of our other platforms that use CC.
1295 AIX*|SunOS*|HP-UX*|IRIX*)
1296 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001297 *)
1298 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1299 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001300 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001301else
1302 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1303 AC_CACHE_VAL(ac_cv_olimit_ok,
1304 [ac_save_cc="$CC"
1305 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001306 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001307 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001308 [ac_cv_olimit_ok=yes],
1309 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001310 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001311 CC="$ac_save_cc"])
1312 AC_MSG_RESULT($ac_cv_olimit_ok)
1313 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001314 case $ac_sys_system in
1315 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1316 HP-UX*)
1317 ;;
1318 *)
1319 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1320 ;;
1321 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001322 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001323fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001324
Martin v. Löwisaac13162006-10-19 10:58:46 +00001325# Check whether GCC supports PyArg_ParseTuple format
1326if test "$GCC" = "yes"
1327then
1328 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1329 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001330 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001331 AC_COMPILE_IFELSE([
1332 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1333 ],[
1334 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1335 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1336 AC_MSG_RESULT(yes)
1337 ],[
1338 AC_MSG_RESULT(no)
1339 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001340 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001341fi
1342
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001343# On some compilers, pthreads are available without further options
1344# (e.g. MacOS X). On some of these systems, the compiler will not
1345# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1346# So we have to see first whether pthreads are available without
1347# options before we can check whether -Kpthread improves anything.
1348AC_MSG_CHECKING(whether pthreads are available without options)
1349AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001350[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001351#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001352#include <pthread.h>
1353
1354void* routine(void* p){return NULL;}
1355
1356int main(){
1357 pthread_t p;
1358 if(pthread_create(&p,NULL,routine,NULL)!=0)
1359 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001360 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001361 return 0;
1362}
Matthias Klosec511b472010-05-08 11:01:39 +00001363]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001364 ac_cv_pthread_is_default=yes
1365 ac_cv_kthread=no
1366 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001367],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001368])
1369AC_MSG_RESULT($ac_cv_pthread_is_default)
1370
1371
1372if test $ac_cv_pthread_is_default = yes
1373then
1374 ac_cv_kpthread=no
1375else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001376# -Kpthread, if available, provides the right #defines
1377# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001378# Some compilers won't report that they do not support -Kpthread,
1379# so we need to run a program to see whether it really made the
1380# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001381AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1382AC_CACHE_VAL(ac_cv_kpthread,
1383[ac_save_cc="$CC"
1384CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001385AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001386#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001387#include <pthread.h>
1388
1389void* routine(void* p){return NULL;}
1390
1391int main(){
1392 pthread_t p;
1393 if(pthread_create(&p,NULL,routine,NULL)!=0)
1394 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001395 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001396 return 0;
1397}
Matthias Klosec511b472010-05-08 11:01:39 +00001398]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001399CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001400AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001401fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001402
Skip Montanarod8d39a02003-07-10 20:44:10 +00001403if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001404then
1405# -Kthread, if available, provides the right #defines
1406# and linker options to make pthread_create available
1407# Some compilers won't report that they do not support -Kthread,
1408# so we need to run a program to see whether it really made the
1409# function available.
1410AC_MSG_CHECKING(whether $CC accepts -Kthread)
1411AC_CACHE_VAL(ac_cv_kthread,
1412[ac_save_cc="$CC"
1413CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001414AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001415#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001416#include <pthread.h>
1417
1418void* routine(void* p){return NULL;}
1419
1420int main(){
1421 pthread_t p;
1422 if(pthread_create(&p,NULL,routine,NULL)!=0)
1423 return 1;
1424 (void)pthread_detach(p);
1425 return 0;
1426}
Matthias Klosec511b472010-05-08 11:01:39 +00001427]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001428CC="$ac_save_cc"])
1429AC_MSG_RESULT($ac_cv_kthread)
1430fi
1431
Skip Montanarod8d39a02003-07-10 20:44:10 +00001432if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001433then
1434# -pthread, if available, provides the right #defines
1435# and linker options to make pthread_create available
1436# Some compilers won't report that they do not support -pthread,
1437# so we need to run a program to see whether it really made the
1438# function available.
1439AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001440AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001441[ac_save_cc="$CC"
1442CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001443AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001444#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001445#include <pthread.h>
1446
1447void* routine(void* p){return NULL;}
1448
1449int main(){
1450 pthread_t p;
1451 if(pthread_create(&p,NULL,routine,NULL)!=0)
1452 return 1;
1453 (void)pthread_detach(p);
1454 return 0;
1455}
Matthias Klosec511b472010-05-08 11:01:39 +00001456]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001457CC="$ac_save_cc"])
1458AC_MSG_RESULT($ac_cv_pthread)
1459fi
1460
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001461# If we have set a CC compiler flag for thread support then
1462# check if it works for CXX, too.
1463ac_cv_cxx_thread=no
1464if test ! -z "$CXX"
1465then
1466AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1467ac_save_cxx="$CXX"
1468
1469if test "$ac_cv_kpthread" = "yes"
1470then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001471 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001472 ac_cv_cxx_thread=yes
1473elif test "$ac_cv_kthread" = "yes"
1474then
1475 CXX="$CXX -Kthread"
1476 ac_cv_cxx_thread=yes
1477elif test "$ac_cv_pthread" = "yes"
1478then
1479 CXX="$CXX -pthread"
1480 ac_cv_cxx_thread=yes
1481fi
1482
1483if test $ac_cv_cxx_thread = yes
1484then
1485 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1486 $CXX -c conftest.$ac_ext 2>&5
1487 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1488 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1489 then
1490 ac_cv_cxx_thread=yes
1491 else
1492 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001493 fi
1494 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001495fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001496AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001497fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001498CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001499
Fred Drakece81d592000-07-09 14:39:29 +00001500dnl # check for ANSI or K&R ("traditional") preprocessor
1501dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001502dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001503dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1504dnl int foo;
1505dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001506dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001507dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001508
Guido van Rossum627b2d71993-12-24 10:39:16 +00001509# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001510AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001511AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001512fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001513ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001514shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001515unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001516sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1517sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001518sys/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 +00001519sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001520sys/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 +00001521sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes3aa138f2013-06-18 13:25:24 +02001522bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001523AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001524AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001525
Martin v. Löwis11017b12006-01-14 18:12:57 +00001526# On Linux, netlink.h requires asm/types.h
1527AC_CHECK_HEADERS(linux/netlink.h,,,[
1528#ifdef HAVE_ASM_TYPES_H
1529#include <asm/types.h>
1530#endif
1531#ifdef HAVE_SYS_SOCKET_H
1532#include <sys/socket.h>
1533#endif
1534])
1535
Guido van Rossum627b2d71993-12-24 10:39:16 +00001536# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001537was_it_defined=no
1538AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001539AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1540 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1541])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001542AC_MSG_RESULT($was_it_defined)
1543
Neal Norwitz11690112002-07-30 01:08:28 +00001544# Check whether using makedev requires defining _OSF_SOURCE
1545AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001546AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001547#if defined(MAJOR_IN_MKDEV)
1548#include <sys/mkdev.h>
1549#elif defined(MAJOR_IN_SYSMACROS)
1550#include <sys/sysmacros.h>
1551#else
1552#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001553#endif ]], [[ makedev(0, 0) ]])],
1554[ac_cv_has_makedev=yes],
1555[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001556if test "$ac_cv_has_makedev" = "no"; then
1557 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001558 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001559#define _OSF_SOURCE 1
1560#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001561 ]], [[ makedev(0, 0) ]])],
1562[ac_cv_has_makedev=yes],
1563[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001564 if test "$ac_cv_has_makedev" = "yes"; then
1565 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1566 fi
1567fi
1568AC_MSG_RESULT($ac_cv_has_makedev)
1569if test "$ac_cv_has_makedev" = "yes"; then
1570 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1571fi
1572
Martin v. Löwis399a6892002-10-04 10:22:02 +00001573# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1574# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1575# defined, but the compiler does not support pragma redefine_extname,
1576# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1577# structures (such as rlimit64) without declaring them. As a
1578# work-around, disable LFS on such configurations
1579
1580use_lfs=yes
1581AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001582AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001583#define _LARGEFILE_SOURCE 1
1584#define _FILE_OFFSET_BITS 64
1585#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001586]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001587AC_MSG_RESULT($sol_lfs_bug)
1588if test "$sol_lfs_bug" = "yes"; then
1589 use_lfs=no
1590fi
1591
1592if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001593# Two defines needed to enable largefile support on various platforms
1594# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001595case $ac_sys_system/$ac_sys_release in
1596AIX*)
1597 AC_DEFINE(_LARGE_FILES, 1,
1598 [This must be defined on AIX systems to enable large file support.])
1599 ;;
1600esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001601AC_DEFINE(_LARGEFILE_SOURCE, 1,
1602[This must be defined on some systems to enable large file support.])
1603AC_DEFINE(_FILE_OFFSET_BITS, 64,
1604[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001605fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001606
Guido van Rossum300fda71996-08-19 21:58:16 +00001607# Add some code to confdefs.h so that the test for off_t works on SCO
1608cat >> confdefs.h <<\EOF
1609#if defined(SCO_DS)
1610#undef _OFF_T
1611#endif
1612EOF
1613
Guido van Rossumef2255b2000-03-10 22:30:29 +00001614# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001615AC_TYPE_MODE_T
1616AC_TYPE_OFF_T
1617AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001618AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001619AC_TYPE_SIZE_T
1620AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001621
1622# There are two separate checks for each of the exact-width integer types we
1623# need. First we check whether the type is available using the usual
1624# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1625# and <stdint.h> where available). We then also use the special type checks of
1626# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1627# directly, #define's uint32_t to be a suitable type.
1628
1629AC_CHECK_TYPE(uint32_t,
1630 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001631AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001632
1633AC_CHECK_TYPE(uint64_t,
1634 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001635AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001636
1637AC_CHECK_TYPE(int32_t,
1638 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001639AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001640
1641AC_CHECK_TYPE(int64_t,
1642 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001643AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001644
Christian Heimes951cc0f2008-01-31 23:08:23 +00001645AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001646 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001647
Guido van Rossumef2255b2000-03-10 22:30:29 +00001648# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001649# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001650AC_CHECK_SIZEOF(int, 4)
1651AC_CHECK_SIZEOF(long, 4)
1652AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001653AC_CHECK_SIZEOF(short, 2)
1654AC_CHECK_SIZEOF(float, 4)
1655AC_CHECK_SIZEOF(double, 8)
1656AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001657AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001658AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001659
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001660AC_MSG_CHECKING(for long long support)
1661have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001662AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001663 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1664 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001665],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001666AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001667if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001668AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001669fi
1670
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001671AC_MSG_CHECKING(for long double support)
1672have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001673AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001674 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1675 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001676],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001677AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001678if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001679AC_CHECK_SIZEOF(long double, 12)
1680fi
1681
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001682AC_MSG_CHECKING(for _Bool support)
1683have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001684AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001685 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1686 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001687],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001688AC_MSG_RESULT($have_c99_bool)
1689if test "$have_c99_bool" = yes ; then
1690AC_CHECK_SIZEOF(_Bool, 1)
1691fi
1692
Martin v. Löwisebe26702006-10-02 14:55:51 +00001693AC_CHECK_TYPES(uintptr_t,
1694 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001695 [], [#ifdef HAVE_STDINT_H
1696 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001697 #endif
1698 #ifdef HAVE_INTTYPES_H
1699 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001700 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001701
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001702AC_CHECK_SIZEOF(off_t, [], [
1703#ifdef HAVE_SYS_TYPES_H
1704#include <sys/types.h>
1705#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001706])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001707
1708AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001709if test "$have_long_long" = yes
1710then
1711if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001712 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001713 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1714 [Defined to enable large file support when an off_t is bigger than a long
1715 and long long is available and at least as big as an off_t. You may need
1716 to add some flags for configuration and compilation to enable this mode.
1717 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001718 AC_MSG_RESULT(yes)
1719else
1720 AC_MSG_RESULT(no)
1721fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001722else
1723 AC_MSG_RESULT(no)
1724fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001725
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001726AC_CHECK_SIZEOF(time_t, [], [
1727#ifdef HAVE_SYS_TYPES_H
1728#include <sys/types.h>
1729#endif
1730#ifdef HAVE_TIME_H
1731#include <time.h>
1732#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001733])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001734
Trent Mick635f6fb2000-08-23 21:33:05 +00001735# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001736ac_save_cc="$CC"
1737if test "$ac_cv_kpthread" = "yes"
1738then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001739elif test "$ac_cv_kthread" = "yes"
1740then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001741elif test "$ac_cv_pthread" = "yes"
1742then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001743fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001744AC_MSG_CHECKING(for pthread_t)
1745have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001746AC_COMPILE_IFELSE([
1747 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1748],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001749AC_MSG_RESULT($have_pthread_t)
1750if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001751 AC_CHECK_SIZEOF(pthread_t, [], [
1752#ifdef HAVE_PTHREAD_H
1753#include <pthread.h>
1754#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001755 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001756fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001757CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001758
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001759AC_MSG_CHECKING(for --enable-toolbox-glue)
1760AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001761 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001762
1763if test -z "$enable_toolbox_glue"
1764then
1765 case $ac_sys_system/$ac_sys_release in
1766 Darwin/*)
1767 enable_toolbox_glue="yes";;
1768 *)
1769 enable_toolbox_glue="no";;
1770 esac
1771fi
1772case "$enable_toolbox_glue" in
1773yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001774 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001775 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001776 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1777 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001778 ;;
1779*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001780 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001781 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001782 ;;
1783esac
1784AC_MSG_RESULT($enable_toolbox_glue)
1785
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001786
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001787AC_SUBST(OTHER_LIBTOOL_OPT)
1788case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001789 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001790 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1791 ;;
1792 Darwin/*)
1793 OTHER_LIBTOOL_OPT=""
1794 ;;
1795esac
1796
Ronald Oussoren25967582009-09-06 10:00:26 +00001797
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001798AC_SUBST(LIBTOOL_CRUFT)
1799case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001800 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001801 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1802 if test "${enable_universalsdk}"; then
1803 :
1804 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001805 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001806 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001807 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001808 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001809 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001810 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001811 if test ${gcc_version} '<' 4.0
1812 then
1813 LIBTOOL_CRUFT="-lcc_dynamic"
1814 else
1815 LIBTOOL_CRUFT=""
1816 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001817 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001818 #include <unistd.h>
1819 int main(int argc, char*argv[])
1820 {
1821 if (sizeof(long) == 4) {
1822 return 0;
1823 } else {
1824 return 1;
1825 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001826 }
Matthias Klosec511b472010-05-08 11:01:39 +00001827 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001828
1829 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001830 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001831 i386)
1832 MACOSX_DEFAULT_ARCH="i386"
1833 ;;
1834 ppc)
1835 MACOSX_DEFAULT_ARCH="ppc"
1836 ;;
1837 *)
1838 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1839 ;;
1840 esac
1841 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001842 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001843 i386)
1844 MACOSX_DEFAULT_ARCH="x86_64"
1845 ;;
1846 ppc)
1847 MACOSX_DEFAULT_ARCH="ppc64"
1848 ;;
1849 *)
1850 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1851 ;;
1852 esac
1853
1854 #ARCH_RUN_32BIT="true"
1855 fi
1856
1857 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001858 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001859 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001860esac
1861
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001862AC_MSG_CHECKING(for --enable-framework)
1863if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001864then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001865 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001866 # -F. is needed to allow linking to the framework while
1867 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001868 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1869 [Define if you want to produce an OpenStep/Rhapsody framework
1870 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001871 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001872 if test $enable_shared = "yes"
1873 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001874 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 +00001875 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001876else
1877 AC_MSG_RESULT(no)
1878fi
1879
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001880AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001881case $ac_sys_system/$ac_sys_release in
1882 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001883 AC_DEFINE(WITH_DYLD, 1,
1884 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1885 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1886 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001887 AC_MSG_RESULT(always on for Darwin)
1888 ;;
1889 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001890 AC_MSG_RESULT(no)
1891 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001892esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001893
Guido van Rossumac405f61994-09-12 10:56:06 +00001894# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001895AC_SUBST(SO)
1896AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001897AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001898AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001899AC_SUBST(CCSHARED)
1900AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001901# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001902# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001903AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001904if test -z "$SO"
1905then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001906 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001907 hp*|HP*)
1908 case `uname -m` in
1909 ia64) SO=.so;;
1910 *) SO=.sl;;
1911 esac
1912 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001913 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001914 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001915 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001916else
1917 # this might also be a termcap variable, see #610332
1918 echo
1919 echo '====================================================================='
1920 echo '+ +'
1921 echo '+ WARNING: You have set SO in your environment. +'
1922 echo '+ Do you really mean to change the extension for shared libraries? +'
1923 echo '+ Continuing in 10 seconds to let you to ponder. +'
1924 echo '+ +'
1925 echo '====================================================================='
1926 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001927fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001928AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001929
Neal Norwitz58e28882006-05-19 07:00:58 +00001930AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001931# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001932# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001933# (Shared libraries in this instance are shared modules to be loaded into
1934# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001935AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001936if test -z "$LDSHARED"
1937then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001938 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001939 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001940 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001941 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001942 ;;
1943 BeOS*)
1944 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001945 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001946 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001947 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001948 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001949 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001950 if test "$GCC" = "yes" ; then
1951 LDSHARED='$(CC) -shared'
1952 LDCXXSHARED='$(CXX) -shared'
1953 else
1954 LDSHARED='$(CC) -G'
1955 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001956 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001957 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001958 if test "$GCC" = "yes" ; then
1959 LDSHARED='$(CC) -shared'
1960 LDCXXSHARED='$(CXX) -shared'
1961 else
1962 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001963 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001964 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001965 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001966 LDSHARED='$(CC) -bundle'
1967 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001968 if test "$enable_framework" ; then
1969 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001970 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1971 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001972 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001973 else
1974 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001975 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001976 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001977 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001978 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001979 LDSHARED='$(CC) -bundle'
1980 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001981 if test "$enable_framework" ; then
1982 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001983 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1984 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001985 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001986 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001987 # No framework, use the Python app as bundle-loader
1988 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001989 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001990 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001991 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001992 Darwin/*)
1993 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1994 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00001995
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001996 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
Jack Jansen6b08a402004-06-03 12:41:45 +00001997 then
Ronald Oussoren988117f2006-04-29 11:31:35 +00001998 if test "${enable_universalsdk}"; then
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001999 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
Ronald Oussoren988117f2006-04-29 11:31:35 +00002000 fi
Stefan Krah3a3e2032010-11-28 15:30:05 +00002001 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2002 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
Jack Jansen6b08a402004-06-03 12:41:45 +00002003 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002004 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002005 LDSHARED='$(CC) -bundle'
2006 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002007 if test "$enable_framework" ; then
2008 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002009 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2010 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002011 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002012 else
2013 # No framework, use the Python app as bundle-loader
2014 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2015 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002016 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002017 fi
2018 fi
2019 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002020 Linux*|GNU*|QNX*)
2021 LDSHARED='$(CC) -shared'
2022 LDCXXSHARED='$(CXX) -shared';;
2023 BSD/OS*/4*)
2024 LDSHARED="gcc -shared"
2025 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002026 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002027 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002028 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002029 LDSHARED='$(CC) -shared'
2030 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002031 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002032 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002033 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002034 OpenBSD*)
2035 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2036 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002037 LDSHARED='$(CC) -shared $(CCSHARED)'
2038 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002039 else
2040 case `uname -r` in
2041 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2042 LDSHARED="ld -Bshareable ${LDFLAGS}"
2043 ;;
2044 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002045 LDSHARED='$(CC) -shared $(CCSHARED)'
2046 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002047 ;;
2048 esac
2049 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002050 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002051 LDSHARED='$(CC) -shared'
2052 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002053 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002054 if test "$GCC" = "yes" ; then
2055 LDSHARED='$(CC) -shared'
2056 LDCXXSHARED='$(CXX) -shared'
2057 else
2058 LDSHARED='$(CC) -G'
2059 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002060 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002061 SCO_SV*)
2062 LDSHARED='$(CC) -Wl,-G,-Bexport'
2063 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2064 CYGWIN*)
2065 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2066 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2067 atheos*)
2068 LDSHARED="gcc -shared"
2069 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002070 *) LDSHARED="ld";;
2071 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002072fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002073AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002074LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002075BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002076# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002077# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002078AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002079if test -z "$CCSHARED"
2080then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002081 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002082 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002083 then CCSHARED="-fPIC";
2084 elif test `uname -p` = sparc;
2085 then CCSHARED="-xcode=pic32";
2086 else CCSHARED="-Kpic";
2087 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002088 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002089 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002090 else CCSHARED="+z";
2091 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002092 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002093 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002094 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002095 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002096 if test "$GCC" = "yes"
2097 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002098 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002099 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002100 SCO_SV*)
2101 if test "$GCC" = "yes"
2102 then CCSHARED="-fPIC"
2103 else CCSHARED="-Kpic -belf"
2104 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002105 IRIX*/6*) case $CC in
2106 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002107 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002108 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002109 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002110 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002111fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002112AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002113# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002114# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002115AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002116if test -z "$LINKFORSHARED"
2117then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002118 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002119 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002120 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002121 LINKFORSHARED="-Wl,-E -Wl,+s";;
2122# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002123 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002124 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002125 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002126 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002127 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2128 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002129 # not used by the core itself but which needs to be in the core so
2130 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002131 # -prebind is no longer used, because it actually seems to give a
2132 # slowdown in stead of a speedup, maybe due to the large number of
2133 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002134
2135 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002136 if test "$enable_framework"
2137 then
Jack Jansenda49e192005-01-07 13:08:22 +00002138 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002139 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002140 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002141 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002142 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002143 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002144 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002145 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2146 then
2147 LINKFORSHARED="-Wl,--export-dynamic"
2148 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002149 SunOS/5*) case $CC in
2150 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002151 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002152 then
2153 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002154 fi;;
2155 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002156 CYGWIN*)
2157 if test $enable_shared = "no"
2158 then
2159 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2160 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002161 QNX*)
2162 # -Wl,-E causes the symbols to be added to the dynamic
2163 # symbol table so that they can be found when a module
2164 # is loaded. -N 2048K causes the stack size to be set
2165 # to 2048 kilobytes so that the stack doesn't overflow
2166 # when running test_compile.py.
2167 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002168 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002169fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002170AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002171
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002172
Neil Schemenauer61c51152001-01-26 16:18:16 +00002173AC_SUBST(CFLAGSFORSHARED)
2174AC_MSG_CHECKING(CFLAGSFORSHARED)
2175if test ! "$LIBRARY" = "$LDLIBRARY"
2176then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002177 case $ac_sys_system in
2178 CYGWIN*)
2179 # Cygwin needs CCSHARED when building extension DLLs
2180 # but not when building the interpreter DLL.
2181 CFLAGSFORSHARED='';;
2182 *)
2183 CFLAGSFORSHARED='$(CCSHARED)'
2184 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002185fi
2186AC_MSG_RESULT($CFLAGSFORSHARED)
2187
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002188# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2189# library (with --enable-shared).
2190# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002191# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2192# if it is not required, since it creates a dependency of the shared library
2193# to LIBS. This, in turn, means that applications linking the shared libpython
2194# don't need to link LIBS explicitly. The default should be only changed
2195# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002196AC_SUBST(SHLIBS)
2197AC_MSG_CHECKING(SHLIBS)
2198case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002199 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002200 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002201esac
2202AC_MSG_RESULT($SHLIBS)
2203
2204
Guido van Rossum627b2d71993-12-24 10:39:16 +00002205# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002206AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2207AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002208
Skip Montanaro4d756af2008-12-01 01:55:22 +00002209# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002210if test "$with_threads" = "yes" -o -z "$with_threads"; then
2211 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2212 # posix4 on Solaris 2.6
2213 # pthread (first!) on Linux
2214fi
2215
Martin v. Löwis19d17342003-06-14 21:03:05 +00002216# check if we need libintl for locale functions
2217AC_CHECK_LIB(intl, textdomain,
2218 AC_DEFINE(WITH_LIBINTL, 1,
2219 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002220
2221# checks for system dependent C++ extensions support
2222case "$ac_sys_system" in
2223 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002224 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002225 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002226 [[loadAndInit("", 0, "")]])
2227 ],[
2228 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002229 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2230 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002231 AC_MSG_RESULT(yes)
2232 ],[
2233 AC_MSG_RESULT(no)
2234 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002235 *) ;;
2236esac
2237
Guido van Rossum70c7f481998-03-26 18:44:10 +00002238# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002239# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002240AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002241AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002242
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002243case "$ac_sys_system" in
2244BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002245AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2246;;
2247esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002248
Guido van Rossumc5a39031996-07-31 17:35:03 +00002249AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002250AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002251 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002252[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002253AC_MSG_RESULT($withval)
2254LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002255],
2256[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002257
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002258AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2259
Benjamin Peterson2c196742009-12-31 03:17:18 +00002260# Check for use of the system expat library
2261AC_MSG_CHECKING(for --with-system-expat)
2262AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002263 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2264 [],
2265 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002266
2267AC_MSG_RESULT($with_system_expat)
2268
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002269# Check for use of the system libffi library
2270AC_MSG_CHECKING(for --with-system-ffi)
2271AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002272 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2273 [],
2274 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002275
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002276if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002277 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2278else
2279 LIBFFI_INCLUDEDIR=""
2280fi
2281AC_SUBST(LIBFFI_INCLUDEDIR)
2282
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002283AC_MSG_RESULT($with_system_ffi)
2284
Ned Deilya2a9f572013-10-25 00:30:10 -07002285# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2286AC_SUBST(TCLTK_INCLUDES)
2287AC_SUBST(TCLTK_LIBS)
2288AC_MSG_CHECKING(for --with-tcltk-includes)
2289AC_ARG_WITH(tcltk-includes,
2290 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2291 [],
2292 [with_tcltk_includes="default"])
2293AC_MSG_RESULT($with_tcltk_includes)
2294AC_MSG_CHECKING(for --with-tcltk-libs)
2295AC_ARG_WITH(tcltk-libs,
2296 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2297 [],
2298 [with_tcltk_libs="default"])
2299AC_MSG_RESULT($with_tcltk_libs)
2300if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2301then
2302 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2303 then
2304 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2305 fi
2306 TCLTK_INCLUDES=""
2307 TCLTK_LIBS=""
2308else
2309 TCLTK_INCLUDES="$with_tcltk_includes"
2310 TCLTK_LIBS="$with_tcltk_libs"
2311fi
2312
Matthias Klose10cbe482009-04-29 17:18:19 +00002313# Check for --with-dbmliborder
2314AC_MSG_CHECKING(for --with-dbmliborder)
2315AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002316 AS_HELP_STRING([--with-dbmliborder=db1:db2:...], [order to check db backends for dbm. Valid value is a colon separated string with the backend names `ndbm', `gdbm' and `bdb'.]),
Matthias Klose10cbe482009-04-29 17:18:19 +00002317[
2318if test x$with_dbmliborder = xyes
2319then
2320AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2321else
2322 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2323 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2324 then
2325 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2326 fi
2327 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002328fi])
2329AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002330
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002331# Determine if signalmodule should be used.
2332AC_SUBST(USE_SIGNAL_MODULE)
2333AC_SUBST(SIGNAL_OBJS)
2334AC_MSG_CHECKING(for --with-signal-module)
2335AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002336 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002337
2338if test -z "$with_signal_module"
2339then with_signal_module="yes"
2340fi
2341AC_MSG_RESULT($with_signal_module)
2342
2343if test "${with_signal_module}" = "yes"; then
2344 USE_SIGNAL_MODULE=""
2345 SIGNAL_OBJS=""
2346else
2347 USE_SIGNAL_MODULE="#"
2348 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2349fi
2350
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002351# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002352AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002353USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002354
Guido van Rossum54d93d41997-01-22 20:51:58 +00002355AC_MSG_CHECKING(for --with-dec-threads)
2356AC_SUBST(LDLAST)
2357AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002358 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002359[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002360AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002361LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002362if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002363 with_thread="$withval";
2364fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002365[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002366
Martin v. Löwis11437992002-04-12 09:54:03 +00002367# Templates for things AC_DEFINEd more than once.
2368# For a single AC_DEFINE, no template is needed.
2369AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2370AH_TEMPLATE(_REENTRANT,
2371 [Define to force use of thread-safe errno, h_errno, and other functions])
2372AH_TEMPLATE(WITH_THREAD,
2373 [Define if you want to compile in rudimentary thread support])
2374
Guido van Rossum54d93d41997-01-22 20:51:58 +00002375AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002376dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002377AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002378 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002379
Barry Warsawc0d24d82000-06-29 16:12:00 +00002380# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002381dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002382AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002383 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002384 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002385
2386if test -z "$with_threads"
2387then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002388fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002389AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002390
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002391AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002392if test "$with_threads" = "no"
2393then
2394 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002395elif test "$ac_cv_pthread_is_default" = yes
2396then
2397 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002398 # Defining _REENTRANT on system with POSIX threads should not hurt.
2399 AC_DEFINE(_REENTRANT)
2400 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002401 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002402elif test "$ac_cv_kpthread" = "yes"
2403then
2404 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002405 if test "$ac_cv_cxx_thread" = "yes"; then
2406 CXX="$CXX -Kpthread"
2407 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002408 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002409 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002410 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002411elif test "$ac_cv_kthread" = "yes"
2412then
2413 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002414 if test "$ac_cv_cxx_thread" = "yes"; then
2415 CXX="$CXX -Kthread"
2416 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002417 AC_DEFINE(WITH_THREAD)
2418 posix_threads=yes
2419 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002420elif test "$ac_cv_pthread" = "yes"
2421then
2422 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002423 if test "$ac_cv_cxx_thread" = "yes"; then
2424 CXX="$CXX -pthread"
2425 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002426 AC_DEFINE(WITH_THREAD)
2427 posix_threads=yes
2428 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002429else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002430 if test ! -z "$with_threads" -a -d "$with_threads"
2431 then LDFLAGS="$LDFLAGS -L$with_threads"
2432 fi
2433 if test ! -z "$withval" -a -d "$withval"
2434 then LDFLAGS="$LDFLAGS -L$withval"
2435 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002436
2437 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002438 # define _POSIX_THREADS in unistd.h. Some apparently don't
2439 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002440 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2441 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002442 [
2443#include <unistd.h>
2444#ifdef _POSIX_THREADS
2445yes
2446#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002447 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2448 AC_MSG_RESULT($unistd_defines_pthreads)
2449
Martin v. Löwis130fb172001-07-19 11:00:41 +00002450 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002451 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2452 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002453 AC_DEFINE(HURD_C_THREADS, 1,
2454 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002455 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002456 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002457 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2458 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002459 AC_DEFINE(MACH_C_THREADS, 1,
2460 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002461 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002462 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002463 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002464 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002465 [AC_MSG_RESULT($withval)
2466 AC_DEFINE([WITH_THREAD])
2467 AC_DEFINE([HAVE_PTH], 1,
2468 [Define if you have GNU PTH threads.])
2469 LIBS="-lpth $LIBS"
2470 THREADOBJ="Python/thread.o"],
2471 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002472
2473 # Just looking for pthread_create in libpthread is not enough:
2474 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2475 # So we really have to include pthread.h, and then link.
2476 _libs=$LIBS
2477 LIBS="$LIBS -lpthread"
2478 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002479 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2480#include <stdio.h>
2481#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002482
Matthias Klosec511b472010-05-08 11:01:39 +00002483void * start_routine (void *arg) { exit (0); }]], [[
2484pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002485 AC_MSG_RESULT(yes)
2486 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002487 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002488 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002489 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002490 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002491 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002492 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002493 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2494 AC_DEFINE(ATHEOS_THREADS, 1,
2495 [Define this if you have AtheOS threads.])
2496 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002497 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002498 AC_DEFINE(BEOS_THREADS, 1,
2499 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002500 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002501 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002502 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002503 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002504 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002505 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002506 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002507 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002508 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002509 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002510 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002511 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002512 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002513 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002514 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002515 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002516 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002517 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002518 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002519
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002520 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2521 LIBS="$LIBS -lmpc"
2522 THREADOBJ="Python/thread.o"
2523 USE_THREAD_MODULE=""])
2524
2525 if test "$posix_threads" != "yes"; then
2526 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2527 LIBS="$LIBS -lthread"
2528 THREADOBJ="Python/thread.o"
2529 USE_THREAD_MODULE=""])
2530 fi
2531
2532 if test "$USE_THREAD_MODULE" != "#"
2533 then
2534 # If the above checks didn't disable threads, (at least) OSF1
2535 # needs this '-threads' argument during linking.
2536 case $ac_sys_system in
2537 OSF1) LDLAST=-threads;;
2538 esac
2539 fi
2540fi
2541
2542if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002543 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002544 AC_DEFINE(_POSIX_THREADS, 1,
2545 [Define if you have POSIX threads,
2546 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002547 fi
2548
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002549 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2550 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002551 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002552 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002553 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002554 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002555 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002556 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002557 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002558 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002559 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002560 esac
2561
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002562 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2563 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002564 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2565 #include <stdio.h>
2566 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002567 void *foo(void *parm) {
2568 return NULL;
2569 }
2570 main() {
2571 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002572 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002573 if (pthread_attr_init(&attr)) exit(-1);
2574 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002575 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002576 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002577 }]])],
2578 [ac_cv_pthread_system_supported=yes],
2579 [ac_cv_pthread_system_supported=no],
2580 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002581 ])
2582 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2583 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002584 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002585 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002586 AC_CHECK_FUNCS(pthread_sigmask,
2587 [case $ac_sys_system in
2588 CYGWIN*)
2589 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2590 [Define if pthread_sigmask() does not work on your system.])
2591 ;;
2592 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002593 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002594fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002595
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002596
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002597# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002598AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002599AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002600AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002601[ --enable-ipv6 Enable ipv6 (with ipv4) support
2602 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002603[ case "$enableval" in
2604 no)
2605 AC_MSG_RESULT(no)
2606 ipv6=no
2607 ;;
2608 *) AC_MSG_RESULT(yes)
2609 AC_DEFINE(ENABLE_IPV6)
2610 ipv6=yes
2611 ;;
2612 esac ],
2613
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002614[
2615dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002616 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002617#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002618#include <sys/socket.h>]],
2619[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002620 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002621 ipv6=yes
2622],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002623 AC_MSG_RESULT(no)
2624 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002625])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002626
2627if test "$ipv6" = "yes"; then
2628 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002629 AC_COMPILE_IFELSE([
2630 AC_LANG_PROGRAM([[#include <sys/types.h>
2631#include <netinet/in.h>]],
2632 [[struct sockaddr_in6 x;
2633 x.sin6_scope_id;]])
2634 ],[
2635 AC_MSG_RESULT(yes)
2636 ipv6=yes
2637 ],[
2638 AC_MSG_RESULT(no, IPv6 disabled)
2639 ipv6=no
2640 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002641fi
2642
2643if test "$ipv6" = "yes"; then
2644 AC_DEFINE(ENABLE_IPV6)
2645fi
2646])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002647
2648ipv6type=unknown
2649ipv6lib=none
2650ipv6trylibc=no
2651
2652if test "$ipv6" = "yes"; then
2653 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002654 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2655 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002656 case $i in
2657 inria)
2658 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002659 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002660#include <netinet/in.h>
2661#ifdef IPV6_INRIA_VERSION
2662yes
2663#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002664 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002665 ;;
2666 kame)
2667 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002668 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002669#include <netinet/in.h>
2670#ifdef __KAME__
2671yes
2672#endif],
2673 [ipv6type=$i;
2674 ipv6lib=inet6
2675 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002676 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002677 ;;
2678 linux-glibc)
2679 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002680 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002681#include <features.h>
2682#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2683yes
2684#endif],
2685 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002686 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002687 ;;
2688 linux-inet6)
2689 dnl http://www.v6.linux.or.jp/
2690 if test -d /usr/inet6; then
2691 ipv6type=$i
2692 ipv6lib=inet6
2693 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002694 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002695 fi
2696 ;;
2697 solaris)
2698 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002699 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002700 ipv6type=$i
2701 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002702 fi
2703 fi
2704 ;;
2705 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002706 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002707#include <sys/param.h>
2708#ifdef _TOSHIBA_INET6
2709yes
2710#endif],
2711 [ipv6type=$i;
2712 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002713 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002714 ;;
2715 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002716 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002717#include </usr/local/v6/include/sys/v6config.h>
2718#ifdef __V6D__
2719yes
2720#endif],
2721 [ipv6type=$i;
2722 ipv6lib=v6;
2723 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002724 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002725 ;;
2726 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002727 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002728#include <sys/param.h>
2729#ifdef _ZETA_MINAMI_INET6
2730yes
2731#endif],
2732 [ipv6type=$i;
2733 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002734 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002735 ;;
2736 esac
2737 if test "$ipv6type" != "unknown"; then
2738 break
2739 fi
2740 done
2741 AC_MSG_RESULT($ipv6type)
2742fi
2743
2744if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2745 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2746 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2747 echo "using lib$ipv6lib"
2748 else
2749 if test $ipv6trylibc = "yes"; then
2750 echo "using libc"
2751 else
2752 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2753 echo "You need to fetch lib$ipv6lib.a from appropriate"
2754 echo 'ipv6 kit and compile beforehand.'
2755 exit 1
2756 fi
2757 fi
2758fi
2759
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002760AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002761AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002762 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002763],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002764 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002765 AC_MSG_RESULT(yes)
2766],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002767 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002768])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002769
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002770# Check for --with-doc-strings
2771AC_MSG_CHECKING(for --with-doc-strings)
2772AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002773 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002774
2775if test -z "$with_doc_strings"
2776then with_doc_strings="yes"
2777fi
2778if test "$with_doc_strings" != "no"
2779then
2780 AC_DEFINE(WITH_DOC_STRINGS, 1,
2781 [Define if you want documentation strings in extension modules])
2782fi
2783AC_MSG_RESULT($with_doc_strings)
2784
Neil Schemenauera35c6882001-02-27 04:45:05 +00002785# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002786AC_MSG_CHECKING(for --with-tsc)
2787AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002788 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002789if test "$withval" != no
2790then
2791 AC_DEFINE(WITH_TSC, 1,
2792 [Define to profile with the Pentium timestamp counter])
2793 AC_MSG_RESULT(yes)
2794else AC_MSG_RESULT(no)
2795fi],
2796[AC_MSG_RESULT(no)])
2797
2798# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002799AC_MSG_CHECKING(for --with-pymalloc)
2800AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002801 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002802
2803if test -z "$with_pymalloc"
2804then with_pymalloc="yes"
2805fi
2806if test "$with_pymalloc" != "no"
2807then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002808 AC_DEFINE(WITH_PYMALLOC, 1,
2809 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002810fi
2811AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002812
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002813# Check for Valgrind support
2814AC_MSG_CHECKING([for --with-valgrind])
2815AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002816 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002817 with_valgrind=no)
2818AC_MSG_RESULT([$with_valgrind])
2819if test "$with_valgrind" != no; then
2820 AC_CHECK_HEADER([valgrind/valgrind.h],
2821 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2822 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2823 )
2824fi
2825
Barry Warsawef82cd72000-06-30 16:21:01 +00002826# Check for --with-wctype-functions
2827AC_MSG_CHECKING(for --with-wctype-functions)
2828AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002829 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002830[
Barry Warsawef82cd72000-06-30 16:21:01 +00002831if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002832then
2833 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2834 [Define if you want wctype.h functions to be used instead of the
2835 one supplied by Python itself. (see Include/unicodectype.h).])
2836 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002837else AC_MSG_RESULT(no)
2838fi],
2839[AC_MSG_RESULT(no)])
2840
Guido van Rossum68242b51996-05-28 22:53:03 +00002841# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002842AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002843DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002844
Guido van Rossume97ee181999-12-20 21:27:22 +00002845# the dlopen() function means we might want to use dynload_shlib.o. some
2846# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002847AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002848
2849# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2850# loading of modules.
2851AC_SUBST(DYNLOADFILE)
2852AC_MSG_CHECKING(DYNLOADFILE)
2853if test -z "$DYNLOADFILE"
2854then
2855 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002856 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2857 if test "$ac_cv_func_dlopen" = yes
2858 then DYNLOADFILE="dynload_shlib.o"
2859 else DYNLOADFILE="dynload_aix.o"
2860 fi
2861 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002862 BeOS*) DYNLOADFILE="dynload_beos.o";;
2863 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002864 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2865 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002866 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002867 *)
2868 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2869 # out any dynamic loading
2870 if test "$ac_cv_func_dlopen" = yes
2871 then DYNLOADFILE="dynload_shlib.o"
2872 else DYNLOADFILE="dynload_stub.o"
2873 fi
2874 ;;
2875 esac
2876fi
2877AC_MSG_RESULT($DYNLOADFILE)
2878if test "$DYNLOADFILE" != "dynload_stub.o"
2879then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002880 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2881 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002882fi
2883
Jack Jansenc49e5b72001-06-19 15:00:23 +00002884# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2885
2886AC_SUBST(MACHDEP_OBJS)
2887AC_MSG_CHECKING(MACHDEP_OBJS)
2888if test -z "$MACHDEP_OBJS"
2889then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002890 MACHDEP_OBJS=$extra_machdep_objs
2891else
2892 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002893fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002894AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002895
Guido van Rossum627b2d71993-12-24 10:39:16 +00002896# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002897AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2898 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002899 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002900 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05002901 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002902 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002903 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002904 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2905 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002906 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002907 setlocale setregid setreuid setresuid setresgid \
2908 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002909 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002910 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002911 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002912
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002913# For some functions, having a definition is not sufficient, since
2914# we want to take their address.
2915AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002916AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2917 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2918 AC_MSG_RESULT(yes)],
2919 [AC_MSG_RESULT(no)
2920])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002921AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002922AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2923 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2924 AC_MSG_RESULT(yes)],
2925 [AC_MSG_RESULT(no)
2926])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002927AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002928AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2929 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2930 AC_MSG_RESULT(yes)],
2931 [AC_MSG_RESULT(no)
2932])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002933AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002934AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2935 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2936 AC_MSG_RESULT(yes)],
2937 [AC_MSG_RESULT(no)
2938])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002939AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002940AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2941 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2942 AC_MSG_RESULT(yes)],
2943 [AC_MSG_RESULT(no)
2944])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002945AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002946AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2947 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2948 AC_MSG_RESULT(yes)],
2949 [AC_MSG_RESULT(no)
2950])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002951AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002952AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2953 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2954 AC_MSG_RESULT(yes)],
2955 [AC_MSG_RESULT(no)
2956])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002957AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002958AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002959#include <sys/types.h>
2960#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002961 ]], [[int x=kqueue()]])],
2962 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2963 AC_MSG_RESULT(yes)],
2964 [AC_MSG_RESULT(no)
2965])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002966# On some systems (eg. FreeBSD 5), we would find a definition of the
2967# functions ctermid_r, setgroups in the library, but no prototype
2968# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2969# address to avoid compiler warnings and potential miscompilations
2970# because of the missing prototypes.
2971
2972AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002973AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002974#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002975]], [[void* p = ctermid_r]])],
2976 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2977 AC_MSG_RESULT(yes)],
2978 [AC_MSG_RESULT(no)
2979])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002980
Antoine Pitroub170f172010-09-10 18:47:36 +00002981AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2982 [AC_COMPILE_IFELSE(
2983 [AC_LANG_PROGRAM(
2984 [#include <sys/file.h>],
2985 [void* p = flock]
2986 )],
2987 [ac_cv_flock_decl=yes],
2988 [ac_cv_flock_decl=no]
2989 )
Matthias Klosec511b472010-05-08 11:01:39 +00002990])
Antoine Pitroub170f172010-09-10 18:47:36 +00002991if test "x${ac_cv_flock_decl}" = xyes; then
2992 AC_CHECK_FUNCS(flock,,
2993 AC_CHECK_LIB(bsd,flock,
2994 [AC_DEFINE(HAVE_FLOCK)
2995 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
2996 ])
2997 )
Antoine Pitrou85729812010-09-07 14:55:24 +00002998fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00002999
3000AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003001AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003002#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003003]], [[void* p = getpagesize]])],
3004 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3005 AC_MSG_RESULT(yes)],
3006 [AC_MSG_RESULT(no)
3007])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003008
Charles-François Natali93a11752011-11-27 13:01:35 +01003009AC_MSG_CHECKING(for broken unsetenv)
3010AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3011#include <stdlib.h>
3012]], [[int res = unsetenv("DUMMY")]])],
3013 [AC_MSG_RESULT(no)],
3014 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3015 AC_MSG_RESULT(yes)
3016])
3017
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003018dnl check for true
3019AC_CHECK_PROGS(TRUE, true, /bin/true)
3020
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003021dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3022dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003023AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003024 AC_CHECK_LIB(resolv, inet_aton)
3025)
3026
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003027# On Tru64, chflags seems to be present, but calling it will
3028# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003029AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003030AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003031#include <sys/stat.h>
3032#include <unistd.h>
3033int main(int argc, char*argv[])
3034{
3035 if(chflags(argv[0], 0) != 0)
3036 return 1;
3037 return 0;
3038}
Ned Deily43e10542011-06-27 23:41:53 -07003039]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003040[ac_cv_have_chflags=yes],
3041[ac_cv_have_chflags=no],
3042[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003043])
3044if test "$ac_cv_have_chflags" = cross ; then
3045 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3046fi
3047if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003048 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003049fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003050
Gregory P. Smithbb213892009-11-02 01:37:37 +00003051AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003052AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003053#include <sys/stat.h>
3054#include <unistd.h>
3055int main(int argc, char*argv[])
3056{
3057 if(lchflags(argv[0], 0) != 0)
3058 return 1;
3059 return 0;
3060}
Ned Deily43e10542011-06-27 23:41:53 -07003061]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003062])
3063if test "$ac_cv_have_lchflags" = cross ; then
3064 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3065fi
3066if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003067 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003068fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003069
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003070dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003071dnl
3072dnl On MacOSX the linker will search for dylibs on the entire linker path
3073dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3074dnl to revert to a more traditional unix behaviour and make it possible to
3075dnl override the system libz with a local static library of libz. Temporarily
3076dnl add that flag to our CFLAGS as well to ensure that we check the version
3077dnl of libz that will be used by setup.py.
3078dnl The -L/usr/local/lib is needed as wel to get the same compilation
3079dnl environment as setup.py (and leaving it out can cause configure to use the
3080dnl wrong version of the library)
3081case $ac_sys_system/$ac_sys_release in
3082Darwin/*)
3083 _CUR_CFLAGS="${CFLAGS}"
3084 _CUR_LDFLAGS="${LDFLAGS}"
3085 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3086 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3087 ;;
3088esac
3089
Matthias Klose5183ebd2010-04-24 16:38:36 +00003090AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003091
Ronald Oussorenf8752642006-07-06 10:13:35 +00003092case $ac_sys_system/$ac_sys_release in
3093Darwin/*)
3094 CFLAGS="${_CUR_CFLAGS}"
3095 LDFLAGS="${_CUR_LDFLAGS}"
3096 ;;
3097esac
3098
Martin v. Löwise9416172003-05-03 10:12:45 +00003099AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003100AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003101#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003102]], [[void* p = hstrerror; hstrerror(0)]])],
3103 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3104 AC_MSG_RESULT(yes)],
3105 [AC_MSG_RESULT(no)
3106])
Martin v. Löwise9416172003-05-03 10:12:45 +00003107
3108AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003109AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003110#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003111#include <sys/socket.h>
3112#include <netinet/in.h>
3113#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003114]], [[void* p = inet_aton;inet_aton(0,0)]])],
3115 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3116 AC_MSG_RESULT(yes)],
3117 [AC_MSG_RESULT(no)
3118])
Martin v. Löwise9416172003-05-03 10:12:45 +00003119
3120AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003121AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003122#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003123#include <sys/socket.h>
3124#include <netinet/in.h>
3125#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003126]], [[void* p = inet_pton]])],
3127 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3128 AC_MSG_RESULT(yes)],
3129 [AC_MSG_RESULT(no)
3130])
Martin v. Löwise9416172003-05-03 10:12:45 +00003131
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003132# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003133AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003134AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003135#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003136#ifdef HAVE_GRP_H
3137#include <grp.h>
3138#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003139]], [[void* p = setgroups]])],
3140 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3141 AC_MSG_RESULT(yes)],
3142 [AC_MSG_RESULT(no)
3143])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003144
Fred Drake8cef4cf2000-06-28 16:40:38 +00003145# check for openpty and forkpty
3146
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003147AC_CHECK_FUNCS(openpty,,
3148 AC_CHECK_LIB(util,openpty,
3149 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3150 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3151 )
3152)
3153AC_CHECK_FUNCS(forkpty,,
3154 AC_CHECK_LIB(util,forkpty,
3155 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3156 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3157 )
3158)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003159
Brett Cannonaa5778d2008-03-18 04:09:00 +00003160# Stuff for expat.
3161AC_CHECK_FUNCS(memmove)
3162
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003163# check for long file support functions
3164AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3165
Brett Cannonaa5778d2008-03-18 04:09:00 +00003166AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003167AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003168 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3169 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3170 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003171)
Jack Jansen150753c2003-03-29 22:07:47 +00003172AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003173 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3174 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3175 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003176)
3177AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003178 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3179 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3180 [],
3181 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3182 [Define if gettimeofday() does not have second (timezone) argument
3183 This is the case on Motorola V4 (R40V4.2)])
3184 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003185)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003186
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003187AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003188AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003189#if defined(MAJOR_IN_MKDEV)
3190#include <sys/mkdev.h>
3191#elif defined(MAJOR_IN_SYSMACROS)
3192#include <sys/sysmacros.h>
3193#else
3194#include <sys/types.h>
3195#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003196]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003197 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003198]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003199 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3200 [Define to 1 if you have the device macros.])
3201 AC_MSG_RESULT(yes)
3202],[
3203 AC_MSG_RESULT(no)
3204])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003205
3206# On OSF/1 V5.1, getaddrinfo is available, but a define
3207# for [no]getaddrinfo in netdb.h.
3208AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003209AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003210#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003211#include <sys/socket.h>
3212#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003213#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003214]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3215[have_getaddrinfo=yes],
3216[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003217AC_MSG_RESULT($have_getaddrinfo)
3218if test $have_getaddrinfo = yes
3219then
3220 AC_MSG_CHECKING(getaddrinfo bug)
3221 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003222 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003223#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003224#include <sys/types.h>
3225#include <netdb.h>
3226#include <string.h>
3227#include <sys/socket.h>
3228#include <netinet/in.h>
3229
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003230int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003231{
3232 int passive, gaierr, inet4 = 0, inet6 = 0;
3233 struct addrinfo hints, *ai, *aitop;
3234 char straddr[INET6_ADDRSTRLEN], strport[16];
3235
3236 for (passive = 0; passive <= 1; passive++) {
3237 memset(&hints, 0, sizeof(hints));
3238 hints.ai_family = AF_UNSPEC;
3239 hints.ai_flags = passive ? AI_PASSIVE : 0;
3240 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003241 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003242 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3243 (void)gai_strerror(gaierr);
3244 goto bad;
3245 }
3246 for (ai = aitop; ai; ai = ai->ai_next) {
3247 if (ai->ai_addr == NULL ||
3248 ai->ai_addrlen == 0 ||
3249 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3250 straddr, sizeof(straddr), strport, sizeof(strport),
3251 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3252 goto bad;
3253 }
3254 switch (ai->ai_family) {
3255 case AF_INET:
3256 if (strcmp(strport, "54321") != 0) {
3257 goto bad;
3258 }
3259 if (passive) {
3260 if (strcmp(straddr, "0.0.0.0") != 0) {
3261 goto bad;
3262 }
3263 } else {
3264 if (strcmp(straddr, "127.0.0.1") != 0) {
3265 goto bad;
3266 }
3267 }
3268 inet4++;
3269 break;
3270 case AF_INET6:
3271 if (strcmp(strport, "54321") != 0) {
3272 goto bad;
3273 }
3274 if (passive) {
3275 if (strcmp(straddr, "::") != 0) {
3276 goto bad;
3277 }
3278 } else {
3279 if (strcmp(straddr, "::1") != 0) {
3280 goto bad;
3281 }
3282 }
3283 inet6++;
3284 break;
3285 case AF_UNSPEC:
3286 goto bad;
3287 break;
3288 default:
3289 /* another family support? */
3290 break;
3291 }
3292 }
3293 }
3294
3295 if (!(inet4 == 0 || inet4 == 2))
3296 goto bad;
3297 if (!(inet6 == 0 || inet6 == 2))
3298 goto bad;
3299
3300 if (aitop)
3301 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003302 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003303
3304 bad:
3305 if (aitop)
3306 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003307 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003308}
Matthias Klosec511b472010-05-08 11:01:39 +00003309]]])],
3310[ac_cv_buggy_getaddrinfo=no],
3311[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003312[
3313if test "${enable_ipv6+set}" = set; then
3314 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3315else
3316 ac_cv_buggy_getaddrinfo=yes
3317fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003318fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003319
Benjamin Peterson75fed812010-11-01 01:47:19 +00003320AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3321
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003322if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003323then
3324 if test $ipv6 = yes
3325 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003326 echo 'Fatal: You must get working getaddrinfo() function.'
3327 echo ' or you can specify "--disable-ipv6"'.
3328 exit 1
3329 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003330else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003331 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003332fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003333
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003334AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003335
Guido van Rossum627b2d71993-12-24 10:39:16 +00003336# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003337AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003338AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003339AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003340AC_CHECK_MEMBERS([struct stat.st_rdev])
3341AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003342AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003343AC_CHECK_MEMBERS([struct stat.st_gen])
3344AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003345AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003346
3347AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003348AC_CACHE_VAL(ac_cv_header_time_altzone,[
3349 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3350 [ac_cv_header_time_altzone=yes],
3351 [ac_cv_header_time_altzone=no])
3352 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003353AC_MSG_RESULT($ac_cv_header_time_altzone)
3354if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003355 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003356fi
3357
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003358was_it_defined=no
3359AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003360AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003361#include <sys/types.h>
3362#include <sys/select.h>
3363#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003364]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003365 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3366 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3367 (which you can't on SCO ODT 3.0).])
3368 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003369],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003370AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003371
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003372AC_MSG_CHECKING(for addrinfo)
3373AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003374AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3375 [ac_cv_struct_addrinfo=yes],
3376 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003377AC_MSG_RESULT($ac_cv_struct_addrinfo)
3378if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003379 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003380fi
3381
3382AC_MSG_CHECKING(for sockaddr_storage)
3383AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003384AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003385# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003386# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3387 [ac_cv_struct_sockaddr_storage=yes],
3388 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003389AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3390if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003391 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003392fi
3393
Guido van Rossum627b2d71993-12-24 10:39:16 +00003394# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003395
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003396AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003397AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003398
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003399works=no
3400AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003401AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3402 [works=yes],
3403 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003404)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003405AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003406
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003407works=no
3408AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003409AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3410 [works=yes],
3411 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003412)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003413AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003414
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003415have_prototypes=no
3416AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003417AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3418 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3419 [Define if your compiler supports function prototype])
3420 have_prototypes=yes],
3421 []
3422)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003423AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003424
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003425works=no
3426AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003427AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003428#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003429int foo(int x, ...) {
3430 va_list va;
3431 va_start(va, x);
3432 va_arg(va, int);
3433 va_arg(va, char *);
3434 va_arg(va, double);
3435 return 0;
3436}
Matthias Klosec511b472010-05-08 11:01:39 +00003437]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003438 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3439 [Define if your compiler supports variable length function prototypes
3440 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3441 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003442],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003443AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003444
Dave Cole331708b2004-08-09 04:51:41 +00003445# check for socketpair
3446AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003447AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003448#include <sys/types.h>
3449#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003450]], [[void *x=socketpair]])],
3451 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3452 AC_MSG_RESULT(yes)],
3453 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003454)
3455
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003456# check if sockaddr has sa_len member
3457AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003458AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3459#include <sys/socket.h>]], [[struct sockaddr x;
3460x.sa_len = 0;]])],
3461 [AC_MSG_RESULT(yes)
3462 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3463 [AC_MSG_RESULT(no)]
3464)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003465
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003466va_list_is_array=no
3467AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003468AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003469#ifdef HAVE_STDARG_PROTOTYPES
3470#include <stdarg.h>
3471#else
3472#include <varargs.h>
3473#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003474]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003475 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3476 va_list_is_array=yes
3477])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003478AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003479
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003480# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003481AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3482 [Define this if you have some version of gethostbyname_r()])
3483
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003484AC_CHECK_FUNC(gethostbyname_r, [
3485 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3486 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3487 OLD_CFLAGS=$CFLAGS
3488 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003489 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003490# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003491 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003492 char *name;
3493 struct hostent *he, *res;
3494 char buffer[2048];
3495 int buflen = 2048;
3496 int h_errnop;
3497
3498 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003499 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003500 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003501 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3502 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003503 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003504 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003505 AC_MSG_RESULT(no)
3506 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003507 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003508# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003509 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003510 char *name;
3511 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003512 char buffer[2048];
3513 int buflen = 2048;
3514 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003515
Matthias Klosec511b472010-05-08 11:01:39 +00003516 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3517 ]])],
3518 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003519 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003520 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3521 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003522 AC_MSG_RESULT(yes)
3523 ], [
3524 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003525 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3526 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3527# include <netdb.h>
3528 ]], [[
3529 char *name;
3530 struct hostent *he;
3531 struct hostent_data data;
3532
3533 (void) gethostbyname_r(name, he, &data);
3534 ]])],
3535 [
3536 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3537 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3538 [Define this if you have the 3-arg version of gethostbyname_r().])
3539 AC_MSG_RESULT(yes)
3540 ], [
3541 AC_MSG_RESULT(no)
3542 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003543 ])
3544 ])
3545 CFLAGS=$OLD_CFLAGS
3546], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003547 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003548])
3549AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3550AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3551AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003552AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003553AC_SUBST(HAVE_GETHOSTBYNAME)
3554
Guido van Rossum627b2d71993-12-24 10:39:16 +00003555# checks for system services
3556# (none yet)
3557
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003558# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003559AC_CHECK_FUNC(__fpu_control,
3560 [],
3561 [AC_CHECK_LIB(ieee, __fpu_control)
3562])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003563
Guido van Rossum93274221997-05-09 02:42:00 +00003564# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003565AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003566AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003567 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003568[
Guido van Rossum93274221997-05-09 02:42:00 +00003569if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003570then
3571 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3572 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3573 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003574else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003575fi],
3576[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003577
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003578# check for --with-libm=...
3579AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003580case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003581Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003582BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003583*) LIBM=-lm
3584esac
Guido van Rossum93274221997-05-09 02:42:00 +00003585AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003586AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003587 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003588[
Guido van Rossum93274221997-05-09 02:42:00 +00003589if test "$withval" = no
3590then LIBM=
3591 AC_MSG_RESULT(force LIBM empty)
3592elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003593then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003594 AC_MSG_RESULT(set LIBM="$withval")
3595else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003596fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003597[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003598
3599# check for --with-libc=...
3600AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003601AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003602AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003603 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003604[
Guido van Rossum93274221997-05-09 02:42:00 +00003605if test "$withval" = no
3606then LIBC=
3607 AC_MSG_RESULT(force LIBC empty)
3608elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003609then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003610 AC_MSG_RESULT(set LIBC="$withval")
3611else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003612fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003613[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003614
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003615# **************************************************
3616# * Check for various properties of floating point *
3617# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003618
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003619AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3620AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003621AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003622#include <string.h>
3623int main() {
3624 double x = 9006104071832581.0;
3625 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3626 return 0;
3627 else
3628 return 1;
3629}
Matthias Klosec511b472010-05-08 11:01:39 +00003630]])],
3631[ac_cv_little_endian_double=yes],
3632[ac_cv_little_endian_double=no],
3633[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003634AC_MSG_RESULT($ac_cv_little_endian_double)
3635if test "$ac_cv_little_endian_double" = yes
3636then
3637 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3638 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3639 with the least significant byte first])
3640fi
3641
3642AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3643AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003644AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003645#include <string.h>
3646int main() {
3647 double x = 9006104071832581.0;
3648 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3649 return 0;
3650 else
3651 return 1;
3652}
Matthias Klosec511b472010-05-08 11:01:39 +00003653]])],
3654[ac_cv_big_endian_double=yes],
3655[ac_cv_big_endian_double=no],
3656[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003657AC_MSG_RESULT($ac_cv_big_endian_double)
3658if test "$ac_cv_big_endian_double" = yes
3659then
3660 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3661 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3662 with the most significant byte first])
3663fi
3664
3665# Some ARM platforms use a mixed-endian representation for doubles.
3666# While Python doesn't currently have full support for these platforms
3667# (see e.g., issue 1762561), we can at least make sure that float <-> string
3668# conversions work.
3669AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3670AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003671AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003672#include <string.h>
3673int main() {
3674 double x = 9006104071832581.0;
3675 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3676 return 0;
3677 else
3678 return 1;
3679}
Matthias Klosec511b472010-05-08 11:01:39 +00003680]])],
3681[ac_cv_mixed_endian_double=yes],
3682[ac_cv_mixed_endian_double=no],
3683[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003684AC_MSG_RESULT($ac_cv_mixed_endian_double)
3685if test "$ac_cv_mixed_endian_double" = yes
3686then
3687 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3688 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3689 in ARM mixed-endian order (byte order 45670123)])
3690fi
3691
3692# The short float repr introduced in Python 3.1 requires the
3693# correctly-rounded string <-> double conversion functions from
3694# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3695# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003696# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003697# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003698
3699# This inline assembler syntax may also work for suncc and icc,
3700# so we try it on all platforms.
3701
3702AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003703AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003704 unsigned short cw;
3705 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3706 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003707]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003708AC_MSG_RESULT($have_gcc_asm_for_x87)
3709if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003710then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003711 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3712 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003713fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003714
Mark Dickinson04b27232009-01-04 12:29:36 +00003715# Detect whether system arithmetic is subject to x87-style double
3716# rounding issues. The result of this test has little meaning on non
3717# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3718# mode is round-to-nearest and double rounding issues are present, and
3719# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3720AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003721# $BASECFLAGS may affect the result
3722ac_save_cc="$CC"
3723CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003724AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003725#include <stdlib.h>
3726#include <math.h>
3727int main() {
3728 volatile double x, y, z;
3729 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3730 x = 0.99999999999999989; /* 1-2**-53 */
3731 y = 1./x;
3732 if (y != 1.)
3733 exit(0);
3734 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3735 x = 1e16;
3736 y = 2.99999;
3737 z = x + y;
3738 if (z != 1e16+4.)
3739 exit(0);
3740 /* both tests show evidence of double rounding */
3741 exit(1);
3742}
Matthias Klosec511b472010-05-08 11:01:39 +00003743]])],
3744[ac_cv_x87_double_rounding=no],
3745[ac_cv_x87_double_rounding=yes],
3746[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003747CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003748AC_MSG_RESULT($ac_cv_x87_double_rounding)
3749if test "$ac_cv_x87_double_rounding" = yes
3750then
3751 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3752 [Define if arithmetic is subject to x87-style double rounding issue])
3753fi
3754
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003755# ************************************
3756# * Check for mathematical functions *
3757# ************************************
3758
3759LIBS_SAVE=$LIBS
3760LIBS="$LIBS $LIBM"
3761
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003762# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3763# -0. on some architectures.
3764AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3765AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003766AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003767#include <math.h>
3768#include <stdlib.h>
3769int main() {
3770 /* return 0 if either negative zeros don't exist
3771 on this platform or if negative zeros exist
3772 and tanh(-0.) == -0. */
3773 if (atan2(0., -1.) == atan2(-0., -1.) ||
3774 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3775 else exit(1);
3776}
Matthias Klosec511b472010-05-08 11:01:39 +00003777]])],
3778[ac_cv_tanh_preserves_zero_sign=yes],
3779[ac_cv_tanh_preserves_zero_sign=no],
3780[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003781AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3782if test "$ac_cv_tanh_preserves_zero_sign" = yes
3783then
3784 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3785 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3786fi
3787
3788AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3789AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3790AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3791
3792LIBS=$LIBS_SAVE
3793
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003794# For multiprocessing module, check that sem_open
3795# actually works. For FreeBSD versions <= 7.2,
3796# the kernel module that provides POSIX semaphores
3797# isn't loaded by default, so an attempt to call
3798# sem_open results in a 'Signal 12' error.
3799AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3800AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003801AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003802#include <unistd.h>
3803#include <fcntl.h>
3804#include <stdio.h>
3805#include <semaphore.h>
3806#include <sys/stat.h>
3807
3808int main(void) {
3809 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3810 if (a == SEM_FAILED) {
3811 perror("sem_open");
3812 return 1;
3813 }
3814 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003815 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003816 return 0;
3817}
Matthias Klosec511b472010-05-08 11:01:39 +00003818]])],
3819[ac_cv_posix_semaphores_enabled=yes],
3820[ac_cv_posix_semaphores_enabled=no],
3821[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003822)
3823AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3824if test $ac_cv_posix_semaphores_enabled = no
3825then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003826 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3827 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003828fi
3829
Jesse Noller355b1262009-04-02 00:03:28 +00003830# Multiprocessing check for broken sem_getvalue
3831AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003832AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003833AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003834#include <unistd.h>
3835#include <fcntl.h>
3836#include <stdio.h>
3837#include <semaphore.h>
3838#include <sys/stat.h>
3839
3840int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003841 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003842 int count;
3843 int res;
3844 if(a==SEM_FAILED){
3845 perror("sem_open");
3846 return 1;
3847
3848 }
3849 res = sem_getvalue(a, &count);
3850 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003851 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003852 return res==-1 ? 1 : 0;
3853}
Matthias Klosec511b472010-05-08 11:01:39 +00003854]])],
3855[ac_cv_broken_sem_getvalue=no],
3856[ac_cv_broken_sem_getvalue=yes],
3857[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003858)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003859AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3860if test $ac_cv_broken_sem_getvalue = yes
3861then
3862 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3863 [define to 1 if your sem_getvalue is broken.])
3864fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003865
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003866# determine what size digit to use for Python's longs
3867AC_MSG_CHECKING([digit size for Python's longs])
3868AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003869AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003870[case $enable_big_digits in
3871yes)
3872 enable_big_digits=30 ;;
3873no)
3874 enable_big_digits=15 ;;
3875[15|30])
3876 ;;
3877*)
3878 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3879esac
3880AC_MSG_RESULT($enable_big_digits)
3881AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3882],
3883[AC_MSG_RESULT(no value specified)])
3884
Guido van Rossumef2255b2000-03-10 22:30:29 +00003885# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003886AC_CHECK_HEADER(wchar.h, [
3887 AC_DEFINE(HAVE_WCHAR_H, 1,
3888 [Define if the compiler provides a wchar.h header file.])
3889 wchar_h="yes"
3890],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003891wchar_h="no"
3892)
3893
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003894# determine wchar_t size
3895if test "$wchar_h" = yes
3896then
Guido van Rossum67b26592001-10-20 14:21:45 +00003897 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003898fi
3899
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003900AC_MSG_CHECKING(for UCS-4 tcl)
3901have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003902AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003903#include <tcl.h>
3904#if TCL_UTF_MAX != 6
3905# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003906#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003907 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3908 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003909],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003910AC_MSG_RESULT($have_ucs4_tcl)
3911
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003912# check whether wchar_t is signed or not
3913if test "$wchar_h" = yes
3914then
3915 # check whether wchar_t is signed or not
3916 AC_MSG_CHECKING(whether wchar_t is signed)
3917 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003918 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003919 #include <wchar.h>
3920 int main()
3921 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003922 /* Success: exit code 0 */
3923 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003924 }
Matthias Klosec511b472010-05-08 11:01:39 +00003925 ]])],
3926 [ac_cv_wchar_t_signed=yes],
3927 [ac_cv_wchar_t_signed=no],
3928 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003929 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3930fi
3931
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003932AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003933dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003934AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003935 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003936 [],
3937 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003938
3939if test $enable_unicode = yes
3940then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003941 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003942 case "$have_ucs4_tcl" in
3943 yes) enable_unicode="ucs4"
3944 ;;
3945 *) enable_unicode="ucs2"
3946 ;;
3947 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003948fi
3949
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003950AH_TEMPLATE(Py_UNICODE_SIZE,
3951 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003952case "$enable_unicode" in
3953ucs2) unicode_size="2"
3954 AC_DEFINE(Py_UNICODE_SIZE,2)
3955 ;;
3956ucs4) unicode_size="4"
3957 AC_DEFINE(Py_UNICODE_SIZE,4)
3958 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003959no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003960*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003961esac
3962
Martin v. Löwis11437992002-04-12 09:54:03 +00003963AH_TEMPLATE(PY_UNICODE_TYPE,
3964 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003965
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003966AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003967if test "$enable_unicode" = "no"
3968then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003969 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003970 AC_MSG_RESULT(not used)
3971else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003972 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003973 AC_DEFINE(Py_USING_UNICODE, 1,
3974 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003975
3976 # wchar_t is only usable if it maps to an unsigned type
3977 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003978 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003979 then
3980 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003981 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3982 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003983 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003984 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003985 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3986 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3987 then
3988 PY_UNICODE_TYPE="unsigned short"
3989 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3990 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3991 then
3992 PY_UNICODE_TYPE="unsigned long"
3993 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3994 else
3995 PY_UNICODE_TYPE="no type found"
3996 fi
3997 AC_MSG_RESULT($PY_UNICODE_TYPE)
3998fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00003999
4000# check for endianness
4001AC_C_BIGENDIAN
4002
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004003# Check whether right shifting a negative integer extends the sign bit
4004# or fills with zeros (like the Cray J90, according to Tim Peters).
4005AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004006AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004007AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004008int main()
4009{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004010 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004011}
Matthias Klosec511b472010-05-08 11:01:39 +00004012]])],
4013[ac_cv_rshift_extends_sign=yes],
4014[ac_cv_rshift_extends_sign=no],
4015[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004016AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4017if test "$ac_cv_rshift_extends_sign" = no
4018then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004019 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4020 [Define if i>>j for signed int i does not extend the sign bit
4021 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004022fi
4023
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004024# check for getc_unlocked and related locking functions
4025AC_MSG_CHECKING(for getc_unlocked() and friends)
4026AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004027AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004028 FILE *f = fopen("/dev/null", "r");
4029 flockfile(f);
4030 getc_unlocked(f);
4031 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004032]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004033AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4034if test "$ac_cv_have_getc_unlocked" = yes
4035then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004036 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4037 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004038fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004039
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004040# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004041# save the value of LIBS so we don't actually link Python with readline
4042LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004043
4044# On some systems we need to link readline to a termcap compatible
4045# library. NOTE: Keep the precedence of listed libraries synchronised
4046# with setup.py.
4047py_cv_lib_readline=no
4048AC_MSG_CHECKING([how to link readline libs])
4049for py_libtermcap in "" ncursesw ncurses curses termcap; do
4050 if test -z "$py_libtermcap"; then
4051 READLINE_LIBS="-lreadline"
4052 else
4053 READLINE_LIBS="-lreadline -l$py_libtermcap"
4054 fi
4055 LIBS="$READLINE_LIBS $LIBS_no_readline"
4056 AC_LINK_IFELSE(
4057 [AC_LANG_CALL([],[readline])],
4058 [py_cv_lib_readline=yes])
4059 if test $py_cv_lib_readline = yes; then
4060 break
4061 fi
4062done
4063# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4064#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004065if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004066 AC_MSG_RESULT([none])
4067else
4068 AC_MSG_RESULT([$READLINE_LIBS])
4069 AC_DEFINE(HAVE_LIBREADLINE, 1,
4070 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004071fi
4072
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004073# check for readline 2.1
4074AC_CHECK_LIB(readline, rl_callback_handler_install,
4075 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004076 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004077
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004078# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004079AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4080 [have_readline=yes],
4081 [have_readline=no]
4082)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004083if test $have_readline = yes
4084then
4085 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4086 [readline/readline.h],
4087 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4088 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004089 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4090 [readline/readline.h],
4091 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4092 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004093fi
4094
Martin v. Löwis0daad592001-09-30 21:09:59 +00004095# check for readline 4.0
4096AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004097 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004098 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004099
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004100# also in 4.0
4101AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4102 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004103 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004104
Guido van Rossum353ae582001-07-10 16:45:32 +00004105# check for readline 4.2
4106AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004107 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004108 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004109
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004110# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004111AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4112 [have_readline=yes],
4113 [have_readline=no]
4114)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004115if test $have_readline = yes
4116then
4117 AC_EGREP_HEADER([extern int rl_catch_signals;],
4118 [readline/readline.h],
4119 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4120 [Define if you can turn off readline's signal handling.]), )
4121fi
4122
Martin v. Löwis82bca632006-02-10 20:49:30 +00004123# End of readline checks: restore LIBS
4124LIBS=$LIBS_no_readline
4125
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004126AC_MSG_CHECKING(for broken nice())
4127AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004128AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004129int main()
4130{
4131 int val1 = nice(1);
4132 if (val1 != -1 && val1 == nice(2))
4133 exit(0);
4134 exit(1);
4135}
Matthias Klosec511b472010-05-08 11:01:39 +00004136]])],
4137[ac_cv_broken_nice=yes],
4138[ac_cv_broken_nice=no],
4139[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004140AC_MSG_RESULT($ac_cv_broken_nice)
4141if test "$ac_cv_broken_nice" = yes
4142then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004143 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4144 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004145fi
4146
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004147AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004148AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004149AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004150#include <poll.h>
4151
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004152int main()
4153{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004154 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004155 int poll_test;
4156
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004157 close (42);
4158
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004159 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004160 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004161 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004162 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004163 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004164 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004165 return 1;
4166}
Matthias Klosec511b472010-05-08 11:01:39 +00004167]])],
4168[ac_cv_broken_poll=yes],
4169[ac_cv_broken_poll=no],
4170[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004171AC_MSG_RESULT($ac_cv_broken_poll)
4172if test "$ac_cv_broken_poll" = yes
4173then
4174 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4175 [Define if poll() sets errno on invalid file descriptors.])
4176fi
4177
Brett Cannon43802422005-02-10 20:48:03 +00004178# Before we can test tzset, we need to check if struct tm has a tm_zone
4179# (which is not required by ISO C or UNIX spec) and/or if we support
4180# tzname[]
4181AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004182
Brett Cannon43802422005-02-10 20:48:03 +00004183# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004184AC_MSG_CHECKING(for working tzset())
4185AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004186AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004187#include <stdlib.h>
4188#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004189#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004190
4191#if HAVE_TZNAME
4192extern char *tzname[];
4193#endif
4194
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004195int main()
4196{
Brett Cannon18367812003-09-19 00:59:16 +00004197 /* Note that we need to ensure that not only does tzset(3)
4198 do 'something' with localtime, but it works as documented
4199 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004200 This includes making sure that tzname is set properly if
4201 tm->tm_zone does not exist since it is the alternative way
4202 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004203
4204 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004205 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004206 */
4207
Brett Cannon43802422005-02-10 20:48:03 +00004208 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004209 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4210
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004211 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004212 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004213 if (localtime(&groundhogday)->tm_hour != 0)
4214 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004215#if HAVE_TZNAME
4216 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4217 if (strcmp(tzname[0], "UTC") ||
4218 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4219 exit(1);
4220#endif
Brett Cannon18367812003-09-19 00:59:16 +00004221
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004222 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004223 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004224 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004225 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004226#if HAVE_TZNAME
4227 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4228 exit(1);
4229#endif
Brett Cannon18367812003-09-19 00:59:16 +00004230
4231 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4232 tzset();
4233 if (localtime(&groundhogday)->tm_hour != 11)
4234 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004235#if HAVE_TZNAME
4236 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4237 exit(1);
4238#endif
4239
4240#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004241 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4242 exit(1);
4243 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4244 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004245#endif
Brett Cannon18367812003-09-19 00:59:16 +00004246
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004247 exit(0);
4248}
Matthias Klosec511b472010-05-08 11:01:39 +00004249]])],
4250[ac_cv_working_tzset=yes],
4251[ac_cv_working_tzset=no],
4252[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004253AC_MSG_RESULT($ac_cv_working_tzset)
4254if test "$ac_cv_working_tzset" = yes
4255then
4256 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4257 [Define if tzset() actually switches the local timezone in a meaningful way.])
4258fi
4259
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004260# Look for subsecond timestamps in struct stat
4261AC_MSG_CHECKING(for tv_nsec in struct stat)
4262AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004263AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004264struct stat st;
4265st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004266]])],
4267[ac_cv_stat_tv_nsec=yes],
4268[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004269AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4270if test "$ac_cv_stat_tv_nsec" = yes
4271then
4272 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4273 [Define if you have struct stat.st_mtim.tv_nsec])
4274fi
4275
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004276# Look for BSD style subsecond timestamps in struct stat
4277AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4278AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004279AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004280struct stat st;
4281st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004282]])],
4283[ac_cv_stat_tv_nsec2=yes],
4284[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004285AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4286if test "$ac_cv_stat_tv_nsec2" = yes
4287then
4288 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4289 [Define if you have struct stat.st_mtimensec])
4290fi
4291
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004292# first curses configure check
4293ac_save_cppflags="$CPPFLAGS"
4294CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4295
4296AC_CHECK_HEADERS(curses.h ncurses.h)
4297
4298# On Solaris, term.h requires curses.h
4299AC_CHECK_HEADERS(term.h,,,[
4300#ifdef HAVE_CURSES_H
4301#include <curses.h>
4302#endif
4303])
4304
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004305# On HP/UX 11.0, mvwdelch is a block with a return statement
4306AC_MSG_CHECKING(whether mvwdelch is an expression)
4307AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004308AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004309 int rtn;
4310 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004311]])],
4312[ac_cv_mvwdelch_is_expression=yes],
4313[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004314AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4315
4316if test "$ac_cv_mvwdelch_is_expression" = yes
4317then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004318 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4319 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004320fi
4321
4322AC_MSG_CHECKING(whether WINDOW has _flags)
4323AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004324AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004325 WINDOW *w;
4326 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004327]])],
4328[ac_cv_window_has_flags=yes],
4329[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004330AC_MSG_RESULT($ac_cv_window_has_flags)
4331
4332
4333if test "$ac_cv_window_has_flags" = yes
4334then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004335 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4336 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004337fi
4338
Walter Dörwald4994d952006-06-19 08:07:50 +00004339AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004340AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4341 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4342 AC_MSG_RESULT(yes)],
4343 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004344)
4345
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004346AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004347AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4348 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4349 AC_MSG_RESULT(yes)],
4350 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004351)
4352
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004353AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004354AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4355 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4356 AC_MSG_RESULT(yes)],
4357 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004358)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004359# last curses configure check
4360CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004361
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004362AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004363
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004364dnl NOTE: Inform user how to proceed with files when cross compiling.
4365if test "x$cross_compiling" = xyes; then
4366 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4367 AC_MSG_CHECKING([for /dev/ptmx])
4368 AC_MSG_RESULT([not set])
4369 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4370 fi
4371 if test "${ac_cv_file__dev_ptc+set}" != set; then
4372 AC_MSG_CHECKING([for /dev/ptc])
4373 AC_MSG_RESULT([not set])
4374 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4375 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004376fi
4377
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004378AC_CHECK_FILE(/dev/ptmx, [], [])
4379if test "x$ac_cv_file__dev_ptmx" = xyes; then
4380 AC_DEFINE(HAVE_DEV_PTMX, 1,
4381 [Define to 1 if you have the /dev/ptmx device file.])
4382fi
4383AC_CHECK_FILE(/dev/ptc, [], [])
4384if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004385 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004386 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004387fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004388
Mark Dickinson82864d12009-11-15 16:18:58 +00004389if test "$have_long_long" = yes
4390then
4391 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4392 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004393 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004394 #include <stdio.h>
4395 #include <stddef.h>
4396 #include <string.h>
4397
4398 #ifdef HAVE_SYS_TYPES_H
4399 #include <sys/types.h>
4400 #endif
4401
4402 int main()
4403 {
4404 char buffer[256];
4405
4406 if (sprintf(buffer, "%lld", (long long)123) < 0)
4407 return 1;
4408 if (strcmp(buffer, "123"))
4409 return 1;
4410
4411 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4412 return 1;
4413 if (strcmp(buffer, "-123"))
4414 return 1;
4415
4416 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4417 return 1;
4418 if (strcmp(buffer, "123"))
4419 return 1;
4420
4421 return 0;
4422 }
Matthias Klosec511b472010-05-08 11:01:39 +00004423 ]]])],
4424 [ac_cv_have_long_long_format=yes],
4425 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004426 [ac_cv_have_long_long_format="cross -- assuming no"
4427 if test x$GCC = xyes; then
4428 save_CFLAGS=$CFLAGS
4429 CFLAGS="$CFLAGS -Werror -Wformat"
4430 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4431 #include <stdio.h>
4432 #include <stddef.h>
4433 ]], [[
4434 char *buffer;
4435 sprintf(buffer, "%lld", (long long)123);
4436 sprintf(buffer, "%lld", (long long)-123);
4437 sprintf(buffer, "%llu", (unsigned long long)123);
4438 ]])],
4439 ac_cv_have_long_long_format=yes
4440 )
4441 CFLAGS=$save_CFLAGS
4442 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004443 )
4444 AC_MSG_RESULT($ac_cv_have_long_long_format)
4445fi
4446
Mark Dickinson5ce84742009-12-31 20:48:04 +00004447if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004448then
4449 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4450 [Define to printf format modifier for long long type])
4451fi
4452
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004453if test $ac_sys_system = Darwin
4454then
4455 LIBS="$LIBS -framework CoreFoundation"
4456fi
4457
Mark Dickinson82864d12009-11-15 16:18:58 +00004458
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004459AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004460AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004461#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004462#include <stddef.h>
4463#include <string.h>
4464
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004465#ifdef HAVE_SYS_TYPES_H
4466#include <sys/types.h>
4467#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004468
4469#ifdef HAVE_SSIZE_T
4470typedef ssize_t Py_ssize_t;
4471#elif SIZEOF_VOID_P == SIZEOF_LONG
4472typedef long Py_ssize_t;
4473#else
4474typedef int Py_ssize_t;
4475#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004476
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004477int main()
4478{
4479 char buffer[256];
4480
Brett Cannon09d12362006-05-11 05:11:33 +00004481 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4482 return 1;
4483
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004484 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004485 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004486
4487 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4488 return 1;
4489
4490 if (strcmp(buffer, "-123"))
4491 return 1;
4492
Brett Cannon09d12362006-05-11 05:11:33 +00004493 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004494}
Matthias Klosec511b472010-05-08 11:01:39 +00004495]])],
4496[ac_cv_have_size_t_format=yes],
4497[ac_cv_have_size_t_format=no],
4498[ac_cv_have_size_t_format="cross -- assuming yes"
4499])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004500if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004501 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4502 [Define to printf format modifier for Py_ssize_t])
4503fi
Brett Cannon09d12362006-05-11 05:11:33 +00004504
Martin v. Löwis01c04012002-11-11 14:58:44 +00004505AC_CHECK_TYPE(socklen_t,,
4506 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004507 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004508#ifdef HAVE_SYS_TYPES_H
4509#include <sys/types.h>
4510#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004511#ifdef HAVE_SYS_SOCKET_H
4512#include <sys/socket.h>
4513#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004514])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004515
R. David Murray1d9d16e2010-10-16 00:43:13 +00004516case $ac_sys_system in
4517AIX*)
4518 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4519esac
4520
4521
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004522AC_SUBST(THREADHEADERS)
4523
4524for h in `(cd $srcdir;echo Python/thread_*.h)`
4525do
4526 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4527done
4528
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004529AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004530SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004531AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004532for dir in $SRCDIRS; do
4533 if test ! -d $dir; then
4534 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004535 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004536done
4537AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004538
Guido van Rossum627b2d71993-12-24 10:39:16 +00004539# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004540AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004541AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004542AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004543
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004544echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004545if test ! -f Modules/Setup
4546then
4547 cp $srcdir/Modules/Setup.dist Modules/Setup
4548fi
4549
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004550echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004551if test ! -f Modules/Setup.local
4552then
4553 echo "# Edit this file for local setup changes" >Modules/Setup.local
4554fi
4555
4556echo "creating Makefile"
4557$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4558 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004559 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004560
4561case $ac_sys_system in
4562BeOS)
4563 AC_MSG_WARN([
4564
4565 Support for BeOS is deprecated as of Python 2.6.
4566 See PEP 11 for the gory details.
4567 ])
4568 ;;
4569*) ;;
4570esac
4571
Neil Schemenauer66252162001-02-19 04:47:42 +00004572mv config.c Modules