blob: 54f8c0f69f8815086e6960e6c1dc5d4254210285 [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 #
Ned Deilyc40b9032014-06-25 13:48:46 -07001152 cur_target_major=`sw_vers -productVersion | \
1153 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1154 cur_target_minor=`sw_vers -productVersion | \
1155 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1156 cur_target="${cur_target_major}.${cur_target_minor}"
1157 if test ${cur_target_major} -eq 10 && \
1158 test ${cur_target_minor} -ge 3
1159 then
Benjamin Peterson4347c442008-07-17 15:59:24 +00001160 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001161 if test ${enable_universalsdk}; then
1162 if test "${UNIVERSAL_ARCHS}" = "all"; then
1163 # Ensure that the default platform for a
1164 # 4-way universal build is OSX 10.5,
1165 # that's the first OS release where
1166 # 4-way builds make sense.
1167 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001168
1169 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1170 cur_target='10.5'
1171
1172 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1173 cur_target='10.5'
1174
1175 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1176 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001177 fi
1178 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001179 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001180 # On Intel macs default to a deployment
1181 # target of 10.4, that's the first OSX
1182 # release with Intel support.
1183 cur_target="10.4"
1184 fi
1185 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001186 fi
1187 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1188
1189 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1190 # environment with a value that is the same as what we'll use
1191 # in the Makefile to ensure that we'll get the same compiler
1192 # environment during configure and build time.
1193 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1194 export MACOSX_DEPLOYMENT_TARGET
1195 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1196
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001197 if test "${enable_universalsdk}"; then
1198 UNIVERSAL_ARCH_FLAGS=""
1199 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1200 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1201 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001202 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001203
1204 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1205 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1206 LIPO_32BIT_FLAGS=""
1207 ARCH_RUN_32BIT="true"
1208
1209 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1210 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1211 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001212 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001213
1214 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1215 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1216 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001217 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001218
1219 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1220 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1221 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001222 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001223
1224 else
1225 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1226
1227 fi
1228
1229
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001230 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1231 if test "${UNIVERSALSDK}" != "/"
1232 then
1233 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1234 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1235 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001236 fi
1237
1238 fi
1239
1240
Skip Montanarodecc6a42003-01-01 20:07:49 +00001241 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001242 OSF*)
1243 BASECFLAGS="$BASECFLAGS -mieee"
1244 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001245 esac
1246 ;;
1247
1248*)
1249 case $ac_sys_system in
1250 OpenUNIX*|UnixWare*)
1251 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1252 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001253 OSF*)
1254 BASECFLAGS="$BASECFLAGS -ieee -std"
1255 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001256 SCO_SV*)
1257 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1258 ;;
1259 esac
1260 ;;
1261esac
1262
Fred Drakee1ceaa02001-12-04 20:55:47 +00001263if test "$Py_DEBUG" = 'true'; then
1264 :
1265else
1266 OPT="-DNDEBUG $OPT"
1267fi
1268
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001269if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001270then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001271 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001272fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001273
Neal Norwitz020c46a2006-01-07 21:39:28 +00001274# disable check for icc since it seems to pass, but generates a warning
1275if test "$CC" = icc
1276then
1277 ac_cv_opt_olimit_ok=no
1278fi
1279
Guido van Rossum91922671997-10-09 20:24:13 +00001280AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1281AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1282[ac_save_cc="$CC"
1283CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001284AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001285 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001286 [ac_cv_opt_olimit_ok=yes],
1287 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001288 )
Guido van Rossum91922671997-10-09 20:24:13 +00001289CC="$ac_save_cc"])
1290AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001291if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001292 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001293 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1294 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1295 # environment?
1296 Darwin*)
1297 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001298 # XXX thankfully this useless troublemaker of a flag has been
1299 # eradicated in the 3.x line. For now, make sure it isn't picked
1300 # up by any of our other platforms that use CC.
1301 AIX*|SunOS*|HP-UX*|IRIX*)
1302 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001303 *)
1304 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1305 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001306 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001307else
1308 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1309 AC_CACHE_VAL(ac_cv_olimit_ok,
1310 [ac_save_cc="$CC"
1311 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001312 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001313 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001314 [ac_cv_olimit_ok=yes],
1315 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001316 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001317 CC="$ac_save_cc"])
1318 AC_MSG_RESULT($ac_cv_olimit_ok)
1319 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001320 case $ac_sys_system in
1321 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1322 HP-UX*)
1323 ;;
1324 *)
1325 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1326 ;;
1327 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001328 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001329fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001330
Martin v. Löwisaac13162006-10-19 10:58:46 +00001331# Check whether GCC supports PyArg_ParseTuple format
1332if test "$GCC" = "yes"
1333then
1334 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1335 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001336 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001337 AC_COMPILE_IFELSE([
1338 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1339 ],[
1340 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1341 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1342 AC_MSG_RESULT(yes)
1343 ],[
1344 AC_MSG_RESULT(no)
1345 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001346 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001347fi
1348
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001349# On some compilers, pthreads are available without further options
1350# (e.g. MacOS X). On some of these systems, the compiler will not
1351# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1352# So we have to see first whether pthreads are available without
1353# options before we can check whether -Kpthread improves anything.
1354AC_MSG_CHECKING(whether pthreads are available without options)
1355AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001356[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001357#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001358#include <pthread.h>
1359
1360void* routine(void* p){return NULL;}
1361
1362int main(){
1363 pthread_t p;
1364 if(pthread_create(&p,NULL,routine,NULL)!=0)
1365 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001366 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001367 return 0;
1368}
Matthias Klosec511b472010-05-08 11:01:39 +00001369]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001370 ac_cv_pthread_is_default=yes
1371 ac_cv_kthread=no
1372 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001373],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001374])
1375AC_MSG_RESULT($ac_cv_pthread_is_default)
1376
1377
1378if test $ac_cv_pthread_is_default = yes
1379then
1380 ac_cv_kpthread=no
1381else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001382# -Kpthread, if available, provides the right #defines
1383# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001384# Some compilers won't report that they do not support -Kpthread,
1385# so we need to run a program to see whether it really made the
1386# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001387AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1388AC_CACHE_VAL(ac_cv_kpthread,
1389[ac_save_cc="$CC"
1390CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001391AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001392#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001393#include <pthread.h>
1394
1395void* routine(void* p){return NULL;}
1396
1397int main(){
1398 pthread_t p;
1399 if(pthread_create(&p,NULL,routine,NULL)!=0)
1400 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001401 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001402 return 0;
1403}
Matthias Klosec511b472010-05-08 11:01:39 +00001404]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001405CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001406AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001407fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001408
Skip Montanarod8d39a02003-07-10 20:44:10 +00001409if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001410then
1411# -Kthread, if available, provides the right #defines
1412# and linker options to make pthread_create available
1413# Some compilers won't report that they do not support -Kthread,
1414# so we need to run a program to see whether it really made the
1415# function available.
1416AC_MSG_CHECKING(whether $CC accepts -Kthread)
1417AC_CACHE_VAL(ac_cv_kthread,
1418[ac_save_cc="$CC"
1419CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001420AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001421#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001422#include <pthread.h>
1423
1424void* routine(void* p){return NULL;}
1425
1426int main(){
1427 pthread_t p;
1428 if(pthread_create(&p,NULL,routine,NULL)!=0)
1429 return 1;
1430 (void)pthread_detach(p);
1431 return 0;
1432}
Matthias Klosec511b472010-05-08 11:01:39 +00001433]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001434CC="$ac_save_cc"])
1435AC_MSG_RESULT($ac_cv_kthread)
1436fi
1437
Skip Montanarod8d39a02003-07-10 20:44:10 +00001438if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001439then
1440# -pthread, if available, provides the right #defines
1441# and linker options to make pthread_create available
1442# Some compilers won't report that they do not support -pthread,
1443# so we need to run a program to see whether it really made the
1444# function available.
1445AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001446AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001447[ac_save_cc="$CC"
1448CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001449AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001450#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001451#include <pthread.h>
1452
1453void* routine(void* p){return NULL;}
1454
1455int main(){
1456 pthread_t p;
1457 if(pthread_create(&p,NULL,routine,NULL)!=0)
1458 return 1;
1459 (void)pthread_detach(p);
1460 return 0;
1461}
Matthias Klosec511b472010-05-08 11:01:39 +00001462]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001463CC="$ac_save_cc"])
1464AC_MSG_RESULT($ac_cv_pthread)
1465fi
1466
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001467# If we have set a CC compiler flag for thread support then
1468# check if it works for CXX, too.
1469ac_cv_cxx_thread=no
1470if test ! -z "$CXX"
1471then
1472AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1473ac_save_cxx="$CXX"
1474
1475if test "$ac_cv_kpthread" = "yes"
1476then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001477 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001478 ac_cv_cxx_thread=yes
1479elif test "$ac_cv_kthread" = "yes"
1480then
1481 CXX="$CXX -Kthread"
1482 ac_cv_cxx_thread=yes
1483elif test "$ac_cv_pthread" = "yes"
1484then
1485 CXX="$CXX -pthread"
1486 ac_cv_cxx_thread=yes
1487fi
1488
1489if test $ac_cv_cxx_thread = yes
1490then
1491 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1492 $CXX -c conftest.$ac_ext 2>&5
1493 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1494 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1495 then
1496 ac_cv_cxx_thread=yes
1497 else
1498 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001499 fi
1500 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001501fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001502AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001503fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001504CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001505
Fred Drakece81d592000-07-09 14:39:29 +00001506dnl # check for ANSI or K&R ("traditional") preprocessor
1507dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001508dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001509dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1510dnl int foo;
1511dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001512dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001513dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001514
Guido van Rossum627b2d71993-12-24 10:39:16 +00001515# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001516AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001517AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001518fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001519ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001520shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001521unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001522sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1523sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001524sys/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 +00001525sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001526sys/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 +00001527sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes3aa138f2013-06-18 13:25:24 +02001528bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001529AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001530AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001531
Martin v. Löwis11017b12006-01-14 18:12:57 +00001532# On Linux, netlink.h requires asm/types.h
1533AC_CHECK_HEADERS(linux/netlink.h,,,[
1534#ifdef HAVE_ASM_TYPES_H
1535#include <asm/types.h>
1536#endif
1537#ifdef HAVE_SYS_SOCKET_H
1538#include <sys/socket.h>
1539#endif
1540])
1541
Guido van Rossum627b2d71993-12-24 10:39:16 +00001542# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001543was_it_defined=no
1544AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001545AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1546 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1547])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001548AC_MSG_RESULT($was_it_defined)
1549
Neal Norwitz11690112002-07-30 01:08:28 +00001550# Check whether using makedev requires defining _OSF_SOURCE
1551AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001552AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001553#if defined(MAJOR_IN_MKDEV)
1554#include <sys/mkdev.h>
1555#elif defined(MAJOR_IN_SYSMACROS)
1556#include <sys/sysmacros.h>
1557#else
1558#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001559#endif ]], [[ makedev(0, 0) ]])],
1560[ac_cv_has_makedev=yes],
1561[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001562if test "$ac_cv_has_makedev" = "no"; then
1563 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001564 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001565#define _OSF_SOURCE 1
1566#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001567 ]], [[ makedev(0, 0) ]])],
1568[ac_cv_has_makedev=yes],
1569[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001570 if test "$ac_cv_has_makedev" = "yes"; then
1571 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1572 fi
1573fi
1574AC_MSG_RESULT($ac_cv_has_makedev)
1575if test "$ac_cv_has_makedev" = "yes"; then
1576 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1577fi
1578
Martin v. Löwis399a6892002-10-04 10:22:02 +00001579# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1580# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1581# defined, but the compiler does not support pragma redefine_extname,
1582# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1583# structures (such as rlimit64) without declaring them. As a
1584# work-around, disable LFS on such configurations
1585
1586use_lfs=yes
1587AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001588AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001589#define _LARGEFILE_SOURCE 1
1590#define _FILE_OFFSET_BITS 64
1591#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001592]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001593AC_MSG_RESULT($sol_lfs_bug)
1594if test "$sol_lfs_bug" = "yes"; then
1595 use_lfs=no
1596fi
1597
1598if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001599# Two defines needed to enable largefile support on various platforms
1600# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001601case $ac_sys_system/$ac_sys_release in
1602AIX*)
1603 AC_DEFINE(_LARGE_FILES, 1,
1604 [This must be defined on AIX systems to enable large file support.])
1605 ;;
1606esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001607AC_DEFINE(_LARGEFILE_SOURCE, 1,
1608[This must be defined on some systems to enable large file support.])
1609AC_DEFINE(_FILE_OFFSET_BITS, 64,
1610[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001611fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001612
Guido van Rossum300fda71996-08-19 21:58:16 +00001613# Add some code to confdefs.h so that the test for off_t works on SCO
1614cat >> confdefs.h <<\EOF
1615#if defined(SCO_DS)
1616#undef _OFF_T
1617#endif
1618EOF
1619
Guido van Rossumef2255b2000-03-10 22:30:29 +00001620# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001621AC_TYPE_MODE_T
1622AC_TYPE_OFF_T
1623AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001624AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001625AC_TYPE_SIZE_T
1626AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001627
1628# There are two separate checks for each of the exact-width integer types we
1629# need. First we check whether the type is available using the usual
1630# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1631# and <stdint.h> where available). We then also use the special type checks of
1632# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1633# directly, #define's uint32_t to be a suitable type.
1634
1635AC_CHECK_TYPE(uint32_t,
1636 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001637AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001638
1639AC_CHECK_TYPE(uint64_t,
1640 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001641AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001642
1643AC_CHECK_TYPE(int32_t,
1644 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001645AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001646
1647AC_CHECK_TYPE(int64_t,
1648 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001649AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001650
Christian Heimes951cc0f2008-01-31 23:08:23 +00001651AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001652 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001653
Guido van Rossumef2255b2000-03-10 22:30:29 +00001654# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001655# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001656AC_CHECK_SIZEOF(int, 4)
1657AC_CHECK_SIZEOF(long, 4)
1658AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001659AC_CHECK_SIZEOF(short, 2)
1660AC_CHECK_SIZEOF(float, 4)
1661AC_CHECK_SIZEOF(double, 8)
1662AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001663AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001664AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001665
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001666AC_MSG_CHECKING(for long long support)
1667have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001668AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001669 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1670 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001671],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001672AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001673if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001674AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001675fi
1676
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001677AC_MSG_CHECKING(for long double support)
1678have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001679AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001680 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1681 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001682],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001683AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001684if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001685AC_CHECK_SIZEOF(long double, 12)
1686fi
1687
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001688AC_MSG_CHECKING(for _Bool support)
1689have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001690AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001691 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1692 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001693],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001694AC_MSG_RESULT($have_c99_bool)
1695if test "$have_c99_bool" = yes ; then
1696AC_CHECK_SIZEOF(_Bool, 1)
1697fi
1698
Martin v. Löwisebe26702006-10-02 14:55:51 +00001699AC_CHECK_TYPES(uintptr_t,
1700 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001701 [], [#ifdef HAVE_STDINT_H
1702 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001703 #endif
1704 #ifdef HAVE_INTTYPES_H
1705 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001706 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001707
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001708AC_CHECK_SIZEOF(off_t, [], [
1709#ifdef HAVE_SYS_TYPES_H
1710#include <sys/types.h>
1711#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001712])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001713
1714AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001715if test "$have_long_long" = yes
1716then
1717if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001718 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001719 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1720 [Defined to enable large file support when an off_t is bigger than a long
1721 and long long is available and at least as big as an off_t. You may need
1722 to add some flags for configuration and compilation to enable this mode.
1723 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001724 AC_MSG_RESULT(yes)
1725else
1726 AC_MSG_RESULT(no)
1727fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001728else
1729 AC_MSG_RESULT(no)
1730fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001731
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001732AC_CHECK_SIZEOF(time_t, [], [
1733#ifdef HAVE_SYS_TYPES_H
1734#include <sys/types.h>
1735#endif
1736#ifdef HAVE_TIME_H
1737#include <time.h>
1738#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001739])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001740
Trent Mick635f6fb2000-08-23 21:33:05 +00001741# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001742ac_save_cc="$CC"
1743if test "$ac_cv_kpthread" = "yes"
1744then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001745elif test "$ac_cv_kthread" = "yes"
1746then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001747elif test "$ac_cv_pthread" = "yes"
1748then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001749fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001750AC_MSG_CHECKING(for pthread_t)
1751have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001752AC_COMPILE_IFELSE([
1753 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1754],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001755AC_MSG_RESULT($have_pthread_t)
1756if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001757 AC_CHECK_SIZEOF(pthread_t, [], [
1758#ifdef HAVE_PTHREAD_H
1759#include <pthread.h>
1760#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001761 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001762fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001763CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001764
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001765AC_MSG_CHECKING(for --enable-toolbox-glue)
1766AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001767 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001768
1769if test -z "$enable_toolbox_glue"
1770then
1771 case $ac_sys_system/$ac_sys_release in
1772 Darwin/*)
1773 enable_toolbox_glue="yes";;
1774 *)
1775 enable_toolbox_glue="no";;
1776 esac
1777fi
1778case "$enable_toolbox_glue" in
1779yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001780 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001781 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001782 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1783 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001784 ;;
1785*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001786 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001787 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001788 ;;
1789esac
1790AC_MSG_RESULT($enable_toolbox_glue)
1791
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001792
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001793AC_SUBST(OTHER_LIBTOOL_OPT)
1794case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001795 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001796 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1797 ;;
1798 Darwin/*)
1799 OTHER_LIBTOOL_OPT=""
1800 ;;
1801esac
1802
Ronald Oussoren25967582009-09-06 10:00:26 +00001803
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001804AC_SUBST(LIBTOOL_CRUFT)
1805case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001806 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001807 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1808 if test "${enable_universalsdk}"; then
1809 :
1810 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001811 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001812 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001813 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001814 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001815 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001816 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001817 if test ${gcc_version} '<' 4.0
1818 then
1819 LIBTOOL_CRUFT="-lcc_dynamic"
1820 else
1821 LIBTOOL_CRUFT=""
1822 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001823 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001824 #include <unistd.h>
1825 int main(int argc, char*argv[])
1826 {
1827 if (sizeof(long) == 4) {
1828 return 0;
1829 } else {
1830 return 1;
1831 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001832 }
Matthias Klosec511b472010-05-08 11:01:39 +00001833 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001834
1835 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001836 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001837 i386)
1838 MACOSX_DEFAULT_ARCH="i386"
1839 ;;
1840 ppc)
1841 MACOSX_DEFAULT_ARCH="ppc"
1842 ;;
1843 *)
1844 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1845 ;;
1846 esac
1847 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001848 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001849 i386)
1850 MACOSX_DEFAULT_ARCH="x86_64"
1851 ;;
1852 ppc)
1853 MACOSX_DEFAULT_ARCH="ppc64"
1854 ;;
1855 *)
1856 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1857 ;;
1858 esac
1859
1860 #ARCH_RUN_32BIT="true"
1861 fi
1862
1863 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001864 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001865 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001866esac
1867
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001868AC_MSG_CHECKING(for --enable-framework)
1869if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001870then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001871 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001872 # -F. is needed to allow linking to the framework while
1873 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001874 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1875 [Define if you want to produce an OpenStep/Rhapsody framework
1876 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001877 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001878 if test $enable_shared = "yes"
1879 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001880 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 +00001881 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001882else
1883 AC_MSG_RESULT(no)
1884fi
1885
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001886AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001887case $ac_sys_system/$ac_sys_release in
1888 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001889 AC_DEFINE(WITH_DYLD, 1,
1890 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1891 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1892 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001893 AC_MSG_RESULT(always on for Darwin)
1894 ;;
1895 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001896 AC_MSG_RESULT(no)
1897 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00001898esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001899
Guido van Rossumac405f61994-09-12 10:56:06 +00001900# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00001901AC_SUBST(SO)
1902AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00001903AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001904AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001905AC_SUBST(CCSHARED)
1906AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001907# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00001908# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001909AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00001910if test -z "$SO"
1911then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001912 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00001913 hp*|HP*)
1914 case `uname -m` in
1915 ia64) SO=.so;;
1916 *) SO=.sl;;
1917 esac
1918 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001919 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001920 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00001921 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00001922else
1923 # this might also be a termcap variable, see #610332
1924 echo
1925 echo '====================================================================='
1926 echo '+ +'
1927 echo '+ WARNING: You have set SO in your environment. +'
1928 echo '+ Do you really mean to change the extension for shared libraries? +'
1929 echo '+ Continuing in 10 seconds to let you to ponder. +'
1930 echo '+ +'
1931 echo '====================================================================='
1932 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00001933fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001934AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00001935
Neal Norwitz58e28882006-05-19 07:00:58 +00001936AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00001937# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00001938# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001939# (Shared libraries in this instance are shared modules to be loaded into
1940# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001941AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00001942if test -z "$LDSHARED"
1943then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001944 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001945 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00001946 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00001947 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001948 ;;
1949 BeOS*)
1950 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00001951 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00001952 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00001953 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00001954 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00001955 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001956 if test "$GCC" = "yes" ; then
1957 LDSHARED='$(CC) -shared'
1958 LDCXXSHARED='$(CXX) -shared'
1959 else
1960 LDSHARED='$(CC) -G'
1961 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00001962 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00001963 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00001964 if test "$GCC" = "yes" ; then
1965 LDSHARED='$(CC) -shared'
1966 LDCXXSHARED='$(CXX) -shared'
1967 else
1968 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00001969 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00001970 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00001971 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001972 LDSHARED='$(CC) -bundle'
1973 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00001974 if test "$enable_framework" ; then
1975 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001976 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1977 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001978 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001979 else
1980 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00001981 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00001982 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00001983 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001984 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00001985 LDSHARED='$(CC) -bundle'
1986 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001987 if test "$enable_framework" ; then
1988 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00001989 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1990 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001991 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001992 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00001993 # No framework, use the Python app as bundle-loader
1994 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00001995 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00001996 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001997 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00001998 Darwin/*)
1999 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2000 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002001
Ned Deilyc40b9032014-06-25 13:48:46 -07002002 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2003 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2004 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2005 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2006 if test ${dep_target_major} -eq 10 && \
2007 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002008 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002009 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002010 LDSHARED='$(CC) -bundle'
2011 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002012 if test "$enable_framework" ; then
2013 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002014 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2015 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002016 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002017 else
2018 # No framework, use the Python app as bundle-loader
2019 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2020 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002021 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002022 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002023 else
2024 # building for OS X 10.3 and later
2025 if test "${enable_universalsdk}"; then
2026 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2027 fi
2028 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2029 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2030 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002031 fi
2032 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002033 Linux*|GNU*|QNX*)
2034 LDSHARED='$(CC) -shared'
2035 LDCXXSHARED='$(CXX) -shared';;
2036 BSD/OS*/4*)
2037 LDSHARED="gcc -shared"
2038 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002039 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002040 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002041 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002042 LDSHARED='$(CC) -shared'
2043 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002044 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002045 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002046 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002047 OpenBSD*)
2048 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2049 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002050 LDSHARED='$(CC) -shared $(CCSHARED)'
2051 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002052 else
2053 case `uname -r` in
2054 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2055 LDSHARED="ld -Bshareable ${LDFLAGS}"
2056 ;;
2057 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002058 LDSHARED='$(CC) -shared $(CCSHARED)'
2059 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002060 ;;
2061 esac
2062 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002063 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002064 LDSHARED='$(CC) -shared'
2065 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002066 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002067 if test "$GCC" = "yes" ; then
2068 LDSHARED='$(CC) -shared'
2069 LDCXXSHARED='$(CXX) -shared'
2070 else
2071 LDSHARED='$(CC) -G'
2072 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002073 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002074 SCO_SV*)
2075 LDSHARED='$(CC) -Wl,-G,-Bexport'
2076 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2077 CYGWIN*)
2078 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2079 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2080 atheos*)
2081 LDSHARED="gcc -shared"
2082 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002083 *) LDSHARED="ld";;
2084 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002085fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002086AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002087LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002088BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002089# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002090# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002091AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002092if test -z "$CCSHARED"
2093then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002094 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002095 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002096 then CCSHARED="-fPIC";
2097 elif test `uname -p` = sparc;
2098 then CCSHARED="-xcode=pic32";
2099 else CCSHARED="-Kpic";
2100 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002101 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002102 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002103 else CCSHARED="+z";
2104 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002105 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002106 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002107 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002108 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002109 if test "$GCC" = "yes"
2110 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002111 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002112 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002113 SCO_SV*)
2114 if test "$GCC" = "yes"
2115 then CCSHARED="-fPIC"
2116 else CCSHARED="-Kpic -belf"
2117 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002118 IRIX*/6*) case $CC in
2119 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002120 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002121 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002122 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002123 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002124fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002125AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002126# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002127# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002128AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002129if test -z "$LINKFORSHARED"
2130then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002131 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002132 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002133 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002134 LINKFORSHARED="-Wl,-E -Wl,+s";;
2135# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002136 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002137 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002138 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002139 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002140 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2141 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002142 # not used by the core itself but which needs to be in the core so
2143 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002144 # -prebind is no longer used, because it actually seems to give a
2145 # slowdown in stead of a speedup, maybe due to the large number of
2146 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002147
2148 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002149 if test "$enable_framework"
2150 then
Jack Jansenda49e192005-01-07 13:08:22 +00002151 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002152 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002153 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002154 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002155 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002156 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002157 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002158 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2159 then
2160 LINKFORSHARED="-Wl,--export-dynamic"
2161 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002162 SunOS/5*) case $CC in
2163 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002164 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002165 then
2166 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002167 fi;;
2168 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002169 CYGWIN*)
2170 if test $enable_shared = "no"
2171 then
2172 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2173 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002174 QNX*)
2175 # -Wl,-E causes the symbols to be added to the dynamic
2176 # symbol table so that they can be found when a module
2177 # is loaded. -N 2048K causes the stack size to be set
2178 # to 2048 kilobytes so that the stack doesn't overflow
2179 # when running test_compile.py.
2180 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002181 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002182fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002183AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002184
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002185
Neil Schemenauer61c51152001-01-26 16:18:16 +00002186AC_SUBST(CFLAGSFORSHARED)
2187AC_MSG_CHECKING(CFLAGSFORSHARED)
2188if test ! "$LIBRARY" = "$LDLIBRARY"
2189then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002190 case $ac_sys_system in
2191 CYGWIN*)
2192 # Cygwin needs CCSHARED when building extension DLLs
2193 # but not when building the interpreter DLL.
2194 CFLAGSFORSHARED='';;
2195 *)
2196 CFLAGSFORSHARED='$(CCSHARED)'
2197 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002198fi
2199AC_MSG_RESULT($CFLAGSFORSHARED)
2200
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002201# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2202# library (with --enable-shared).
2203# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002204# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2205# if it is not required, since it creates a dependency of the shared library
2206# to LIBS. This, in turn, means that applications linking the shared libpython
2207# don't need to link LIBS explicitly. The default should be only changed
2208# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002209AC_SUBST(SHLIBS)
2210AC_MSG_CHECKING(SHLIBS)
2211case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002212 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002213 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002214esac
2215AC_MSG_RESULT($SHLIBS)
2216
2217
Guido van Rossum627b2d71993-12-24 10:39:16 +00002218# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002219AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2220AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002221
Skip Montanaro4d756af2008-12-01 01:55:22 +00002222# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002223if test "$with_threads" = "yes" -o -z "$with_threads"; then
2224 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2225 # posix4 on Solaris 2.6
2226 # pthread (first!) on Linux
2227fi
2228
Martin v. Löwis19d17342003-06-14 21:03:05 +00002229# check if we need libintl for locale functions
2230AC_CHECK_LIB(intl, textdomain,
2231 AC_DEFINE(WITH_LIBINTL, 1,
2232 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002233
2234# checks for system dependent C++ extensions support
2235case "$ac_sys_system" in
2236 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002237 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002238 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002239 [[loadAndInit("", 0, "")]])
2240 ],[
2241 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002242 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2243 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002244 AC_MSG_RESULT(yes)
2245 ],[
2246 AC_MSG_RESULT(no)
2247 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002248 *) ;;
2249esac
2250
Guido van Rossum70c7f481998-03-26 18:44:10 +00002251# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002252# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002253AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002254AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002255
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002256case "$ac_sys_system" in
2257BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002258AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2259;;
2260esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002261
Guido van Rossumc5a39031996-07-31 17:35:03 +00002262AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002263AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002264 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002265[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002266AC_MSG_RESULT($withval)
2267LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002268],
2269[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002270
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002271AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2272
Benjamin Peterson2c196742009-12-31 03:17:18 +00002273# Check for use of the system expat library
2274AC_MSG_CHECKING(for --with-system-expat)
2275AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002276 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2277 [],
2278 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002279
2280AC_MSG_RESULT($with_system_expat)
2281
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002282# Check for use of the system libffi library
2283AC_MSG_CHECKING(for --with-system-ffi)
2284AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002285 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2286 [],
2287 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002288
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002289if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002290 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2291else
2292 LIBFFI_INCLUDEDIR=""
2293fi
2294AC_SUBST(LIBFFI_INCLUDEDIR)
2295
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002296AC_MSG_RESULT($with_system_ffi)
2297
Ned Deilya2a9f572013-10-25 00:30:10 -07002298# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2299AC_SUBST(TCLTK_INCLUDES)
2300AC_SUBST(TCLTK_LIBS)
2301AC_MSG_CHECKING(for --with-tcltk-includes)
2302AC_ARG_WITH(tcltk-includes,
2303 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2304 [],
2305 [with_tcltk_includes="default"])
2306AC_MSG_RESULT($with_tcltk_includes)
2307AC_MSG_CHECKING(for --with-tcltk-libs)
2308AC_ARG_WITH(tcltk-libs,
2309 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2310 [],
2311 [with_tcltk_libs="default"])
2312AC_MSG_RESULT($with_tcltk_libs)
2313if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2314then
2315 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2316 then
2317 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2318 fi
2319 TCLTK_INCLUDES=""
2320 TCLTK_LIBS=""
2321else
2322 TCLTK_INCLUDES="$with_tcltk_includes"
2323 TCLTK_LIBS="$with_tcltk_libs"
2324fi
2325
Matthias Klose10cbe482009-04-29 17:18:19 +00002326# Check for --with-dbmliborder
2327AC_MSG_CHECKING(for --with-dbmliborder)
2328AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002329 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 +00002330[
2331if test x$with_dbmliborder = xyes
2332then
2333AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2334else
2335 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2336 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2337 then
2338 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2339 fi
2340 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002341fi])
2342AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002343
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002344# Determine if signalmodule should be used.
2345AC_SUBST(USE_SIGNAL_MODULE)
2346AC_SUBST(SIGNAL_OBJS)
2347AC_MSG_CHECKING(for --with-signal-module)
2348AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002349 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002350
2351if test -z "$with_signal_module"
2352then with_signal_module="yes"
2353fi
2354AC_MSG_RESULT($with_signal_module)
2355
2356if test "${with_signal_module}" = "yes"; then
2357 USE_SIGNAL_MODULE=""
2358 SIGNAL_OBJS=""
2359else
2360 USE_SIGNAL_MODULE="#"
2361 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2362fi
2363
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002364# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002365AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002366USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002367
Guido van Rossum54d93d41997-01-22 20:51:58 +00002368AC_MSG_CHECKING(for --with-dec-threads)
2369AC_SUBST(LDLAST)
2370AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002371 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002372[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002373AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002374LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002375if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002376 with_thread="$withval";
2377fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002378[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002379
Martin v. Löwis11437992002-04-12 09:54:03 +00002380# Templates for things AC_DEFINEd more than once.
2381# For a single AC_DEFINE, no template is needed.
2382AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2383AH_TEMPLATE(_REENTRANT,
2384 [Define to force use of thread-safe errno, h_errno, and other functions])
2385AH_TEMPLATE(WITH_THREAD,
2386 [Define if you want to compile in rudimentary thread support])
2387
Guido van Rossum54d93d41997-01-22 20:51:58 +00002388AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002389dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002390AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002391 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002392
Barry Warsawc0d24d82000-06-29 16:12:00 +00002393# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002394dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002395AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002396 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002397 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002398
2399if test -z "$with_threads"
2400then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002401fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002402AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002403
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002404AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002405if test "$with_threads" = "no"
2406then
2407 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002408elif test "$ac_cv_pthread_is_default" = yes
2409then
2410 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002411 # Defining _REENTRANT on system with POSIX threads should not hurt.
2412 AC_DEFINE(_REENTRANT)
2413 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002414 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002415elif test "$ac_cv_kpthread" = "yes"
2416then
2417 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002418 if test "$ac_cv_cxx_thread" = "yes"; then
2419 CXX="$CXX -Kpthread"
2420 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002421 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002422 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002423 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002424elif test "$ac_cv_kthread" = "yes"
2425then
2426 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002427 if test "$ac_cv_cxx_thread" = "yes"; then
2428 CXX="$CXX -Kthread"
2429 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002430 AC_DEFINE(WITH_THREAD)
2431 posix_threads=yes
2432 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002433elif test "$ac_cv_pthread" = "yes"
2434then
2435 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002436 if test "$ac_cv_cxx_thread" = "yes"; then
2437 CXX="$CXX -pthread"
2438 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002439 AC_DEFINE(WITH_THREAD)
2440 posix_threads=yes
2441 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002442else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002443 if test ! -z "$with_threads" -a -d "$with_threads"
2444 then LDFLAGS="$LDFLAGS -L$with_threads"
2445 fi
2446 if test ! -z "$withval" -a -d "$withval"
2447 then LDFLAGS="$LDFLAGS -L$withval"
2448 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002449
2450 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002451 # define _POSIX_THREADS in unistd.h. Some apparently don't
2452 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002453 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2454 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002455 [
2456#include <unistd.h>
2457#ifdef _POSIX_THREADS
2458yes
2459#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002460 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2461 AC_MSG_RESULT($unistd_defines_pthreads)
2462
Martin v. Löwis130fb172001-07-19 11:00:41 +00002463 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002464 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2465 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002466 AC_DEFINE(HURD_C_THREADS, 1,
2467 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002468 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002469 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002470 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2471 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002472 AC_DEFINE(MACH_C_THREADS, 1,
2473 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002474 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002475 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002476 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002477 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002478 [AC_MSG_RESULT($withval)
2479 AC_DEFINE([WITH_THREAD])
2480 AC_DEFINE([HAVE_PTH], 1,
2481 [Define if you have GNU PTH threads.])
2482 LIBS="-lpth $LIBS"
2483 THREADOBJ="Python/thread.o"],
2484 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002485
2486 # Just looking for pthread_create in libpthread is not enough:
2487 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2488 # So we really have to include pthread.h, and then link.
2489 _libs=$LIBS
2490 LIBS="$LIBS -lpthread"
2491 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002492 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2493#include <stdio.h>
2494#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002495
Matthias Klosec511b472010-05-08 11:01:39 +00002496void * start_routine (void *arg) { exit (0); }]], [[
2497pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002498 AC_MSG_RESULT(yes)
2499 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002500 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002501 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002502 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002503 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002504 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002505 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002506 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2507 AC_DEFINE(ATHEOS_THREADS, 1,
2508 [Define this if you have AtheOS threads.])
2509 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002510 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002511 AC_DEFINE(BEOS_THREADS, 1,
2512 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002513 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002514 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002515 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002516 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002517 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002518 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002519 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002520 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002521 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002522 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002523 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002524 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002525 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002526 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002527 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002528 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002529 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002530 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002531 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002532
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002533 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2534 LIBS="$LIBS -lmpc"
2535 THREADOBJ="Python/thread.o"
2536 USE_THREAD_MODULE=""])
2537
2538 if test "$posix_threads" != "yes"; then
2539 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2540 LIBS="$LIBS -lthread"
2541 THREADOBJ="Python/thread.o"
2542 USE_THREAD_MODULE=""])
2543 fi
2544
2545 if test "$USE_THREAD_MODULE" != "#"
2546 then
2547 # If the above checks didn't disable threads, (at least) OSF1
2548 # needs this '-threads' argument during linking.
2549 case $ac_sys_system in
2550 OSF1) LDLAST=-threads;;
2551 esac
2552 fi
2553fi
2554
2555if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002556 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002557 AC_DEFINE(_POSIX_THREADS, 1,
2558 [Define if you have POSIX threads,
2559 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002560 fi
2561
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002562 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2563 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002564 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002565 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002566 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002567 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002568 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002569 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002570 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002571 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002572 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002573 esac
2574
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002575 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2576 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002577 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2578 #include <stdio.h>
2579 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002580 void *foo(void *parm) {
2581 return NULL;
2582 }
2583 main() {
2584 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002585 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002586 if (pthread_attr_init(&attr)) exit(-1);
2587 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002588 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002589 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002590 }]])],
2591 [ac_cv_pthread_system_supported=yes],
2592 [ac_cv_pthread_system_supported=no],
2593 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002594 ])
2595 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2596 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002597 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002598 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002599 AC_CHECK_FUNCS(pthread_sigmask,
2600 [case $ac_sys_system in
2601 CYGWIN*)
2602 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2603 [Define if pthread_sigmask() does not work on your system.])
2604 ;;
2605 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002606 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002607fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002608
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002609
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002610# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002611AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002612AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002613AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002614[ --enable-ipv6 Enable ipv6 (with ipv4) support
2615 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002616[ case "$enableval" in
2617 no)
2618 AC_MSG_RESULT(no)
2619 ipv6=no
2620 ;;
2621 *) AC_MSG_RESULT(yes)
2622 AC_DEFINE(ENABLE_IPV6)
2623 ipv6=yes
2624 ;;
2625 esac ],
2626
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002627[
2628dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002629 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002630#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002631#include <sys/socket.h>]],
2632[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002633 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002634 ipv6=yes
2635],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002636 AC_MSG_RESULT(no)
2637 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002638])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002639
2640if test "$ipv6" = "yes"; then
2641 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002642 AC_COMPILE_IFELSE([
2643 AC_LANG_PROGRAM([[#include <sys/types.h>
2644#include <netinet/in.h>]],
2645 [[struct sockaddr_in6 x;
2646 x.sin6_scope_id;]])
2647 ],[
2648 AC_MSG_RESULT(yes)
2649 ipv6=yes
2650 ],[
2651 AC_MSG_RESULT(no, IPv6 disabled)
2652 ipv6=no
2653 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002654fi
2655
2656if test "$ipv6" = "yes"; then
2657 AC_DEFINE(ENABLE_IPV6)
2658fi
2659])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002660
2661ipv6type=unknown
2662ipv6lib=none
2663ipv6trylibc=no
2664
2665if test "$ipv6" = "yes"; then
2666 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002667 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2668 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002669 case $i in
2670 inria)
2671 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002672 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002673#include <netinet/in.h>
2674#ifdef IPV6_INRIA_VERSION
2675yes
2676#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002677 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002678 ;;
2679 kame)
2680 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002681 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002682#include <netinet/in.h>
2683#ifdef __KAME__
2684yes
2685#endif],
2686 [ipv6type=$i;
2687 ipv6lib=inet6
2688 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002689 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002690 ;;
2691 linux-glibc)
2692 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002693 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002694#include <features.h>
2695#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2696yes
2697#endif],
2698 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002699 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002700 ;;
2701 linux-inet6)
2702 dnl http://www.v6.linux.or.jp/
2703 if test -d /usr/inet6; then
2704 ipv6type=$i
2705 ipv6lib=inet6
2706 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002707 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002708 fi
2709 ;;
2710 solaris)
2711 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002712 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002713 ipv6type=$i
2714 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002715 fi
2716 fi
2717 ;;
2718 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002719 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002720#include <sys/param.h>
2721#ifdef _TOSHIBA_INET6
2722yes
2723#endif],
2724 [ipv6type=$i;
2725 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002726 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002727 ;;
2728 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002729 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002730#include </usr/local/v6/include/sys/v6config.h>
2731#ifdef __V6D__
2732yes
2733#endif],
2734 [ipv6type=$i;
2735 ipv6lib=v6;
2736 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002737 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002738 ;;
2739 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002740 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002741#include <sys/param.h>
2742#ifdef _ZETA_MINAMI_INET6
2743yes
2744#endif],
2745 [ipv6type=$i;
2746 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002747 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002748 ;;
2749 esac
2750 if test "$ipv6type" != "unknown"; then
2751 break
2752 fi
2753 done
2754 AC_MSG_RESULT($ipv6type)
2755fi
2756
2757if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2758 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2759 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2760 echo "using lib$ipv6lib"
2761 else
2762 if test $ipv6trylibc = "yes"; then
2763 echo "using libc"
2764 else
2765 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2766 echo "You need to fetch lib$ipv6lib.a from appropriate"
2767 echo 'ipv6 kit and compile beforehand.'
2768 exit 1
2769 fi
2770 fi
2771fi
2772
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002773AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002774AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002775 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002776],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002777 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002778 AC_MSG_RESULT(yes)
2779],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002780 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002781])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002782
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002783# Check for --with-doc-strings
2784AC_MSG_CHECKING(for --with-doc-strings)
2785AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002786 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002787
2788if test -z "$with_doc_strings"
2789then with_doc_strings="yes"
2790fi
2791if test "$with_doc_strings" != "no"
2792then
2793 AC_DEFINE(WITH_DOC_STRINGS, 1,
2794 [Define if you want documentation strings in extension modules])
2795fi
2796AC_MSG_RESULT($with_doc_strings)
2797
Neil Schemenauera35c6882001-02-27 04:45:05 +00002798# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002799AC_MSG_CHECKING(for --with-tsc)
2800AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002801 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002802if test "$withval" != no
2803then
2804 AC_DEFINE(WITH_TSC, 1,
2805 [Define to profile with the Pentium timestamp counter])
2806 AC_MSG_RESULT(yes)
2807else AC_MSG_RESULT(no)
2808fi],
2809[AC_MSG_RESULT(no)])
2810
2811# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002812AC_MSG_CHECKING(for --with-pymalloc)
2813AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002814 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002815
2816if test -z "$with_pymalloc"
2817then with_pymalloc="yes"
2818fi
2819if test "$with_pymalloc" != "no"
2820then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002821 AC_DEFINE(WITH_PYMALLOC, 1,
2822 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002823fi
2824AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002825
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002826# Check for Valgrind support
2827AC_MSG_CHECKING([for --with-valgrind])
2828AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002829 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002830 with_valgrind=no)
2831AC_MSG_RESULT([$with_valgrind])
2832if test "$with_valgrind" != no; then
2833 AC_CHECK_HEADER([valgrind/valgrind.h],
2834 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2835 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2836 )
2837fi
2838
Barry Warsawef82cd72000-06-30 16:21:01 +00002839# Check for --with-wctype-functions
2840AC_MSG_CHECKING(for --with-wctype-functions)
2841AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002842 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002843[
Barry Warsawef82cd72000-06-30 16:21:01 +00002844if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002845then
2846 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2847 [Define if you want wctype.h functions to be used instead of the
2848 one supplied by Python itself. (see Include/unicodectype.h).])
2849 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002850else AC_MSG_RESULT(no)
2851fi],
2852[AC_MSG_RESULT(no)])
2853
Guido van Rossum68242b51996-05-28 22:53:03 +00002854# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002855AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002856DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002857
Guido van Rossume97ee181999-12-20 21:27:22 +00002858# the dlopen() function means we might want to use dynload_shlib.o. some
2859# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002860AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002861
2862# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2863# loading of modules.
2864AC_SUBST(DYNLOADFILE)
2865AC_MSG_CHECKING(DYNLOADFILE)
2866if test -z "$DYNLOADFILE"
2867then
2868 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002869 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2870 if test "$ac_cv_func_dlopen" = yes
2871 then DYNLOADFILE="dynload_shlib.o"
2872 else DYNLOADFILE="dynload_aix.o"
2873 fi
2874 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002875 BeOS*) DYNLOADFILE="dynload_beos.o";;
2876 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002877 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2878 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002879 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002880 *)
2881 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2882 # out any dynamic loading
2883 if test "$ac_cv_func_dlopen" = yes
2884 then DYNLOADFILE="dynload_shlib.o"
2885 else DYNLOADFILE="dynload_stub.o"
2886 fi
2887 ;;
2888 esac
2889fi
2890AC_MSG_RESULT($DYNLOADFILE)
2891if test "$DYNLOADFILE" != "dynload_stub.o"
2892then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002893 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2894 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00002895fi
2896
Jack Jansenc49e5b72001-06-19 15:00:23 +00002897# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2898
2899AC_SUBST(MACHDEP_OBJS)
2900AC_MSG_CHECKING(MACHDEP_OBJS)
2901if test -z "$MACHDEP_OBJS"
2902then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002903 MACHDEP_OBJS=$extra_machdep_objs
2904else
2905 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00002906fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002907AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00002908
Guido van Rossum627b2d71993-12-24 10:39:16 +00002909# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00002910AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2911 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00002912 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002913 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05002914 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00002915 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00002916 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00002917 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2918 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00002919 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00002920 setlocale setregid setreuid setresuid setresgid \
2921 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00002922 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00002923 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00002924 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00002925
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002926# For some functions, having a definition is not sufficient, since
2927# we want to take their address.
2928AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00002929AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2930 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2931 AC_MSG_RESULT(yes)],
2932 [AC_MSG_RESULT(no)
2933])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002934AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00002935AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2936 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2937 AC_MSG_RESULT(yes)],
2938 [AC_MSG_RESULT(no)
2939])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00002940AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00002941AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2942 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2943 AC_MSG_RESULT(yes)],
2944 [AC_MSG_RESULT(no)
2945])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002946AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00002947AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2948 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2949 AC_MSG_RESULT(yes)],
2950 [AC_MSG_RESULT(no)
2951])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002952AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00002953AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2954 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2955 AC_MSG_RESULT(yes)],
2956 [AC_MSG_RESULT(no)
2957])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00002958AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00002959AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2960 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2961 AC_MSG_RESULT(yes)],
2962 [AC_MSG_RESULT(no)
2963])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002964AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00002965AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2966 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2967 AC_MSG_RESULT(yes)],
2968 [AC_MSG_RESULT(no)
2969])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002970AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00002971AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00002972#include <sys/types.h>
2973#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002974 ]], [[int x=kqueue()]])],
2975 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2976 AC_MSG_RESULT(yes)],
2977 [AC_MSG_RESULT(no)
2978])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002979# On some systems (eg. FreeBSD 5), we would find a definition of the
2980# functions ctermid_r, setgroups in the library, but no prototype
2981# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2982# address to avoid compiler warnings and potential miscompilations
2983# because of the missing prototypes.
2984
2985AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00002986AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00002987#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00002988]], [[void* p = ctermid_r]])],
2989 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2990 AC_MSG_RESULT(yes)],
2991 [AC_MSG_RESULT(no)
2992])
Martin v. Löwisd5843682002-11-21 20:41:28 +00002993
Antoine Pitroub170f172010-09-10 18:47:36 +00002994AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
2995 [AC_COMPILE_IFELSE(
2996 [AC_LANG_PROGRAM(
2997 [#include <sys/file.h>],
2998 [void* p = flock]
2999 )],
3000 [ac_cv_flock_decl=yes],
3001 [ac_cv_flock_decl=no]
3002 )
Matthias Klosec511b472010-05-08 11:01:39 +00003003])
Antoine Pitroub170f172010-09-10 18:47:36 +00003004if test "x${ac_cv_flock_decl}" = xyes; then
3005 AC_CHECK_FUNCS(flock,,
3006 AC_CHECK_LIB(bsd,flock,
3007 [AC_DEFINE(HAVE_FLOCK)
3008 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3009 ])
3010 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003011fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003012
3013AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003014AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003015#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003016]], [[void* p = getpagesize]])],
3017 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3018 AC_MSG_RESULT(yes)],
3019 [AC_MSG_RESULT(no)
3020])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003021
Charles-François Natali93a11752011-11-27 13:01:35 +01003022AC_MSG_CHECKING(for broken unsetenv)
3023AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3024#include <stdlib.h>
3025]], [[int res = unsetenv("DUMMY")]])],
3026 [AC_MSG_RESULT(no)],
3027 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3028 AC_MSG_RESULT(yes)
3029])
3030
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003031dnl check for true
3032AC_CHECK_PROGS(TRUE, true, /bin/true)
3033
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003034dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3035dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003036AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003037 AC_CHECK_LIB(resolv, inet_aton)
3038)
3039
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003040# On Tru64, chflags seems to be present, but calling it will
3041# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003042AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003043AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003044#include <sys/stat.h>
3045#include <unistd.h>
3046int main(int argc, char*argv[])
3047{
3048 if(chflags(argv[0], 0) != 0)
3049 return 1;
3050 return 0;
3051}
Ned Deily43e10542011-06-27 23:41:53 -07003052]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003053[ac_cv_have_chflags=yes],
3054[ac_cv_have_chflags=no],
3055[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003056])
3057if test "$ac_cv_have_chflags" = cross ; then
3058 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3059fi
3060if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003061 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003062fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003063
Gregory P. Smithbb213892009-11-02 01:37:37 +00003064AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003065AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003066#include <sys/stat.h>
3067#include <unistd.h>
3068int main(int argc, char*argv[])
3069{
3070 if(lchflags(argv[0], 0) != 0)
3071 return 1;
3072 return 0;
3073}
Ned Deily43e10542011-06-27 23:41:53 -07003074]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003075])
3076if test "$ac_cv_have_lchflags" = cross ; then
3077 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3078fi
3079if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003080 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003081fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003082
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003083dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003084dnl
3085dnl On MacOSX the linker will search for dylibs on the entire linker path
3086dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3087dnl to revert to a more traditional unix behaviour and make it possible to
3088dnl override the system libz with a local static library of libz. Temporarily
3089dnl add that flag to our CFLAGS as well to ensure that we check the version
3090dnl of libz that will be used by setup.py.
3091dnl The -L/usr/local/lib is needed as wel to get the same compilation
3092dnl environment as setup.py (and leaving it out can cause configure to use the
3093dnl wrong version of the library)
3094case $ac_sys_system/$ac_sys_release in
3095Darwin/*)
3096 _CUR_CFLAGS="${CFLAGS}"
3097 _CUR_LDFLAGS="${LDFLAGS}"
3098 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3099 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3100 ;;
3101esac
3102
Matthias Klose5183ebd2010-04-24 16:38:36 +00003103AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003104
Ronald Oussorenf8752642006-07-06 10:13:35 +00003105case $ac_sys_system/$ac_sys_release in
3106Darwin/*)
3107 CFLAGS="${_CUR_CFLAGS}"
3108 LDFLAGS="${_CUR_LDFLAGS}"
3109 ;;
3110esac
3111
Martin v. Löwise9416172003-05-03 10:12:45 +00003112AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003113AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003114#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003115]], [[void* p = hstrerror; hstrerror(0)]])],
3116 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3117 AC_MSG_RESULT(yes)],
3118 [AC_MSG_RESULT(no)
3119])
Martin v. Löwise9416172003-05-03 10:12:45 +00003120
3121AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003122AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003123#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003124#include <sys/socket.h>
3125#include <netinet/in.h>
3126#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003127]], [[void* p = inet_aton;inet_aton(0,0)]])],
3128 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3129 AC_MSG_RESULT(yes)],
3130 [AC_MSG_RESULT(no)
3131])
Martin v. Löwise9416172003-05-03 10:12:45 +00003132
3133AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003134AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003135#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003136#include <sys/socket.h>
3137#include <netinet/in.h>
3138#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003139]], [[void* p = inet_pton]])],
3140 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3141 AC_MSG_RESULT(yes)],
3142 [AC_MSG_RESULT(no)
3143])
Martin v. Löwise9416172003-05-03 10:12:45 +00003144
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003145# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003146AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003147AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003148#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003149#ifdef HAVE_GRP_H
3150#include <grp.h>
3151#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003152]], [[void* p = setgroups]])],
3153 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3154 AC_MSG_RESULT(yes)],
3155 [AC_MSG_RESULT(no)
3156])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003157
Fred Drake8cef4cf2000-06-28 16:40:38 +00003158# check for openpty and forkpty
3159
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003160AC_CHECK_FUNCS(openpty,,
3161 AC_CHECK_LIB(util,openpty,
3162 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3163 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3164 )
3165)
3166AC_CHECK_FUNCS(forkpty,,
3167 AC_CHECK_LIB(util,forkpty,
3168 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3169 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3170 )
3171)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003172
Brett Cannonaa5778d2008-03-18 04:09:00 +00003173# Stuff for expat.
3174AC_CHECK_FUNCS(memmove)
3175
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003176# check for long file support functions
3177AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3178
Brett Cannonaa5778d2008-03-18 04:09:00 +00003179AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003180AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3182 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3183 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003184)
Jack Jansen150753c2003-03-29 22:07:47 +00003185AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3187 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3188 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003189)
3190AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003191 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3192 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3193 [],
3194 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3195 [Define if gettimeofday() does not have second (timezone) argument
3196 This is the case on Motorola V4 (R40V4.2)])
3197 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003198)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003199
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003200AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003201AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003202#if defined(MAJOR_IN_MKDEV)
3203#include <sys/mkdev.h>
3204#elif defined(MAJOR_IN_SYSMACROS)
3205#include <sys/sysmacros.h>
3206#else
3207#include <sys/types.h>
3208#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003209]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003210 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003211]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003212 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3213 [Define to 1 if you have the device macros.])
3214 AC_MSG_RESULT(yes)
3215],[
3216 AC_MSG_RESULT(no)
3217])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003218
3219# On OSF/1 V5.1, getaddrinfo is available, but a define
3220# for [no]getaddrinfo in netdb.h.
3221AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003222AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003223#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003224#include <sys/socket.h>
3225#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003226#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003227]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3228[have_getaddrinfo=yes],
3229[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003230AC_MSG_RESULT($have_getaddrinfo)
3231if test $have_getaddrinfo = yes
3232then
3233 AC_MSG_CHECKING(getaddrinfo bug)
3234 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003235 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003236#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003237#include <sys/types.h>
3238#include <netdb.h>
3239#include <string.h>
3240#include <sys/socket.h>
3241#include <netinet/in.h>
3242
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003243int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003244{
3245 int passive, gaierr, inet4 = 0, inet6 = 0;
3246 struct addrinfo hints, *ai, *aitop;
3247 char straddr[INET6_ADDRSTRLEN], strport[16];
3248
3249 for (passive = 0; passive <= 1; passive++) {
3250 memset(&hints, 0, sizeof(hints));
3251 hints.ai_family = AF_UNSPEC;
3252 hints.ai_flags = passive ? AI_PASSIVE : 0;
3253 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003254 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003255 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3256 (void)gai_strerror(gaierr);
3257 goto bad;
3258 }
3259 for (ai = aitop; ai; ai = ai->ai_next) {
3260 if (ai->ai_addr == NULL ||
3261 ai->ai_addrlen == 0 ||
3262 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3263 straddr, sizeof(straddr), strport, sizeof(strport),
3264 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3265 goto bad;
3266 }
3267 switch (ai->ai_family) {
3268 case AF_INET:
3269 if (strcmp(strport, "54321") != 0) {
3270 goto bad;
3271 }
3272 if (passive) {
3273 if (strcmp(straddr, "0.0.0.0") != 0) {
3274 goto bad;
3275 }
3276 } else {
3277 if (strcmp(straddr, "127.0.0.1") != 0) {
3278 goto bad;
3279 }
3280 }
3281 inet4++;
3282 break;
3283 case AF_INET6:
3284 if (strcmp(strport, "54321") != 0) {
3285 goto bad;
3286 }
3287 if (passive) {
3288 if (strcmp(straddr, "::") != 0) {
3289 goto bad;
3290 }
3291 } else {
3292 if (strcmp(straddr, "::1") != 0) {
3293 goto bad;
3294 }
3295 }
3296 inet6++;
3297 break;
3298 case AF_UNSPEC:
3299 goto bad;
3300 break;
3301 default:
3302 /* another family support? */
3303 break;
3304 }
3305 }
3306 }
3307
3308 if (!(inet4 == 0 || inet4 == 2))
3309 goto bad;
3310 if (!(inet6 == 0 || inet6 == 2))
3311 goto bad;
3312
3313 if (aitop)
3314 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003315 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003316
3317 bad:
3318 if (aitop)
3319 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003320 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003321}
Matthias Klosec511b472010-05-08 11:01:39 +00003322]]])],
3323[ac_cv_buggy_getaddrinfo=no],
3324[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003325[
3326if test "${enable_ipv6+set}" = set; then
3327 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3328else
3329 ac_cv_buggy_getaddrinfo=yes
3330fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003331fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003332
Benjamin Peterson75fed812010-11-01 01:47:19 +00003333AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3334
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003335if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003336then
3337 if test $ipv6 = yes
3338 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003339 echo 'Fatal: You must get working getaddrinfo() function.'
3340 echo ' or you can specify "--disable-ipv6"'.
3341 exit 1
3342 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003343else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003344 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003345fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003346
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003347AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003348
Guido van Rossum627b2d71993-12-24 10:39:16 +00003349# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003350AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003351AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003352AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003353AC_CHECK_MEMBERS([struct stat.st_rdev])
3354AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003355AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003356AC_CHECK_MEMBERS([struct stat.st_gen])
3357AC_CHECK_MEMBERS([struct stat.st_birthtime])
Guido van Rossum98bf58f2001-10-18 20:34:25 +00003358AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003359
3360AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003361AC_CACHE_VAL(ac_cv_header_time_altzone,[
3362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3363 [ac_cv_header_time_altzone=yes],
3364 [ac_cv_header_time_altzone=no])
3365 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003366AC_MSG_RESULT($ac_cv_header_time_altzone)
3367if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003368 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003369fi
3370
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003371was_it_defined=no
3372AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003373AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003374#include <sys/types.h>
3375#include <sys/select.h>
3376#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003377]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003378 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3379 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3380 (which you can't on SCO ODT 3.0).])
3381 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003382],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003383AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003384
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003385AC_MSG_CHECKING(for addrinfo)
3386AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003387AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3388 [ac_cv_struct_addrinfo=yes],
3389 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003390AC_MSG_RESULT($ac_cv_struct_addrinfo)
3391if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003392 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003393fi
3394
3395AC_MSG_CHECKING(for sockaddr_storage)
3396AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003397AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003398# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003399# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3400 [ac_cv_struct_sockaddr_storage=yes],
3401 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003402AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3403if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003404 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003405fi
3406
Guido van Rossum627b2d71993-12-24 10:39:16 +00003407# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003408
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003409AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003410AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003411
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003412works=no
3413AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003414AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3415 [works=yes],
3416 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003417)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003418AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003419
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003420works=no
3421AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003422AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3423 [works=yes],
3424 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003425)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003426AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003427
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003428have_prototypes=no
3429AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003430AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3431 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3432 [Define if your compiler supports function prototype])
3433 have_prototypes=yes],
3434 []
3435)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003436AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003437
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003438works=no
3439AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003440AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003441#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003442int foo(int x, ...) {
3443 va_list va;
3444 va_start(va, x);
3445 va_arg(va, int);
3446 va_arg(va, char *);
3447 va_arg(va, double);
3448 return 0;
3449}
Matthias Klosec511b472010-05-08 11:01:39 +00003450]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003451 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3452 [Define if your compiler supports variable length function prototypes
3453 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3454 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003455],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003456AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003457
Dave Cole331708b2004-08-09 04:51:41 +00003458# check for socketpair
3459AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003460AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003461#include <sys/types.h>
3462#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003463]], [[void *x=socketpair]])],
3464 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3465 AC_MSG_RESULT(yes)],
3466 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003467)
3468
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003469# check if sockaddr has sa_len member
3470AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003471AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3472#include <sys/socket.h>]], [[struct sockaddr x;
3473x.sa_len = 0;]])],
3474 [AC_MSG_RESULT(yes)
3475 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3476 [AC_MSG_RESULT(no)]
3477)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003478
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003479va_list_is_array=no
3480AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003481AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003482#ifdef HAVE_STDARG_PROTOTYPES
3483#include <stdarg.h>
3484#else
3485#include <varargs.h>
3486#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003487]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003488 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3489 va_list_is_array=yes
3490])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003491AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003492
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003493# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003494AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3495 [Define this if you have some version of gethostbyname_r()])
3496
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003497AC_CHECK_FUNC(gethostbyname_r, [
3498 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3499 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3500 OLD_CFLAGS=$CFLAGS
3501 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003502 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003503# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003504 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003505 char *name;
3506 struct hostent *he, *res;
3507 char buffer[2048];
3508 int buflen = 2048;
3509 int h_errnop;
3510
3511 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003512 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003513 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003514 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3515 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003516 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003517 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003518 AC_MSG_RESULT(no)
3519 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003520 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003521# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003522 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003523 char *name;
3524 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003525 char buffer[2048];
3526 int buflen = 2048;
3527 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003528
Matthias Klosec511b472010-05-08 11:01:39 +00003529 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3530 ]])],
3531 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003532 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003533 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3534 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003535 AC_MSG_RESULT(yes)
3536 ], [
3537 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003538 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3539 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3540# include <netdb.h>
3541 ]], [[
3542 char *name;
3543 struct hostent *he;
3544 struct hostent_data data;
3545
3546 (void) gethostbyname_r(name, he, &data);
3547 ]])],
3548 [
3549 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3550 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3551 [Define this if you have the 3-arg version of gethostbyname_r().])
3552 AC_MSG_RESULT(yes)
3553 ], [
3554 AC_MSG_RESULT(no)
3555 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003556 ])
3557 ])
3558 CFLAGS=$OLD_CFLAGS
3559], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003560 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003561])
3562AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3563AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3564AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003565AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003566AC_SUBST(HAVE_GETHOSTBYNAME)
3567
Guido van Rossum627b2d71993-12-24 10:39:16 +00003568# checks for system services
3569# (none yet)
3570
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003571# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003572AC_CHECK_FUNC(__fpu_control,
3573 [],
3574 [AC_CHECK_LIB(ieee, __fpu_control)
3575])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003576
Guido van Rossum93274221997-05-09 02:42:00 +00003577# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003578AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003579AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003580 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003581[
Guido van Rossum93274221997-05-09 02:42:00 +00003582if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003583then
3584 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3585 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3586 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003587else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003588fi],
3589[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003590
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003591# check for --with-libm=...
3592AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003593case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003594Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003595BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003596*) LIBM=-lm
3597esac
Guido van Rossum93274221997-05-09 02:42:00 +00003598AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003599AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003600 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003601[
Guido van Rossum93274221997-05-09 02:42:00 +00003602if test "$withval" = no
3603then LIBM=
3604 AC_MSG_RESULT(force LIBM empty)
3605elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003606then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003607 AC_MSG_RESULT(set LIBM="$withval")
3608else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003609fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003610[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003611
3612# check for --with-libc=...
3613AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003614AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003615AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003616 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003617[
Guido van Rossum93274221997-05-09 02:42:00 +00003618if test "$withval" = no
3619then LIBC=
3620 AC_MSG_RESULT(force LIBC empty)
3621elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003622then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003623 AC_MSG_RESULT(set LIBC="$withval")
3624else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003625fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003626[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003627
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003628# **************************************************
3629# * Check for various properties of floating point *
3630# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003631
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003632AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3633AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003634AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003635#include <string.h>
3636int main() {
3637 double x = 9006104071832581.0;
3638 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3639 return 0;
3640 else
3641 return 1;
3642}
Matthias Klosec511b472010-05-08 11:01:39 +00003643]])],
3644[ac_cv_little_endian_double=yes],
3645[ac_cv_little_endian_double=no],
3646[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003647AC_MSG_RESULT($ac_cv_little_endian_double)
3648if test "$ac_cv_little_endian_double" = yes
3649then
3650 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3651 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3652 with the least significant byte first])
3653fi
3654
3655AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3656AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003657AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003658#include <string.h>
3659int main() {
3660 double x = 9006104071832581.0;
3661 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3662 return 0;
3663 else
3664 return 1;
3665}
Matthias Klosec511b472010-05-08 11:01:39 +00003666]])],
3667[ac_cv_big_endian_double=yes],
3668[ac_cv_big_endian_double=no],
3669[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003670AC_MSG_RESULT($ac_cv_big_endian_double)
3671if test "$ac_cv_big_endian_double" = yes
3672then
3673 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3674 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3675 with the most significant byte first])
3676fi
3677
3678# Some ARM platforms use a mixed-endian representation for doubles.
3679# While Python doesn't currently have full support for these platforms
3680# (see e.g., issue 1762561), we can at least make sure that float <-> string
3681# conversions work.
3682AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3683AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003684AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003685#include <string.h>
3686int main() {
3687 double x = 9006104071832581.0;
3688 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3689 return 0;
3690 else
3691 return 1;
3692}
Matthias Klosec511b472010-05-08 11:01:39 +00003693]])],
3694[ac_cv_mixed_endian_double=yes],
3695[ac_cv_mixed_endian_double=no],
3696[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003697AC_MSG_RESULT($ac_cv_mixed_endian_double)
3698if test "$ac_cv_mixed_endian_double" = yes
3699then
3700 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3701 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3702 in ARM mixed-endian order (byte order 45670123)])
3703fi
3704
3705# The short float repr introduced in Python 3.1 requires the
3706# correctly-rounded string <-> double conversion functions from
3707# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3708# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003709# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003710# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003711
3712# This inline assembler syntax may also work for suncc and icc,
3713# so we try it on all platforms.
3714
3715AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Matthias Klosec511b472010-05-08 11:01:39 +00003716AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003717 unsigned short cw;
3718 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3719 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003720]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003721AC_MSG_RESULT($have_gcc_asm_for_x87)
3722if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003723then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003724 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3725 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003726fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003727
Mark Dickinson04b27232009-01-04 12:29:36 +00003728# Detect whether system arithmetic is subject to x87-style double
3729# rounding issues. The result of this test has little meaning on non
3730# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3731# mode is round-to-nearest and double rounding issues are present, and
3732# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3733AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003734# $BASECFLAGS may affect the result
3735ac_save_cc="$CC"
3736CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003737AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003738#include <stdlib.h>
3739#include <math.h>
3740int main() {
3741 volatile double x, y, z;
3742 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3743 x = 0.99999999999999989; /* 1-2**-53 */
3744 y = 1./x;
3745 if (y != 1.)
3746 exit(0);
3747 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3748 x = 1e16;
3749 y = 2.99999;
3750 z = x + y;
3751 if (z != 1e16+4.)
3752 exit(0);
3753 /* both tests show evidence of double rounding */
3754 exit(1);
3755}
Matthias Klosec511b472010-05-08 11:01:39 +00003756]])],
3757[ac_cv_x87_double_rounding=no],
3758[ac_cv_x87_double_rounding=yes],
3759[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003760CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003761AC_MSG_RESULT($ac_cv_x87_double_rounding)
3762if test "$ac_cv_x87_double_rounding" = yes
3763then
3764 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3765 [Define if arithmetic is subject to x87-style double rounding issue])
3766fi
3767
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003768# ************************************
3769# * Check for mathematical functions *
3770# ************************************
3771
3772LIBS_SAVE=$LIBS
3773LIBS="$LIBS $LIBM"
3774
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003775# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3776# -0. on some architectures.
3777AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3778AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003779AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003780#include <math.h>
3781#include <stdlib.h>
3782int main() {
3783 /* return 0 if either negative zeros don't exist
3784 on this platform or if negative zeros exist
3785 and tanh(-0.) == -0. */
3786 if (atan2(0., -1.) == atan2(-0., -1.) ||
3787 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3788 else exit(1);
3789}
Matthias Klosec511b472010-05-08 11:01:39 +00003790]])],
3791[ac_cv_tanh_preserves_zero_sign=yes],
3792[ac_cv_tanh_preserves_zero_sign=no],
3793[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003794AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3795if test "$ac_cv_tanh_preserves_zero_sign" = yes
3796then
3797 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3798 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3799fi
3800
3801AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3802AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3803AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3804
3805LIBS=$LIBS_SAVE
3806
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003807# For multiprocessing module, check that sem_open
3808# actually works. For FreeBSD versions <= 7.2,
3809# the kernel module that provides POSIX semaphores
3810# isn't loaded by default, so an attempt to call
3811# sem_open results in a 'Signal 12' error.
3812AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3813AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003814AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003815#include <unistd.h>
3816#include <fcntl.h>
3817#include <stdio.h>
3818#include <semaphore.h>
3819#include <sys/stat.h>
3820
3821int main(void) {
3822 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3823 if (a == SEM_FAILED) {
3824 perror("sem_open");
3825 return 1;
3826 }
3827 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003828 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003829 return 0;
3830}
Matthias Klosec511b472010-05-08 11:01:39 +00003831]])],
3832[ac_cv_posix_semaphores_enabled=yes],
3833[ac_cv_posix_semaphores_enabled=no],
3834[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003835)
3836AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3837if test $ac_cv_posix_semaphores_enabled = no
3838then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003839 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3840 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003841fi
3842
Jesse Noller355b1262009-04-02 00:03:28 +00003843# Multiprocessing check for broken sem_getvalue
3844AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003845AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003846AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003847#include <unistd.h>
3848#include <fcntl.h>
3849#include <stdio.h>
3850#include <semaphore.h>
3851#include <sys/stat.h>
3852
3853int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003854 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003855 int count;
3856 int res;
3857 if(a==SEM_FAILED){
3858 perror("sem_open");
3859 return 1;
3860
3861 }
3862 res = sem_getvalue(a, &count);
3863 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003864 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003865 return res==-1 ? 1 : 0;
3866}
Matthias Klosec511b472010-05-08 11:01:39 +00003867]])],
3868[ac_cv_broken_sem_getvalue=no],
3869[ac_cv_broken_sem_getvalue=yes],
3870[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003871)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003872AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3873if test $ac_cv_broken_sem_getvalue = yes
3874then
3875 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3876 [define to 1 if your sem_getvalue is broken.])
3877fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003878
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003879# determine what size digit to use for Python's longs
3880AC_MSG_CHECKING([digit size for Python's longs])
3881AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00003882AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003883[case $enable_big_digits in
3884yes)
3885 enable_big_digits=30 ;;
3886no)
3887 enable_big_digits=15 ;;
3888[15|30])
3889 ;;
3890*)
3891 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3892esac
3893AC_MSG_RESULT($enable_big_digits)
3894AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3895],
3896[AC_MSG_RESULT(no value specified)])
3897
Guido van Rossumef2255b2000-03-10 22:30:29 +00003898# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003899AC_CHECK_HEADER(wchar.h, [
3900 AC_DEFINE(HAVE_WCHAR_H, 1,
3901 [Define if the compiler provides a wchar.h header file.])
3902 wchar_h="yes"
3903],
Guido van Rossumef2255b2000-03-10 22:30:29 +00003904wchar_h="no"
3905)
3906
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003907# determine wchar_t size
3908if test "$wchar_h" = yes
3909then
Guido van Rossum67b26592001-10-20 14:21:45 +00003910 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003911fi
3912
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003913AC_MSG_CHECKING(for UCS-4 tcl)
3914have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00003915AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003916#include <tcl.h>
3917#if TCL_UTF_MAX != 6
3918# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00003919#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003920 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3921 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003922],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003923AC_MSG_RESULT($have_ucs4_tcl)
3924
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003925# check whether wchar_t is signed or not
3926if test "$wchar_h" = yes
3927then
3928 # check whether wchar_t is signed or not
3929 AC_MSG_CHECKING(whether wchar_t is signed)
3930 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00003931 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003932 #include <wchar.h>
3933 int main()
3934 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00003935 /* Success: exit code 0 */
3936 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003937 }
Matthias Klosec511b472010-05-08 11:01:39 +00003938 ]])],
3939 [ac_cv_wchar_t_signed=yes],
3940 [ac_cv_wchar_t_signed=no],
3941 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003942 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3943fi
3944
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003945AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003946dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003947AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00003948 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003949 [],
3950 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003951
3952if test $enable_unicode = yes
3953then
Martin v. Löwisfd917792001-06-27 20:22:04 +00003954 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00003955 case "$have_ucs4_tcl" in
3956 yes) enable_unicode="ucs4"
3957 ;;
3958 *) enable_unicode="ucs2"
3959 ;;
3960 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003961fi
3962
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003963AH_TEMPLATE(Py_UNICODE_SIZE,
3964 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003965case "$enable_unicode" in
3966ucs2) unicode_size="2"
3967 AC_DEFINE(Py_UNICODE_SIZE,2)
3968 ;;
3969ucs4) unicode_size="4"
3970 AC_DEFINE(Py_UNICODE_SIZE,4)
3971 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02003972no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00003973*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003974esac
3975
Martin v. Löwis11437992002-04-12 09:54:03 +00003976AH_TEMPLATE(PY_UNICODE_TYPE,
3977 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00003978
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003979AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003980if test "$enable_unicode" = "no"
3981then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003982 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003983 AC_MSG_RESULT(not used)
3984else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00003985 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003986 AC_DEFINE(Py_USING_UNICODE, 1,
3987 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003988
3989 # wchar_t is only usable if it maps to an unsigned type
3990 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00003991 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003992 then
3993 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003994 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3995 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00003996 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003997 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00003998 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3999 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4000 then
4001 PY_UNICODE_TYPE="unsigned short"
4002 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4003 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4004 then
4005 PY_UNICODE_TYPE="unsigned long"
4006 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4007 else
4008 PY_UNICODE_TYPE="no type found"
4009 fi
4010 AC_MSG_RESULT($PY_UNICODE_TYPE)
4011fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004012
4013# check for endianness
4014AC_C_BIGENDIAN
4015
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004016# Check whether right shifting a negative integer extends the sign bit
4017# or fills with zeros (like the Cray J90, according to Tim Peters).
4018AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004019AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004020AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004021int main()
4022{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004023 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004024}
Matthias Klosec511b472010-05-08 11:01:39 +00004025]])],
4026[ac_cv_rshift_extends_sign=yes],
4027[ac_cv_rshift_extends_sign=no],
4028[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004029AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4030if test "$ac_cv_rshift_extends_sign" = no
4031then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004032 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4033 [Define if i>>j for signed int i does not extend the sign bit
4034 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004035fi
4036
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004037# check for getc_unlocked and related locking functions
4038AC_MSG_CHECKING(for getc_unlocked() and friends)
4039AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004040AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004041 FILE *f = fopen("/dev/null", "r");
4042 flockfile(f);
4043 getc_unlocked(f);
4044 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004045]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004046AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4047if test "$ac_cv_have_getc_unlocked" = yes
4048then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004049 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4050 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004051fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004052
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004053# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004054# save the value of LIBS so we don't actually link Python with readline
4055LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004056
4057# On some systems we need to link readline to a termcap compatible
4058# library. NOTE: Keep the precedence of listed libraries synchronised
4059# with setup.py.
4060py_cv_lib_readline=no
4061AC_MSG_CHECKING([how to link readline libs])
4062for py_libtermcap in "" ncursesw ncurses curses termcap; do
4063 if test -z "$py_libtermcap"; then
4064 READLINE_LIBS="-lreadline"
4065 else
4066 READLINE_LIBS="-lreadline -l$py_libtermcap"
4067 fi
4068 LIBS="$READLINE_LIBS $LIBS_no_readline"
4069 AC_LINK_IFELSE(
4070 [AC_LANG_CALL([],[readline])],
4071 [py_cv_lib_readline=yes])
4072 if test $py_cv_lib_readline = yes; then
4073 break
4074 fi
4075done
4076# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4077#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004078if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004079 AC_MSG_RESULT([none])
4080else
4081 AC_MSG_RESULT([$READLINE_LIBS])
4082 AC_DEFINE(HAVE_LIBREADLINE, 1,
4083 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004084fi
4085
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004086# check for readline 2.1
4087AC_CHECK_LIB(readline, rl_callback_handler_install,
4088 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004089 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004090
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004091# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004092AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4093 [have_readline=yes],
4094 [have_readline=no]
4095)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004096if test $have_readline = yes
4097then
4098 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4099 [readline/readline.h],
4100 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4101 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004102 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4103 [readline/readline.h],
4104 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4105 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004106fi
4107
Martin v. Löwis0daad592001-09-30 21:09:59 +00004108# check for readline 4.0
4109AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004110 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004111 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004112
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004113# also in 4.0
4114AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4115 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004116 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004117
Guido van Rossum353ae582001-07-10 16:45:32 +00004118# check for readline 4.2
4119AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004120 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004121 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004122
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004123# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004124AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4125 [have_readline=yes],
4126 [have_readline=no]
4127)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004128if test $have_readline = yes
4129then
4130 AC_EGREP_HEADER([extern int rl_catch_signals;],
4131 [readline/readline.h],
4132 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4133 [Define if you can turn off readline's signal handling.]), )
4134fi
4135
Martin v. Löwis82bca632006-02-10 20:49:30 +00004136# End of readline checks: restore LIBS
4137LIBS=$LIBS_no_readline
4138
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004139AC_MSG_CHECKING(for broken nice())
4140AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004141AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004142int main()
4143{
4144 int val1 = nice(1);
4145 if (val1 != -1 && val1 == nice(2))
4146 exit(0);
4147 exit(1);
4148}
Matthias Klosec511b472010-05-08 11:01:39 +00004149]])],
4150[ac_cv_broken_nice=yes],
4151[ac_cv_broken_nice=no],
4152[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004153AC_MSG_RESULT($ac_cv_broken_nice)
4154if test "$ac_cv_broken_nice" = yes
4155then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004156 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4157 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004158fi
4159
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004160AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004161AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004162AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004163#include <poll.h>
4164
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004165int main()
4166{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004167 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004168 int poll_test;
4169
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004170 close (42);
4171
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004172 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004173 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004174 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004175 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004176 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004177 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004178 return 1;
4179}
Matthias Klosec511b472010-05-08 11:01:39 +00004180]])],
4181[ac_cv_broken_poll=yes],
4182[ac_cv_broken_poll=no],
4183[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004184AC_MSG_RESULT($ac_cv_broken_poll)
4185if test "$ac_cv_broken_poll" = yes
4186then
4187 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4188 [Define if poll() sets errno on invalid file descriptors.])
4189fi
4190
Brett Cannon43802422005-02-10 20:48:03 +00004191# Before we can test tzset, we need to check if struct tm has a tm_zone
4192# (which is not required by ISO C or UNIX spec) and/or if we support
4193# tzname[]
4194AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004195
Brett Cannon43802422005-02-10 20:48:03 +00004196# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004197AC_MSG_CHECKING(for working tzset())
4198AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004199AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004200#include <stdlib.h>
4201#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004202#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004203
4204#if HAVE_TZNAME
4205extern char *tzname[];
4206#endif
4207
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004208int main()
4209{
Brett Cannon18367812003-09-19 00:59:16 +00004210 /* Note that we need to ensure that not only does tzset(3)
4211 do 'something' with localtime, but it works as documented
4212 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004213 This includes making sure that tzname is set properly if
4214 tm->tm_zone does not exist since it is the alternative way
4215 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004216
4217 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004218 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004219 */
4220
Brett Cannon43802422005-02-10 20:48:03 +00004221 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004222 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4223
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004224 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004225 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004226 if (localtime(&groundhogday)->tm_hour != 0)
4227 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004228#if HAVE_TZNAME
4229 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4230 if (strcmp(tzname[0], "UTC") ||
4231 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4232 exit(1);
4233#endif
Brett Cannon18367812003-09-19 00:59:16 +00004234
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004235 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004236 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004237 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004238 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004239#if HAVE_TZNAME
4240 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4241 exit(1);
4242#endif
Brett Cannon18367812003-09-19 00:59:16 +00004243
4244 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4245 tzset();
4246 if (localtime(&groundhogday)->tm_hour != 11)
4247 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004248#if HAVE_TZNAME
4249 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4250 exit(1);
4251#endif
4252
4253#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004254 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4255 exit(1);
4256 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4257 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004258#endif
Brett Cannon18367812003-09-19 00:59:16 +00004259
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004260 exit(0);
4261}
Matthias Klosec511b472010-05-08 11:01:39 +00004262]])],
4263[ac_cv_working_tzset=yes],
4264[ac_cv_working_tzset=no],
4265[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004266AC_MSG_RESULT($ac_cv_working_tzset)
4267if test "$ac_cv_working_tzset" = yes
4268then
4269 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4270 [Define if tzset() actually switches the local timezone in a meaningful way.])
4271fi
4272
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004273# Look for subsecond timestamps in struct stat
4274AC_MSG_CHECKING(for tv_nsec in struct stat)
4275AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004276AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004277struct stat st;
4278st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004279]])],
4280[ac_cv_stat_tv_nsec=yes],
4281[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004282AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4283if test "$ac_cv_stat_tv_nsec" = yes
4284then
4285 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4286 [Define if you have struct stat.st_mtim.tv_nsec])
4287fi
4288
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004289# Look for BSD style subsecond timestamps in struct stat
4290AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4291AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004292AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004293struct stat st;
4294st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004295]])],
4296[ac_cv_stat_tv_nsec2=yes],
4297[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004298AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4299if test "$ac_cv_stat_tv_nsec2" = yes
4300then
4301 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4302 [Define if you have struct stat.st_mtimensec])
4303fi
4304
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004305# first curses configure check
4306ac_save_cppflags="$CPPFLAGS"
4307CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4308
4309AC_CHECK_HEADERS(curses.h ncurses.h)
4310
4311# On Solaris, term.h requires curses.h
4312AC_CHECK_HEADERS(term.h,,,[
4313#ifdef HAVE_CURSES_H
4314#include <curses.h>
4315#endif
4316])
4317
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004318# On HP/UX 11.0, mvwdelch is a block with a return statement
4319AC_MSG_CHECKING(whether mvwdelch is an expression)
4320AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004321AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004322 int rtn;
4323 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004324]])],
4325[ac_cv_mvwdelch_is_expression=yes],
4326[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004327AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4328
4329if test "$ac_cv_mvwdelch_is_expression" = yes
4330then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004331 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4332 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004333fi
4334
4335AC_MSG_CHECKING(whether WINDOW has _flags)
4336AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004337AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004338 WINDOW *w;
4339 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004340]])],
4341[ac_cv_window_has_flags=yes],
4342[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004343AC_MSG_RESULT($ac_cv_window_has_flags)
4344
4345
4346if test "$ac_cv_window_has_flags" = yes
4347then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004348 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4349 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004350fi
4351
Walter Dörwald4994d952006-06-19 08:07:50 +00004352AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004353AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4354 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4355 AC_MSG_RESULT(yes)],
4356 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004357)
4358
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004359AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004360AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4361 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4362 AC_MSG_RESULT(yes)],
4363 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004364)
4365
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004366AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004367AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4368 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4369 AC_MSG_RESULT(yes)],
4370 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004371)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004372# last curses configure check
4373CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004374
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004375AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004376
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004377dnl NOTE: Inform user how to proceed with files when cross compiling.
4378if test "x$cross_compiling" = xyes; then
4379 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4380 AC_MSG_CHECKING([for /dev/ptmx])
4381 AC_MSG_RESULT([not set])
4382 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4383 fi
4384 if test "${ac_cv_file__dev_ptc+set}" != set; then
4385 AC_MSG_CHECKING([for /dev/ptc])
4386 AC_MSG_RESULT([not set])
4387 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4388 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004389fi
4390
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004391AC_CHECK_FILE(/dev/ptmx, [], [])
4392if test "x$ac_cv_file__dev_ptmx" = xyes; then
4393 AC_DEFINE(HAVE_DEV_PTMX, 1,
4394 [Define to 1 if you have the /dev/ptmx device file.])
4395fi
4396AC_CHECK_FILE(/dev/ptc, [], [])
4397if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004398 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004399 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004400fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004401
Mark Dickinson82864d12009-11-15 16:18:58 +00004402if test "$have_long_long" = yes
4403then
4404 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4405 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004406 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004407 #include <stdio.h>
4408 #include <stddef.h>
4409 #include <string.h>
4410
4411 #ifdef HAVE_SYS_TYPES_H
4412 #include <sys/types.h>
4413 #endif
4414
4415 int main()
4416 {
4417 char buffer[256];
4418
4419 if (sprintf(buffer, "%lld", (long long)123) < 0)
4420 return 1;
4421 if (strcmp(buffer, "123"))
4422 return 1;
4423
4424 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4425 return 1;
4426 if (strcmp(buffer, "-123"))
4427 return 1;
4428
4429 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4430 return 1;
4431 if (strcmp(buffer, "123"))
4432 return 1;
4433
4434 return 0;
4435 }
Matthias Klosec511b472010-05-08 11:01:39 +00004436 ]]])],
4437 [ac_cv_have_long_long_format=yes],
4438 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004439 [ac_cv_have_long_long_format="cross -- assuming no"
4440 if test x$GCC = xyes; then
4441 save_CFLAGS=$CFLAGS
4442 CFLAGS="$CFLAGS -Werror -Wformat"
4443 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4444 #include <stdio.h>
4445 #include <stddef.h>
4446 ]], [[
4447 char *buffer;
4448 sprintf(buffer, "%lld", (long long)123);
4449 sprintf(buffer, "%lld", (long long)-123);
4450 sprintf(buffer, "%llu", (unsigned long long)123);
4451 ]])],
4452 ac_cv_have_long_long_format=yes
4453 )
4454 CFLAGS=$save_CFLAGS
4455 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004456 )
4457 AC_MSG_RESULT($ac_cv_have_long_long_format)
4458fi
4459
Mark Dickinson5ce84742009-12-31 20:48:04 +00004460if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004461then
4462 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4463 [Define to printf format modifier for long long type])
4464fi
4465
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004466if test $ac_sys_system = Darwin
4467then
4468 LIBS="$LIBS -framework CoreFoundation"
4469fi
4470
Mark Dickinson82864d12009-11-15 16:18:58 +00004471
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004472AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004473AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004474#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004475#include <stddef.h>
4476#include <string.h>
4477
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004478#ifdef HAVE_SYS_TYPES_H
4479#include <sys/types.h>
4480#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004481
4482#ifdef HAVE_SSIZE_T
4483typedef ssize_t Py_ssize_t;
4484#elif SIZEOF_VOID_P == SIZEOF_LONG
4485typedef long Py_ssize_t;
4486#else
4487typedef int Py_ssize_t;
4488#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004489
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004490int main()
4491{
4492 char buffer[256];
4493
Brett Cannon09d12362006-05-11 05:11:33 +00004494 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4495 return 1;
4496
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004497 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004498 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004499
4500 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4501 return 1;
4502
4503 if (strcmp(buffer, "-123"))
4504 return 1;
4505
Brett Cannon09d12362006-05-11 05:11:33 +00004506 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004507}
Matthias Klosec511b472010-05-08 11:01:39 +00004508]])],
4509[ac_cv_have_size_t_format=yes],
4510[ac_cv_have_size_t_format=no],
4511[ac_cv_have_size_t_format="cross -- assuming yes"
4512])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004513if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004514 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4515 [Define to printf format modifier for Py_ssize_t])
4516fi
Brett Cannon09d12362006-05-11 05:11:33 +00004517
Martin v. Löwis01c04012002-11-11 14:58:44 +00004518AC_CHECK_TYPE(socklen_t,,
4519 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004520 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004521#ifdef HAVE_SYS_TYPES_H
4522#include <sys/types.h>
4523#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004524#ifdef HAVE_SYS_SOCKET_H
4525#include <sys/socket.h>
4526#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004527])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004528
R. David Murray1d9d16e2010-10-16 00:43:13 +00004529case $ac_sys_system in
4530AIX*)
4531 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4532esac
4533
4534
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004535AC_SUBST(THREADHEADERS)
4536
4537for h in `(cd $srcdir;echo Python/thread_*.h)`
4538do
4539 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4540done
4541
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004542AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004543SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004544AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004545for dir in $SRCDIRS; do
4546 if test ! -d $dir; then
4547 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004548 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004549done
4550AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004551
Guido van Rossum627b2d71993-12-24 10:39:16 +00004552# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004553AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004554AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004555AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004556
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004557echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004558if test ! -f Modules/Setup
4559then
4560 cp $srcdir/Modules/Setup.dist Modules/Setup
4561fi
4562
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004563echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004564if test ! -f Modules/Setup.local
4565then
4566 echo "# Edit this file for local setup changes" >Modules/Setup.local
4567fi
4568
4569echo "creating Makefile"
4570$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4571 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004572 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004573
4574case $ac_sys_system in
4575BeOS)
4576 AC_MSG_WARN([
4577
4578 Support for BeOS is deprecated as of Python 2.6.
4579 See PEP 11 for the gory details.
4580 ])
4581 ;;
4582*) ;;
4583esac
4584
Neil Schemenauer66252162001-02-19 04:47:42 +00004585mv config.c Modules