blob: e620b088ca42309364e7ddb5018c47b07aefc5af [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$)
Benjamin Petersoncc8929b2016-08-03 22:01:32 -070011AC_INIT(python, PYTHON_VERSION, https://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
Ned Deily983df862014-08-22 13:30:59 -070019# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
20rm -f pybuilddir.txt
21
doko@python.orgd65e2ba2013-01-31 23:52:03 +010022if test "$cross_compiling" = yes; then
23 AC_MSG_CHECKING([for python interpreter for cross build])
24 if test -z "$PYTHON_FOR_BUILD"; then
25 for interp in python$PACKAGE_VERSION python2 python; do
26 which $interp >/dev/null 2>&1 || continue
27 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
28 break
29 fi
30 interp=
31 done
32 if test x$interp = x; then
33 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
34 fi
35 AC_MSG_RESULT($interp)
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +020036 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/$(PLATDIR) '$interp
doko@python.orgd65e2ba2013-01-31 23:52:03 +010037 fi
Martin Panterbc82de02016-07-29 05:52:32 +000038 # Used to comment out stuff for rebuilding generated files
39 GENERATED_COMMENT='#'
doko@python.orgd65e2ba2013-01-31 23:52:03 +010040elif test "$cross_compiling" = maybe; then
41 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
42else
43 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
Martin Panterbc82de02016-07-29 05:52:32 +000044 GENERATED_COMMENT=''
doko@python.orgd65e2ba2013-01-31 23:52:03 +010045fi
46AC_SUBST(PYTHON_FOR_BUILD)
Martin Panterbc82de02016-07-29 05:52:32 +000047AC_SUBST(GENERATED_COMMENT)
doko@python.orgd65e2ba2013-01-31 23:52:03 +010048
Georg Brandlbcd64a32009-03-31 21:45:18 +000049dnl Ensure that if prefix is specified, it does not end in a slash. If
50dnl it does, we get path names containing '//' which is both ugly and
51dnl can cause trouble.
52
53dnl Last slash shouldn't be stripped if prefix=/
54if test "$prefix" != "/"; then
55 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
56fi
57
Martin v. Löwis8316feb2003-06-14 07:48:07 +000058dnl This is for stuff that absolutely must end up in pyconfig.h.
59dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000060AH_TOP([
61#ifndef Py_PYCONFIG_H
62#define Py_PYCONFIG_H
63])
Martin v. Löwis11437992002-04-12 09:54:03 +000064AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000065/* Define the macros needed if on a UnixWare 7.x system. */
66#if defined(__USLC__) && defined(__SCO_VERSION__)
67#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
68#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000069
70#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000071])
72
Martin v. Löwis8316feb2003-06-14 07:48:07 +000073# We don't use PACKAGE_ variables, and they cause conflicts
74# with other autoconf-based packages that include Python.h
75grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
76rm confdefs.h
77mv confdefs.h.new confdefs.h
78
Guido van Rossum642b6781997-07-19 19:35:41 +000079AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000080VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000081
Martin v. Löwis1142de32002-03-29 16:28:31 +000082AC_SUBST(SOVERSION)
83SOVERSION=1.0
84
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000085# The later defininition of _XOPEN_SOURCE disables certain features
86# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
87AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
88
Martin v. Löwisbcd93962003-05-03 10:32:18 +000089# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
90# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
91# them.
92AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
93
Andrew MacIntyreabccf412003-07-02 13:53:25 +000094# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
95# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
96# them.
97AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
98
Martin v. Löwisd6320502004-08-12 13:45:08 +000099# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
100# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
101AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
102
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000103# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
104# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
105# them.
106AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
107
108
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000109define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000110
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000111# Arguments passed to configure.
112AC_SUBST(CONFIG_ARGS)
113CONFIG_ARGS="$ac_configure_args"
114
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000115AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +0000116AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +0000117 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000118[
119 case $enableval in
120 yes)
121 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000122 if test ! -d "${enableval}"
123 then
124 enableval=/
125 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000126 ;;
127 esac
128 case $enableval in
129 no)
130 UNIVERSALSDK=
131 enable_universalsdk=
132 ;;
133 *)
134 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000135 if test ! -d "${UNIVERSALSDK}"
136 then
137 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
138 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000139 ;;
140 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000141
Ronald Oussoren988117f2006-04-29 11:31:35 +0000142],[
143 UNIVERSALSDK=
144 enable_universalsdk=
145])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000146if test -n "${UNIVERSALSDK}"
147then
148 AC_MSG_RESULT(${UNIVERSALSDK})
149else
150 AC_MSG_RESULT(no)
151fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000152AC_SUBST(UNIVERSALSDK)
153
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000154AC_SUBST(ARCH_RUN_32BIT)
Ned Deily8e60f6e2013-05-30 00:14:29 -0700155ARCH_RUN_32BIT=""
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000156
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000157UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000158AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000159AC_MSG_CHECKING(for --with-universal-archs)
160AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000161 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 +0000162[
163 AC_MSG_RESULT($withval)
164 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000165 if test "${enable_universalsdk}" ; then
166 :
167 else
168 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
169 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000170],
171[
172 AC_MSG_RESULT(32-bit)
173])
174
175
176
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000177AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000178 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000179 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000180[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000181 if test "${enable_framework}"; then
182 :
183 else
184 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
185 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000186 PYTHONFRAMEWORK=${withval}
187 PYTHONFRAMEWORKDIR=${withval}.framework
188 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
189 ],[
190 PYTHONFRAMEWORK=Python
191 PYTHONFRAMEWORKDIR=Python.framework
192 PYTHONFRAMEWORKIDENTIFIER=org.python.python
193])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000194dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000195AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000196 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000197[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000198 case $enableval in
199 yes)
200 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000201 esac
202 case $enableval in
203 no)
204 PYTHONFRAMEWORK=
205 PYTHONFRAMEWORKDIR=no-framework
206 PYTHONFRAMEWORKPREFIX=
207 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000208 FRAMEWORKINSTALLFIRST=
209 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000210 FRAMEWORKALTINSTALLFIRST=
211 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000212 if test "x${prefix}" = "xNONE"; then
213 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
214 else
215 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
216 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000217 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000218 ;;
219 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000220 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000221 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000222 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000223 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000224 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
225 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000226 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000227
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000228 if test "x${prefix}" = "xNONE" ; then
229 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000230
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000231 else
232 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
233 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000234
235 case "${enableval}" in
236 /System*)
237 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
238 if test "${prefix}" = "NONE" ; then
239 # See below
240 FRAMEWORKUNIXTOOLSPREFIX="/usr"
241 fi
242 ;;
243
244 /Library*)
245 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
246 ;;
247
248 */Library/Frameworks)
249 MDIR="`dirname "${enableval}"`"
250 MDIR="`dirname "${MDIR}"`"
251 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
252
253 if test "${prefix}" = "NONE"; then
254 # User hasn't specified the
255 # --prefix option, but wants to install
256 # the framework in a non-default location,
257 # ensure that the compatibility links get
258 # installed relative to that prefix as well
259 # instead of in /usr/local.
260 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
261 fi
262 ;;
263
264 *)
265 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
266 ;;
267 esac
268
Jack Jansen127e56e2001-09-11 14:41:54 +0000269 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000270
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000271 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000272 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000273 AC_CONFIG_FILES(Mac/Makefile)
274 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
275 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000276 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
277 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000278 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000279 ],[
280 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000281 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000282 PYTHONFRAMEWORKPREFIX=
283 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000284 FRAMEWORKINSTALLFIRST=
285 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000286 FRAMEWORKALTINSTALLFIRST=
287 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000288 if test "x${prefix}" = "xNONE" ; then
289 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
290 else
291 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
292 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000293 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000294
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000295])
296AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000297AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000298AC_SUBST(PYTHONFRAMEWORKDIR)
299AC_SUBST(PYTHONFRAMEWORKPREFIX)
300AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000301AC_SUBST(FRAMEWORKINSTALLFIRST)
302AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000303AC_SUBST(FRAMEWORKALTINSTALLFIRST)
304AC_SUBST(FRAMEWORKALTINSTALLLAST)
305AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000306AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000307
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000308##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000309## AS_HELP_STRING([--with-dyld],
310## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000311##
Guido van Rossumb418f891996-07-30 18:06:02 +0000312# Set name for machine-dependent library files
313AC_SUBST(MACHDEP)
314AC_MSG_CHECKING(MACHDEP)
315if test -z "$MACHDEP"
316then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100317 # avoid using uname for cross builds
318 if test "$cross_compiling" = yes; then
319 # ac_sys_system and ac_sys_release are only used for setting
320 # `define_xopen_source' in the case statement below. For the
321 # current supported cross builds, this macro is not adjusted.
322 case "$host" in
323 *-*-linux*)
324 ac_sys_system=Linux
325 ;;
326 *-*-cygwin*)
327 ac_sys_system=Cygwin
328 ;;
329 *)
330 # for now, limit cross builds to known configurations
331 MACHDEP="unknown"
332 AC_MSG_ERROR([cross build not supported for $host])
333 esac
334 ac_sys_release=
335 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000336 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000337 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000338 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000339 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000340 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000341 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000342 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100343 fi
344 ac_md_system=`echo $ac_sys_system |
345 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
346 ac_md_release=`echo $ac_sys_release |
347 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
348 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000349
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100350 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200351 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000352 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000353 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000354 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000355 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000356 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100357 esac
358fi
359
360AC_SUBST(_PYTHON_HOST_PLATFORM)
361if test "$cross_compiling" = yes; then
362 case "$host" in
363 *-*-linux*)
364 case "$host_cpu" in
365 arm*)
366 _host_cpu=arm
367 ;;
368 *)
369 _host_cpu=$host_cpu
370 esac
371 ;;
372 *-*-cygwin*)
373 _host_cpu=
374 ;;
375 *)
376 # for now, limit cross builds to known configurations
377 MACHDEP="unknown"
378 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000379 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100380 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000381fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000382
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000383# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
384# disable features if it is defined, without any means to access these
385# features as extensions. For these systems, we skip the definition of
386# _XOPEN_SOURCE. Before adding a system to the list to gain access to
387# some feature, make sure there is no alternative way to access this
388# feature. Also, when using wildcards, make sure you have verified the
389# need for not defining _XOPEN_SOURCE on all systems matching the
390# wildcard, and that the wildcard does not include future systems
391# (which may remove their limitations).
392dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
393case $ac_sys_system/$ac_sys_release in
394 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
395 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000396 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000397 # In addition, Stefan Krah confirms that issue #1244610 exists through
398 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200399 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000400 define_xopen_source=no
401 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
402 # also defined. This can be overridden by defining _BSD_SOURCE
403 # As this has a different meaning on Linux, only define it on OpenBSD
404 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
405 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200406 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000407 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
408 # also defined. This can be overridden by defining _BSD_SOURCE
409 # As this has a different meaning on Linux, only define it on OpenBSD
410 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
411 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000412 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
413 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
414 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000415 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 +0000416 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000417 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
418 # request to enable features supported by the standard as a request
419 # to disable features not supported by the standard. The best way
420 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
421 # entirely and define __EXTENSIONS__ instead.
422 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000423 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000424 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
425 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000426 # Reconfirmed for 7.1.4 by Martin v. Loewis.
427 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000428 define_xopen_source=no;;
429 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000430 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000431 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000432 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000433 # On FreeBSD 4, the math functions C89 does not cover are never defined
434 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
435 FreeBSD/4.*)
436 define_xopen_source=no;;
437 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
438 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
439 # identifies itself as Darwin/7.*
440 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
441 # disables platform specific features beyond repair.
442 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
443 # has no effect, don't bother defining them
444 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000445 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000446 Darwin/1@<:@0-9@:>@.*)
447 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000448 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
449 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
450 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000451 AIX/4)
452 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000453 AIX/5)
454 if test `uname -r` -eq 1; then
455 define_xopen_source=no
456 fi
457 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000458 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
459 # defining NI_NUMERICHOST.
460 QNX/6.3.2)
461 define_xopen_source=no
462 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000463
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000464esac
465
466if test $define_xopen_source = yes
467then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000468 AC_DEFINE(_XOPEN_SOURCE, 600,
469 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000470
471 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
472 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
473 # several APIs are not declared. Since this is also needed in some
474 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000475 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
476 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000477
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000478 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
479
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000480fi
481
Guido van Rossum91922671997-10-09 20:24:13 +0000482#
483# SGI compilers allow the specification of the both the ABI and the
484# ISA on the command line. Depending on the values of these switches,
Martin Panterb1d867f2016-05-26 05:28:50 +0000485# different and often incompatible code will be generated.
Guido van Rossum91922671997-10-09 20:24:13 +0000486#
487# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
488# thus supply support for various ABI/ISA combinations. The MACHDEP
489# variable is also adjusted.
490#
491AC_SUBST(SGI_ABI)
492if test ! -z "$SGI_ABI"
493then
494 CC="cc $SGI_ABI"
495 LDFLAGS="$SGI_ABI $LDFLAGS"
496 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
497fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000498AC_MSG_RESULT($MACHDEP)
499
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +0200500AC_SUBST(PLATDIR)
501PLATDIR=plat-$MACHDEP
502
Jack Jansen83f898c2002-12-30 22:23:40 +0000503# And add extra plat-mac for darwin
504AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000505AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000506AC_MSG_CHECKING(EXTRAPLATDIR)
507if test -z "$EXTRAPLATDIR"
508then
509 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000510 darwin)
511 EXTRAPLATDIR="\$(PLATMACDIRS)"
512 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
513 ;;
514 *)
515 EXTRAPLATDIR=""
516 EXTRAMACHDEPPATH=""
517 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000518 esac
519fi
520AC_MSG_RESULT($EXTRAPLATDIR)
521
Jack Jansen6b08a402004-06-03 12:41:45 +0000522# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
523# it may influence the way we can build extensions, so distutils
524# needs to check it
525AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000526AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000527CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000528EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000529
Guido van Rossum627b2d71993-12-24 10:39:16 +0000530# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000531
532# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
533# for debug/optimization stuff. BASECFLAGS is for flags that are required
534# just to get things to compile and link. Users are free to override OPT
535# when running configure or make. The build should not break if they do.
536# BASECFLAGS should generally not be messed with, however.
537
538# XXX shouldn't some/most/all of this code be merged with the stuff later
539# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000540AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000541AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000542 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000543[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000544 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000545 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000546 without_gcc=yes;;
547 yes) CC=gcc
548 without_gcc=no;;
549 *) CC=$withval
550 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000551 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000552 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000553 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000554 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000555 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000556 case $BE_HOST_CPU in
557 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000558 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000559 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000560 BASECFLAGS="$BASECFLAGS -export pragma"
561 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000562 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000563 ;;
564 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000565 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000566 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000567 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000568 ;;
569 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000570 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000571 ;;
572 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000573 AR="\$(srcdir)/Modules/ar_beos"
574 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000575 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000576 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000577 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000578AC_MSG_RESULT($without_gcc)
579
Zachary Ware6ed42ea2015-12-21 11:43:03 -0600580AC_MSG_CHECKING(for --with-icc)
581AC_ARG_WITH(icc,
582 AS_HELP_STRING([--with-icc], [build with icc]),
583[
584 case $withval in
585 no) CC=${CC:-cc}
586 with_icc=no;;
587 yes) CC=icc
588 CXX=icpc
589 with_icc=yes;;
590 *) CC=$withval
591 with_icc=$withval;;
592 esac], [
593 with_icc=no])
594AC_MSG_RESULT($with_icc)
595
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000596# If the user switches compilers, we can't believe the cache
597if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
598then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000599 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
600(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000601fi
602
Trent Nelson15daa352012-12-13 06:46:39 +0000603if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
604 # Normally, MIPSpro CC treats #error directives as warnings, which means
605 # a successful exit code is returned (0). This is a problem because IRIX
606 # has a bunch of system headers with this guard at the top:
607 #
608 # #ifndef __c99
609 # #error This header file is to be used only for c99 mode compilations
610 # #else
611 #
612 # When autoconf tests for such a header, like stdint.h, this happens:
613 #
614 # configure:4619: cc -c conftest.c >&5
615 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
616 # #error directive: This header file is to be used only for c99 mode
617 # compilations
618 #
619 # #error This header file is to be used only for c99 mode compilations
620 # ^
621 #
622 # configure:4619: $? = 0
623 # configure:4619: result: yes
624 #
625 # Therefore, we use `-diag_error 1035` to have the compiler treat the
626 # warning as an error, which causes cc to return a non-zero result,
627 # which autoconf can interpret correctly.
628 CFLAGS="$CFLAGS -diag_error 1035"
629 # Whilst we're here, we might as well make sure CXX defaults to something
630 # sensible if we're not using gcc.
631 if test -z "$CXX"; then
632 CXX="CC"
633 fi
634fi
635
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000636# If the user set CFLAGS, use this instead of the automatically
637# determined setting
638preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000639AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000640if test ! -z "$preset_cflags"
641then
642 CFLAGS=$preset_cflags
643fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000644
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000645AC_SUBST(CXX)
646AC_SUBST(MAINCC)
647AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
648AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000649 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000650 [compile main() and link python executable with C++ compiler]),
651[
652
653 case $withval in
654 no) with_cxx_main=no
655 MAINCC='$(CC)';;
656 yes) with_cxx_main=yes
657 MAINCC='$(CXX)';;
658 *) with_cxx_main=yes
659 MAINCC=$withval
660 if test -z "$CXX"
661 then
662 CXX=$withval
663 fi;;
664 esac], [
665 with_cxx_main=no
666 MAINCC='$(CC)'
667])
668AC_MSG_RESULT($with_cxx_main)
669
670preset_cxx="$CXX"
671if test -z "$CXX"
672then
673 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100674 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
675 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000676 esac
677 if test "$CXX" = "notfound"
678 then
679 CXX=""
680 fi
681fi
682if test -z "$CXX"
683then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100684 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000685 if test "$CXX" = "notfound"
686 then
687 CXX=""
688 fi
689fi
690if test "$preset_cxx" != "$CXX"
691then
692 AC_MSG_WARN([
693
694 By default, distutils will build C++ extension modules with "$CXX".
695 If this is not intended, then set CXX on the configure command line.
696 ])
697fi
698
doko@python.org4e63fbe2013-01-25 13:08:27 +0100699MULTIARCH=$($CC --print-multiarch 2>/dev/null)
700AC_SUBST(MULTIARCH)
701
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000702
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000703# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000704AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000705
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000706# Check for unsupported systems
707case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000708atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000709 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
710 echo See README for details.
711 exit 1;;
712esac
713
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000714AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000715AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000716AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000717 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000718[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000719 case $withval in
720 no) EXEEXT=;;
721 yes) EXEEXT=.exe;;
722 *) EXEEXT=$withval;;
723 esac])
724AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000725
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000726# Test whether we're running on a non-case-sensitive system, in which
727# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000728AC_SUBST(BUILDEXEEXT)
729AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000730if test ! -d CaseSensitiveTestDir; then
731mkdir CaseSensitiveTestDir
732fi
733
734if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000735then
Jack Jansen1999ef42001-12-06 21:47:20 +0000736 AC_MSG_RESULT(yes)
737 BUILDEXEEXT=.exe
738else
739 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000740 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000741fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000742rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000743
Guido van Rossumdd997f71998-10-07 19:58:26 +0000744case $MACHDEP in
745bsdos*)
746 case $CC in
747 gcc) CC="$CC -D_HAVE_BSDI";;
748 esac;;
749esac
750
Guido van Rossum84561611997-08-21 00:08:11 +0000751case $ac_sys_system in
752hp*|HP*)
753 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000754 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000755 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000756SunOS*)
757 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000758 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000759 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000760esac
761
Martin v. Löwise8964d42001-03-06 12:09:07 +0000762
Neil Schemenauer61c51152001-01-26 16:18:16 +0000763AC_SUBST(LIBRARY)
764AC_MSG_CHECKING(LIBRARY)
765if test -z "$LIBRARY"
766then
767 LIBRARY='libpython$(VERSION).a'
768fi
769AC_MSG_RESULT($LIBRARY)
770
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000771# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000772# name of the library into which to insert object files). BLDLIBRARY is also
773# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
774# is blank as the main program is not linked directly against LDLIBRARY.
775# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
776# systems without shared libraries, LDLIBRARY is the same as LIBRARY
777# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
778# DLLLIBRARY is the shared (i.e., DLL) library.
779#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000780# RUNSHARED is used to run shared python without installed libraries
781#
782# INSTSONAME is the name of the shared library that will be use to install
783# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000784AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000785AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000786AC_SUBST(BLDLIBRARY)
787AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000788AC_SUBST(INSTSONAME)
789AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000790LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000791BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000792INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000793DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000794LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000795RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000796
Guido van Rossumfb842551997-08-06 23:42:07 +0000797# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000798# If CXX is set, and if it is needed to link a main function that was
799# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
800# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000801# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000802# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000803AC_SUBST(LINKCC)
804AC_MSG_CHECKING(LINKCC)
805if test -z "$LINKCC"
806then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000807 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000808 case $ac_sys_system in
809 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000810 exp_extra="\"\""
811 if test $ac_sys_release -ge 5 -o \
812 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
813 exp_extra="."
814 fi
815 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000816 QNX*)
817 # qcc must be used because the other compilers do not
818 # support -N.
819 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000820 esac
821fi
822AC_MSG_RESULT($LINKCC)
823
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000824# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
825# make sure we default having it set to "no": this is used by
826# distutils.unixccompiler to know if it should add --enable-new-dtags
827# to linker command lines, and failing to detect GNU ld simply results
828# in the same bahaviour as before.
829AC_SUBST(GNULD)
830AC_MSG_CHECKING(for GNU ld)
831ac_prog=ld
832if test "$GCC" = yes; then
833 ac_prog=`$CC -print-prog-name=ld`
834fi
835case `"$ac_prog" -V 2>&1 < /dev/null` in
836 *GNU*)
837 GNULD=yes;;
838 *)
839 GNULD=no;;
840esac
841AC_MSG_RESULT($GNULD)
842
Martin v. Löwis1142de32002-03-29 16:28:31 +0000843AC_MSG_CHECKING(for --enable-shared)
844AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000845 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000846
Martin v. Löwis1142de32002-03-29 16:28:31 +0000847if test -z "$enable_shared"
848then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000849 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000850 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000851 enable_shared="yes";;
852 *)
853 enable_shared="no";;
854 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000855fi
856AC_MSG_RESULT($enable_shared)
857
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000858AC_MSG_CHECKING(for --enable-profiling)
859AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100860 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
861if test "x$enable_profiling" = xyes; then
862 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400863 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100864 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
865 [],
866 [enable_profiling=no])
867 CC="$ac_save_cc"
868else
869 enable_profiling=no
870fi
871AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000872
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100873if test "x$enable_profiling" = xyes; then
874 BASECFLAGS="-pg $BASECFLAGS"
875 LDFLAGS="-pg $LDFLAGS"
876fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000877
878AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000879
Guido van Rossumb8552162001-09-05 14:58:11 +0000880# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
881# library that we build, but we do not want to link against it (we
882# will find it with a -framework option). For this reason there is an
883# extra variable BLDLIBRARY against which Python and the extension
884# modules are linked, BLDLIBRARY. This is normally the same as
885# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000886if test "$enable_framework"
887then
888 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200889 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000890 BLDLIBRARY=''
891else
892 BLDLIBRARY='$(LDLIBRARY)'
893fi
894
Martin v. Löwis1142de32002-03-29 16:28:31 +0000895# Other platforms follow
896if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000897 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000898 case $ac_sys_system in
899 BeOS*)
900 LDLIBRARY='libpython$(VERSION).so'
901 ;;
902 CYGWIN*)
903 LDLIBRARY='libpython$(VERSION).dll.a'
904 DLLLIBRARY='libpython$(VERSION).dll'
905 ;;
906 SunOS*)
907 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000908 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200909 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000910 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000911 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200912 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000913 LDLIBRARY='libpython$(VERSION).so'
914 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200915 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000916 case $ac_sys_system in
917 FreeBSD*)
918 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
919 ;;
920 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000921 INSTSONAME="$LDLIBRARY".$SOVERSION
922 ;;
923 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000924 case `uname -m` in
925 ia64)
926 LDLIBRARY='libpython$(VERSION).so'
927 ;;
928 *)
929 LDLIBRARY='libpython$(VERSION).sl'
930 ;;
931 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000932 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200933 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000934 ;;
935 OSF*)
936 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000937 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200938 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000939 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000940 atheos*)
941 LDLIBRARY='libpython$(VERSION).so'
942 BLDLIBRARY='-L. -lpython$(VERSION)'
943 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
944 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000945 Darwin*)
946 LDLIBRARY='libpython$(VERSION).dylib'
947 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200948 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000949 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000950 AIX*)
951 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200952 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000953 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000954
Martin v. Löwis1142de32002-03-29 16:28:31 +0000955 esac
Jason Tishler30765592003-09-04 11:04:06 +0000956else # shared is disabled
957 case $ac_sys_system in
958 CYGWIN*)
959 BLDLIBRARY='$(LIBRARY)'
960 LDLIBRARY='libpython$(VERSION).dll.a'
961 ;;
962 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000963fi
964
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100965if test "$cross_compiling" = yes; then
966 RUNSHARED=
967fi
968
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000969AC_MSG_RESULT($LDLIBRARY)
970
Guido van Rossum627b2d71993-12-24 10:39:16 +0000971AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000972AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100973AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000974
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000975# tweak ARFLAGS only if the user didn't set it on the command line
976AC_SUBST(ARFLAGS)
977if test -z "$ARFLAGS"
978then
979 ARFLAGS="rc"
980fi
981
Victor Stinner2c7085f2017-05-02 16:55:50 +0200982AC_SUBST(GITVERSION)
983AC_SUBST(GITTAG)
984AC_SUBST(GITBRANCH)
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000985
Victor Stinner2c7085f2017-05-02 16:55:50 +0200986if test -e $srcdir/.git/HEAD
Georg Brandl3a5508e2011-03-06 10:42:21 +0100987then
Victor Stinner2c7085f2017-05-02 16:55:50 +0200988AC_CHECK_PROG(HAS_GIT, git, found, not-found)
Georg Brandl3a5508e2011-03-06 10:42:21 +0100989else
Victor Stinner2c7085f2017-05-02 16:55:50 +0200990HAS_GIT=no-repository
991fi
992if test $HAS_GIT = found
993then
994 GITVERSION="git -C \$(srcdir) rev-parse --short HEAD"
995 GITTAG="git -C \$(srcdir) describe --all --always --dirty"
996 GITBRANCH="git -C \$(srcdir) name-rev --name-only HEAD"
997else
998 GITVERSION=""
999 GITTAG=""
1000 GITBRANCH=""
Georg Brandl3a5508e2011-03-06 10:42:21 +01001001fi
1002
Neil Schemenauera42c8272001-03-31 00:01:55 +00001003case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +00001004bsdos*|hp*|HP*)
1005 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001006 if test -z "$INSTALL"
1007 then
1008 INSTALL="${srcdir}/install-sh -c"
1009 fi
1010esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001011AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001012AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001013
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001014# Not every filesystem supports hard links
1015AC_SUBST(LN)
1016if test -z "$LN" ; then
1017 case $ac_sys_system in
1018 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001019 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001020 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001021 *) LN=ln;;
1022 esac
1023fi
1024
Fred Drake9f715822001-07-11 06:27:00 +00001025# Check for --with-pydebug
1026AC_MSG_CHECKING(for --with-pydebug)
1027AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001028 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001029[
Fred Drake9f715822001-07-11 06:27:00 +00001030if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001031then
1032 AC_DEFINE(Py_DEBUG, 1,
1033 [Define if you want to build an interpreter with many run-time checks.])
1034 AC_MSG_RESULT(yes);
1035 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001036else AC_MSG_RESULT(no); Py_DEBUG='false'
1037fi],
1038[AC_MSG_RESULT(no)])
1039
Skip Montanarodecc6a42003-01-01 20:07:49 +00001040# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1041# merged with this chunk of code?
1042
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001043# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001044# ------------------------
1045# (The following bit of code is complicated enough - please keep things
1046# indented properly. Just pretend you're editing Python code. ;-)
1047
1048# There are two parallel sets of case statements below, one that checks to
1049# see if OPT was set and one that does BASECFLAGS setting based upon
1050# compiler and platform. BASECFLAGS tweaks need to be made even if the
1051# user set OPT.
1052
1053# tweak OPT based on compiler and platform, only if the user didn't set
1054# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001055AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001056if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001057then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001058 case $GCC in
1059 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001060 if test "$CC" != 'g++' ; then
1061 STRICT_PROTO="-Wstrict-prototypes"
1062 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001063 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1064 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1065 WRAP="-fwrapv"
1066 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001067
1068 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001069 case $CC in
1070 *clang*) WRAP="-fwrapv"
1071 ;;
1072 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001073
Skip Montanarodecc6a42003-01-01 20:07:49 +00001074 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001075 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001076 if test "$Py_DEBUG" = 'true' ; then
1077 # Optimization messes up debuggers, so turn it off for
1078 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001079 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001080 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001081 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001082 fi
1083 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001084 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001085 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001086 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001087 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001088 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001089 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1090 ;;
1091 esac
Fred Drake9f715822001-07-11 06:27:00 +00001092 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001093
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001094 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001095 OPT="-O"
1096 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001097 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001098fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001099
Skip Montanarodecc6a42003-01-01 20:07:49 +00001100AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001101
1102# The -arch flags for universal builds on OSX
1103UNIVERSAL_ARCH_FLAGS=
1104AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1105
Skip Montanarodecc6a42003-01-01 20:07:49 +00001106# tweak BASECFLAGS based on compiler and platform
1107case $GCC in
1108yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001109 # Python violates C99 rules, by casting between incompatible
1110 # pointer types. GCC may generate bad code as a result of that,
1111 # so use -fno-strict-aliasing if supported.
1112 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1113 ac_save_cc="$CC"
1114 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001115 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001116 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001117 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001118 [ac_cv_no_strict_aliasing_ok=yes],
1119 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001120 CC="$ac_save_cc"
1121 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1122 if test $ac_cv_no_strict_aliasing_ok = yes
1123 then
1124 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1125 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001126
1127 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1128 # support. Without this, treatment of subnormals doesn't follow
1129 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001130 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001131 alpha*)
1132 BASECFLAGS="$BASECFLAGS -mieee"
1133 ;;
1134 esac
1135
Skip Montanarodecc6a42003-01-01 20:07:49 +00001136 case $ac_sys_system in
1137 SCO_SV*)
1138 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1139 ;;
1140 # is there any other compiler on Darwin besides gcc?
1141 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001142 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1143 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001144 if test "${CC}" = gcc
1145 then
1146 AC_MSG_CHECKING(which compiler should be used)
1147 case "${UNIVERSALSDK}" in
1148 */MacOSX10.4u.sdk)
1149 # Build using 10.4 SDK, force usage of gcc when the
1150 # compiler is gcc, otherwise the user will get very
1151 # confusing error messages when building on OSX 10.6
1152 CC=gcc-4.0
1153 CPP=cpp-4.0
1154 ;;
1155 esac
1156 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001157 fi
1158
Benjamin Peterson4347c442008-07-17 15:59:24 +00001159 # Calculate the right deployment target for this build.
1160 #
Ned Deilyc40b9032014-06-25 13:48:46 -07001161 cur_target_major=`sw_vers -productVersion | \
1162 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1163 cur_target_minor=`sw_vers -productVersion | \
1164 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1165 cur_target="${cur_target_major}.${cur_target_minor}"
1166 if test ${cur_target_major} -eq 10 && \
1167 test ${cur_target_minor} -ge 3
1168 then
Benjamin Peterson4347c442008-07-17 15:59:24 +00001169 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001170 if test ${enable_universalsdk}; then
1171 if test "${UNIVERSAL_ARCHS}" = "all"; then
1172 # Ensure that the default platform for a
1173 # 4-way universal build is OSX 10.5,
1174 # that's the first OS release where
1175 # 4-way builds make sense.
1176 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001177
1178 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1179 cur_target='10.5'
1180
1181 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1182 cur_target='10.5'
1183
1184 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1185 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001186 fi
1187 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001188 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001189 # On Intel macs default to a deployment
1190 # target of 10.4, that's the first OSX
1191 # release with Intel support.
1192 cur_target="10.4"
1193 fi
1194 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001195 fi
1196 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1197
1198 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1199 # environment with a value that is the same as what we'll use
1200 # in the Makefile to ensure that we'll get the same compiler
1201 # environment during configure and build time.
1202 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1203 export MACOSX_DEPLOYMENT_TARGET
1204 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1205
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001206 if test "${enable_universalsdk}"; then
1207 UNIVERSAL_ARCH_FLAGS=""
1208 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1209 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1210 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001211 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001212
1213 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1214 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1215 LIPO_32BIT_FLAGS=""
1216 ARCH_RUN_32BIT="true"
1217
1218 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1219 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1220 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001221 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001222
1223 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1224 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1225 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001226 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001227
1228 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1229 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1230 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001231 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001232
1233 else
1234 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1235
1236 fi
1237
1238
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001239 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1240 if test "${UNIVERSALSDK}" != "/"
1241 then
1242 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1243 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1244 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001245 fi
1246
1247 fi
1248
1249
Skip Montanarodecc6a42003-01-01 20:07:49 +00001250 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001251 OSF*)
1252 BASECFLAGS="$BASECFLAGS -mieee"
1253 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001254 esac
1255 ;;
1256
1257*)
1258 case $ac_sys_system in
1259 OpenUNIX*|UnixWare*)
1260 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1261 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001262 OSF*)
1263 BASECFLAGS="$BASECFLAGS -ieee -std"
1264 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001265 SCO_SV*)
1266 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1267 ;;
1268 esac
1269 ;;
1270esac
1271
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001272# ICC needs -fp-model strict or floats behave badly
1273case "$CC" in
1274*icc*)
1275 BASECFLAGS="$BASECFLAGS -fp-model strict"
1276 ;;
1277esac
1278
Fred Drakee1ceaa02001-12-04 20:55:47 +00001279if test "$Py_DEBUG" = 'true'; then
1280 :
1281else
1282 OPT="-DNDEBUG $OPT"
1283fi
1284
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001285if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001286then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001287 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001288fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001289
Neal Norwitz020c46a2006-01-07 21:39:28 +00001290# disable check for icc since it seems to pass, but generates a warning
1291if test "$CC" = icc
1292then
1293 ac_cv_opt_olimit_ok=no
1294fi
1295
Guido van Rossum91922671997-10-09 20:24:13 +00001296AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1297AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1298[ac_save_cc="$CC"
1299CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001300AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001301 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001302 [ac_cv_opt_olimit_ok=yes],
1303 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001304 )
Guido van Rossum91922671997-10-09 20:24:13 +00001305CC="$ac_save_cc"])
1306AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001307if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001308 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001309 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1310 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1311 # environment?
1312 Darwin*)
1313 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001314 # XXX thankfully this useless troublemaker of a flag has been
1315 # eradicated in the 3.x line. For now, make sure it isn't picked
1316 # up by any of our other platforms that use CC.
1317 AIX*|SunOS*|HP-UX*|IRIX*)
1318 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001319 *)
1320 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1321 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001322 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001323else
1324 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1325 AC_CACHE_VAL(ac_cv_olimit_ok,
1326 [ac_save_cc="$CC"
1327 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001328 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001329 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001330 [ac_cv_olimit_ok=yes],
1331 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001332 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001333 CC="$ac_save_cc"])
1334 AC_MSG_RESULT($ac_cv_olimit_ok)
1335 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001336 case $ac_sys_system in
1337 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1338 HP-UX*)
1339 ;;
1340 *)
1341 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1342 ;;
1343 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001344 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001345fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001346
Martin v. Löwisaac13162006-10-19 10:58:46 +00001347# Check whether GCC supports PyArg_ParseTuple format
1348if test "$GCC" = "yes"
1349then
1350 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1351 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001352 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001353 AC_COMPILE_IFELSE([
1354 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1355 ],[
1356 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1357 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1358 AC_MSG_RESULT(yes)
1359 ],[
1360 AC_MSG_RESULT(no)
1361 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001362 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001363fi
1364
Brett Cannon4ff151a2015-09-18 15:09:42 -07001365
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001366# Enable optimization flags
1367AC_SUBST(DEF_MAKE_ALL_RULE)
1368AC_SUBST(DEF_MAKE_RULE)
1369Py_OPT='false'
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001370AC_MSG_CHECKING(for --enable-optimizations)
1371AC_ARG_ENABLE(optimizations, AS_HELP_STRING([--enable-optimizations], [Enable expensive optimizations (PGO, maybe LTO, etc). Disabled by default.]),
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001372[
INADA Naoki6a04ef72017-03-29 01:50:48 +09001373if test "$enableval" != no
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001374then
1375 Py_OPT='true'
1376 AC_MSG_RESULT(yes);
1377else
1378 Py_OPT='false'
1379 AC_MSG_RESULT(no);
1380fi],
1381[AC_MSG_RESULT(no)])
1382if test "$Py_OPT" = 'true' ; then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)9cbfa792016-09-08 22:44:44 +00001383 # Intentionally not forcing Py_LTO='true' here. Too many toolchains do not
1384 # compile working code using it and both test_distutils and test_gdb are
1385 # broken when you do managed to get a toolchain that works with it. People
1386 # who want LTO need to use --with-lto themselves.
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001387 Py_LTO='true'
1388 DEF_MAKE_ALL_RULE="profile-opt"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001389 REQUIRE_PGO="yes"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001390 DEF_MAKE_RULE="build_all"
1391else
1392 DEF_MAKE_ALL_RULE="build_all"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001393 REQUIRE_PGO="no"
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07001394 DEF_MAKE_RULE="all"
1395fi
1396
1397
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)c543a0f2016-06-02 23:44:40 +00001398# Enable LTO flags
1399AC_SUBST(LTOFLAGS)
1400AC_MSG_CHECKING(for --with-lto)
1401AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]),
1402[
1403if test "$withval" != no
1404then
1405 Py_LTO='true'
1406 AC_MSG_RESULT(yes);
1407else
1408 Py_LTO='false'
1409 AC_MSG_RESULT(no);
1410fi],
1411[AC_MSG_RESULT(no)])
1412if test "$Py_LTO" = 'true' ; then
1413 case $CC in
1414 *clang*)
1415 # Any changes made here should be reflected in the GCC+Darwin case below
1416 LTOFLAGS="-flto"
1417 ;;
1418 *gcc*)
1419 case $ac_sys_system in
1420 Darwin*)
1421 LTOFLAGS="-flto"
1422 ;;
1423 *)
1424 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1425 ;;
1426 esac
1427 ;;
1428 esac
1429fi
1430
1431
Brett Cannon4ff151a2015-09-18 15:09:42 -07001432# Enable PGO flags.
1433AC_SUBST(PGO_PROF_GEN_FLAG)
1434AC_SUBST(PGO_PROF_USE_FLAG)
1435AC_SUBST(LLVM_PROF_MERGER)
1436AC_SUBST(LLVM_PROF_FILE)
1437AC_SUBST(LLVM_PROF_ERR)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001438# Make this work on systems where llvm tools are not installed with their
1439# normal names in the default $PATH (ie: Ubuntu). They exist under the
1440# non-suffixed name in their versioned llvm directory.
1441llvm_bin_dir=''
1442llvm_path="${PATH}"
1443if test "${CC}" = "clang"
1444then
1445 clang_bin=`which clang`
1446 # Some systems install clang elsewhere as a symlink to the real path
1447 # which is where the related llvm tools are located.
1448 if test -L "${clang_bin}"
1449 then
1450 clang_dir=`dirname "${clang_bin}"`
1451 clang_bin=`readlink "${clang_bin}"`
1452 llvm_bin_dir="${clang_dir}/"`dirname "${clang_bin}"`
1453 llvm_path="${llvm_path}${PATH_SEPARATOR}${llvm_bin_dir}"
1454 fi
1455fi
1456AC_SUBST(LLVM_PROFDATA)
1457AC_PATH_TARGET_TOOL(LLVM_PROFDATA, llvm-profdata, '', ${llvm_path})
Brett Cannon4ff151a2015-09-18 15:09:42 -07001458AC_SUBST(LLVM_PROF_FOUND)
Gregory P. Smith794b2912016-09-08 00:07:40 -07001459if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
1460then
1461 LLVM_PROF_FOUND="found"
1462else
1463 LLVM_PROF_FOUND="not-found"
1464fi
1465if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
1466then
1467 found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
1468 if test -n "${found_llvm_profdata}"
1469 then
1470 # llvm-profdata isn't directly in $PATH in some cases.
1471 # https://apple.stackexchange.com/questions/197053/
1472 LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
1473 LLVM_PROF_FOUND=found
1474 AC_MSG_NOTICE([llvm-profdata found via xcrun: ${LLVM_PROFDATA}])
1475 fi
1476fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001477LLVM_PROF_ERR=no
1478case $CC in
1479 *clang*)
1480 # Any changes made here should be reflected in the GCC+Darwin case below
1481 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1482 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001483 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001484 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
1485 if test $LLVM_PROF_FOUND = not-found
1486 then
1487 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001488 if test "${REQUIRE_PGO}" = "yes"
1489 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001490 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
Gregory P. Smith794b2912016-09-08 00:07:40 -07001491 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001492 fi
1493 ;;
1494 *gcc*)
1495 case $ac_sys_system in
1496 Darwin*)
1497 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1498 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
Gregory P. Smith794b2912016-09-08 00:07:40 -07001499 LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001500 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
Gregory P. Smith794b2912016-09-08 00:07:40 -07001501 if test "${LLVM_PROF_FOUND}" = "not-found"
Brett Cannon4ff151a2015-09-18 15:09:42 -07001502 then
1503 LLVM_PROF_ERR=yes
Gregory P. Smith794b2912016-09-08 00:07:40 -07001504 if test "${REQUIRE_PGO}" = "yes"
1505 then
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00001506 AC_MSG_ERROR([llvm-profdata is required for a --enable-optimizations build but could not be found.])
Gregory P. Smith794b2912016-09-08 00:07:40 -07001507 fi
Brett Cannon4ff151a2015-09-18 15:09:42 -07001508 fi
1509 ;;
1510 *)
1511 PGO_PROF_GEN_FLAG="-fprofile-generate"
1512 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
1513 LLVM_PROF_MERGER="true"
1514 LLVM_PROF_FILE=""
1515 ;;
1516 esac
1517 ;;
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001518 *icc*)
1519 PGO_PROF_GEN_FLAG="-prof-gen"
1520 PGO_PROF_USE_FLAG="-prof-use"
1521 LLVM_PROF_MERGER="true"
1522 LLVM_PROF_FILE=""
1523 ;;
Brett Cannon4ff151a2015-09-18 15:09:42 -07001524esac
1525
1526
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001527# On some compilers, pthreads are available without further options
1528# (e.g. MacOS X). On some of these systems, the compiler will not
1529# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1530# So we have to see first whether pthreads are available without
1531# options before we can check whether -Kpthread improves anything.
1532AC_MSG_CHECKING(whether pthreads are available without options)
1533AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001534[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001535#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001536#include <pthread.h>
1537
1538void* routine(void* p){return NULL;}
1539
1540int main(){
1541 pthread_t p;
1542 if(pthread_create(&p,NULL,routine,NULL)!=0)
1543 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001544 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001545 return 0;
1546}
Matthias Klosec511b472010-05-08 11:01:39 +00001547]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001548 ac_cv_pthread_is_default=yes
1549 ac_cv_kthread=no
1550 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001551],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001552])
1553AC_MSG_RESULT($ac_cv_pthread_is_default)
1554
1555
1556if test $ac_cv_pthread_is_default = yes
1557then
1558 ac_cv_kpthread=no
1559else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001560# -Kpthread, if available, provides the right #defines
1561# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001562# Some compilers won't report that they do not support -Kpthread,
1563# so we need to run a program to see whether it really made the
1564# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001565AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1566AC_CACHE_VAL(ac_cv_kpthread,
1567[ac_save_cc="$CC"
1568CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001569AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001570#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001571#include <pthread.h>
1572
1573void* routine(void* p){return NULL;}
1574
1575int main(){
1576 pthread_t p;
1577 if(pthread_create(&p,NULL,routine,NULL)!=0)
1578 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001579 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001580 return 0;
1581}
Matthias Klosec511b472010-05-08 11:01:39 +00001582]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001583CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001584AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001585fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001586
Skip Montanarod8d39a02003-07-10 20:44:10 +00001587if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001588then
1589# -Kthread, if available, provides the right #defines
1590# and linker options to make pthread_create available
1591# Some compilers won't report that they do not support -Kthread,
1592# so we need to run a program to see whether it really made the
1593# function available.
1594AC_MSG_CHECKING(whether $CC accepts -Kthread)
1595AC_CACHE_VAL(ac_cv_kthread,
1596[ac_save_cc="$CC"
1597CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001598AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001599#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001600#include <pthread.h>
1601
1602void* routine(void* p){return NULL;}
1603
1604int main(){
1605 pthread_t p;
1606 if(pthread_create(&p,NULL,routine,NULL)!=0)
1607 return 1;
1608 (void)pthread_detach(p);
1609 return 0;
1610}
Matthias Klosec511b472010-05-08 11:01:39 +00001611]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001612CC="$ac_save_cc"])
1613AC_MSG_RESULT($ac_cv_kthread)
1614fi
1615
Skip Montanarod8d39a02003-07-10 20:44:10 +00001616if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001617then
1618# -pthread, if available, provides the right #defines
1619# and linker options to make pthread_create available
1620# Some compilers won't report that they do not support -pthread,
1621# so we need to run a program to see whether it really made the
1622# function available.
1623AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001624AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001625[ac_save_cc="$CC"
1626CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001627AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001628#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001629#include <pthread.h>
1630
1631void* routine(void* p){return NULL;}
1632
1633int main(){
1634 pthread_t p;
1635 if(pthread_create(&p,NULL,routine,NULL)!=0)
1636 return 1;
1637 (void)pthread_detach(p);
1638 return 0;
1639}
Matthias Klosec511b472010-05-08 11:01:39 +00001640]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001641CC="$ac_save_cc"])
1642AC_MSG_RESULT($ac_cv_pthread)
1643fi
1644
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001645# If we have set a CC compiler flag for thread support then
1646# check if it works for CXX, too.
1647ac_cv_cxx_thread=no
1648if test ! -z "$CXX"
1649then
1650AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1651ac_save_cxx="$CXX"
1652
1653if test "$ac_cv_kpthread" = "yes"
1654then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001655 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001656 ac_cv_cxx_thread=yes
1657elif test "$ac_cv_kthread" = "yes"
1658then
1659 CXX="$CXX -Kthread"
1660 ac_cv_cxx_thread=yes
1661elif test "$ac_cv_pthread" = "yes"
1662then
1663 CXX="$CXX -pthread"
1664 ac_cv_cxx_thread=yes
1665fi
1666
1667if test $ac_cv_cxx_thread = yes
1668then
1669 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1670 $CXX -c conftest.$ac_ext 2>&5
1671 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1672 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1673 then
1674 ac_cv_cxx_thread=yes
1675 else
1676 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001677 fi
1678 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001679fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001680AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001681fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001682CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001683
Fred Drakece81d592000-07-09 14:39:29 +00001684dnl # check for ANSI or K&R ("traditional") preprocessor
1685dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001686dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001687dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1688dnl int foo;
1689dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001690dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001691dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001692
Guido van Rossum627b2d71993-12-24 10:39:16 +00001693# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001694AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001695AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001696fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001697ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001698shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001699unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001700sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1701sys/lock.h sys/mkdev.h sys/modem.h \
Benjamin Peterson6b1c9092016-12-19 23:54:25 -08001702sys/param.h sys/poll.h sys/random.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001703sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001704sys/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 +00001705sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes3aa138f2013-06-18 13:25:24 +02001706bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001707AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001708AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001709
Martin v. Löwis11017b12006-01-14 18:12:57 +00001710# On Linux, netlink.h requires asm/types.h
1711AC_CHECK_HEADERS(linux/netlink.h,,,[
1712#ifdef HAVE_ASM_TYPES_H
1713#include <asm/types.h>
1714#endif
1715#ifdef HAVE_SYS_SOCKET_H
1716#include <sys/socket.h>
1717#endif
1718])
1719
Guido van Rossum627b2d71993-12-24 10:39:16 +00001720# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001721was_it_defined=no
1722AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001723AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1724 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1725])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001726AC_MSG_RESULT($was_it_defined)
1727
Neal Norwitz11690112002-07-30 01:08:28 +00001728# Check whether using makedev requires defining _OSF_SOURCE
1729AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001730AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001731#if defined(MAJOR_IN_MKDEV)
1732#include <sys/mkdev.h>
1733#elif defined(MAJOR_IN_SYSMACROS)
1734#include <sys/sysmacros.h>
1735#else
1736#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001737#endif ]], [[ makedev(0, 0) ]])],
1738[ac_cv_has_makedev=yes],
1739[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001740if test "$ac_cv_has_makedev" = "no"; then
1741 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001742 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001743#define _OSF_SOURCE 1
1744#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001745 ]], [[ makedev(0, 0) ]])],
1746[ac_cv_has_makedev=yes],
1747[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001748 if test "$ac_cv_has_makedev" = "yes"; then
1749 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1750 fi
1751fi
1752AC_MSG_RESULT($ac_cv_has_makedev)
1753if test "$ac_cv_has_makedev" = "yes"; then
1754 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1755fi
1756
Martin v. Löwis399a6892002-10-04 10:22:02 +00001757# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1758# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1759# defined, but the compiler does not support pragma redefine_extname,
1760# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1761# structures (such as rlimit64) without declaring them. As a
1762# work-around, disable LFS on such configurations
1763
1764use_lfs=yes
1765AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001766AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001767#define _LARGEFILE_SOURCE 1
1768#define _FILE_OFFSET_BITS 64
1769#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001770]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001771AC_MSG_RESULT($sol_lfs_bug)
1772if test "$sol_lfs_bug" = "yes"; then
1773 use_lfs=no
1774fi
1775
1776if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001777# Two defines needed to enable largefile support on various platforms
1778# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001779case $ac_sys_system/$ac_sys_release in
1780AIX*)
1781 AC_DEFINE(_LARGE_FILES, 1,
1782 [This must be defined on AIX systems to enable large file support.])
1783 ;;
1784esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001785AC_DEFINE(_LARGEFILE_SOURCE, 1,
1786[This must be defined on some systems to enable large file support.])
1787AC_DEFINE(_FILE_OFFSET_BITS, 64,
1788[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001789fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001790
Guido van Rossum300fda71996-08-19 21:58:16 +00001791# Add some code to confdefs.h so that the test for off_t works on SCO
1792cat >> confdefs.h <<\EOF
1793#if defined(SCO_DS)
1794#undef _OFF_T
1795#endif
1796EOF
1797
Guido van Rossumef2255b2000-03-10 22:30:29 +00001798# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001799AC_TYPE_MODE_T
1800AC_TYPE_OFF_T
1801AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001802AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001803AC_TYPE_SIZE_T
1804AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001805
1806# There are two separate checks for each of the exact-width integer types we
1807# need. First we check whether the type is available using the usual
1808# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1809# and <stdint.h> where available). We then also use the special type checks of
1810# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1811# directly, #define's uint32_t to be a suitable type.
1812
1813AC_CHECK_TYPE(uint32_t,
1814 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001815AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001816
1817AC_CHECK_TYPE(uint64_t,
1818 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001819AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001820
1821AC_CHECK_TYPE(int32_t,
1822 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001823AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001824
1825AC_CHECK_TYPE(int64_t,
1826 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001827AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001828
Christian Heimes951cc0f2008-01-31 23:08:23 +00001829AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001830 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001831
Guido van Rossumef2255b2000-03-10 22:30:29 +00001832# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001833# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001834AC_CHECK_SIZEOF(int, 4)
1835AC_CHECK_SIZEOF(long, 4)
1836AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001837AC_CHECK_SIZEOF(short, 2)
1838AC_CHECK_SIZEOF(float, 4)
1839AC_CHECK_SIZEOF(double, 8)
1840AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001841AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001842AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001843
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001844AC_MSG_CHECKING(for long long support)
1845have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001846AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001847 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1848 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001849],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001850AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001851if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001852AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001853fi
1854
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001855AC_MSG_CHECKING(for long double support)
1856have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001857AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001858 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1859 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001860],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001861AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001862if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001863AC_CHECK_SIZEOF(long double, 12)
1864fi
1865
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001866AC_MSG_CHECKING(for _Bool support)
1867have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001868AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001869 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1870 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001871],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001872AC_MSG_RESULT($have_c99_bool)
1873if test "$have_c99_bool" = yes ; then
1874AC_CHECK_SIZEOF(_Bool, 1)
1875fi
1876
Martin v. Löwisebe26702006-10-02 14:55:51 +00001877AC_CHECK_TYPES(uintptr_t,
1878 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001879 [], [#ifdef HAVE_STDINT_H
1880 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001881 #endif
1882 #ifdef HAVE_INTTYPES_H
1883 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001884 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001885
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001886AC_CHECK_SIZEOF(off_t, [], [
1887#ifdef HAVE_SYS_TYPES_H
1888#include <sys/types.h>
1889#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001890])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001891
1892AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001893if test "$have_long_long" = yes
1894then
1895if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001896 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001897 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1898 [Defined to enable large file support when an off_t is bigger than a long
1899 and long long is available and at least as big as an off_t. You may need
1900 to add some flags for configuration and compilation to enable this mode.
1901 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001902 AC_MSG_RESULT(yes)
1903else
1904 AC_MSG_RESULT(no)
1905fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001906else
1907 AC_MSG_RESULT(no)
1908fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001909
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001910AC_CHECK_SIZEOF(time_t, [], [
1911#ifdef HAVE_SYS_TYPES_H
1912#include <sys/types.h>
1913#endif
1914#ifdef HAVE_TIME_H
1915#include <time.h>
1916#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001917])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001918
Trent Mick635f6fb2000-08-23 21:33:05 +00001919# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001920ac_save_cc="$CC"
1921if test "$ac_cv_kpthread" = "yes"
1922then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001923elif test "$ac_cv_kthread" = "yes"
1924then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001925elif test "$ac_cv_pthread" = "yes"
1926then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001927fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001928AC_MSG_CHECKING(for pthread_t)
1929have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001930AC_COMPILE_IFELSE([
1931 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1932],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001933AC_MSG_RESULT($have_pthread_t)
1934if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001935 AC_CHECK_SIZEOF(pthread_t, [], [
1936#ifdef HAVE_PTHREAD_H
1937#include <pthread.h>
1938#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001939 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001940fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001941CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001942
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001943AC_MSG_CHECKING(for --enable-toolbox-glue)
1944AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001945 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001946
1947if test -z "$enable_toolbox_glue"
1948then
1949 case $ac_sys_system/$ac_sys_release in
1950 Darwin/*)
1951 enable_toolbox_glue="yes";;
1952 *)
1953 enable_toolbox_glue="no";;
1954 esac
1955fi
1956case "$enable_toolbox_glue" in
1957yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001958 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001959 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001960 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1961 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001962 ;;
1963*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001964 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001965 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001966 ;;
1967esac
1968AC_MSG_RESULT($enable_toolbox_glue)
1969
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001970
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001971AC_SUBST(OTHER_LIBTOOL_OPT)
1972case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001973 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001974 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1975 ;;
1976 Darwin/*)
1977 OTHER_LIBTOOL_OPT=""
1978 ;;
1979esac
1980
Ronald Oussoren25967582009-09-06 10:00:26 +00001981
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001982AC_SUBST(LIBTOOL_CRUFT)
1983case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001984 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001985 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1986 if test "${enable_universalsdk}"; then
1987 :
1988 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001989 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001990 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001991 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001992 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001993 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001994 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001995 if test ${gcc_version} '<' 4.0
1996 then
1997 LIBTOOL_CRUFT="-lcc_dynamic"
1998 else
1999 LIBTOOL_CRUFT=""
2000 fi
Matthias Klosec511b472010-05-08 11:01:39 +00002001 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00002002 #include <unistd.h>
2003 int main(int argc, char*argv[])
2004 {
2005 if (sizeof(long) == 4) {
2006 return 0;
2007 } else {
2008 return 1;
2009 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00002010 }
Matthias Klosec511b472010-05-08 11:01:39 +00002011 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00002012
2013 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002014 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002015 i386)
2016 MACOSX_DEFAULT_ARCH="i386"
2017 ;;
2018 ppc)
2019 MACOSX_DEFAULT_ARCH="ppc"
2020 ;;
2021 *)
2022 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2023 ;;
2024 esac
2025 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00002026 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00002027 i386)
2028 MACOSX_DEFAULT_ARCH="x86_64"
2029 ;;
2030 ppc)
2031 MACOSX_DEFAULT_ARCH="ppc64"
2032 ;;
2033 *)
2034 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
2035 ;;
2036 esac
2037
2038 #ARCH_RUN_32BIT="true"
2039 fi
2040
2041 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00002042 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002043 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002044esac
2045
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002046AC_MSG_CHECKING(for --enable-framework)
2047if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002048then
Skip Montanarodecc6a42003-01-01 20:07:49 +00002049 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002050 # -F. is needed to allow linking to the framework while
2051 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002052 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
2053 [Define if you want to produce an OpenStep/Rhapsody framework
2054 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002055 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00002056 if test $enable_shared = "yes"
2057 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00002058 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 +00002059 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002060else
2061 AC_MSG_RESULT(no)
2062fi
2063
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002064AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002065case $ac_sys_system/$ac_sys_release in
2066 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002067 AC_DEFINE(WITH_DYLD, 1,
2068 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
2069 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
2070 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002071 AC_MSG_RESULT(always on for Darwin)
2072 ;;
2073 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002074 AC_MSG_RESULT(no)
2075 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002076esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002077
Guido van Rossumac405f61994-09-12 10:56:06 +00002078# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00002079AC_SUBST(SO)
2080AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002081AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002082AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002083AC_SUBST(CCSHARED)
2084AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002085# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00002086# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002087AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00002088if test -z "$SO"
2089then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002090 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00002091 hp*|HP*)
2092 case `uname -m` in
2093 ia64) SO=.so;;
2094 *) SO=.sl;;
2095 esac
2096 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00002097 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002098 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00002099 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00002100else
2101 # this might also be a termcap variable, see #610332
2102 echo
2103 echo '====================================================================='
2104 echo '+ +'
2105 echo '+ WARNING: You have set SO in your environment. +'
2106 echo '+ Do you really mean to change the extension for shared libraries? +'
2107 echo '+ Continuing in 10 seconds to let you to ponder. +'
2108 echo '+ +'
2109 echo '====================================================================='
2110 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00002111fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002112AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00002113
Neal Norwitz58e28882006-05-19 07:00:58 +00002114AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00002115# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00002116# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002117# (Shared libraries in this instance are shared modules to be loaded into
2118# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002119AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002120if test -z "$LDSHARED"
2121then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002122 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002123 AIX*)
Martin Panterf75a2eb2016-11-20 09:31:41 +00002124 BLDSHARED="Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00002125 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002126 ;;
2127 BeOS*)
2128 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00002129 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002130 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002131 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00002132 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00002133 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002134 if test "$GCC" = "yes" ; then
2135 LDSHARED='$(CC) -shared'
2136 LDCXXSHARED='$(CXX) -shared'
2137 else
2138 LDSHARED='$(CC) -G'
2139 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00002140 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00002141 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002142 if test "$GCC" = "yes" ; then
2143 LDSHARED='$(CC) -shared'
2144 LDCXXSHARED='$(CXX) -shared'
2145 else
2146 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00002147 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00002148 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00002149 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002150 LDSHARED='$(CC) -bundle'
2151 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00002152 if test "$enable_framework" ; then
2153 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002154 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2155 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002156 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002157 else
2158 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00002159 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00002160 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00002161 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002162 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002163 LDSHARED='$(CC) -bundle'
2164 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002165 if test "$enable_framework" ; then
2166 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002167 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2168 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002169 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002170 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00002171 # No framework, use the Python app as bundle-loader
2172 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002173 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002174 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002175 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002176 Darwin/*)
2177 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2178 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002179
Ned Deilyc40b9032014-06-25 13:48:46 -07002180 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2181 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2182 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2183 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2184 if test ${dep_target_major} -eq 10 && \
2185 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002186 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002187 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002188 LDSHARED='$(CC) -bundle'
2189 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002190 if test "$enable_framework" ; then
2191 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002192 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2193 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002194 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002195 else
2196 # No framework, use the Python app as bundle-loader
2197 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2198 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002199 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002200 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002201 else
2202 # building for OS X 10.3 and later
2203 if test "${enable_universalsdk}"; then
2204 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2205 fi
2206 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2207 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2208 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002209 fi
2210 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002211 Linux*|GNU*|QNX*)
2212 LDSHARED='$(CC) -shared'
2213 LDCXXSHARED='$(CXX) -shared';;
2214 BSD/OS*/4*)
2215 LDSHARED="gcc -shared"
2216 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002217 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002218 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002219 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002220 LDSHARED='$(CC) -shared'
2221 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002222 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002223 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002224 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002225 OpenBSD*)
2226 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2227 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002228 LDSHARED='$(CC) -shared $(CCSHARED)'
2229 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002230 else
2231 case `uname -r` in
2232 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2233 LDSHARED="ld -Bshareable ${LDFLAGS}"
2234 ;;
2235 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002236 LDSHARED='$(CC) -shared $(CCSHARED)'
2237 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002238 ;;
2239 esac
2240 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002241 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002242 LDSHARED='$(CC) -shared'
2243 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002244 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002245 if test "$GCC" = "yes" ; then
2246 LDSHARED='$(CC) -shared'
2247 LDCXXSHARED='$(CXX) -shared'
2248 else
2249 LDSHARED='$(CC) -G'
2250 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002251 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002252 SCO_SV*)
2253 LDSHARED='$(CC) -Wl,-G,-Bexport'
2254 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2255 CYGWIN*)
2256 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2257 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2258 atheos*)
2259 LDSHARED="gcc -shared"
2260 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002261 *) LDSHARED="ld";;
2262 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002263fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002264AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002265LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002266BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002267# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002268# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002269AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002270if test -z "$CCSHARED"
2271then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002272 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002273 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002274 then CCSHARED="-fPIC";
2275 elif test `uname -p` = sparc;
2276 then CCSHARED="-xcode=pic32";
2277 else CCSHARED="-Kpic";
2278 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002279 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002280 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002281 else CCSHARED="+z";
2282 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002283 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002284 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002285 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002286 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002287 if test "$GCC" = "yes"
2288 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002289 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002290 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002291 SCO_SV*)
2292 if test "$GCC" = "yes"
2293 then CCSHARED="-fPIC"
2294 else CCSHARED="-Kpic -belf"
2295 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002296 IRIX*/6*) case $CC in
2297 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002298 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002299 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002300 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002301 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002302fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002303AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002304# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002305# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002306AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002307if test -z "$LINKFORSHARED"
2308then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002309 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002310 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002311 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002312 LINKFORSHARED="-Wl,-E -Wl,+s";;
2313# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002314 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002315 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002316 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002317 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002318 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2319 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002320 # not used by the core itself but which needs to be in the core so
2321 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002322 # -prebind is no longer used, because it actually seems to give a
2323 # slowdown in stead of a speedup, maybe due to the large number of
2324 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002325
2326 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002327 if test "$enable_framework"
2328 then
Jack Jansenda49e192005-01-07 13:08:22 +00002329 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002330 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002331 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002332 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002333 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002334 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002335 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002336 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2337 then
2338 LINKFORSHARED="-Wl,--export-dynamic"
2339 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002340 SunOS/5*) case $CC in
2341 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002342 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002343 then
2344 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002345 fi;;
2346 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002347 CYGWIN*)
2348 if test $enable_shared = "no"
2349 then
2350 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2351 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002352 QNX*)
2353 # -Wl,-E causes the symbols to be added to the dynamic
2354 # symbol table so that they can be found when a module
2355 # is loaded. -N 2048K causes the stack size to be set
2356 # to 2048 kilobytes so that the stack doesn't overflow
2357 # when running test_compile.py.
2358 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002359 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002360fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002361AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002362
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002363
Neil Schemenauer61c51152001-01-26 16:18:16 +00002364AC_SUBST(CFLAGSFORSHARED)
2365AC_MSG_CHECKING(CFLAGSFORSHARED)
2366if test ! "$LIBRARY" = "$LDLIBRARY"
2367then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002368 case $ac_sys_system in
2369 CYGWIN*)
2370 # Cygwin needs CCSHARED when building extension DLLs
2371 # but not when building the interpreter DLL.
2372 CFLAGSFORSHARED='';;
2373 *)
2374 CFLAGSFORSHARED='$(CCSHARED)'
2375 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002376fi
2377AC_MSG_RESULT($CFLAGSFORSHARED)
2378
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002379# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2380# library (with --enable-shared).
2381# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002382# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2383# if it is not required, since it creates a dependency of the shared library
2384# to LIBS. This, in turn, means that applications linking the shared libpython
2385# don't need to link LIBS explicitly. The default should be only changed
2386# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002387AC_SUBST(SHLIBS)
2388AC_MSG_CHECKING(SHLIBS)
2389case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002390 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002391 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002392esac
2393AC_MSG_RESULT($SHLIBS)
2394
2395
Guido van Rossum627b2d71993-12-24 10:39:16 +00002396# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002397AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2398AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis519adae2003-09-20 10:47:47 +00002399
Skip Montanaro4d756af2008-12-01 01:55:22 +00002400# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002401if test "$with_threads" = "yes" -o -z "$with_threads"; then
2402 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2403 # posix4 on Solaris 2.6
2404 # pthread (first!) on Linux
2405fi
2406
Martin v. Löwis19d17342003-06-14 21:03:05 +00002407# check if we need libintl for locale functions
2408AC_CHECK_LIB(intl, textdomain,
2409 AC_DEFINE(WITH_LIBINTL, 1,
2410 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002411
2412# checks for system dependent C++ extensions support
2413case "$ac_sys_system" in
2414 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002415 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002416 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002417 [[loadAndInit("", 0, "")]])
2418 ],[
2419 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002420 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2421 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002422 AC_MSG_RESULT(yes)
2423 ],[
2424 AC_MSG_RESULT(no)
2425 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002426 *) ;;
2427esac
2428
Guido van Rossum70c7f481998-03-26 18:44:10 +00002429# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002430# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002431AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002432AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002433
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002434case "$ac_sys_system" in
2435BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002436AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2437;;
2438esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002439
Guido van Rossumc5a39031996-07-31 17:35:03 +00002440AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002441AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002442 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002443[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002444AC_MSG_RESULT($withval)
2445LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002446],
2447[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002448
Benjamin Peterson64e8f6e2014-12-15 00:00:23 -05002449PKG_PROG_PKG_CONFIG
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002450
Benjamin Peterson2c196742009-12-31 03:17:18 +00002451# Check for use of the system expat library
2452AC_MSG_CHECKING(for --with-system-expat)
2453AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002454 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2455 [],
2456 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002457
2458AC_MSG_RESULT($with_system_expat)
2459
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002460# Check for use of the system libffi library
2461AC_MSG_CHECKING(for --with-system-ffi)
2462AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002463 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2464 [],
2465 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002466
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002467if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002468 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2469else
2470 LIBFFI_INCLUDEDIR=""
2471fi
2472AC_SUBST(LIBFFI_INCLUDEDIR)
2473
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002474AC_MSG_RESULT($with_system_ffi)
2475
Ned Deilya2a9f572013-10-25 00:30:10 -07002476# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2477AC_SUBST(TCLTK_INCLUDES)
2478AC_SUBST(TCLTK_LIBS)
2479AC_MSG_CHECKING(for --with-tcltk-includes)
2480AC_ARG_WITH(tcltk-includes,
2481 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2482 [],
2483 [with_tcltk_includes="default"])
2484AC_MSG_RESULT($with_tcltk_includes)
2485AC_MSG_CHECKING(for --with-tcltk-libs)
2486AC_ARG_WITH(tcltk-libs,
2487 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2488 [],
2489 [with_tcltk_libs="default"])
2490AC_MSG_RESULT($with_tcltk_libs)
2491if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2492then
2493 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2494 then
2495 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2496 fi
2497 TCLTK_INCLUDES=""
2498 TCLTK_LIBS=""
2499else
2500 TCLTK_INCLUDES="$with_tcltk_includes"
2501 TCLTK_LIBS="$with_tcltk_libs"
2502fi
2503
Matthias Klose10cbe482009-04-29 17:18:19 +00002504# Check for --with-dbmliborder
2505AC_MSG_CHECKING(for --with-dbmliborder)
2506AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002507 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 +00002508[
2509if test x$with_dbmliborder = xyes
2510then
2511AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2512else
2513 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2514 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2515 then
2516 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2517 fi
2518 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002519fi])
2520AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002521
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002522# Determine if signalmodule should be used.
2523AC_SUBST(USE_SIGNAL_MODULE)
2524AC_SUBST(SIGNAL_OBJS)
2525AC_MSG_CHECKING(for --with-signal-module)
2526AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002527 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002528
2529if test -z "$with_signal_module"
2530then with_signal_module="yes"
2531fi
2532AC_MSG_RESULT($with_signal_module)
2533
2534if test "${with_signal_module}" = "yes"; then
2535 USE_SIGNAL_MODULE=""
2536 SIGNAL_OBJS=""
2537else
2538 USE_SIGNAL_MODULE="#"
2539 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2540fi
2541
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002542# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002543AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002544USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002545
Guido van Rossum54d93d41997-01-22 20:51:58 +00002546AC_MSG_CHECKING(for --with-dec-threads)
2547AC_SUBST(LDLAST)
2548AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002549 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002550[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002551AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002552LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002553if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002554 with_thread="$withval";
2555fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002556[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002557
Martin v. Löwis11437992002-04-12 09:54:03 +00002558# Templates for things AC_DEFINEd more than once.
2559# For a single AC_DEFINE, no template is needed.
2560AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2561AH_TEMPLATE(_REENTRANT,
2562 [Define to force use of thread-safe errno, h_errno, and other functions])
2563AH_TEMPLATE(WITH_THREAD,
2564 [Define if you want to compile in rudimentary thread support])
2565
Guido van Rossum54d93d41997-01-22 20:51:58 +00002566AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002567dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002568AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002569 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002570
Barry Warsawc0d24d82000-06-29 16:12:00 +00002571# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002572dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002573AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002574 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002575 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002576
2577if test -z "$with_threads"
2578then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002579fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002580AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002581
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002582AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002583if test "$with_threads" = "no"
2584then
2585 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002586elif test "$ac_cv_pthread_is_default" = yes
2587then
2588 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002589 # Defining _REENTRANT on system with POSIX threads should not hurt.
2590 AC_DEFINE(_REENTRANT)
2591 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002592 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002593elif test "$ac_cv_kpthread" = "yes"
2594then
2595 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002596 if test "$ac_cv_cxx_thread" = "yes"; then
2597 CXX="$CXX -Kpthread"
2598 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002599 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002600 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002601 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002602elif test "$ac_cv_kthread" = "yes"
2603then
2604 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002605 if test "$ac_cv_cxx_thread" = "yes"; then
2606 CXX="$CXX -Kthread"
2607 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002608 AC_DEFINE(WITH_THREAD)
2609 posix_threads=yes
2610 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002611elif test "$ac_cv_pthread" = "yes"
2612then
2613 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002614 if test "$ac_cv_cxx_thread" = "yes"; then
2615 CXX="$CXX -pthread"
2616 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002617 AC_DEFINE(WITH_THREAD)
2618 posix_threads=yes
2619 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002620else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002621 if test ! -z "$with_threads" -a -d "$with_threads"
2622 then LDFLAGS="$LDFLAGS -L$with_threads"
2623 fi
2624 if test ! -z "$withval" -a -d "$withval"
2625 then LDFLAGS="$LDFLAGS -L$withval"
2626 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002627
2628 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002629 # define _POSIX_THREADS in unistd.h. Some apparently don't
2630 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002631 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2632 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002633 [
2634#include <unistd.h>
2635#ifdef _POSIX_THREADS
2636yes
2637#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002638 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2639 AC_MSG_RESULT($unistd_defines_pthreads)
2640
Martin v. Löwis130fb172001-07-19 11:00:41 +00002641 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002642 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2643 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002644 AC_DEFINE(HURD_C_THREADS, 1,
2645 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002646 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002647 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002648 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2649 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002650 AC_DEFINE(MACH_C_THREADS, 1,
2651 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002652 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002653 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002654 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002655 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002656 [AC_MSG_RESULT($withval)
2657 AC_DEFINE([WITH_THREAD])
2658 AC_DEFINE([HAVE_PTH], 1,
2659 [Define if you have GNU PTH threads.])
2660 LIBS="-lpth $LIBS"
2661 THREADOBJ="Python/thread.o"],
2662 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002663
2664 # Just looking for pthread_create in libpthread is not enough:
2665 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2666 # So we really have to include pthread.h, and then link.
2667 _libs=$LIBS
2668 LIBS="$LIBS -lpthread"
2669 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002670 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2671#include <stdio.h>
2672#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002673
Matthias Klosec511b472010-05-08 11:01:39 +00002674void * start_routine (void *arg) { exit (0); }]], [[
2675pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002676 AC_MSG_RESULT(yes)
2677 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002678 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002679 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002680 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002681 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002682 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002683 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002684 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2685 AC_DEFINE(ATHEOS_THREADS, 1,
2686 [Define this if you have AtheOS threads.])
2687 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002688 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002689 AC_DEFINE(BEOS_THREADS, 1,
2690 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002691 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002692 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002693 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002694 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002695 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002696 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002697 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002698 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002699 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002700 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002701 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002702 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002703 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002704 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002705 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002706 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002707 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002708 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002709 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002710
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002711 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2712 LIBS="$LIBS -lmpc"
2713 THREADOBJ="Python/thread.o"
2714 USE_THREAD_MODULE=""])
2715
2716 if test "$posix_threads" != "yes"; then
2717 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2718 LIBS="$LIBS -lthread"
2719 THREADOBJ="Python/thread.o"
2720 USE_THREAD_MODULE=""])
2721 fi
2722
2723 if test "$USE_THREAD_MODULE" != "#"
2724 then
2725 # If the above checks didn't disable threads, (at least) OSF1
2726 # needs this '-threads' argument during linking.
2727 case $ac_sys_system in
2728 OSF1) LDLAST=-threads;;
2729 esac
2730 fi
2731fi
2732
2733if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002734 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002735 AC_DEFINE(_POSIX_THREADS, 1,
2736 [Define if you have POSIX threads,
2737 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002738 fi
2739
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002740 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2741 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002742 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002743 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002744 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002745 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002746 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002747 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002748 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002749 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002750 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002751 esac
2752
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002753 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2754 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002755 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2756 #include <stdio.h>
2757 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002758 void *foo(void *parm) {
2759 return NULL;
2760 }
2761 main() {
2762 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002763 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002764 if (pthread_attr_init(&attr)) exit(-1);
2765 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002766 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002767 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002768 }]])],
2769 [ac_cv_pthread_system_supported=yes],
2770 [ac_cv_pthread_system_supported=no],
2771 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002772 ])
2773 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2774 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002775 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002776 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002777 AC_CHECK_FUNCS(pthread_sigmask,
2778 [case $ac_sys_system in
2779 CYGWIN*)
2780 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2781 [Define if pthread_sigmask() does not work on your system.])
2782 ;;
2783 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002784 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002785fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002786
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002787
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002788# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002789AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002790AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002791AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002792[ --enable-ipv6 Enable ipv6 (with ipv4) support
2793 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002794[ case "$enableval" in
2795 no)
2796 AC_MSG_RESULT(no)
2797 ipv6=no
2798 ;;
2799 *) AC_MSG_RESULT(yes)
2800 AC_DEFINE(ENABLE_IPV6)
2801 ipv6=yes
2802 ;;
2803 esac ],
2804
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002805[
2806dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002807 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002808#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002809#include <sys/socket.h>]],
2810[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002811 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002812 ipv6=yes
2813],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002814 AC_MSG_RESULT(no)
2815 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002816])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002817
2818if test "$ipv6" = "yes"; then
2819 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002820 AC_COMPILE_IFELSE([
2821 AC_LANG_PROGRAM([[#include <sys/types.h>
2822#include <netinet/in.h>]],
2823 [[struct sockaddr_in6 x;
2824 x.sin6_scope_id;]])
2825 ],[
2826 AC_MSG_RESULT(yes)
2827 ipv6=yes
2828 ],[
2829 AC_MSG_RESULT(no, IPv6 disabled)
2830 ipv6=no
2831 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002832fi
2833
2834if test "$ipv6" = "yes"; then
2835 AC_DEFINE(ENABLE_IPV6)
2836fi
2837])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002838
2839ipv6type=unknown
2840ipv6lib=none
2841ipv6trylibc=no
2842
2843if test "$ipv6" = "yes"; then
2844 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002845 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2846 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002847 case $i in
2848 inria)
2849 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002850 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002851#include <netinet/in.h>
2852#ifdef IPV6_INRIA_VERSION
2853yes
2854#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002855 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002856 ;;
2857 kame)
2858 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002859 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002860#include <netinet/in.h>
2861#ifdef __KAME__
2862yes
2863#endif],
2864 [ipv6type=$i;
2865 ipv6lib=inet6
2866 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002867 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002868 ;;
2869 linux-glibc)
2870 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002871 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002872#include <features.h>
2873#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2874yes
2875#endif],
2876 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002877 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002878 ;;
2879 linux-inet6)
2880 dnl http://www.v6.linux.or.jp/
2881 if test -d /usr/inet6; then
2882 ipv6type=$i
2883 ipv6lib=inet6
2884 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002885 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002886 fi
2887 ;;
2888 solaris)
2889 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002890 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002891 ipv6type=$i
2892 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002893 fi
2894 fi
2895 ;;
2896 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002897 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002898#include <sys/param.h>
2899#ifdef _TOSHIBA_INET6
2900yes
2901#endif],
2902 [ipv6type=$i;
2903 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002904 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002905 ;;
2906 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002907 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002908#include </usr/local/v6/include/sys/v6config.h>
2909#ifdef __V6D__
2910yes
2911#endif],
2912 [ipv6type=$i;
2913 ipv6lib=v6;
2914 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002915 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002916 ;;
2917 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002918 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002919#include <sys/param.h>
2920#ifdef _ZETA_MINAMI_INET6
2921yes
2922#endif],
2923 [ipv6type=$i;
2924 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002925 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002926 ;;
2927 esac
2928 if test "$ipv6type" != "unknown"; then
2929 break
2930 fi
2931 done
2932 AC_MSG_RESULT($ipv6type)
2933fi
2934
2935if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2936 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2937 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2938 echo "using lib$ipv6lib"
2939 else
2940 if test $ipv6trylibc = "yes"; then
2941 echo "using libc"
2942 else
2943 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2944 echo "You need to fetch lib$ipv6lib.a from appropriate"
2945 echo 'ipv6 kit and compile beforehand.'
2946 exit 1
2947 fi
2948 fi
2949fi
2950
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002951AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002952AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002953 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002954],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002955 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002956 AC_MSG_RESULT(yes)
2957],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002958 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002959])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002960
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002961# Check for --with-doc-strings
2962AC_MSG_CHECKING(for --with-doc-strings)
2963AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002964 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002965
2966if test -z "$with_doc_strings"
2967then with_doc_strings="yes"
2968fi
2969if test "$with_doc_strings" != "no"
2970then
2971 AC_DEFINE(WITH_DOC_STRINGS, 1,
2972 [Define if you want documentation strings in extension modules])
2973fi
2974AC_MSG_RESULT($with_doc_strings)
2975
Neil Schemenauera35c6882001-02-27 04:45:05 +00002976# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002977AC_MSG_CHECKING(for --with-tsc)
2978AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002979 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002980if test "$withval" != no
2981then
2982 AC_DEFINE(WITH_TSC, 1,
2983 [Define to profile with the Pentium timestamp counter])
2984 AC_MSG_RESULT(yes)
2985else AC_MSG_RESULT(no)
2986fi],
2987[AC_MSG_RESULT(no)])
2988
2989# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002990AC_MSG_CHECKING(for --with-pymalloc)
2991AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002992 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002993
2994if test -z "$with_pymalloc"
2995then with_pymalloc="yes"
2996fi
2997if test "$with_pymalloc" != "no"
2998then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002999 AC_DEFINE(WITH_PYMALLOC, 1,
3000 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00003001fi
3002AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00003003
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003004# Check for Valgrind support
3005AC_MSG_CHECKING([for --with-valgrind])
3006AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00003007 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00003008 with_valgrind=no)
3009AC_MSG_RESULT([$with_valgrind])
3010if test "$with_valgrind" != no; then
3011 AC_CHECK_HEADER([valgrind/valgrind.h],
3012 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
3013 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
3014 )
3015fi
3016
Barry Warsawef82cd72000-06-30 16:21:01 +00003017# Check for --with-wctype-functions
3018AC_MSG_CHECKING(for --with-wctype-functions)
3019AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00003020 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003021[
Barry Warsawef82cd72000-06-30 16:21:01 +00003022if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003023then
3024 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
3025 [Define if you want wctype.h functions to be used instead of the
3026 one supplied by Python itself. (see Include/unicodectype.h).])
3027 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00003028else AC_MSG_RESULT(no)
3029fi],
3030[AC_MSG_RESULT(no)])
3031
Guido van Rossum68242b51996-05-28 22:53:03 +00003032# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003033AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00003034DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003035
Guido van Rossume97ee181999-12-20 21:27:22 +00003036# the dlopen() function means we might want to use dynload_shlib.o. some
3037# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00003038AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00003039
3040# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
3041# loading of modules.
3042AC_SUBST(DYNLOADFILE)
3043AC_MSG_CHECKING(DYNLOADFILE)
3044if test -z "$DYNLOADFILE"
3045then
3046 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00003047 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
3048 if test "$ac_cv_func_dlopen" = yes
3049 then DYNLOADFILE="dynload_shlib.o"
3050 else DYNLOADFILE="dynload_aix.o"
3051 fi
3052 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00003053 BeOS*) DYNLOADFILE="dynload_beos.o";;
3054 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00003055 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
3056 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00003057 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00003058 *)
3059 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
3060 # out any dynamic loading
3061 if test "$ac_cv_func_dlopen" = yes
3062 then DYNLOADFILE="dynload_shlib.o"
3063 else DYNLOADFILE="dynload_stub.o"
3064 fi
3065 ;;
3066 esac
3067fi
3068AC_MSG_RESULT($DYNLOADFILE)
3069if test "$DYNLOADFILE" != "dynload_stub.o"
3070then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003071 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
3072 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00003073fi
3074
Jack Jansenc49e5b72001-06-19 15:00:23 +00003075# MACHDEP_OBJS can be set to platform-specific object files needed by Python
3076
3077AC_SUBST(MACHDEP_OBJS)
3078AC_MSG_CHECKING(MACHDEP_OBJS)
3079if test -z "$MACHDEP_OBJS"
3080then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003081 MACHDEP_OBJS=$extra_machdep_objs
3082else
3083 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00003084fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003085AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00003086
Guido van Rossum627b2d71993-12-24 10:39:16 +00003087# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00003088AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
3089 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00003090 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Benjamin Peterson27c269a2014-12-26 11:09:00 -06003091 getentropy \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003092 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05003093 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00003094 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00003095 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00003096 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
3097 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00003098 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003099 setlocale setregid setreuid setresuid setresgid \
3100 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00003101 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00003102 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00003103 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003104
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003105# For some functions, having a definition is not sufficient, since
3106# we want to take their address.
3107AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00003108AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
3109 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
3110 AC_MSG_RESULT(yes)],
3111 [AC_MSG_RESULT(no)
3112])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003113AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00003114AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
3115 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
3116 AC_MSG_RESULT(yes)],
3117 [AC_MSG_RESULT(no)
3118])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003119AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00003120AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
3121 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
3122 AC_MSG_RESULT(yes)],
3123 [AC_MSG_RESULT(no)
3124])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003125AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00003126AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
3127 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
3128 AC_MSG_RESULT(yes)],
3129 [AC_MSG_RESULT(no)
3130])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003131AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00003132AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
3133 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
3134 AC_MSG_RESULT(yes)],
3135 [AC_MSG_RESULT(no)
3136])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003137AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00003138AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
3139 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
3140 AC_MSG_RESULT(yes)],
3141 [AC_MSG_RESULT(no)
3142])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003143AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00003144AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
3145 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
3146 AC_MSG_RESULT(yes)],
3147 [AC_MSG_RESULT(no)
3148])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003149AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00003150AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003151#include <sys/types.h>
3152#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003153 ]], [[int x=kqueue()]])],
3154 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
3155 AC_MSG_RESULT(yes)],
3156 [AC_MSG_RESULT(no)
3157])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003158# On some systems (eg. FreeBSD 5), we would find a definition of the
3159# functions ctermid_r, setgroups in the library, but no prototype
3160# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
3161# address to avoid compiler warnings and potential miscompilations
3162# because of the missing prototypes.
3163
3164AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00003165AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00003166#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003167]], [[void* p = ctermid_r]])],
3168 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3169 AC_MSG_RESULT(yes)],
3170 [AC_MSG_RESULT(no)
3171])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003172
Antoine Pitroub170f172010-09-10 18:47:36 +00003173AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3174 [AC_COMPILE_IFELSE(
3175 [AC_LANG_PROGRAM(
3176 [#include <sys/file.h>],
3177 [void* p = flock]
3178 )],
3179 [ac_cv_flock_decl=yes],
3180 [ac_cv_flock_decl=no]
3181 )
Matthias Klosec511b472010-05-08 11:01:39 +00003182])
Antoine Pitroub170f172010-09-10 18:47:36 +00003183if test "x${ac_cv_flock_decl}" = xyes; then
3184 AC_CHECK_FUNCS(flock,,
3185 AC_CHECK_LIB(bsd,flock,
3186 [AC_DEFINE(HAVE_FLOCK)
3187 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3188 ])
3189 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003190fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003191
3192AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003193AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003194#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003195]], [[void* p = getpagesize]])],
3196 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3197 AC_MSG_RESULT(yes)],
3198 [AC_MSG_RESULT(no)
3199])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003200
Charles-François Natali93a11752011-11-27 13:01:35 +01003201AC_MSG_CHECKING(for broken unsetenv)
3202AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3203#include <stdlib.h>
3204]], [[int res = unsetenv("DUMMY")]])],
3205 [AC_MSG_RESULT(no)],
3206 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3207 AC_MSG_RESULT(yes)
3208])
3209
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003210dnl check for true
3211AC_CHECK_PROGS(TRUE, true, /bin/true)
3212
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003213dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3214dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003215AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003216 AC_CHECK_LIB(resolv, inet_aton)
3217)
3218
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003219# On Tru64, chflags seems to be present, but calling it will
3220# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003221AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003222AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003223#include <sys/stat.h>
3224#include <unistd.h>
3225int main(int argc, char*argv[])
3226{
3227 if(chflags(argv[0], 0) != 0)
3228 return 1;
3229 return 0;
3230}
Ned Deily43e10542011-06-27 23:41:53 -07003231]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003232[ac_cv_have_chflags=yes],
3233[ac_cv_have_chflags=no],
3234[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003235])
3236if test "$ac_cv_have_chflags" = cross ; then
3237 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3238fi
3239if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003240 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003241fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003242
Gregory P. Smithbb213892009-11-02 01:37:37 +00003243AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003244AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003245#include <sys/stat.h>
3246#include <unistd.h>
3247int main(int argc, char*argv[])
3248{
3249 if(lchflags(argv[0], 0) != 0)
3250 return 1;
3251 return 0;
3252}
Ned Deily43e10542011-06-27 23:41:53 -07003253]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003254])
3255if test "$ac_cv_have_lchflags" = cross ; then
3256 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3257fi
3258if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003259 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003260fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003261
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003262dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003263dnl
3264dnl On MacOSX the linker will search for dylibs on the entire linker path
3265dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3266dnl to revert to a more traditional unix behaviour and make it possible to
3267dnl override the system libz with a local static library of libz. Temporarily
3268dnl add that flag to our CFLAGS as well to ensure that we check the version
3269dnl of libz that will be used by setup.py.
3270dnl The -L/usr/local/lib is needed as wel to get the same compilation
3271dnl environment as setup.py (and leaving it out can cause configure to use the
3272dnl wrong version of the library)
3273case $ac_sys_system/$ac_sys_release in
3274Darwin/*)
3275 _CUR_CFLAGS="${CFLAGS}"
3276 _CUR_LDFLAGS="${LDFLAGS}"
3277 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3278 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3279 ;;
3280esac
3281
Matthias Klose5183ebd2010-04-24 16:38:36 +00003282AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003283
Ronald Oussorenf8752642006-07-06 10:13:35 +00003284case $ac_sys_system/$ac_sys_release in
3285Darwin/*)
3286 CFLAGS="${_CUR_CFLAGS}"
3287 LDFLAGS="${_CUR_LDFLAGS}"
3288 ;;
3289esac
3290
Martin v. Löwise9416172003-05-03 10:12:45 +00003291AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003292AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003293#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003294]], [[void* p = hstrerror; hstrerror(0)]])],
3295 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3296 AC_MSG_RESULT(yes)],
3297 [AC_MSG_RESULT(no)
3298])
Martin v. Löwise9416172003-05-03 10:12:45 +00003299
3300AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003301AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003302#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003303#include <sys/socket.h>
3304#include <netinet/in.h>
3305#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003306]], [[void* p = inet_aton;inet_aton(0,0)]])],
3307 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3308 AC_MSG_RESULT(yes)],
3309 [AC_MSG_RESULT(no)
3310])
Martin v. Löwise9416172003-05-03 10:12:45 +00003311
3312AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003313AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003314#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003315#include <sys/socket.h>
3316#include <netinet/in.h>
3317#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003318]], [[void* p = inet_pton]])],
3319 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3320 AC_MSG_RESULT(yes)],
3321 [AC_MSG_RESULT(no)
3322])
Martin v. Löwise9416172003-05-03 10:12:45 +00003323
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003324# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003325AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003326AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003327#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003328#ifdef HAVE_GRP_H
3329#include <grp.h>
3330#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003331]], [[void* p = setgroups]])],
3332 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3333 AC_MSG_RESULT(yes)],
3334 [AC_MSG_RESULT(no)
3335])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003336
Fred Drake8cef4cf2000-06-28 16:40:38 +00003337# check for openpty and forkpty
3338
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003339AC_CHECK_FUNCS(openpty,,
3340 AC_CHECK_LIB(util,openpty,
3341 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3342 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3343 )
3344)
3345AC_CHECK_FUNCS(forkpty,,
3346 AC_CHECK_LIB(util,forkpty,
3347 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3348 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3349 )
3350)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003351
Brett Cannonaa5778d2008-03-18 04:09:00 +00003352# Stuff for expat.
3353AC_CHECK_FUNCS(memmove)
3354
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003355# check for long file support functions
3356AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3357
Brett Cannonaa5778d2008-03-18 04:09:00 +00003358AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003359AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003360 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3361 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3362 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003363)
Jack Jansen150753c2003-03-29 22:07:47 +00003364AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003365 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3366 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3367 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003368)
3369AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003370 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3371 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3372 [],
3373 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3374 [Define if gettimeofday() does not have second (timezone) argument
3375 This is the case on Motorola V4 (R40V4.2)])
3376 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003377)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003378
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003379AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003380AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003381#if defined(MAJOR_IN_MKDEV)
3382#include <sys/mkdev.h>
3383#elif defined(MAJOR_IN_SYSMACROS)
3384#include <sys/sysmacros.h>
3385#else
3386#include <sys/types.h>
3387#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003388]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003389 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003390]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003391 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3392 [Define to 1 if you have the device macros.])
3393 AC_MSG_RESULT(yes)
3394],[
3395 AC_MSG_RESULT(no)
3396])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003397
3398# On OSF/1 V5.1, getaddrinfo is available, but a define
3399# for [no]getaddrinfo in netdb.h.
3400AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003401AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003402#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003403#include <sys/socket.h>
3404#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003405#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003406]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3407[have_getaddrinfo=yes],
3408[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003409AC_MSG_RESULT($have_getaddrinfo)
3410if test $have_getaddrinfo = yes
3411then
3412 AC_MSG_CHECKING(getaddrinfo bug)
3413 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003414 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003415#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003416#include <sys/types.h>
3417#include <netdb.h>
3418#include <string.h>
3419#include <sys/socket.h>
3420#include <netinet/in.h>
3421
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003422int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003423{
3424 int passive, gaierr, inet4 = 0, inet6 = 0;
3425 struct addrinfo hints, *ai, *aitop;
3426 char straddr[INET6_ADDRSTRLEN], strport[16];
3427
3428 for (passive = 0; passive <= 1; passive++) {
3429 memset(&hints, 0, sizeof(hints));
3430 hints.ai_family = AF_UNSPEC;
3431 hints.ai_flags = passive ? AI_PASSIVE : 0;
3432 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003433 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003434 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3435 (void)gai_strerror(gaierr);
3436 goto bad;
3437 }
3438 for (ai = aitop; ai; ai = ai->ai_next) {
3439 if (ai->ai_addr == NULL ||
3440 ai->ai_addrlen == 0 ||
3441 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3442 straddr, sizeof(straddr), strport, sizeof(strport),
3443 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3444 goto bad;
3445 }
3446 switch (ai->ai_family) {
3447 case AF_INET:
3448 if (strcmp(strport, "54321") != 0) {
3449 goto bad;
3450 }
3451 if (passive) {
3452 if (strcmp(straddr, "0.0.0.0") != 0) {
3453 goto bad;
3454 }
3455 } else {
3456 if (strcmp(straddr, "127.0.0.1") != 0) {
3457 goto bad;
3458 }
3459 }
3460 inet4++;
3461 break;
3462 case AF_INET6:
3463 if (strcmp(strport, "54321") != 0) {
3464 goto bad;
3465 }
3466 if (passive) {
3467 if (strcmp(straddr, "::") != 0) {
3468 goto bad;
3469 }
3470 } else {
3471 if (strcmp(straddr, "::1") != 0) {
3472 goto bad;
3473 }
3474 }
3475 inet6++;
3476 break;
3477 case AF_UNSPEC:
3478 goto bad;
3479 break;
3480 default:
3481 /* another family support? */
3482 break;
3483 }
3484 }
Benjamin Petersond34677c2016-09-06 15:54:24 -07003485 freeaddrinfo(aitop);
3486 aitop = NULL;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003487 }
3488
3489 if (!(inet4 == 0 || inet4 == 2))
3490 goto bad;
3491 if (!(inet6 == 0 || inet6 == 2))
3492 goto bad;
3493
3494 if (aitop)
3495 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003496 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003497
3498 bad:
3499 if (aitop)
3500 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003501 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003502}
Matthias Klosec511b472010-05-08 11:01:39 +00003503]]])],
3504[ac_cv_buggy_getaddrinfo=no],
3505[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003506[
3507if test "${enable_ipv6+set}" = set; then
3508 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3509else
3510 ac_cv_buggy_getaddrinfo=yes
3511fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003512fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003513
Benjamin Peterson75fed812010-11-01 01:47:19 +00003514AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3515
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003516if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003517then
3518 if test $ipv6 = yes
3519 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003520 echo 'Fatal: You must get working getaddrinfo() function.'
3521 echo ' or you can specify "--disable-ipv6"'.
3522 exit 1
3523 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003524else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003525 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003526fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003527
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003528AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003529
Guido van Rossum627b2d71993-12-24 10:39:16 +00003530# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003531AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003532AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003533AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003534AC_CHECK_MEMBERS([struct stat.st_rdev])
3535AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003536AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003537AC_CHECK_MEMBERS([struct stat.st_gen])
3538AC_CHECK_MEMBERS([struct stat.st_birthtime])
Martin Pantera45120d2016-03-18 02:36:41 +00003539AC_CHECK_MEMBERS([struct stat.st_blocks])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003540
3541AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003542AC_CACHE_VAL(ac_cv_header_time_altzone,[
3543 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3544 [ac_cv_header_time_altzone=yes],
3545 [ac_cv_header_time_altzone=no])
3546 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003547AC_MSG_RESULT($ac_cv_header_time_altzone)
3548if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003549 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003550fi
3551
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003552was_it_defined=no
3553AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003554AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003555#include <sys/types.h>
3556#include <sys/select.h>
3557#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003558]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003559 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3560 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3561 (which you can't on SCO ODT 3.0).])
3562 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003563],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003564AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003565
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003566AC_MSG_CHECKING(for addrinfo)
3567AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003568AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3569 [ac_cv_struct_addrinfo=yes],
3570 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003571AC_MSG_RESULT($ac_cv_struct_addrinfo)
3572if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003573 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003574fi
3575
3576AC_MSG_CHECKING(for sockaddr_storage)
3577AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003578AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003579# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003580# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3581 [ac_cv_struct_sockaddr_storage=yes],
3582 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003583AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3584if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003585 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003586fi
3587
Guido van Rossum627b2d71993-12-24 10:39:16 +00003588# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003589
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003590AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003591AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003592
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003593works=no
3594AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003595AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3596 [works=yes],
3597 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003598)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003599AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003600
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003601works=no
3602AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003603AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3604 [works=yes],
3605 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003606)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003607AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003608
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003609have_prototypes=no
3610AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003611AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3612 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3613 [Define if your compiler supports function prototype])
3614 have_prototypes=yes],
3615 []
3616)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003617AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003618
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003619works=no
3620AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003621AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003622#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003623int foo(int x, ...) {
3624 va_list va;
3625 va_start(va, x);
3626 va_arg(va, int);
3627 va_arg(va, char *);
3628 va_arg(va, double);
3629 return 0;
3630}
Matthias Klosec511b472010-05-08 11:01:39 +00003631]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003632 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3633 [Define if your compiler supports variable length function prototypes
3634 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3635 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003636],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003637AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003638
Dave Cole331708b2004-08-09 04:51:41 +00003639# check for socketpair
3640AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003641AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003642#include <sys/types.h>
3643#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003644]], [[void *x=socketpair]])],
3645 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3646 AC_MSG_RESULT(yes)],
3647 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003648)
3649
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003650# check if sockaddr has sa_len member
3651AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003652AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3653#include <sys/socket.h>]], [[struct sockaddr x;
3654x.sa_len = 0;]])],
3655 [AC_MSG_RESULT(yes)
3656 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3657 [AC_MSG_RESULT(no)]
3658)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003659
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003660va_list_is_array=no
3661AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003662AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003663#ifdef HAVE_STDARG_PROTOTYPES
3664#include <stdarg.h>
3665#else
3666#include <varargs.h>
3667#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003668]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003669 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3670 va_list_is_array=yes
3671])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003672AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003673
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003674# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003675AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3676 [Define this if you have some version of gethostbyname_r()])
3677
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003678AC_CHECK_FUNC(gethostbyname_r, [
3679 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3680 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3681 OLD_CFLAGS=$CFLAGS
3682 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003683 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003684# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003685 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003686 char *name;
3687 struct hostent *he, *res;
3688 char buffer[2048];
3689 int buflen = 2048;
3690 int h_errnop;
3691
3692 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003693 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003694 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003695 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3696 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003697 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003698 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003699 AC_MSG_RESULT(no)
3700 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003701 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003702# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003703 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003704 char *name;
3705 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003706 char buffer[2048];
3707 int buflen = 2048;
3708 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003709
Matthias Klosec511b472010-05-08 11:01:39 +00003710 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3711 ]])],
3712 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003713 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003714 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3715 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003716 AC_MSG_RESULT(yes)
3717 ], [
3718 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003719 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3720 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3721# include <netdb.h>
3722 ]], [[
3723 char *name;
3724 struct hostent *he;
3725 struct hostent_data data;
3726
3727 (void) gethostbyname_r(name, he, &data);
3728 ]])],
3729 [
3730 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3731 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3732 [Define this if you have the 3-arg version of gethostbyname_r().])
3733 AC_MSG_RESULT(yes)
3734 ], [
3735 AC_MSG_RESULT(no)
3736 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003737 ])
3738 ])
3739 CFLAGS=$OLD_CFLAGS
3740], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003741 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003742])
3743AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3744AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3745AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003746AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003747AC_SUBST(HAVE_GETHOSTBYNAME)
3748
Guido van Rossum627b2d71993-12-24 10:39:16 +00003749# checks for system services
3750# (none yet)
3751
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003752# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003753AC_CHECK_FUNC(__fpu_control,
3754 [],
3755 [AC_CHECK_LIB(ieee, __fpu_control)
3756])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003757
Guido van Rossum93274221997-05-09 02:42:00 +00003758# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003759AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003760AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003761 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003762[
Guido van Rossum93274221997-05-09 02:42:00 +00003763if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003764then
3765 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3766 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3767 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003768else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003769fi],
3770[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003771
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003772# check for --with-libm=...
3773AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003774case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003775Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003776BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003777*) LIBM=-lm
3778esac
Guido van Rossum93274221997-05-09 02:42:00 +00003779AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003780AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003781 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003782[
Guido van Rossum93274221997-05-09 02:42:00 +00003783if test "$withval" = no
3784then LIBM=
3785 AC_MSG_RESULT(force LIBM empty)
3786elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003787then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003788 AC_MSG_RESULT(set LIBM="$withval")
3789else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003790fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003791[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003792
3793# check for --with-libc=...
3794AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003795AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003796AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003797 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003798[
Guido van Rossum93274221997-05-09 02:42:00 +00003799if test "$withval" = no
3800then LIBC=
3801 AC_MSG_RESULT(force LIBC empty)
3802elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003803then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003804 AC_MSG_RESULT(set LIBC="$withval")
3805else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003806fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003807[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003808
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003809# **************************************************
3810# * Check for various properties of floating point *
3811# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003812
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003813AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3814AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003815AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003816#include <string.h>
3817int main() {
3818 double x = 9006104071832581.0;
3819 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3820 return 0;
3821 else
3822 return 1;
3823}
Matthias Klosec511b472010-05-08 11:01:39 +00003824]])],
3825[ac_cv_little_endian_double=yes],
3826[ac_cv_little_endian_double=no],
3827[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003828AC_MSG_RESULT($ac_cv_little_endian_double)
3829if test "$ac_cv_little_endian_double" = yes
3830then
3831 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3832 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3833 with the least significant byte first])
3834fi
3835
3836AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3837AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003838AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003839#include <string.h>
3840int main() {
3841 double x = 9006104071832581.0;
3842 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3843 return 0;
3844 else
3845 return 1;
3846}
Matthias Klosec511b472010-05-08 11:01:39 +00003847]])],
3848[ac_cv_big_endian_double=yes],
3849[ac_cv_big_endian_double=no],
3850[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003851AC_MSG_RESULT($ac_cv_big_endian_double)
3852if test "$ac_cv_big_endian_double" = yes
3853then
3854 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3855 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3856 with the most significant byte first])
3857fi
3858
3859# Some ARM platforms use a mixed-endian representation for doubles.
3860# While Python doesn't currently have full support for these platforms
3861# (see e.g., issue 1762561), we can at least make sure that float <-> string
3862# conversions work.
3863AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3864AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003865AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003866#include <string.h>
3867int main() {
3868 double x = 9006104071832581.0;
3869 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3870 return 0;
3871 else
3872 return 1;
3873}
Matthias Klosec511b472010-05-08 11:01:39 +00003874]])],
3875[ac_cv_mixed_endian_double=yes],
3876[ac_cv_mixed_endian_double=no],
3877[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003878AC_MSG_RESULT($ac_cv_mixed_endian_double)
3879if test "$ac_cv_mixed_endian_double" = yes
3880then
3881 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3882 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3883 in ARM mixed-endian order (byte order 45670123)])
3884fi
3885
3886# The short float repr introduced in Python 3.1 requires the
3887# correctly-rounded string <-> double conversion functions from
3888# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3889# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003890# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003891# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003892
3893# This inline assembler syntax may also work for suncc and icc,
3894# so we try it on all platforms.
3895
3896AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Stefan Krah99e36b92015-07-03 15:30:54 +02003897AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003898 unsigned short cw;
3899 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3900 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003901]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003902AC_MSG_RESULT($have_gcc_asm_for_x87)
3903if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003904then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003905 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3906 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003907fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003908
Mark Dickinson04b27232009-01-04 12:29:36 +00003909# Detect whether system arithmetic is subject to x87-style double
3910# rounding issues. The result of this test has little meaning on non
3911# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3912# mode is round-to-nearest and double rounding issues are present, and
3913# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3914AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003915# $BASECFLAGS may affect the result
3916ac_save_cc="$CC"
3917CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003918AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003919#include <stdlib.h>
3920#include <math.h>
3921int main() {
3922 volatile double x, y, z;
3923 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3924 x = 0.99999999999999989; /* 1-2**-53 */
3925 y = 1./x;
3926 if (y != 1.)
3927 exit(0);
3928 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3929 x = 1e16;
3930 y = 2.99999;
3931 z = x + y;
3932 if (z != 1e16+4.)
3933 exit(0);
3934 /* both tests show evidence of double rounding */
3935 exit(1);
3936}
Matthias Klosec511b472010-05-08 11:01:39 +00003937]])],
3938[ac_cv_x87_double_rounding=no],
3939[ac_cv_x87_double_rounding=yes],
3940[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003941CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003942AC_MSG_RESULT($ac_cv_x87_double_rounding)
3943if test "$ac_cv_x87_double_rounding" = yes
3944then
3945 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3946 [Define if arithmetic is subject to x87-style double rounding issue])
3947fi
3948
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003949# ************************************
3950# * Check for mathematical functions *
3951# ************************************
3952
3953LIBS_SAVE=$LIBS
3954LIBS="$LIBS $LIBM"
3955
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003956# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3957# -0. on some architectures.
3958AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3959AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003960AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003961#include <math.h>
3962#include <stdlib.h>
3963int main() {
3964 /* return 0 if either negative zeros don't exist
3965 on this platform or if negative zeros exist
3966 and tanh(-0.) == -0. */
3967 if (atan2(0., -1.) == atan2(-0., -1.) ||
3968 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3969 else exit(1);
3970}
Matthias Klosec511b472010-05-08 11:01:39 +00003971]])],
3972[ac_cv_tanh_preserves_zero_sign=yes],
3973[ac_cv_tanh_preserves_zero_sign=no],
3974[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003975AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3976if test "$ac_cv_tanh_preserves_zero_sign" = yes
3977then
3978 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3979 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3980fi
3981
3982AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3983AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3984AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3985
3986LIBS=$LIBS_SAVE
3987
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003988# For multiprocessing module, check that sem_open
3989# actually works. For FreeBSD versions <= 7.2,
3990# the kernel module that provides POSIX semaphores
3991# isn't loaded by default, so an attempt to call
3992# sem_open results in a 'Signal 12' error.
3993AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3994AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003995AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003996#include <unistd.h>
3997#include <fcntl.h>
3998#include <stdio.h>
3999#include <semaphore.h>
4000#include <sys/stat.h>
4001
4002int main(void) {
4003 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
4004 if (a == SEM_FAILED) {
4005 perror("sem_open");
4006 return 1;
4007 }
4008 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004009 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004010 return 0;
4011}
Matthias Klosec511b472010-05-08 11:01:39 +00004012]])],
4013[ac_cv_posix_semaphores_enabled=yes],
4014[ac_cv_posix_semaphores_enabled=no],
4015[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004016)
4017AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
4018if test $ac_cv_posix_semaphores_enabled = no
4019then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00004020 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
4021 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00004022fi
4023
Jesse Noller355b1262009-04-02 00:03:28 +00004024# Multiprocessing check for broken sem_getvalue
4025AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004026AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00004027AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00004028#include <unistd.h>
4029#include <fcntl.h>
4030#include <stdio.h>
4031#include <semaphore.h>
4032#include <sys/stat.h>
4033
4034int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004035 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00004036 int count;
4037 int res;
4038 if(a==SEM_FAILED){
4039 perror("sem_open");
4040 return 1;
4041
4042 }
4043 res = sem_getvalue(a, &count);
4044 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00004045 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00004046 return res==-1 ? 1 : 0;
4047}
Matthias Klosec511b472010-05-08 11:01:39 +00004048]])],
4049[ac_cv_broken_sem_getvalue=no],
4050[ac_cv_broken_sem_getvalue=yes],
4051[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00004052)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004053AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
4054if test $ac_cv_broken_sem_getvalue = yes
4055then
4056 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
4057 [define to 1 if your sem_getvalue is broken.])
4058fi
Mark Dickinson04b27232009-01-04 12:29:36 +00004059
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004060# determine what size digit to use for Python's longs
4061AC_MSG_CHECKING([digit size for Python's longs])
4062AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00004063AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004064[case $enable_big_digits in
4065yes)
4066 enable_big_digits=30 ;;
4067no)
4068 enable_big_digits=15 ;;
4069[15|30])
4070 ;;
4071*)
4072 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
4073esac
4074AC_MSG_RESULT($enable_big_digits)
4075AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
4076],
4077[AC_MSG_RESULT(no value specified)])
4078
Guido van Rossumef2255b2000-03-10 22:30:29 +00004079# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004080AC_CHECK_HEADER(wchar.h, [
4081 AC_DEFINE(HAVE_WCHAR_H, 1,
4082 [Define if the compiler provides a wchar.h header file.])
4083 wchar_h="yes"
4084],
Guido van Rossumef2255b2000-03-10 22:30:29 +00004085wchar_h="no"
4086)
4087
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004088# determine wchar_t size
4089if test "$wchar_h" = yes
4090then
Guido van Rossum67b26592001-10-20 14:21:45 +00004091 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004092fi
4093
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004094AC_MSG_CHECKING(for UCS-4 tcl)
4095have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00004096AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004097#include <tcl.h>
4098#if TCL_UTF_MAX != 6
4099# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00004100#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004101 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
4102 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00004103],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004104AC_MSG_RESULT($have_ucs4_tcl)
4105
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004106# check whether wchar_t is signed or not
4107if test "$wchar_h" = yes
4108then
4109 # check whether wchar_t is signed or not
4110 AC_MSG_CHECKING(whether wchar_t is signed)
4111 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00004112 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004113 #include <wchar.h>
4114 int main()
4115 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00004116 /* Success: exit code 0 */
4117 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004118 }
Matthias Klosec511b472010-05-08 11:01:39 +00004119 ]])],
4120 [ac_cv_wchar_t_signed=yes],
4121 [ac_cv_wchar_t_signed=no],
4122 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004123 AC_MSG_RESULT($ac_cv_wchar_t_signed)
4124fi
4125
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004126AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004127dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004128AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00004129 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004130 [],
4131 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004132
4133if test $enable_unicode = yes
4134then
Martin v. Löwisfd917792001-06-27 20:22:04 +00004135 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004136 case "$have_ucs4_tcl" in
4137 yes) enable_unicode="ucs4"
4138 ;;
4139 *) enable_unicode="ucs2"
4140 ;;
4141 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004142fi
4143
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004144AH_TEMPLATE(Py_UNICODE_SIZE,
4145 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004146case "$enable_unicode" in
4147ucs2) unicode_size="2"
4148 AC_DEFINE(Py_UNICODE_SIZE,2)
4149 ;;
4150ucs4) unicode_size="4"
4151 AC_DEFINE(Py_UNICODE_SIZE,4)
4152 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02004153no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00004154*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004155esac
4156
Martin v. Löwis11437992002-04-12 09:54:03 +00004157AH_TEMPLATE(PY_UNICODE_TYPE,
4158 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004159
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004160AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004161if test "$enable_unicode" = "no"
4162then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004163 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004164 AC_MSG_RESULT(not used)
4165else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004166 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004167 AC_DEFINE(Py_USING_UNICODE, 1,
4168 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004169
4170 # wchar_t is only usable if it maps to an unsigned type
4171 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004172 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004173 then
4174 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004175 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4176 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004177 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004178 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004179 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4180 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4181 then
4182 PY_UNICODE_TYPE="unsigned short"
4183 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4184 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4185 then
4186 PY_UNICODE_TYPE="unsigned long"
4187 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4188 else
4189 PY_UNICODE_TYPE="no type found"
4190 fi
4191 AC_MSG_RESULT($PY_UNICODE_TYPE)
4192fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004193
4194# check for endianness
4195AC_C_BIGENDIAN
4196
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004197# Check whether right shifting a negative integer extends the sign bit
4198# or fills with zeros (like the Cray J90, according to Tim Peters).
4199AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004200AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004201AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004202int main()
4203{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004204 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004205}
Matthias Klosec511b472010-05-08 11:01:39 +00004206]])],
4207[ac_cv_rshift_extends_sign=yes],
4208[ac_cv_rshift_extends_sign=no],
4209[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004210AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4211if test "$ac_cv_rshift_extends_sign" = no
4212then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004213 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4214 [Define if i>>j for signed int i does not extend the sign bit
4215 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004216fi
4217
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004218# check for getc_unlocked and related locking functions
4219AC_MSG_CHECKING(for getc_unlocked() and friends)
4220AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004221AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004222 FILE *f = fopen("/dev/null", "r");
4223 flockfile(f);
4224 getc_unlocked(f);
4225 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004226]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004227AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4228if test "$ac_cv_have_getc_unlocked" = yes
4229then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004230 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4231 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004232fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004233
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004234# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004235# save the value of LIBS so we don't actually link Python with readline
4236LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004237
4238# On some systems we need to link readline to a termcap compatible
4239# library. NOTE: Keep the precedence of listed libraries synchronised
4240# with setup.py.
4241py_cv_lib_readline=no
4242AC_MSG_CHECKING([how to link readline libs])
4243for py_libtermcap in "" ncursesw ncurses curses termcap; do
4244 if test -z "$py_libtermcap"; then
4245 READLINE_LIBS="-lreadline"
4246 else
4247 READLINE_LIBS="-lreadline -l$py_libtermcap"
4248 fi
4249 LIBS="$READLINE_LIBS $LIBS_no_readline"
4250 AC_LINK_IFELSE(
4251 [AC_LANG_CALL([],[readline])],
4252 [py_cv_lib_readline=yes])
4253 if test $py_cv_lib_readline = yes; then
4254 break
4255 fi
4256done
4257# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4258#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004259if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004260 AC_MSG_RESULT([none])
4261else
4262 AC_MSG_RESULT([$READLINE_LIBS])
4263 AC_DEFINE(HAVE_LIBREADLINE, 1,
4264 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004265fi
4266
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004267# check for readline 2.1
4268AC_CHECK_LIB(readline, rl_callback_handler_install,
4269 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004270 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004271
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004272# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004273AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4274 [have_readline=yes],
4275 [have_readline=no]
4276)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004277if test $have_readline = yes
4278then
4279 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4280 [readline/readline.h],
4281 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4282 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004283 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4284 [readline/readline.h],
4285 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4286 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004287fi
4288
Martin v. Löwis0daad592001-09-30 21:09:59 +00004289# check for readline 4.0
4290AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004291 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004292 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004293
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004294# also in 4.0
4295AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4296 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004297 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004298
Martin Pantera70c3232016-04-03 02:54:58 +00004299# also in 4.0, but not in editline
4300AC_CHECK_LIB(readline, rl_resize_terminal,
4301 AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
4302 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4303
Guido van Rossum353ae582001-07-10 16:45:32 +00004304# check for readline 4.2
4305AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004306 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004307 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004308
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004309# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004310AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4311 [have_readline=yes],
4312 [have_readline=no]
4313)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004314if test $have_readline = yes
4315then
4316 AC_EGREP_HEADER([extern int rl_catch_signals;],
4317 [readline/readline.h],
4318 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4319 [Define if you can turn off readline's signal handling.]), )
4320fi
4321
Martin v. Löwis82bca632006-02-10 20:49:30 +00004322# End of readline checks: restore LIBS
4323LIBS=$LIBS_no_readline
4324
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004325AC_MSG_CHECKING(for broken nice())
4326AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004327AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004328int main()
4329{
4330 int val1 = nice(1);
4331 if (val1 != -1 && val1 == nice(2))
4332 exit(0);
4333 exit(1);
4334}
Matthias Klosec511b472010-05-08 11:01:39 +00004335]])],
4336[ac_cv_broken_nice=yes],
4337[ac_cv_broken_nice=no],
4338[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004339AC_MSG_RESULT($ac_cv_broken_nice)
4340if test "$ac_cv_broken_nice" = yes
4341then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004342 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4343 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004344fi
4345
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004346AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004347AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004348AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004349#include <poll.h>
4350
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004351int main()
4352{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004353 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004354 int poll_test;
4355
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004356 close (42);
4357
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004358 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004359 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004360 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004361 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004362 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004363 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004364 return 1;
4365}
Matthias Klosec511b472010-05-08 11:01:39 +00004366]])],
4367[ac_cv_broken_poll=yes],
4368[ac_cv_broken_poll=no],
4369[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004370AC_MSG_RESULT($ac_cv_broken_poll)
4371if test "$ac_cv_broken_poll" = yes
4372then
4373 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4374 [Define if poll() sets errno on invalid file descriptors.])
4375fi
4376
Brett Cannon43802422005-02-10 20:48:03 +00004377# Before we can test tzset, we need to check if struct tm has a tm_zone
4378# (which is not required by ISO C or UNIX spec) and/or if we support
4379# tzname[]
4380AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004381
Brett Cannon43802422005-02-10 20:48:03 +00004382# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004383AC_MSG_CHECKING(for working tzset())
4384AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004385AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004386#include <stdlib.h>
4387#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004388#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004389
4390#if HAVE_TZNAME
4391extern char *tzname[];
4392#endif
4393
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004394int main()
4395{
Brett Cannon18367812003-09-19 00:59:16 +00004396 /* Note that we need to ensure that not only does tzset(3)
4397 do 'something' with localtime, but it works as documented
4398 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004399 This includes making sure that tzname is set properly if
4400 tm->tm_zone does not exist since it is the alternative way
4401 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004402
4403 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004404 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004405 */
4406
Brett Cannon43802422005-02-10 20:48:03 +00004407 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004408 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4409
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004410 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004411 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004412 if (localtime(&groundhogday)->tm_hour != 0)
4413 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004414#if HAVE_TZNAME
4415 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4416 if (strcmp(tzname[0], "UTC") ||
4417 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4418 exit(1);
4419#endif
Brett Cannon18367812003-09-19 00:59:16 +00004420
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004421 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004422 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004423 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004424 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004425#if HAVE_TZNAME
4426 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4427 exit(1);
4428#endif
Brett Cannon18367812003-09-19 00:59:16 +00004429
4430 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4431 tzset();
4432 if (localtime(&groundhogday)->tm_hour != 11)
4433 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004434#if HAVE_TZNAME
4435 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4436 exit(1);
4437#endif
4438
4439#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004440 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4441 exit(1);
4442 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4443 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004444#endif
Brett Cannon18367812003-09-19 00:59:16 +00004445
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004446 exit(0);
4447}
Matthias Klosec511b472010-05-08 11:01:39 +00004448]])],
4449[ac_cv_working_tzset=yes],
4450[ac_cv_working_tzset=no],
4451[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004452AC_MSG_RESULT($ac_cv_working_tzset)
4453if test "$ac_cv_working_tzset" = yes
4454then
4455 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4456 [Define if tzset() actually switches the local timezone in a meaningful way.])
4457fi
4458
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004459# Look for subsecond timestamps in struct stat
4460AC_MSG_CHECKING(for tv_nsec in struct stat)
4461AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004462AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004463struct stat st;
4464st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004465]])],
4466[ac_cv_stat_tv_nsec=yes],
4467[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004468AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4469if test "$ac_cv_stat_tv_nsec" = yes
4470then
4471 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4472 [Define if you have struct stat.st_mtim.tv_nsec])
4473fi
4474
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004475# Look for BSD style subsecond timestamps in struct stat
4476AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4477AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004478AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004479struct stat st;
4480st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004481]])],
4482[ac_cv_stat_tv_nsec2=yes],
4483[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004484AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4485if test "$ac_cv_stat_tv_nsec2" = yes
4486then
4487 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4488 [Define if you have struct stat.st_mtimensec])
4489fi
4490
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004491# first curses configure check
4492ac_save_cppflags="$CPPFLAGS"
4493CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4494
4495AC_CHECK_HEADERS(curses.h ncurses.h)
4496
4497# On Solaris, term.h requires curses.h
4498AC_CHECK_HEADERS(term.h,,,[
4499#ifdef HAVE_CURSES_H
4500#include <curses.h>
4501#endif
4502])
4503
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004504# On HP/UX 11.0, mvwdelch is a block with a return statement
4505AC_MSG_CHECKING(whether mvwdelch is an expression)
4506AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004507AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004508 int rtn;
4509 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004510]])],
4511[ac_cv_mvwdelch_is_expression=yes],
4512[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004513AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4514
4515if test "$ac_cv_mvwdelch_is_expression" = yes
4516then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004517 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4518 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004519fi
4520
4521AC_MSG_CHECKING(whether WINDOW has _flags)
4522AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004523AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004524 WINDOW *w;
4525 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004526]])],
4527[ac_cv_window_has_flags=yes],
4528[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004529AC_MSG_RESULT($ac_cv_window_has_flags)
4530
4531
4532if test "$ac_cv_window_has_flags" = yes
4533then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004534 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4535 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004536fi
4537
Walter Dörwald4994d952006-06-19 08:07:50 +00004538AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004539AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4540 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4541 AC_MSG_RESULT(yes)],
4542 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004543)
4544
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004545AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004546AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4547 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4548 AC_MSG_RESULT(yes)],
4549 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004550)
4551
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004552AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004553AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4554 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4555 AC_MSG_RESULT(yes)],
4556 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004557)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004558# last curses configure check
4559CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004560
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004561AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004562
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004563dnl NOTE: Inform user how to proceed with files when cross compiling.
4564if test "x$cross_compiling" = xyes; then
4565 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4566 AC_MSG_CHECKING([for /dev/ptmx])
4567 AC_MSG_RESULT([not set])
4568 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4569 fi
4570 if test "${ac_cv_file__dev_ptc+set}" != set; then
4571 AC_MSG_CHECKING([for /dev/ptc])
4572 AC_MSG_RESULT([not set])
4573 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4574 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004575fi
4576
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004577AC_CHECK_FILE(/dev/ptmx, [], [])
4578if test "x$ac_cv_file__dev_ptmx" = xyes; then
4579 AC_DEFINE(HAVE_DEV_PTMX, 1,
4580 [Define to 1 if you have the /dev/ptmx device file.])
4581fi
4582AC_CHECK_FILE(/dev/ptc, [], [])
4583if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004584 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004585 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004586fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004587
Mark Dickinson82864d12009-11-15 16:18:58 +00004588if test "$have_long_long" = yes
4589then
4590 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4591 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004592 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004593 #include <stdio.h>
4594 #include <stddef.h>
4595 #include <string.h>
4596
4597 #ifdef HAVE_SYS_TYPES_H
4598 #include <sys/types.h>
4599 #endif
4600
4601 int main()
4602 {
4603 char buffer[256];
4604
4605 if (sprintf(buffer, "%lld", (long long)123) < 0)
4606 return 1;
4607 if (strcmp(buffer, "123"))
4608 return 1;
4609
4610 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4611 return 1;
4612 if (strcmp(buffer, "-123"))
4613 return 1;
4614
4615 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4616 return 1;
4617 if (strcmp(buffer, "123"))
4618 return 1;
4619
4620 return 0;
4621 }
Matthias Klosec511b472010-05-08 11:01:39 +00004622 ]]])],
4623 [ac_cv_have_long_long_format=yes],
4624 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004625 [ac_cv_have_long_long_format="cross -- assuming no"
4626 if test x$GCC = xyes; then
4627 save_CFLAGS=$CFLAGS
4628 CFLAGS="$CFLAGS -Werror -Wformat"
4629 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4630 #include <stdio.h>
4631 #include <stddef.h>
4632 ]], [[
4633 char *buffer;
4634 sprintf(buffer, "%lld", (long long)123);
4635 sprintf(buffer, "%lld", (long long)-123);
4636 sprintf(buffer, "%llu", (unsigned long long)123);
4637 ]])],
4638 ac_cv_have_long_long_format=yes
4639 )
4640 CFLAGS=$save_CFLAGS
4641 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004642 )
4643 AC_MSG_RESULT($ac_cv_have_long_long_format)
4644fi
4645
Mark Dickinson5ce84742009-12-31 20:48:04 +00004646if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004647then
4648 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4649 [Define to printf format modifier for long long type])
4650fi
4651
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004652if test $ac_sys_system = Darwin
4653then
4654 LIBS="$LIBS -framework CoreFoundation"
4655fi
4656
Mark Dickinson82864d12009-11-15 16:18:58 +00004657
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004658AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004659AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004660#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004661#include <stddef.h>
4662#include <string.h>
4663
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004664#ifdef HAVE_SYS_TYPES_H
4665#include <sys/types.h>
4666#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004667
4668#ifdef HAVE_SSIZE_T
4669typedef ssize_t Py_ssize_t;
4670#elif SIZEOF_VOID_P == SIZEOF_LONG
4671typedef long Py_ssize_t;
4672#else
4673typedef int Py_ssize_t;
4674#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004675
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004676int main()
4677{
4678 char buffer[256];
4679
Brett Cannon09d12362006-05-11 05:11:33 +00004680 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4681 return 1;
4682
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004683 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004684 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004685
4686 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4687 return 1;
4688
4689 if (strcmp(buffer, "-123"))
4690 return 1;
4691
Brett Cannon09d12362006-05-11 05:11:33 +00004692 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004693}
Matthias Klosec511b472010-05-08 11:01:39 +00004694]])],
4695[ac_cv_have_size_t_format=yes],
4696[ac_cv_have_size_t_format=no],
4697[ac_cv_have_size_t_format="cross -- assuming yes"
4698])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004699if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004700 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4701 [Define to printf format modifier for Py_ssize_t])
4702fi
Brett Cannon09d12362006-05-11 05:11:33 +00004703
Martin v. Löwis01c04012002-11-11 14:58:44 +00004704AC_CHECK_TYPE(socklen_t,,
4705 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004706 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004707#ifdef HAVE_SYS_TYPES_H
4708#include <sys/types.h>
4709#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004710#ifdef HAVE_SYS_SOCKET_H
4711#include <sys/socket.h>
4712#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004713])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004714
R. David Murray1d9d16e2010-10-16 00:43:13 +00004715case $ac_sys_system in
4716AIX*)
4717 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4718esac
4719
4720
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004721AC_SUBST(THREADHEADERS)
4722
4723for h in `(cd $srcdir;echo Python/thread_*.h)`
4724do
4725 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4726done
4727
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004728AC_SUBST(SRCDIRS)
Victor Stinner5f4056a2017-04-28 03:41:40 +02004729SRCDIRS="Parser Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004730AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004731for dir in $SRCDIRS; do
4732 if test ! -d $dir; then
4733 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004734 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004735done
Benjamin Peterson2c992a02015-05-28 12:45:31 -05004736
4737# BEGIN_COMPUTED_GOTO
4738# Check for --with-computed-gotos
4739AC_MSG_CHECKING(for --with-computed-gotos)
4740AC_ARG_WITH(computed-gotos,
4741 AS_HELP_STRING([--with(out)-computed-gotos],
4742 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
4743[
4744if test "$withval" = yes
4745then
4746 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4747 [Define if you want to use computed gotos in ceval.c.])
4748 AC_MSG_RESULT(yes)
4749fi
4750if test "$withval" = no
4751then
4752 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4753 [Define if you want to use computed gotos in ceval.c.])
4754 AC_MSG_RESULT(no)
4755fi
4756],
4757[AC_MSG_RESULT(no value specified)])
4758
4759AC_MSG_CHECKING(whether $CC supports computed gotos)
4760AC_CACHE_VAL(ac_cv_computed_gotos,
4761AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4762int main(int argc, char **argv)
4763{
4764 static void *targets[1] = { &&LABEL1 };
4765 goto LABEL2;
4766LABEL1:
4767 return 0;
4768LABEL2:
4769 goto *targets[0];
4770 return 1;
4771}
4772]]])],
4773[ac_cv_computed_gotos=yes],
4774[ac_cv_computed_gotos=no],
4775[if test "${with_computed_gotos+set}" = set; then
4776 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4777 else
4778 ac_cv_computed_gotos=no
4779 fi]))
4780AC_MSG_RESULT($ac_cv_computed_gotos)
4781case "$ac_cv_computed_gotos" in yes*)
4782 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4783 [Define if the C compiler supports computed gotos.])
4784esac
4785# END_COMPUTED_GOTO
4786
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004787AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004788
Ned Deily3f1d0b32014-11-20 02:11:03 -08004789# ensurepip option
4790AC_MSG_CHECKING(for ensurepip)
4791AC_ARG_WITH(ensurepip,
4792 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@],
4793 ["install" or "upgrade" using bundled pip, default is "no"])],
4794 [],
4795 [with_ensurepip=no])
4796AS_CASE($with_ensurepip,
4797 [yes|upgrade],[ENSUREPIP=upgrade],
4798 [install],[ENSUREPIP=install],
4799 [no],[ENSUREPIP=no],
4800 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4801AC_MSG_RESULT($ENSUREPIP)
4802AC_SUBST(ENSUREPIP)
4803
Guido van Rossum627b2d71993-12-24 10:39:16 +00004804# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004805AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004806AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004807AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004808
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004809echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004810if test ! -f Modules/Setup
4811then
4812 cp $srcdir/Modules/Setup.dist Modules/Setup
4813fi
4814
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004815echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004816if test ! -f Modules/Setup.local
4817then
4818 echo "# Edit this file for local setup changes" >Modules/Setup.local
4819fi
4820
4821echo "creating Makefile"
4822$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4823 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004824 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004825
4826case $ac_sys_system in
4827BeOS)
4828 AC_MSG_WARN([
4829
4830 Support for BeOS is deprecated as of Python 2.6.
4831 See PEP 11 for the gory details.
4832 ])
4833 ;;
4834*) ;;
4835esac
4836
Neil Schemenauer66252162001-02-19 04:47:42 +00004837mv config.c Modules
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004838
4839if test "$Py_OPT" = 'false' -a "$Py_DEBUG" != 'true'; then
4840 echo "" >&AS_MESSAGE_FD
4841 echo "" >&AS_MESSAGE_FD
4842 echo "If you want a release build with all optimizations active (LTO, PGO, etc),"
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)b9999152016-11-20 21:19:36 +00004843 echo "please run ./configure --enable-optimizations" >&AS_MESSAGE_FD
Gregory P. Smith6d8fdfc2016-09-07 23:28:23 -07004844 echo "" >&AS_MESSAGE_FD
4845 echo "" >&AS_MESSAGE_FD
4846fi