blob: 06c877b85411a0c35fdac4bf15e49f90752b4a42 [file] [log] [blame]
Benjamin Petersond7c77842008-05-26 13:01:25 +00001dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
Martin v. Löwis88afe662002-10-26 13:47:44 +00004
5# Set VERSION so we only need to edit in one place (i.e., here)
Martin v. Löwis174440b2008-10-03 08:59:41 +00006m4_define(PYTHON_VERSION, 2.7)
Martin v. Löwis88afe662002-10-26 13:47:44 +00007
Georg Brandl71f4fbb2011-02-25 11:04:50 +00008AC_PREREQ(2.65)
Alexandre Vassalotti130ae152009-07-18 00:31:06 +00009
Guido van Rossum76be6ed1995-01-02 18:33:54 +000010AC_REVISION($Revision$)
Georg Brandl464432d2009-05-20 18:24:08 +000011AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
Martin v. Löwis88afe662002-10-26 13:47:44 +000012AC_CONFIG_SRCDIR([Include/object.h])
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000013AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +000014
Martin Pantere9ee3172016-04-23 00:58:44 +000015AC_SUBST(cross_compiling)
doko@python.orgd65e2ba2013-01-31 23:52:03 +010016AC_CANONICAL_HOST
17AC_SUBST(build)
18AC_SUBST(host)
19
Ned Deily983df862014-08-22 13:30:59 -070020# pybuilddir.txt will be created by --generate-posix-vars in the Makefile
21rm -f pybuilddir.txt
22
doko@python.orgd65e2ba2013-01-31 23:52:03 +010023if test "$cross_compiling" = yes; then
24 AC_MSG_CHECKING([for python interpreter for cross build])
25 if test -z "$PYTHON_FOR_BUILD"; then
26 for interp in python$PACKAGE_VERSION python2 python; do
27 which $interp >/dev/null 2>&1 || continue
28 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
29 break
30 fi
31 interp=
32 done
33 if test x$interp = x; then
34 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
35 fi
36 AC_MSG_RESULT($interp)
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +020037 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 +010038 fi
39elif test "$cross_compiling" = maybe; then
40 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
41else
42 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
43fi
44AC_SUBST(PYTHON_FOR_BUILD)
45
Georg Brandlbcd64a32009-03-31 21:45:18 +000046dnl Ensure that if prefix is specified, it does not end in a slash. If
47dnl it does, we get path names containing '//' which is both ugly and
48dnl can cause trouble.
49
50dnl Last slash shouldn't be stripped if prefix=/
51if test "$prefix" != "/"; then
52 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
53fi
54
Martin v. Löwis8316feb2003-06-14 07:48:07 +000055dnl This is for stuff that absolutely must end up in pyconfig.h.
56dnl Please use pyport.h instead, if possible.
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000057AH_TOP([
58#ifndef Py_PYCONFIG_H
59#define Py_PYCONFIG_H
60])
Martin v. Löwis11437992002-04-12 09:54:03 +000061AH_BOTTOM([
Martin v. Löwis11437992002-04-12 09:54:03 +000062/* Define the macros needed if on a UnixWare 7.x system. */
63#if defined(__USLC__) && defined(__SCO_VERSION__)
64#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
65#endif
Martin v. Löwisbddf5a52002-11-11 13:37:28 +000066
67#endif /*Py_PYCONFIG_H*/
Martin v. Löwis11437992002-04-12 09:54:03 +000068])
69
Martin v. Löwis8316feb2003-06-14 07:48:07 +000070# We don't use PACKAGE_ variables, and they cause conflicts
71# with other autoconf-based packages that include Python.h
72grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
73rm confdefs.h
74mv confdefs.h.new confdefs.h
75
Guido van Rossum642b6781997-07-19 19:35:41 +000076AC_SUBST(VERSION)
Martin v. Löwis88afe662002-10-26 13:47:44 +000077VERSION=PYTHON_VERSION
Guido van Rossum642b6781997-07-19 19:35:41 +000078
Martin v. Löwis1142de32002-03-29 16:28:31 +000079AC_SUBST(SOVERSION)
80SOVERSION=1.0
81
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +000082# The later defininition of _XOPEN_SOURCE disables certain features
83# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
84AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
85
Martin v. Löwisbcd93962003-05-03 10:32:18 +000086# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
87# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
88# them.
89AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
90
Andrew MacIntyreabccf412003-07-02 13:53:25 +000091# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
92# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
93# them.
94AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
95
Martin v. Löwisd6320502004-08-12 13:45:08 +000096# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
97# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
98AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
99
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000100# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
101# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
102# them.
103AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
104
105
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000106define_xopen_source=yes
Martin v. Löwis6f18a3c2002-07-20 08:51:52 +0000107
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +0000108# Arguments passed to configure.
109AC_SUBST(CONFIG_ARGS)
110CONFIG_ARGS="$ac_configure_args"
111
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000112AC_MSG_CHECKING([for --enable-universalsdk])
Ronald Oussoren988117f2006-04-29 11:31:35 +0000113AC_ARG_ENABLE(universalsdk,
Matthias Klose22520ea2010-05-08 10:14:46 +0000114 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
Ronald Oussoren988117f2006-04-29 11:31:35 +0000115[
116 case $enableval in
117 yes)
118 enableval=/Developer/SDKs/MacOSX10.4u.sdk
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000119 if test ! -d "${enableval}"
120 then
121 enableval=/
122 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000123 ;;
124 esac
125 case $enableval in
126 no)
127 UNIVERSALSDK=
128 enable_universalsdk=
129 ;;
130 *)
131 UNIVERSALSDK=$enableval
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000132 if test ! -d "${UNIVERSALSDK}"
133 then
134 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
135 fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000136 ;;
137 esac
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000138
Ronald Oussoren988117f2006-04-29 11:31:35 +0000139],[
140 UNIVERSALSDK=
141 enable_universalsdk=
142])
Ronald Oussoren3c0a1262010-01-17 19:27:57 +0000143if test -n "${UNIVERSALSDK}"
144then
145 AC_MSG_RESULT(${UNIVERSALSDK})
146else
147 AC_MSG_RESULT(no)
148fi
Ronald Oussoren988117f2006-04-29 11:31:35 +0000149AC_SUBST(UNIVERSALSDK)
150
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000151AC_SUBST(ARCH_RUN_32BIT)
Ned Deily8e60f6e2013-05-30 00:14:29 -0700152ARCH_RUN_32BIT=""
Benjamin Peterson0e6ea5d2008-07-16 20:17:04 +0000153
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000154UNIVERSAL_ARCHS="32-bit"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000155AC_SUBST(LIPO_32BIT_FLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000156AC_MSG_CHECKING(for --with-universal-archs)
157AC_ARG_WITH(universal-archs,
Matthias Klose22520ea2010-05-08 10:14:46 +0000158 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 +0000159[
160 AC_MSG_RESULT($withval)
161 UNIVERSAL_ARCHS="$withval"
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000162 if test "${enable_universalsdk}" ; then
163 :
164 else
165 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
166 fi
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000167],
168[
169 AC_MSG_RESULT(32-bit)
170])
171
172
173
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000174AC_ARG_WITH(framework-name,
Matthias Klose22520ea2010-05-08 10:14:46 +0000175 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
Matthias Klose5183ebd2010-04-24 16:38:36 +0000176 [specify an alternate name of the framework built with --enable-framework]),
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000177[
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000178 if test "${enable_framework}"; then
179 :
180 else
181 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
182 fi
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000183 PYTHONFRAMEWORK=${withval}
184 PYTHONFRAMEWORKDIR=${withval}.framework
185 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
186 ],[
187 PYTHONFRAMEWORK=Python
188 PYTHONFRAMEWORKDIR=Python.framework
189 PYTHONFRAMEWORKIDENTIFIER=org.python.python
190])
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000191dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000192AC_ARG_ENABLE(framework,
Matthias Klose22520ea2010-05-08 10:14:46 +0000193 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000194[
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000195 case $enableval in
196 yes)
197 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +0000198 esac
199 case $enableval in
200 no)
201 PYTHONFRAMEWORK=
202 PYTHONFRAMEWORKDIR=no-framework
203 PYTHONFRAMEWORKPREFIX=
204 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000205 FRAMEWORKINSTALLFIRST=
206 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000207 FRAMEWORKALTINSTALLFIRST=
208 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000209 if test "x${prefix}" = "xNONE"; then
210 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
211 else
212 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
213 fi
Jack Jansen127e56e2001-09-11 14:41:54 +0000214 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000215 ;;
216 *)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000217 PYTHONFRAMEWORKPREFIX="${enableval}"
Jack Jansen127e56e2001-09-11 14:41:54 +0000218 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000219 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000220 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
Ronald Oussoren92919a62009-12-24 13:30:58 +0000221 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
222 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000223 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000224
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000225 if test "x${prefix}" = "xNONE" ; then
226 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000227
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000228 else
229 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
230 fi
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000231
232 case "${enableval}" in
233 /System*)
234 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
235 if test "${prefix}" = "NONE" ; then
236 # See below
237 FRAMEWORKUNIXTOOLSPREFIX="/usr"
238 fi
239 ;;
240
241 /Library*)
242 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
243 ;;
244
245 */Library/Frameworks)
246 MDIR="`dirname "${enableval}"`"
247 MDIR="`dirname "${MDIR}"`"
248 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
249
250 if test "${prefix}" = "NONE"; then
251 # User hasn't specified the
252 # --prefix option, but wants to install
253 # the framework in a non-default location,
254 # ensure that the compatibility links get
255 # installed relative to that prefix as well
256 # instead of in /usr/local.
257 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
258 fi
259 ;;
260
261 *)
262 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
263 ;;
264 esac
265
Jack Jansen127e56e2001-09-11 14:41:54 +0000266 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Ronald Oussoren836b0392006-05-14 19:56:34 +0000267
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000268 # Add files for Mac specific code to the list of output
Ronald Oussoren836b0392006-05-14 19:56:34 +0000269 # files:
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000270 AC_CONFIG_FILES(Mac/Makefile)
271 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
272 AC_CONFIG_FILES(Mac/IDLE/Makefile)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000273 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
274 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000275 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000276 ],[
277 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +0000278 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000279 PYTHONFRAMEWORKPREFIX=
280 PYTHONFRAMEWORKINSTALLDIR=
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000281 FRAMEWORKINSTALLFIRST=
282 FRAMEWORKINSTALLLAST=
Ronald Oussoren5b787322006-06-06 19:50:24 +0000283 FRAMEWORKALTINSTALLFIRST=
284 FRAMEWORKALTINSTALLLAST=
Ronald Oussoren2db3a8f2006-06-07 19:06:01 +0000285 if test "x${prefix}" = "xNONE" ; then
286 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
287 else
288 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
289 fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000290 enable_framework=
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000291
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000292])
293AC_SUBST(PYTHONFRAMEWORK)
Ronald Oussoren580c7fe2008-05-02 19:45:11 +0000294AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000295AC_SUBST(PYTHONFRAMEWORKDIR)
296AC_SUBST(PYTHONFRAMEWORKPREFIX)
297AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Ronald Oussoren567a8ff2006-05-26 11:43:26 +0000298AC_SUBST(FRAMEWORKINSTALLFIRST)
299AC_SUBST(FRAMEWORKINSTALLLAST)
Ronald Oussoren5b787322006-06-06 19:50:24 +0000300AC_SUBST(FRAMEWORKALTINSTALLFIRST)
301AC_SUBST(FRAMEWORKALTINSTALLLAST)
302AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
Ronald Oussoren01d149f2010-04-30 11:20:14 +0000303AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000304
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000305##AC_ARG_WITH(dyld,
Matthias Klose22520ea2010-05-08 10:14:46 +0000306## AS_HELP_STRING([--with-dyld],
307## [Use (OpenStep|Rhapsody) dynamic linker]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000308##
Guido van Rossumb418f891996-07-30 18:06:02 +0000309# Set name for machine-dependent library files
310AC_SUBST(MACHDEP)
311AC_MSG_CHECKING(MACHDEP)
312if test -z "$MACHDEP"
313then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100314 # avoid using uname for cross builds
315 if test "$cross_compiling" = yes; then
316 # ac_sys_system and ac_sys_release are only used for setting
317 # `define_xopen_source' in the case statement below. For the
318 # current supported cross builds, this macro is not adjusted.
319 case "$host" in
320 *-*-linux*)
321 ac_sys_system=Linux
322 ;;
323 *-*-cygwin*)
324 ac_sys_system=Cygwin
325 ;;
326 *)
327 # for now, limit cross builds to known configurations
328 MACHDEP="unknown"
329 AC_MSG_ERROR([cross build not supported for $host])
330 esac
331 ac_sys_release=
332 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000333 ac_sys_system=`uname -s`
Georg Brandlfe18a112009-09-04 07:55:14 +0000334 if test "$ac_sys_system" = "AIX" \
Martin v. Löwis21ee4092002-09-30 16:19:48 +0000335 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000336 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +0000337 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000338 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +0000339 fi
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100340 fi
341 ac_md_system=`echo $ac_sys_system |
342 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
343 ac_md_release=`echo $ac_sys_release |
344 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
345 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000346
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100347 case $MACHDEP in
Victor Stinneracacbaa2011-08-20 14:02:38 +0200348 linux*) MACHDEP="linux2";;
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +0000349 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +0000350 darwin*) MACHDEP="darwin";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000351 atheos*) MACHDEP="atheos";;
Martin v. Löwisf3322282003-07-13 09:46:13 +0000352 irix646) MACHDEP="irix6";;
Guido van Rossumb97ef171997-09-28 05:44:03 +0000353 '') MACHDEP="unknown";;
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100354 esac
355fi
356
357AC_SUBST(_PYTHON_HOST_PLATFORM)
358if test "$cross_compiling" = yes; then
359 case "$host" in
360 *-*-linux*)
361 case "$host_cpu" in
362 arm*)
363 _host_cpu=arm
364 ;;
365 *)
366 _host_cpu=$host_cpu
367 esac
368 ;;
369 *-*-cygwin*)
370 _host_cpu=
371 ;;
372 *)
373 # for now, limit cross builds to known configurations
374 MACHDEP="unknown"
375 AC_MSG_ERROR([cross build not supported for $host])
Guido van Rossumb418f891996-07-30 18:06:02 +0000376 esac
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100377 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
Guido van Rossumb418f891996-07-30 18:06:02 +0000378fi
Jack Jansen83f898c2002-12-30 22:23:40 +0000379
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000380# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
381# disable features if it is defined, without any means to access these
382# features as extensions. For these systems, we skip the definition of
383# _XOPEN_SOURCE. Before adding a system to the list to gain access to
384# some feature, make sure there is no alternative way to access this
385# feature. Also, when using wildcards, make sure you have verified the
386# need for not defining _XOPEN_SOURCE on all systems matching the
387# wildcard, and that the wildcard does not include future systems
388# (which may remove their limitations).
389dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
390case $ac_sys_system/$ac_sys_release in
391 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
392 # even though select is a POSIX function. Reported by J. Ribbens.
Martin v. Löwis76bafc62003-10-03 13:47:44 +0000393 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
Martin v. Löwis7875ef62010-02-15 21:41:12 +0000394 # In addition, Stefan Krah confirms that issue #1244610 exists through
395 # OpenBSD 4.6, but is fixed in 4.7.
Charles-François Natali97781b02011-07-22 23:43:42 +0200396 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
Martin v. Löwiscb78de62007-12-29 18:49:21 +0000397 define_xopen_source=no
398 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
399 # also defined. This can be overridden by defining _BSD_SOURCE
400 # As this has a different meaning on Linux, only define it on OpenBSD
401 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
402 ;;
Charles-François Natali97781b02011-07-22 23:43:42 +0200403 OpenBSD/*)
Martin v. Löwis5e2dd862010-02-15 08:32:00 +0000404 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
405 # also defined. This can be overridden by defining _BSD_SOURCE
406 # As this has a different meaning on Linux, only define it on OpenBSD
407 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
408 ;;
Martin v. Löwis4d542ec2006-11-25 15:39:19 +0000409 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
410 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
411 # Marc Recht
Georg Brandl4b9bcfc2008-11-16 08:00:17 +0000412 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 +0000413 define_xopen_source=no;;
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000414 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
415 # request to enable features supported by the standard as a request
416 # to disable features not supported by the standard. The best way
417 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
418 # entirely and define __EXTENSIONS__ instead.
419 SunOS/*)
Martin v. Löwisa9d71422003-03-28 18:43:31 +0000420 define_xopen_source=no;;
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000421 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
422 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
Martin v. Löwis253d1f42004-05-07 19:14:14 +0000423 # Reconfirmed for 7.1.4 by Martin v. Loewis.
424 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000425 define_xopen_source=no;;
426 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000427 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
Martin v. Löwisc2409b42003-05-11 05:53:41 +0000428 SCO_SV/3.2)
Martin v. Löwis53e73c32003-05-05 05:13:18 +0000429 define_xopen_source=no;;
Martin v. Löwisbb86d832008-11-04 20:40:09 +0000430 # On FreeBSD 4, the math functions C89 does not cover are never defined
431 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
432 FreeBSD/4.*)
433 define_xopen_source=no;;
434 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
435 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
436 # identifies itself as Darwin/7.*
437 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
438 # disables platform specific features beyond repair.
439 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
440 # has no effect, don't bother defining them
441 Darwin/@<:@6789@:>@.*)
Anthony Baxter6169c6b2003-10-04 07:46:23 +0000442 define_xopen_source=no;;
Ronald Oussorena55af9a2010-01-17 16:25:57 +0000443 Darwin/1@<:@0-9@:>@.*)
444 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000445 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
446 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
447 # or has another value. By not (re)defining it, the defaults come in place.
Martin v. Löwisc19c5a62003-11-18 20:00:44 +0000448 AIX/4)
449 define_xopen_source=no;;
Trent Mickaf16e8c2004-08-25 23:55:59 +0000450 AIX/5)
451 if test `uname -r` -eq 1; then
452 define_xopen_source=no
453 fi
454 ;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000455 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
456 # defining NI_NUMERICHOST.
457 QNX/6.3.2)
458 define_xopen_source=no
459 ;;
Martin v. Löwisa0588362006-04-04 06:03:50 +0000460
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000461esac
462
463if test $define_xopen_source = yes
464then
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000465 AC_DEFINE(_XOPEN_SOURCE, 600,
466 Define to the level of X/Open that your system supports)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000467
468 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
469 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
470 # several APIs are not declared. Since this is also needed in some
471 # cases for HP-UX, we define it globally.
Martin v. Löwisb41afb52010-05-28 15:28:47 +0000472 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
473 Define to activate Unix95-and-earlier features)
Martin v. Löwis678fc1e2002-11-12 06:04:39 +0000474
Bob Ippolito7026a0a2005-03-28 23:23:47 +0000475 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
476
Martin v. Löwise981a4e2002-11-11 13:26:51 +0000477fi
478
Guido van Rossum91922671997-10-09 20:24:13 +0000479#
480# SGI compilers allow the specification of the both the ABI and the
481# ISA on the command line. Depending on the values of these switches,
Martin Panterb1d867f2016-05-26 05:28:50 +0000482# different and often incompatible code will be generated.
Guido van Rossum91922671997-10-09 20:24:13 +0000483#
484# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
485# thus supply support for various ABI/ISA combinations. The MACHDEP
486# variable is also adjusted.
487#
488AC_SUBST(SGI_ABI)
489if test ! -z "$SGI_ABI"
490then
491 CC="cc $SGI_ABI"
492 LDFLAGS="$SGI_ABI $LDFLAGS"
493 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
494fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000495AC_MSG_RESULT($MACHDEP)
496
doko@ubuntu.com9e7ece22015-04-13 21:55:08 +0200497AC_SUBST(PLATDIR)
498PLATDIR=plat-$MACHDEP
499
Jack Jansen83f898c2002-12-30 22:23:40 +0000500# And add extra plat-mac for darwin
501AC_SUBST(EXTRAPLATDIR)
Jack Jansen7b59b422003-03-17 15:44:10 +0000502AC_SUBST(EXTRAMACHDEPPATH)
Jack Jansen83f898c2002-12-30 22:23:40 +0000503AC_MSG_CHECKING(EXTRAPLATDIR)
504if test -z "$EXTRAPLATDIR"
505then
506 case $MACHDEP in
Jack Jansen7b59b422003-03-17 15:44:10 +0000507 darwin)
508 EXTRAPLATDIR="\$(PLATMACDIRS)"
509 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
510 ;;
511 *)
512 EXTRAPLATDIR=""
513 EXTRAMACHDEPPATH=""
514 ;;
Jack Jansen83f898c2002-12-30 22:23:40 +0000515 esac
516fi
517AC_MSG_RESULT($EXTRAPLATDIR)
518
Jack Jansen6b08a402004-06-03 12:41:45 +0000519# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
520# it may influence the way we can build extensions, so distutils
521# needs to check it
522AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
Ronald Oussoren988117f2006-04-29 11:31:35 +0000523AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
Jack Jansen6b08a402004-06-03 12:41:45 +0000524CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
Ronald Oussoren988117f2006-04-29 11:31:35 +0000525EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
Jack Jansen6b08a402004-06-03 12:41:45 +0000526
Guido van Rossum627b2d71993-12-24 10:39:16 +0000527# checks for alternative programs
Skip Montanarodecc6a42003-01-01 20:07:49 +0000528
529# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
530# for debug/optimization stuff. BASECFLAGS is for flags that are required
531# just to get things to compile and link. Users are free to override OPT
532# when running configure or make. The build should not break if they do.
533# BASECFLAGS should generally not be messed with, however.
534
535# XXX shouldn't some/most/all of this code be merged with the stuff later
536# on that fiddles with OPT and BASECFLAGS?
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000537AC_MSG_CHECKING(for --without-gcc)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000538AC_ARG_WITH(gcc,
Matthias Klose22520ea2010-05-08 10:14:46 +0000539 AS_HELP_STRING([--without-gcc], [never use gcc]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000540[
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000541 case $withval in
Skip Montanaro516144f2009-01-04 10:36:58 +0000542 no) CC=${CC:-cc}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000543 without_gcc=yes;;
544 yes) CC=gcc
545 without_gcc=no;;
546 *) CC=$withval
547 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000548 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000549 case $ac_sys_system in
Antoine Pitrou285cd162010-09-21 15:23:17 +0000550 AIX*) CC=${CC:-xlc_r}
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000551 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000552 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000553 case $BE_HOST_CPU in
554 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000555 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000556 without_gcc=yes
Skip Montanarodecc6a42003-01-01 20:07:49 +0000557 BASECFLAGS="$BASECFLAGS -export pragma"
558 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000559 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000560 ;;
561 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000562 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000563 without_gcc=no
Skip Montanarodecc6a42003-01-01 20:07:49 +0000564 OPT="$OPT -O"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000565 ;;
566 *)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000567 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000568 ;;
569 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000570 AR="\$(srcdir)/Modules/ar_beos"
571 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000572 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000573 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000574 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000575AC_MSG_RESULT($without_gcc)
576
Zachary Ware6ed42ea2015-12-21 11:43:03 -0600577AC_MSG_CHECKING(for --with-icc)
578AC_ARG_WITH(icc,
579 AS_HELP_STRING([--with-icc], [build with icc]),
580[
581 case $withval in
582 no) CC=${CC:-cc}
583 with_icc=no;;
584 yes) CC=icc
585 CXX=icpc
586 with_icc=yes;;
587 *) CC=$withval
588 with_icc=$withval;;
589 esac], [
590 with_icc=no])
591AC_MSG_RESULT($with_icc)
592
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000593# If the user switches compilers, we can't believe the cache
594if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
595then
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000596 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
597(it is also a good idea to do 'make clean' before compiling)])
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000598fi
599
Trent Nelson15daa352012-12-13 06:46:39 +0000600if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
601 # Normally, MIPSpro CC treats #error directives as warnings, which means
602 # a successful exit code is returned (0). This is a problem because IRIX
603 # has a bunch of system headers with this guard at the top:
604 #
605 # #ifndef __c99
606 # #error This header file is to be used only for c99 mode compilations
607 # #else
608 #
609 # When autoconf tests for such a header, like stdint.h, this happens:
610 #
611 # configure:4619: cc -c conftest.c >&5
612 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
613 # #error directive: This header file is to be used only for c99 mode
614 # compilations
615 #
616 # #error This header file is to be used only for c99 mode compilations
617 # ^
618 #
619 # configure:4619: $? = 0
620 # configure:4619: result: yes
621 #
622 # Therefore, we use `-diag_error 1035` to have the compiler treat the
623 # warning as an error, which causes cc to return a non-zero result,
624 # which autoconf can interpret correctly.
625 CFLAGS="$CFLAGS -diag_error 1035"
626 # Whilst we're here, we might as well make sure CXX defaults to something
627 # sensible if we're not using gcc.
628 if test -z "$CXX"; then
629 CXX="CC"
630 fi
631fi
632
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000633# If the user set CFLAGS, use this instead of the automatically
634# determined setting
635preset_cflags="$CFLAGS"
Guido van Rossum627b2d71993-12-24 10:39:16 +0000636AC_PROG_CC
Marc-André Lemburg6d5e5792010-04-30 17:20:14 +0000637if test ! -z "$preset_cflags"
638then
639 CFLAGS=$preset_cflags
640fi
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000641
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000642AC_SUBST(CXX)
643AC_SUBST(MAINCC)
644AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
645AC_ARG_WITH(cxx_main,
Matthias Klose22520ea2010-05-08 10:14:46 +0000646 AS_HELP_STRING([--with-cxx-main=<compiler>],
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000647 [compile main() and link python executable with C++ compiler]),
648[
649
650 case $withval in
651 no) with_cxx_main=no
652 MAINCC='$(CC)';;
653 yes) with_cxx_main=yes
654 MAINCC='$(CXX)';;
655 *) with_cxx_main=yes
656 MAINCC=$withval
657 if test -z "$CXX"
658 then
659 CXX=$withval
660 fi;;
661 esac], [
662 with_cxx_main=no
663 MAINCC='$(CC)'
664])
665AC_MSG_RESULT($with_cxx_main)
666
667preset_cxx="$CXX"
668if test -z "$CXX"
669then
670 case "$CC" in
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100671 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
672 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000673 esac
674 if test "$CXX" = "notfound"
675 then
676 CXX=""
677 fi
678fi
679if test -z "$CXX"
680then
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100681 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000682 if test "$CXX" = "notfound"
683 then
684 CXX=""
685 fi
686fi
687if test "$preset_cxx" != "$CXX"
688then
689 AC_MSG_WARN([
690
691 By default, distutils will build C++ extension modules with "$CXX".
692 If this is not intended, then set CXX on the configure command line.
693 ])
694fi
695
doko@python.org4e63fbe2013-01-25 13:08:27 +0100696MULTIARCH=$($CC --print-multiarch 2>/dev/null)
697AC_SUBST(MULTIARCH)
698
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000699
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000700# checks for UNIX variants that set C preprocessor variables
Matthias Klose9f8e0c12010-05-08 10:17:27 +0000701AC_USE_SYSTEM_EXTENSIONS
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000702
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000703# Check for unsupported systems
704case $ac_sys_system/$ac_sys_release in
Brett Cannon19fab762007-06-02 03:02:29 +0000705atheos*|Linux*/1*)
Martin v. Löwis779ffc02002-12-02 22:17:01 +0000706 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
707 echo See README for details.
708 exit 1;;
709esac
710
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000711AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000712AC_MSG_CHECKING(for --with-suffix)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000713AC_ARG_WITH(suffix,
Matthias Klose22520ea2010-05-08 10:14:46 +0000714 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +0000715[
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000716 case $withval in
717 no) EXEEXT=;;
718 yes) EXEEXT=.exe;;
719 *) EXEEXT=$withval;;
720 esac])
721AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000722
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000723# Test whether we're running on a non-case-sensitive system, in which
724# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000725AC_SUBST(BUILDEXEEXT)
726AC_MSG_CHECKING(for case-insensitive build directory)
Jack Jansen3c2c4332002-11-06 13:33:32 +0000727if test ! -d CaseSensitiveTestDir; then
728mkdir CaseSensitiveTestDir
729fi
730
731if test -d casesensitivetestdir
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000732then
Jack Jansen1999ef42001-12-06 21:47:20 +0000733 AC_MSG_RESULT(yes)
734 BUILDEXEEXT=.exe
735else
736 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000737 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000738fi
Jack Jansen3c2c4332002-11-06 13:33:32 +0000739rmdir CaseSensitiveTestDir
Guido van Rossumfb842551997-08-06 23:42:07 +0000740
Guido van Rossumdd997f71998-10-07 19:58:26 +0000741case $MACHDEP in
742bsdos*)
743 case $CC in
744 gcc) CC="$CC -D_HAVE_BSDI";;
745 esac;;
746esac
747
Guido van Rossum84561611997-08-21 00:08:11 +0000748case $ac_sys_system in
749hp*|HP*)
750 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000751 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000752 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000753SunOS*)
754 # Some functions have a prototype only with that define, e.g. confstr
Martin v. Löwisc45929e2002-04-06 10:10:49 +0000755 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
Martin v. Löwise8964d42001-03-06 12:09:07 +0000756 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000757esac
758
Martin v. Löwise8964d42001-03-06 12:09:07 +0000759
Neil Schemenauer61c51152001-01-26 16:18:16 +0000760AC_SUBST(LIBRARY)
761AC_MSG_CHECKING(LIBRARY)
762if test -z "$LIBRARY"
763then
764 LIBRARY='libpython$(VERSION).a'
765fi
766AC_MSG_RESULT($LIBRARY)
767
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000768# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000769# name of the library into which to insert object files). BLDLIBRARY is also
770# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
771# is blank as the main program is not linked directly against LDLIBRARY.
772# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
773# systems without shared libraries, LDLIBRARY is the same as LIBRARY
774# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
775# DLLLIBRARY is the shared (i.e., DLL) library.
776#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000777# RUNSHARED is used to run shared python without installed libraries
778#
779# INSTSONAME is the name of the shared library that will be use to install
780# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000781AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000782AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000783AC_SUBST(BLDLIBRARY)
784AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000785AC_SUBST(INSTSONAME)
786AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000787LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000788BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis09bdf722002-05-08 08:51:29 +0000789INSTSONAME='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000790DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000791LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000792RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000793
Guido van Rossumfb842551997-08-06 23:42:07 +0000794# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000795# If CXX is set, and if it is needed to link a main function that was
796# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
797# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000798# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000799# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000800AC_SUBST(LINKCC)
801AC_MSG_CHECKING(LINKCC)
802if test -z "$LINKCC"
803then
Martin v. Löwis0f48d982006-04-14 14:34:26 +0000804 LINKCC='$(PURIFY) $(MAINCC)'
Guido van Rossumfb842551997-08-06 23:42:07 +0000805 case $ac_sys_system in
806 AIX*)
Neal Norwitz0b27ff92003-03-31 15:53:49 +0000807 exp_extra="\"\""
808 if test $ac_sys_release -ge 5 -o \
809 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
810 exp_extra="."
811 fi
812 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
Martin v. Löwis8c255e42008-05-23 15:06:50 +0000813 QNX*)
814 # qcc must be used because the other compilers do not
815 # support -N.
816 LINKCC=qcc;;
Guido van Rossumfb842551997-08-06 23:42:07 +0000817 esac
818fi
819AC_MSG_RESULT($LINKCC)
820
Tarek Ziadée2be83d2009-05-09 08:28:53 +0000821# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
822# make sure we default having it set to "no": this is used by
823# distutils.unixccompiler to know if it should add --enable-new-dtags
824# to linker command lines, and failing to detect GNU ld simply results
825# in the same bahaviour as before.
826AC_SUBST(GNULD)
827AC_MSG_CHECKING(for GNU ld)
828ac_prog=ld
829if test "$GCC" = yes; then
830 ac_prog=`$CC -print-prog-name=ld`
831fi
832case `"$ac_prog" -V 2>&1 < /dev/null` in
833 *GNU*)
834 GNULD=yes;;
835 *)
836 GNULD=no;;
837esac
838AC_MSG_RESULT($GNULD)
839
Martin v. Löwis1142de32002-03-29 16:28:31 +0000840AC_MSG_CHECKING(for --enable-shared)
841AC_ARG_ENABLE(shared,
Matthias Klose22520ea2010-05-08 10:14:46 +0000842 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000843
Martin v. Löwis1142de32002-03-29 16:28:31 +0000844if test -z "$enable_shared"
845then
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000846 case $ac_sys_system in
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000847 CYGWIN* | atheos*)
Martin v. Löwisb51033d2002-05-03 05:53:15 +0000848 enable_shared="yes";;
849 *)
850 enable_shared="no";;
851 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000852fi
853AC_MSG_RESULT($enable_shared)
854
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000855AC_MSG_CHECKING(for --enable-profiling)
856AC_ARG_ENABLE(profiling,
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100857 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
858if test "x$enable_profiling" = xyes; then
859 ac_save_cc="$CC"
Benjamin Petersonb9be7bb2013-03-26 08:55:37 -0400860 CC="$CC -pg"
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100861 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
862 [],
863 [enable_profiling=no])
864 CC="$ac_save_cc"
865else
866 enable_profiling=no
867fi
868AC_MSG_RESULT($enable_profiling)
Skip Montanaro56f6a4f2004-06-18 02:47:22 +0000869
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100870if test "x$enable_profiling" = xyes; then
871 BASECFLAGS="-pg $BASECFLAGS"
872 LDFLAGS="-pg $LDFLAGS"
873fi
Martin v. Löwis1142de32002-03-29 16:28:31 +0000874
875AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000876
Guido van Rossumb8552162001-09-05 14:58:11 +0000877# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
878# library that we build, but we do not want to link against it (we
879# will find it with a -framework option). For this reason there is an
880# extra variable BLDLIBRARY against which Python and the extension
881# modules are linked, BLDLIBRARY. This is normally the same as
882# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000883if test "$enable_framework"
884then
885 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200886 RUNSHARED=DYLD_FRAMEWORK_PATH=`pwd`${DYLD_FRAMEWORK_PATH:+:${DYLD_FRAMEWORK_PATH}}
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000887 BLDLIBRARY=''
888else
889 BLDLIBRARY='$(LDLIBRARY)'
890fi
891
Martin v. Löwis1142de32002-03-29 16:28:31 +0000892# Other platforms follow
893if test $enable_shared = "yes"; then
Mark Hammond8235ea12002-07-19 06:55:41 +0000894 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
Martin v. Löwis1142de32002-03-29 16:28:31 +0000895 case $ac_sys_system in
896 BeOS*)
897 LDLIBRARY='libpython$(VERSION).so'
898 ;;
899 CYGWIN*)
900 LDLIBRARY='libpython$(VERSION).dll.a'
901 DLLLIBRARY='libpython$(VERSION).dll'
902 ;;
903 SunOS*)
904 LDLIBRARY='libpython$(VERSION).so'
Martin v. Löwisd141a8c2003-06-14 15:20:28 +0000905 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200906 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis2389c412003-10-31 15:42:07 +0000907 INSTSONAME="$LDLIBRARY".$SOVERSION
Martin v. Löwis1142de32002-03-29 16:28:31 +0000908 ;;
Charles-François Natali3de8c732011-07-24 22:33:35 +0200909 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000910 LDLIBRARY='libpython$(VERSION).so'
911 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200912 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Hye-Shik Chang33761492004-10-26 09:53:46 +0000913 case $ac_sys_system in
914 FreeBSD*)
915 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
916 ;;
917 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000918 INSTSONAME="$LDLIBRARY".$SOVERSION
919 ;;
920 hp*|HP*)
Neal Norwitz58e28882006-05-19 07:00:58 +0000921 case `uname -m` in
922 ia64)
923 LDLIBRARY='libpython$(VERSION).so'
924 ;;
925 *)
926 LDLIBRARY='libpython$(VERSION).sl'
927 ;;
928 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000929 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200930 RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000931 ;;
932 OSF*)
933 LDLIBRARY='libpython$(VERSION).so'
Neal Norwitz671b9e32006-01-09 07:07:12 +0000934 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200935 RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Martin v. Löwis1142de32002-03-29 16:28:31 +0000936 ;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +0000937 atheos*)
938 LDLIBRARY='libpython$(VERSION).so'
939 BLDLIBRARY='-L. -lpython$(VERSION)'
940 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
941 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000942 Darwin*)
943 LDLIBRARY='libpython$(VERSION).dylib'
944 BLDLIBRARY='-L. -lpython$(VERSION)'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200945 RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
Ronald Oussoren79f90492009-01-02 10:44:46 +0000946 ;;
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000947 AIX*)
948 LDLIBRARY='libpython$(VERSION).so'
doko@ubuntu.com9ba90c92014-05-07 04:41:26 +0200949 RUNSHARED=LIBPATH=`pwd`${LIBPATH:+:${LIBPATH}}
Antoine Pitrouaabdceb2010-09-10 20:03:17 +0000950 ;;
Ronald Oussoren79f90492009-01-02 10:44:46 +0000951
Martin v. Löwis1142de32002-03-29 16:28:31 +0000952 esac
Jason Tishler30765592003-09-04 11:04:06 +0000953else # shared is disabled
954 case $ac_sys_system in
955 CYGWIN*)
956 BLDLIBRARY='$(LIBRARY)'
957 LDLIBRARY='libpython$(VERSION).dll.a'
958 ;;
959 esac
Martin v. Löwis1142de32002-03-29 16:28:31 +0000960fi
961
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100962if test "$cross_compiling" = yes; then
963 RUNSHARED=
964fi
965
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000966AC_MSG_RESULT($LDLIBRARY)
967
Guido van Rossum627b2d71993-12-24 10:39:16 +0000968AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000969AC_SUBST(AR)
doko@python.orgd65e2ba2013-01-31 23:52:03 +0100970AC_CHECK_TOOLS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000971
Tarek Ziadé99f660a2009-05-07 21:20:34 +0000972# tweak ARFLAGS only if the user didn't set it on the command line
973AC_SUBST(ARFLAGS)
974if test -z "$ARFLAGS"
975then
976 ARFLAGS="rc"
977fi
978
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000979AC_SUBST(SVNVERSION)
Martin v. Löwisff600232006-04-03 19:12:32 +0000980AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000981if test $SVNVERSION = found
982then
983 SVNVERSION="svnversion \$(srcdir)"
984else
Benjamin Petersone5afa3b2009-05-23 19:24:37 +0000985 SVNVERSION="echo Unversioned directory"
Martin v. Löwisc5bf5a02006-01-05 10:33:59 +0000986fi
Martin v. Löwisdea59e52006-01-05 10:00:36 +0000987
Trent Nelsond86ceec2012-10-16 09:42:45 -0400988AC_SUBST(BASECPPFLAGS)
Trent Nelsonabf20512012-10-17 04:32:49 -0400989if test "$abs_srcdir" != "$abs_builddir"; then
Trent Nelsond86ceec2012-10-16 09:42:45 -0400990 # If we're building out-of-tree make sure Include (in the current dir)
991 # gets picked up before its $srcdir counterpart in order for Python-ast.h
992 # and graminit.h to get picked up from the correct directory.
993 # (A side effect of this is that these resources will automatically be
994 # regenerated when building out-of-tree, regardless of whether or not
995 # the $srcdir counterpart is up-to-date. This is an acceptable trade
996 # off.)
997 BASECPPFLAGS="-IInclude"
998else
999 BASECPPFLAGS=""
1000fi
1001
Georg Brandl3a5508e2011-03-06 10:42:21 +01001002AC_SUBST(HGVERSION)
1003AC_SUBST(HGTAG)
1004AC_SUBST(HGBRANCH)
1005AC_CHECK_PROG(HAS_HG, hg, found, not-found)
1006if test $HAS_HG = found
1007then
1008 HGVERSION="hg id -i \$(srcdir)"
1009 HGTAG="hg id -t \$(srcdir)"
1010 HGBRANCH="hg id -b \$(srcdir)"
1011else
1012 HGVERSION=""
1013 HGTAG=""
1014 HGBRANCH=""
1015fi
1016
Neil Schemenauera42c8272001-03-31 00:01:55 +00001017case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +00001018bsdos*|hp*|HP*)
1019 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +00001020 if test -z "$INSTALL"
1021 then
1022 INSTALL="${srcdir}/install-sh -c"
1023 fi
1024esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001025AC_PROG_INSTALL
Trent Nelsonf6407a12012-08-30 14:56:13 +00001026AC_PROG_MKDIR_P
Guido van Rossumb418f891996-07-30 18:06:02 +00001027
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001028# Not every filesystem supports hard links
1029AC_SUBST(LN)
1030if test -z "$LN" ; then
1031 case $ac_sys_system in
1032 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +00001033 CYGWIN*) LN="ln -s";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00001034 atheos*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001035 *) LN=ln;;
1036 esac
1037fi
1038
Fred Drake9f715822001-07-11 06:27:00 +00001039# Check for --with-pydebug
1040AC_MSG_CHECKING(for --with-pydebug)
1041AC_ARG_WITH(pydebug,
Matthias Klose22520ea2010-05-08 10:14:46 +00001042 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00001043[
Fred Drake9f715822001-07-11 06:27:00 +00001044if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001045then
1046 AC_DEFINE(Py_DEBUG, 1,
1047 [Define if you want to build an interpreter with many run-time checks.])
1048 AC_MSG_RESULT(yes);
1049 Py_DEBUG='true'
Fred Drake9f715822001-07-11 06:27:00 +00001050else AC_MSG_RESULT(no); Py_DEBUG='false'
1051fi],
1052[AC_MSG_RESULT(no)])
1053
Skip Montanarodecc6a42003-01-01 20:07:49 +00001054# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1055# merged with this chunk of code?
1056
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001057# Optimizer/debugger flags
Skip Montanarodecc6a42003-01-01 20:07:49 +00001058# ------------------------
1059# (The following bit of code is complicated enough - please keep things
1060# indented properly. Just pretend you're editing Python code. ;-)
1061
1062# There are two parallel sets of case statements below, one that checks to
1063# see if OPT was set and one that does BASECFLAGS setting based upon
1064# compiler and platform. BASECFLAGS tweaks need to be made even if the
1065# user set OPT.
1066
1067# tweak OPT based on compiler and platform, only if the user didn't set
1068# it on the command line
Guido van Rossumb418f891996-07-30 18:06:02 +00001069AC_SUBST(OPT)
Benjamin Petersond4b721b2010-03-23 20:58:37 +00001070if test "${OPT-unset}" = "unset"
Guido van Rossumb418f891996-07-30 18:06:02 +00001071then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001072 case $GCC in
1073 yes)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001074 if test "$CC" != 'g++' ; then
1075 STRICT_PROTO="-Wstrict-prototypes"
1076 fi
Guido van Rossum7c862f82007-12-13 20:50:10 +00001077 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1078 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1079 WRAP="-fwrapv"
1080 fi
Stefan Krah503e5e12011-09-14 15:19:42 +02001081
1082 # Clang also needs -fwrapv
Stefan Krah2bc1e8f2011-12-08 22:26:06 +01001083 case $CC in
1084 *clang*) WRAP="-fwrapv"
1085 ;;
1086 esac
Stefan Krah503e5e12011-09-14 15:19:42 +02001087
Skip Montanarodecc6a42003-01-01 20:07:49 +00001088 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001089 yes)
Fred Drake9f715822001-07-11 06:27:00 +00001090 if test "$Py_DEBUG" = 'true' ; then
1091 # Optimization messes up debuggers, so turn it off for
1092 # debug builds.
Mark Dickinsond2f3e3f2010-05-05 22:23:58 +00001093 OPT="-g -O0 -Wall $STRICT_PROTO"
Fred Drake9f715822001-07-11 06:27:00 +00001094 else
Guido van Rossum7c862f82007-12-13 20:50:10 +00001095 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001096 fi
1097 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001098 *)
Skip Montanaro288a5be2006-04-13 02:00:56 +00001099 OPT="-O3 -Wall $STRICT_PROTO"
Skip Montanarodecc6a42003-01-01 20:07:49 +00001100 ;;
Fred Drake9f715822001-07-11 06:27:00 +00001101 esac
Martin v. Löwis21ee4092002-09-30 16:19:48 +00001102 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001103 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1104 ;;
1105 esac
Fred Drake9f715822001-07-11 06:27:00 +00001106 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001107
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001108 *)
Skip Montanarodecc6a42003-01-01 20:07:49 +00001109 OPT="-O"
1110 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +00001111 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +00001112fi
Guido van Rossum627b2d71993-12-24 10:39:16 +00001113
Skip Montanarodecc6a42003-01-01 20:07:49 +00001114AC_SUBST(BASECFLAGS)
Ronald Oussoren5640ce22008-06-05 12:58:24 +00001115
1116# The -arch flags for universal builds on OSX
1117UNIVERSAL_ARCH_FLAGS=
1118AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1119
Skip Montanarodecc6a42003-01-01 20:07:49 +00001120# tweak BASECFLAGS based on compiler and platform
1121case $GCC in
1122yes)
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001123 # Python violates C99 rules, by casting between incompatible
1124 # pointer types. GCC may generate bad code as a result of that,
1125 # so use -fno-strict-aliasing if supported.
1126 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1127 ac_save_cc="$CC"
1128 CC="$CC -fno-strict-aliasing"
Alexandre Vassalotti00900892009-07-17 05:26:39 +00001129 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
Matthias Klosec511b472010-05-08 11:01:39 +00001130 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001131 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001132 [ac_cv_no_strict_aliasing_ok=yes],
1133 [ac_cv_no_strict_aliasing_ok=no]))
Martin v. Löwis70fedcd2003-07-07 21:26:19 +00001134 CC="$ac_save_cc"
1135 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1136 if test $ac_cv_no_strict_aliasing_ok = yes
1137 then
1138 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1139 fi
Mark Dickinson65134662008-04-25 16:11:04 +00001140
1141 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1142 # support. Without this, treatment of subnormals doesn't follow
1143 # the standard.
doko@python.orgd65e2ba2013-01-31 23:52:03 +01001144 case $host in
Mark Dickinson65134662008-04-25 16:11:04 +00001145 alpha*)
1146 BASECFLAGS="$BASECFLAGS -mieee"
1147 ;;
1148 esac
1149
Skip Montanarodecc6a42003-01-01 20:07:49 +00001150 case $ac_sys_system in
1151 SCO_SV*)
1152 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1153 ;;
1154 # is there any other compiler on Darwin besides gcc?
1155 Darwin*)
Jeffrey Yasskin1b4e45b2008-03-17 14:40:53 +00001156 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1157 # used to be here, but non-Apple gcc doesn't accept them.
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001158 if test "${CC}" = gcc
1159 then
1160 AC_MSG_CHECKING(which compiler should be used)
1161 case "${UNIVERSALSDK}" in
1162 */MacOSX10.4u.sdk)
1163 # Build using 10.4 SDK, force usage of gcc when the
1164 # compiler is gcc, otherwise the user will get very
1165 # confusing error messages when building on OSX 10.6
1166 CC=gcc-4.0
1167 CPP=cpp-4.0
1168 ;;
1169 esac
1170 AC_MSG_RESULT($CC)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001171 fi
1172
Benjamin Peterson4347c442008-07-17 15:59:24 +00001173 # Calculate the right deployment target for this build.
1174 #
Ned Deilyc40b9032014-06-25 13:48:46 -07001175 cur_target_major=`sw_vers -productVersion | \
1176 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
1177 cur_target_minor=`sw_vers -productVersion | \
1178 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
1179 cur_target="${cur_target_major}.${cur_target_minor}"
1180 if test ${cur_target_major} -eq 10 && \
1181 test ${cur_target_minor} -ge 3
1182 then
Benjamin Peterson4347c442008-07-17 15:59:24 +00001183 cur_target=10.3
Ronald Oussoren25967582009-09-06 10:00:26 +00001184 if test ${enable_universalsdk}; then
1185 if test "${UNIVERSAL_ARCHS}" = "all"; then
1186 # Ensure that the default platform for a
1187 # 4-way universal build is OSX 10.5,
1188 # that's the first OS release where
1189 # 4-way builds make sense.
1190 cur_target='10.5'
Ronald Oussoren23d92532009-09-07 06:12:00 +00001191
1192 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1193 cur_target='10.5'
1194
1195 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1196 cur_target='10.5'
1197
1198 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1199 cur_target='10.5'
Ronald Oussoren25967582009-09-06 10:00:26 +00001200 fi
1201 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001202 if test `/usr/bin/arch` = "i386"; then
Ronald Oussoren25967582009-09-06 10:00:26 +00001203 # On Intel macs default to a deployment
1204 # target of 10.4, that's the first OSX
1205 # release with Intel support.
1206 cur_target="10.4"
1207 fi
1208 fi
Benjamin Peterson4347c442008-07-17 15:59:24 +00001209 fi
1210 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1211
1212 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1213 # environment with a value that is the same as what we'll use
1214 # in the Makefile to ensure that we'll get the same compiler
1215 # environment during configure and build time.
1216 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1217 export MACOSX_DEPLOYMENT_TARGET
1218 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1219
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001220 if test "${enable_universalsdk}"; then
1221 UNIVERSAL_ARCH_FLAGS=""
1222 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1223 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1224 ARCH_RUN_32BIT=""
Ronald Oussoren75912852010-04-08 08:13:31 +00001225 LIPO_32BIT_FLAGS=""
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001226
1227 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1228 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1229 LIPO_32BIT_FLAGS=""
1230 ARCH_RUN_32BIT="true"
1231
1232 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1233 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1234 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001235 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001236
1237 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1238 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1239 LIPO_32BIT_FLAGS="-extract i386"
Ronald Oussoren92397ce2010-01-17 19:32:00 +00001240 ARCH_RUN_32BIT="/usr/bin/arch -i386"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001241
1242 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1243 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1244 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
Ronald Oussoren9922f172010-02-11 13:19:34 +00001245 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001246
1247 else
1248 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1249
1250 fi
1251
1252
Ronald Oussoren974eb5e2010-04-18 17:59:37 +00001253 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1254 if test "${UNIVERSALSDK}" != "/"
1255 then
1256 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1257 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1258 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001259 fi
1260
1261 fi
1262
1263
Skip Montanarodecc6a42003-01-01 20:07:49 +00001264 ;;
Neal Norwitzdedeeaa2006-03-31 06:54:45 +00001265 OSF*)
1266 BASECFLAGS="$BASECFLAGS -mieee"
1267 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001268 esac
1269 ;;
1270
1271*)
1272 case $ac_sys_system in
1273 OpenUNIX*|UnixWare*)
1274 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1275 ;;
Neal Norwitzb44f1652003-05-26 14:11:55 +00001276 OSF*)
1277 BASECFLAGS="$BASECFLAGS -ieee -std"
1278 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001279 SCO_SV*)
1280 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1281 ;;
1282 esac
1283 ;;
1284esac
1285
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001286# ICC needs -fp-model strict or floats behave badly
1287case "$CC" in
1288*icc*)
1289 BASECFLAGS="$BASECFLAGS -fp-model strict"
1290 ;;
1291esac
1292
Fred Drakee1ceaa02001-12-04 20:55:47 +00001293if test "$Py_DEBUG" = 'true'; then
1294 :
1295else
1296 OPT="-DNDEBUG $OPT"
1297fi
1298
Guido van Rossum6f2260e1996-09-09 16:21:03 +00001299if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001300then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001301 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +00001302fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001303
Neal Norwitz020c46a2006-01-07 21:39:28 +00001304# disable check for icc since it seems to pass, but generates a warning
1305if test "$CC" = icc
1306then
1307 ac_cv_opt_olimit_ok=no
1308fi
1309
Guido van Rossum91922671997-10-09 20:24:13 +00001310AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1311AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1312[ac_save_cc="$CC"
1313CC="$CC -OPT:Olimit=0"
Matthias Klosec511b472010-05-08 11:01:39 +00001314AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001315 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001316 [ac_cv_opt_olimit_ok=yes],
1317 [ac_cv_opt_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001318 )
Guido van Rossum91922671997-10-09 20:24:13 +00001319CC="$ac_save_cc"])
1320AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +00001321if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +00001322 case $ac_sys_system in
Skip Montanarodecc6a42003-01-01 20:07:49 +00001323 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1324 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1325 # environment?
1326 Darwin*)
1327 ;;
Trent Nelson34562e12012-10-17 18:01:12 -04001328 # XXX thankfully this useless troublemaker of a flag has been
1329 # eradicated in the 3.x line. For now, make sure it isn't picked
1330 # up by any of our other platforms that use CC.
1331 AIX*|SunOS*|HP-UX*|IRIX*)
1332 ;;
Skip Montanarodecc6a42003-01-01 20:07:49 +00001333 *)
1334 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1335 ;;
Guido van Rossum5839e582000-10-09 19:52:35 +00001336 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001337else
1338 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1339 AC_CACHE_VAL(ac_cv_olimit_ok,
1340 [ac_save_cc="$CC"
1341 CC="$CC -Olimit 1500"
Matthias Klosec511b472010-05-08 11:01:39 +00001342 AC_COMPILE_IFELSE(
Mark Dickinson5e13e292010-05-11 08:55:06 +00001343 [AC_LANG_PROGRAM([[]], [[]])],
Matthias Klosec511b472010-05-08 11:01:39 +00001344 [ac_cv_olimit_ok=yes],
1345 [ac_cv_olimit_ok=no]
Gregory P. Smithec3b8bd2009-11-01 21:02:52 +00001346 )
Guido van Rossumf8678121998-07-07 21:05:09 +00001347 CC="$ac_save_cc"])
1348 AC_MSG_RESULT($ac_cv_olimit_ok)
1349 if test $ac_cv_olimit_ok = yes; then
Stefan Krah67473262012-11-29 00:17:05 +01001350 case $ac_sys_system in
1351 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1352 HP-UX*)
1353 ;;
1354 *)
1355 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1356 ;;
1357 esac
Guido van Rossumf8678121998-07-07 21:05:09 +00001358 fi
Guido van Rossum201afe51997-05-14 21:14:44 +00001359fi
Guido van Rossumf8678121998-07-07 21:05:09 +00001360
Martin v. Löwisaac13162006-10-19 10:58:46 +00001361# Check whether GCC supports PyArg_ParseTuple format
1362if test "$GCC" = "yes"
1363then
1364 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1365 save_CFLAGS=$CFLAGS
Benjamin Petersonc8759662013-05-11 13:00:05 -05001366 CFLAGS="$CFLAGS -Werror -Wformat"
Matthias Klosec511b472010-05-08 11:01:39 +00001367 AC_COMPILE_IFELSE([
1368 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1369 ],[
1370 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1371 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1372 AC_MSG_RESULT(yes)
1373 ],[
1374 AC_MSG_RESULT(no)
1375 ])
Martin v. Löwisc1d75972006-10-19 16:01:37 +00001376 CFLAGS=$save_CFLAGS
Martin v. Löwisaac13162006-10-19 10:58:46 +00001377fi
1378
Brett Cannon4ff151a2015-09-18 15:09:42 -07001379
Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D)c543a0f2016-06-02 23:44:40 +00001380# Enable LTO flags
1381AC_SUBST(LTOFLAGS)
1382AC_MSG_CHECKING(for --with-lto)
1383AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [Enable Link Time Optimization in PGO builds. Disabled by default.]),
1384[
1385if test "$withval" != no
1386then
1387 Py_LTO='true'
1388 AC_MSG_RESULT(yes);
1389else
1390 Py_LTO='false'
1391 AC_MSG_RESULT(no);
1392fi],
1393[AC_MSG_RESULT(no)])
1394if test "$Py_LTO" = 'true' ; then
1395 case $CC in
1396 *clang*)
1397 # Any changes made here should be reflected in the GCC+Darwin case below
1398 LTOFLAGS="-flto"
1399 ;;
1400 *gcc*)
1401 case $ac_sys_system in
1402 Darwin*)
1403 LTOFLAGS="-flto"
1404 ;;
1405 *)
1406 LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
1407 ;;
1408 esac
1409 ;;
1410 esac
1411fi
1412
1413
Brett Cannon4ff151a2015-09-18 15:09:42 -07001414# Enable PGO flags.
1415AC_SUBST(PGO_PROF_GEN_FLAG)
1416AC_SUBST(PGO_PROF_USE_FLAG)
1417AC_SUBST(LLVM_PROF_MERGER)
1418AC_SUBST(LLVM_PROF_FILE)
1419AC_SUBST(LLVM_PROF_ERR)
1420AC_SUBST(LLVM_PROF_FOUND)
1421AC_CHECK_PROG(LLVM_PROF_FOUND, llvm-profdata, found, not-found)
1422LLVM_PROF_ERR=no
1423case $CC in
1424 *clang*)
1425 # Any changes made here should be reflected in the GCC+Darwin case below
1426 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1427 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
1428 LLVM_PROF_MERGER="llvm-profdata merge -output=code.profclangd *.profclangr"
1429 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
1430 if test $LLVM_PROF_FOUND = not-found
1431 then
1432 LLVM_PROF_ERR=yes
1433 fi
1434 ;;
1435 *gcc*)
1436 case $ac_sys_system in
1437 Darwin*)
1438 PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
1439 PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
1440 LLVM_PROF_MERGER="llvm-profdata merge -output=code.profclangd *.profclangr"
1441 LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
1442 if test $LLVM_PROF_FOUND = not-found
1443 then
1444 LLVM_PROF_ERR=yes
1445 fi
1446 ;;
1447 *)
1448 PGO_PROF_GEN_FLAG="-fprofile-generate"
1449 PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
1450 LLVM_PROF_MERGER="true"
1451 LLVM_PROF_FILE=""
1452 ;;
1453 esac
1454 ;;
Zachary Ware6ed42ea2015-12-21 11:43:03 -06001455 *icc*)
1456 PGO_PROF_GEN_FLAG="-prof-gen"
1457 PGO_PROF_USE_FLAG="-prof-use"
1458 LLVM_PROF_MERGER="true"
1459 LLVM_PROF_FILE=""
1460 ;;
Brett Cannon4ff151a2015-09-18 15:09:42 -07001461esac
1462
1463
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001464# On some compilers, pthreads are available without further options
1465# (e.g. MacOS X). On some of these systems, the compiler will not
1466# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1467# So we have to see first whether pthreads are available without
1468# options before we can check whether -Kpthread improves anything.
1469AC_MSG_CHECKING(whether pthreads are available without options)
1470AC_CACHE_VAL(ac_cv_pthread_is_default,
Matthias Klosec511b472010-05-08 11:01:39 +00001471[AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001472#include <stdio.h>
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001473#include <pthread.h>
1474
1475void* routine(void* p){return NULL;}
1476
1477int main(){
1478 pthread_t p;
1479 if(pthread_create(&p,NULL,routine,NULL)!=0)
1480 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001481 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001482 return 0;
1483}
Matthias Klosec511b472010-05-08 11:01:39 +00001484]])],[
Skip Montanarod8d39a02003-07-10 20:44:10 +00001485 ac_cv_pthread_is_default=yes
1486 ac_cv_kthread=no
1487 ac_cv_pthread=no
Matthias Klosec511b472010-05-08 11:01:39 +00001488],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001489])
1490AC_MSG_RESULT($ac_cv_pthread_is_default)
1491
1492
1493if test $ac_cv_pthread_is_default = yes
1494then
1495 ac_cv_kpthread=no
1496else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001497# -Kpthread, if available, provides the right #defines
1498# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001499# Some compilers won't report that they do not support -Kpthread,
1500# so we need to run a program to see whether it really made the
1501# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +00001502AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1503AC_CACHE_VAL(ac_cv_kpthread,
1504[ac_save_cc="$CC"
1505CC="$CC -Kpthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001506AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001507#include <stdio.h>
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001508#include <pthread.h>
1509
1510void* routine(void* p){return NULL;}
1511
1512int main(){
1513 pthread_t p;
1514 if(pthread_create(&p,NULL,routine,NULL)!=0)
1515 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +00001516 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +00001517 return 0;
1518}
Matthias Klosec511b472010-05-08 11:01:39 +00001519]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001520CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +00001521AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001522fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00001523
Skip Montanarod8d39a02003-07-10 20:44:10 +00001524if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001525then
1526# -Kthread, if available, provides the right #defines
1527# and linker options to make pthread_create available
1528# Some compilers won't report that they do not support -Kthread,
1529# so we need to run a program to see whether it really made the
1530# function available.
1531AC_MSG_CHECKING(whether $CC accepts -Kthread)
1532AC_CACHE_VAL(ac_cv_kthread,
1533[ac_save_cc="$CC"
1534CC="$CC -Kthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001535AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001536#include <stdio.h>
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001537#include <pthread.h>
1538
1539void* routine(void* p){return NULL;}
1540
1541int main(){
1542 pthread_t p;
1543 if(pthread_create(&p,NULL,routine,NULL)!=0)
1544 return 1;
1545 (void)pthread_detach(p);
1546 return 0;
1547}
Matthias Klosec511b472010-05-08 11:01:39 +00001548]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001549CC="$ac_save_cc"])
1550AC_MSG_RESULT($ac_cv_kthread)
1551fi
1552
Skip Montanarod8d39a02003-07-10 20:44:10 +00001553if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001554then
1555# -pthread, if available, provides the right #defines
1556# and linker options to make pthread_create available
1557# Some compilers won't report that they do not support -pthread,
1558# so we need to run a program to see whether it really made the
1559# function available.
1560AC_MSG_CHECKING(whether $CC accepts -pthread)
doko@python.orgfa3f9a32013-01-25 15:32:31 +01001561AC_CACHE_VAL(ac_cv_pthread,
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001562[ac_save_cc="$CC"
1563CC="$CC -pthread"
Matthias Klosec511b472010-05-08 11:01:39 +00001564AC_RUN_IFELSE([AC_LANG_SOURCE([[
Stefan Krahae66ca62012-11-22 22:36:57 +01001565#include <stdio.h>
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001566#include <pthread.h>
1567
1568void* routine(void* p){return NULL;}
1569
1570int main(){
1571 pthread_t p;
1572 if(pthread_create(&p,NULL,routine,NULL)!=0)
1573 return 1;
1574 (void)pthread_detach(p);
1575 return 0;
1576}
Matthias Klosec511b472010-05-08 11:01:39 +00001577]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001578CC="$ac_save_cc"])
1579AC_MSG_RESULT($ac_cv_pthread)
1580fi
1581
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001582# If we have set a CC compiler flag for thread support then
1583# check if it works for CXX, too.
1584ac_cv_cxx_thread=no
1585if test ! -z "$CXX"
1586then
1587AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1588ac_save_cxx="$CXX"
1589
1590if test "$ac_cv_kpthread" = "yes"
1591then
Martin v. Löwis519adae2003-09-20 10:47:47 +00001592 CXX="$CXX -Kpthread"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001593 ac_cv_cxx_thread=yes
1594elif test "$ac_cv_kthread" = "yes"
1595then
1596 CXX="$CXX -Kthread"
1597 ac_cv_cxx_thread=yes
1598elif test "$ac_cv_pthread" = "yes"
1599then
1600 CXX="$CXX -pthread"
1601 ac_cv_cxx_thread=yes
1602fi
1603
1604if test $ac_cv_cxx_thread = yes
1605then
1606 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1607 $CXX -c conftest.$ac_ext 2>&5
1608 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1609 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1610 then
1611 ac_cv_cxx_thread=yes
1612 else
1613 ac_cv_cxx_thread=no
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001614 fi
1615 rm -fr conftest*
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001616fi
Brett Cannonc601e0f2004-11-07 01:24:12 +00001617AC_MSG_RESULT($ac_cv_cxx_thread)
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001618fi
Martin v. Löwis519adae2003-09-20 10:47:47 +00001619CXX="$ac_save_cxx"
Martin v. Löwisab1e5852003-06-28 07:46:38 +00001620
Fred Drakece81d592000-07-09 14:39:29 +00001621dnl # check for ANSI or K&R ("traditional") preprocessor
1622dnl AC_MSG_CHECKING(for C preprocessor type)
Matthias Klosec511b472010-05-08 11:01:39 +00001623dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Fred Drakece81d592000-07-09 14:39:29 +00001624dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1625dnl int foo;
1626dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
Matthias Klosec511b472010-05-08 11:01:39 +00001627dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
Fred Drakece81d592000-07-09 14:39:29 +00001628dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +00001629
Guido van Rossum627b2d71993-12-24 10:39:16 +00001630# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001631AC_HEADER_STDC
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001632AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001633fcntl.h grp.h \
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02001634ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001635shadow.h signal.h stdint.h stropts.h termios.h thread.h \
Martin v. Löwis14e73b12003-01-01 09:51:12 +00001636unistd.h utime.h \
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00001637sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1638sys/lock.h sys/mkdev.h sys/modem.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001639sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
Martin v. Löwis8c255e42008-05-23 15:06:50 +00001640sys/termio.h sys/time.h \
Martin v. Löwis0e8bd7e2006-06-10 12:23:46 +00001641sys/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 +00001642sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
Christian Heimes3aa138f2013-06-18 13:25:24 +02001643bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001644AC_HEADER_DIRENT
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00001645AC_HEADER_MAJOR
Guido van Rossum627b2d71993-12-24 10:39:16 +00001646
Martin v. Löwis11017b12006-01-14 18:12:57 +00001647# On Linux, netlink.h requires asm/types.h
1648AC_CHECK_HEADERS(linux/netlink.h,,,[
1649#ifdef HAVE_ASM_TYPES_H
1650#include <asm/types.h>
1651#endif
1652#ifdef HAVE_SYS_SOCKET_H
1653#include <sys/socket.h>
1654#endif
1655])
1656
Guido van Rossum627b2d71993-12-24 10:39:16 +00001657# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001658was_it_defined=no
1659AC_MSG_CHECKING(for clock_t in time.h)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001660AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1661 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1662])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001663AC_MSG_RESULT($was_it_defined)
1664
Neal Norwitz11690112002-07-30 01:08:28 +00001665# Check whether using makedev requires defining _OSF_SOURCE
1666AC_MSG_CHECKING(for makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00001667AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Jesus Cea616de772010-04-28 10:32:30 +00001668#if defined(MAJOR_IN_MKDEV)
1669#include <sys/mkdev.h>
1670#elif defined(MAJOR_IN_SYSMACROS)
1671#include <sys/sysmacros.h>
1672#else
1673#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001674#endif ]], [[ makedev(0, 0) ]])],
1675[ac_cv_has_makedev=yes],
1676[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001677if test "$ac_cv_has_makedev" = "no"; then
1678 # we didn't link, try if _OSF_SOURCE will allow us to link
Matthias Klosec511b472010-05-08 11:01:39 +00001679 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00001680#define _OSF_SOURCE 1
1681#include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001682 ]], [[ makedev(0, 0) ]])],
1683[ac_cv_has_makedev=yes],
1684[ac_cv_has_makedev=no])
Neal Norwitz11690112002-07-30 01:08:28 +00001685 if test "$ac_cv_has_makedev" = "yes"; then
1686 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1687 fi
1688fi
1689AC_MSG_RESULT($ac_cv_has_makedev)
1690if test "$ac_cv_has_makedev" = "yes"; then
1691 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1692fi
1693
Martin v. Löwis399a6892002-10-04 10:22:02 +00001694# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1695# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1696# defined, but the compiler does not support pragma redefine_extname,
1697# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1698# structures (such as rlimit64) without declaring them. As a
1699# work-around, disable LFS on such configurations
1700
1701use_lfs=yes
1702AC_MSG_CHECKING(Solaris LFS bug)
Matthias Klosec511b472010-05-08 11:01:39 +00001703AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis399a6892002-10-04 10:22:02 +00001704#define _LARGEFILE_SOURCE 1
1705#define _FILE_OFFSET_BITS 64
1706#include <sys/resource.h>
Matthias Klosec511b472010-05-08 11:01:39 +00001707]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001708AC_MSG_RESULT($sol_lfs_bug)
1709if test "$sol_lfs_bug" = "yes"; then
1710 use_lfs=no
1711fi
1712
1713if test "$use_lfs" = "yes"; then
Guido van Rossum810cc512001-09-09 23:51:39 +00001714# Two defines needed to enable largefile support on various platforms
1715# These may affect some typedefs
Georg Brandl94800df2011-02-25 11:09:02 +00001716case $ac_sys_system/$ac_sys_release in
1717AIX*)
1718 AC_DEFINE(_LARGE_FILES, 1,
1719 [This must be defined on AIX systems to enable large file support.])
1720 ;;
1721esac
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001722AC_DEFINE(_LARGEFILE_SOURCE, 1,
1723[This must be defined on some systems to enable large file support.])
1724AC_DEFINE(_FILE_OFFSET_BITS, 64,
1725[This must be set to 64 on some systems to enable large file support.])
Martin v. Löwis399a6892002-10-04 10:22:02 +00001726fi
Guido van Rossum810cc512001-09-09 23:51:39 +00001727
Guido van Rossum300fda71996-08-19 21:58:16 +00001728# Add some code to confdefs.h so that the test for off_t works on SCO
1729cat >> confdefs.h <<\EOF
1730#if defined(SCO_DS)
1731#undef _OFF_T
1732#endif
1733EOF
1734
Guido van Rossumef2255b2000-03-10 22:30:29 +00001735# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001736AC_TYPE_MODE_T
1737AC_TYPE_OFF_T
1738AC_TYPE_PID_T
Matthias Klosecbf54b12010-05-08 11:04:18 +00001739AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001740AC_TYPE_SIZE_T
1741AC_TYPE_UID_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001742
1743# There are two separate checks for each of the exact-width integer types we
1744# need. First we check whether the type is available using the usual
1745# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1746# and <stdint.h> where available). We then also use the special type checks of
1747# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1748# directly, #define's uint32_t to be a suitable type.
1749
1750AC_CHECK_TYPE(uint32_t,
1751 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001752AC_TYPE_UINT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001753
1754AC_CHECK_TYPE(uint64_t,
1755 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001756AC_TYPE_UINT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001757
1758AC_CHECK_TYPE(int32_t,
1759 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001760AC_TYPE_INT32_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001761
1762AC_CHECK_TYPE(int64_t,
1763 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
Mark Dickinsonefc82f72009-03-20 15:51:55 +00001764AC_TYPE_INT64_T
Mark Dickinson17c50cd2012-12-02 13:13:56 +00001765
Christian Heimes951cc0f2008-01-31 23:08:23 +00001766AC_CHECK_TYPE(ssize_t,
Matthias Klose5183ebd2010-04-24 16:38:36 +00001767 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001768
Guido van Rossumef2255b2000-03-10 22:30:29 +00001769# Sizes of various common basic types
Skip Montanarob9820a32004-01-17 00:16:12 +00001770# ANSI C requires sizeof(char) == 1, so no need to check it
Guido van Rossum3065c942001-09-17 04:03:14 +00001771AC_CHECK_SIZEOF(int, 4)
1772AC_CHECK_SIZEOF(long, 4)
1773AC_CHECK_SIZEOF(void *, 4)
Guido van Rossum3065c942001-09-17 04:03:14 +00001774AC_CHECK_SIZEOF(short, 2)
1775AC_CHECK_SIZEOF(float, 4)
1776AC_CHECK_SIZEOF(double, 8)
1777AC_CHECK_SIZEOF(fpos_t, 4)
Martin v. Löwis18e16552006-02-15 17:27:45 +00001778AC_CHECK_SIZEOF(size_t, 4)
Christian Heimes951cc0f2008-01-31 23:08:23 +00001779AC_CHECK_SIZEOF(pid_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +00001780
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001781AC_MSG_CHECKING(for long long support)
1782have_long_long=no
Matthias Klosec511b472010-05-08 11:01:39 +00001783AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001784 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1785 have_long_long=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001786],[])
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001787AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001788if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +00001789AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001790fi
1791
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001792AC_MSG_CHECKING(for long double support)
1793have_long_double=no
Matthias Klosec511b472010-05-08 11:01:39 +00001794AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001795 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1796 have_long_double=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001797],[])
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001798AC_MSG_RESULT($have_long_double)
Mark Dickinsondc1688a2008-06-27 22:20:14 +00001799if test "$have_long_double" = yes ; then
Travis E. Oliphant711c9e92008-06-06 22:33:21 +00001800AC_CHECK_SIZEOF(long double, 12)
1801fi
1802
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001803AC_MSG_CHECKING(for _Bool support)
1804have_c99_bool=no
Matthias Klosec511b472010-05-08 11:01:39 +00001805AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001806 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1807 have_c99_bool=yes
Matthias Klosec511b472010-05-08 11:01:39 +00001808],[])
Martin v. Löwisaef4c6b2007-01-21 09:33:07 +00001809AC_MSG_RESULT($have_c99_bool)
1810if test "$have_c99_bool" = yes ; then
1811AC_CHECK_SIZEOF(_Bool, 1)
1812fi
1813
Martin v. Löwisebe26702006-10-02 14:55:51 +00001814AC_CHECK_TYPES(uintptr_t,
1815 [AC_CHECK_SIZEOF(uintptr_t, 4)],
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001816 [], [#ifdef HAVE_STDINT_H
1817 #include <stdint.h>
Antoine Pitrou7be5a652010-10-10 08:14:41 +00001818 #endif
1819 #ifdef HAVE_INTTYPES_H
1820 #include <inttypes.h>
Martin v. Löwis40e9aed2006-10-02 15:20:37 +00001821 #endif])
Martin v. Löwisebe26702006-10-02 14:55:51 +00001822
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001823AC_CHECK_SIZEOF(off_t, [], [
1824#ifdef HAVE_SYS_TYPES_H
1825#include <sys/types.h>
1826#endif
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001827])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001828
1829AC_MSG_CHECKING(whether to enable large file support)
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001830if test "$have_long_long" = yes
1831then
1832if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +00001833 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001834 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1835 [Defined to enable large file support when an off_t is bigger than a long
1836 and long long is available and at least as big as an off_t. You may need
1837 to add some flags for configuration and compilation to enable this mode.
1838 (For Solaris and Linux, the necessary defines are already defined.)])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001839 AC_MSG_RESULT(yes)
1840else
1841 AC_MSG_RESULT(no)
1842fi
Mark Dickinson0ef0b912009-12-31 21:11:48 +00001843else
1844 AC_MSG_RESULT(no)
1845fi
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001846
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001847AC_CHECK_SIZEOF(time_t, [], [
1848#ifdef HAVE_SYS_TYPES_H
1849#include <sys/types.h>
1850#endif
1851#ifdef HAVE_TIME_H
1852#include <time.h>
1853#endif
Fred Drakea3f6e912000-06-29 20:44:47 +00001854])
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001855
Trent Mick635f6fb2000-08-23 21:33:05 +00001856# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001857ac_save_cc="$CC"
1858if test "$ac_cv_kpthread" = "yes"
1859then CC="$CC -Kpthread"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00001860elif test "$ac_cv_kthread" = "yes"
1861then CC="$CC -Kthread"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00001862elif test "$ac_cv_pthread" = "yes"
1863then CC="$CC -pthread"
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001864fi
Trent Mick635f6fb2000-08-23 21:33:05 +00001865AC_MSG_CHECKING(for pthread_t)
1866have_pthread_t=no
Matthias Klosec511b472010-05-08 11:01:39 +00001867AC_COMPILE_IFELSE([
1868 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1869],[have_pthread_t=yes],[])
Trent Mick635f6fb2000-08-23 21:33:05 +00001870AC_MSG_RESULT($have_pthread_t)
1871if test "$have_pthread_t" = yes ; then
Alexandre Vassalotti856782e2009-07-17 04:59:05 +00001872 AC_CHECK_SIZEOF(pthread_t, [], [
1873#ifdef HAVE_PTHREAD_H
1874#include <pthread.h>
1875#endif
Trent Mick635f6fb2000-08-23 21:33:05 +00001876 ])
Trent Mick635f6fb2000-08-23 21:33:05 +00001877fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +00001878CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +00001879
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001880AC_MSG_CHECKING(for --enable-toolbox-glue)
1881AC_ARG_ENABLE(toolbox-glue,
Matthias Klose22520ea2010-05-08 10:14:46 +00001882 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001883
1884if test -z "$enable_toolbox_glue"
1885then
1886 case $ac_sys_system/$ac_sys_release in
1887 Darwin/*)
1888 enable_toolbox_glue="yes";;
1889 *)
1890 enable_toolbox_glue="no";;
1891 esac
1892fi
1893case "$enable_toolbox_glue" in
1894yes)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001895 extra_machdep_objs="Python/mactoolboxglue.o"
Raymond Hettingerec6eb362004-11-05 07:02:59 +00001896 extra_undefs="-u _PyMac_Error"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001897 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1898 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001899 ;;
1900*)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001901 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +00001902 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001903 ;;
1904esac
1905AC_MSG_RESULT($enable_toolbox_glue)
1906
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00001907
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001908AC_SUBST(OTHER_LIBTOOL_OPT)
1909case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001910 Darwin/@<:@01567@:>@\..*)
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001911 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1912 ;;
1913 Darwin/*)
1914 OTHER_LIBTOOL_OPT=""
1915 ;;
1916esac
1917
Ronald Oussoren25967582009-09-06 10:00:26 +00001918
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001919AC_SUBST(LIBTOOL_CRUFT)
1920case $ac_sys_system/$ac_sys_release in
Anthony Baxter82201742006-04-09 15:07:40 +00001921 Darwin/@<:@01567@:>@\..*)
Ronald Oussoren988117f2006-04-29 11:31:35 +00001922 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1923 if test "${enable_universalsdk}"; then
1924 :
1925 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001926 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
Ronald Oussoren988117f2006-04-29 11:31:35 +00001927 fi
Jack Jansenb36687a2004-07-16 08:43:47 +00001928 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00001929 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +00001930 Darwin/*)
Ronald Oussorena55af9a2010-01-17 16:25:57 +00001931 gcc_version=`gcc -dumpversion`
Bob Ippolito7026a0a2005-03-28 23:23:47 +00001932 if test ${gcc_version} '<' 4.0
1933 then
1934 LIBTOOL_CRUFT="-lcc_dynamic"
1935 else
1936 LIBTOOL_CRUFT=""
1937 fi
Matthias Klosec511b472010-05-08 11:01:39 +00001938 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Ronald Oussoren25967582009-09-06 10:00:26 +00001939 #include <unistd.h>
1940 int main(int argc, char*argv[])
1941 {
1942 if (sizeof(long) == 4) {
1943 return 0;
1944 } else {
1945 return 1;
1946 }
Ronald Oussoren84ddd722009-09-08 07:17:10 +00001947 }
Matthias Klosec511b472010-05-08 11:01:39 +00001948 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
Ronald Oussoren25967582009-09-06 10:00:26 +00001949
1950 if test "${ac_osx_32bit}" = "yes"; then
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001951 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001952 i386)
1953 MACOSX_DEFAULT_ARCH="i386"
1954 ;;
1955 ppc)
1956 MACOSX_DEFAULT_ARCH="ppc"
1957 ;;
1958 *)
1959 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1960 ;;
1961 esac
1962 else
Ronald Oussorenbc0e83c2010-02-11 13:26:54 +00001963 case `/usr/bin/arch` in
Ronald Oussoren25967582009-09-06 10:00:26 +00001964 i386)
1965 MACOSX_DEFAULT_ARCH="x86_64"
1966 ;;
1967 ppc)
1968 MACOSX_DEFAULT_ARCH="ppc64"
1969 ;;
1970 *)
1971 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1972 ;;
1973 esac
1974
1975 #ARCH_RUN_32BIT="true"
1976 fi
1977
1978 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
Jack Jansenb36687a2004-07-16 08:43:47 +00001979 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001980 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001981esac
1982
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001983AC_MSG_CHECKING(for --enable-framework)
1984if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001985then
Skip Montanarodecc6a42003-01-01 20:07:49 +00001986 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001987 # -F. is needed to allow linking to the framework while
1988 # in the build location.
Martin v. Löwisc45929e2002-04-06 10:10:49 +00001989 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1990 [Define if you want to produce an OpenStep/Rhapsody framework
1991 (shared library plus accessory files).])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001992 AC_MSG_RESULT(yes)
Ronald Oussoren450d5612009-06-08 21:12:41 +00001993 if test $enable_shared = "yes"
1994 then
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00001995 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 +00001996 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00001997else
1998 AC_MSG_RESULT(no)
1999fi
2000
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002001AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002002case $ac_sys_system/$ac_sys_release in
2003 Darwin/*)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002004 AC_DEFINE(WITH_DYLD, 1,
2005 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
2006 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
2007 linker (rld). Dyld is necessary to support frameworks.])
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002008 AC_MSG_RESULT(always on for Darwin)
2009 ;;
2010 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002011 AC_MSG_RESULT(no)
2012 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +00002013esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002014
Guido van Rossumac405f61994-09-12 10:56:06 +00002015# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +00002016AC_SUBST(SO)
2017AC_SUBST(LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002018AC_SUBST(LDCXXSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002019AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002020AC_SUBST(CCSHARED)
2021AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002022# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +00002023# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002024AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +00002025if test -z "$SO"
2026then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002027 case $ac_sys_system in
Neal Norwitz58e28882006-05-19 07:00:58 +00002028 hp*|HP*)
2029 case `uname -m` in
2030 ia64) SO=.so;;
2031 *) SO=.sl;;
2032 esac
2033 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +00002034 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00002035 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +00002036 esac
Martin v. Löwis368de8f2003-06-14 14:46:38 +00002037else
2038 # this might also be a termcap variable, see #610332
2039 echo
2040 echo '====================================================================='
2041 echo '+ +'
2042 echo '+ WARNING: You have set SO in your environment. +'
2043 echo '+ Do you really mean to change the extension for shared libraries? +'
2044 echo '+ Continuing in 10 seconds to let you to ponder. +'
2045 echo '+ +'
2046 echo '====================================================================='
2047 sleep 10
Guido van Rossumac405f61994-09-12 10:56:06 +00002048fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002049AC_MSG_RESULT($SO)
Ronald Oussoren79f90492009-01-02 10:44:46 +00002050
Neal Norwitz58e28882006-05-19 07:00:58 +00002051AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
Guido van Rossumac405f61994-09-12 10:56:06 +00002052# LDSHARED is the ld *command* used to create shared library
Skip Montanaroce59c042004-01-17 14:19:44 +00002053# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002054# (Shared libraries in this instance are shared modules to be loaded into
2055# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002056AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002057if test -z "$LDSHARED"
2058then
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002059 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002060 AIX*)
Georg Brandl71f4fbb2011-02-25 11:04:50 +00002061 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +00002062 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002063 ;;
2064 BeOS*)
2065 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +00002066 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002067 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002068 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +00002069 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Greg Ward57c9a662000-05-26 12:22:54 +00002070 SunOS/5*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002071 if test "$GCC" = "yes" ; then
2072 LDSHARED='$(CC) -shared'
2073 LDCXXSHARED='$(CXX) -shared'
2074 else
2075 LDSHARED='$(CC) -G'
2076 LDCXXSHARED='$(CXX) -G'
Greg Ward57c9a662000-05-26 12:22:54 +00002077 fi ;;
Thomas Hellerdc96a772008-04-04 10:07:55 +00002078 hp*|HP*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002079 if test "$GCC" = "yes" ; then
2080 LDSHARED='$(CC) -shared'
2081 LDCXXSHARED='$(CXX) -shared'
2082 else
2083 LDSHARED='ld -b'
Thomas Hellerdc96a772008-04-04 10:07:55 +00002084 fi ;;
Guido van Rossum71001e41995-01-26 00:44:03 +00002085 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Jack Jansen418c3b12001-11-14 10:59:57 +00002086 Darwin/1.3*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002087 LDSHARED='$(CC) -bundle'
2088 LDCXXSHARED='$(CXX) -bundle'
Jack Jansena3891ea2001-09-07 14:25:12 +00002089 if test "$enable_framework" ; then
2090 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002091 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2092 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002093 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansena3891ea2001-09-07 14:25:12 +00002094 else
2095 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +00002096 LDSHARED="$LDSHARED -undefined suppress"
Tarek Ziadé00002952010-04-03 08:37:59 +00002097 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +00002098 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002099 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002100 LDSHARED='$(CC) -bundle'
2101 LDCXXSHARED='$(CXX) -bundle'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002102 if test "$enable_framework" ; then
2103 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002104 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2105 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002106 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002107 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +00002108 # No framework, use the Python app as bundle-loader
2109 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
Jack Jansenc28fc372003-02-25 13:14:43 +00002110 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002111 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002112 fi ;;
Jack Jansen6b08a402004-06-03 12:41:45 +00002113 Darwin/*)
2114 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2115 # This allows an extension to be used in any Python
Ronald Oussoren38f1b982007-09-02 09:46:07 +00002116
Ned Deilyc40b9032014-06-25 13:48:46 -07002117 dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2118 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
2119 dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
2120 sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
2121 if test ${dep_target_major} -eq 10 && \
2122 test ${dep_target_minor} -le 2
Jack Jansen6b08a402004-06-03 12:41:45 +00002123 then
Ned Deilyc40b9032014-06-25 13:48:46 -07002124 # building for OS X 10.0 through 10.2
Stefan Krah3a3e2032010-11-28 15:30:05 +00002125 LDSHARED='$(CC) -bundle'
2126 LDCXXSHARED='$(CXX) -bundle'
Jack Jansen6b08a402004-06-03 12:41:45 +00002127 if test "$enable_framework" ; then
2128 # Link against the framework. All externals should be defined.
Jack Jansenda49e192005-01-07 13:08:22 +00002129 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2130 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002131 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002132 else
2133 # No framework, use the Python app as bundle-loader
2134 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2135 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Tarek Ziadé00002952010-04-03 08:37:59 +00002136 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
Jack Jansen6b08a402004-06-03 12:41:45 +00002137 fi
Ned Deilyc40b9032014-06-25 13:48:46 -07002138 else
2139 # building for OS X 10.3 and later
2140 if test "${enable_universalsdk}"; then
2141 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2142 fi
2143 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2144 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2145 BLDSHARED="$LDSHARED"
Jack Jansen6b08a402004-06-03 12:41:45 +00002146 fi
2147 ;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002148 Linux*|GNU*|QNX*)
2149 LDSHARED='$(CC) -shared'
2150 LDCXXSHARED='$(CXX) -shared';;
2151 BSD/OS*/4*)
2152 LDSHARED="gcc -shared"
2153 LDCXXSHARED="g++ -shared";;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002154 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +00002155 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +00002156 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002157 LDSHARED='$(CC) -shared'
2158 LDCXXSHARED='$(CXX) -shared'
Guido van Rossum0286ae82000-08-29 15:06:49 +00002159 else
Stefan Krah3a3e2032010-11-28 15:30:05 +00002160 LDSHARED="ld -Bshareable"
Guido van Rossum0286ae82000-08-29 15:06:49 +00002161 fi;;
Martin v. Löwis222c5152006-06-03 07:37:13 +00002162 OpenBSD*)
2163 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2164 then
Stefan Krah3a3e2032010-11-28 15:30:05 +00002165 LDSHARED='$(CC) -shared $(CCSHARED)'
2166 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002167 else
2168 case `uname -r` in
2169 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2170 LDSHARED="ld -Bshareable ${LDFLAGS}"
2171 ;;
2172 *)
Stefan Krah3a3e2032010-11-28 15:30:05 +00002173 LDSHARED='$(CC) -shared $(CCSHARED)'
2174 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
Martin v. Löwis222c5152006-06-03 07:37:13 +00002175 ;;
2176 esac
2177 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002178 NetBSD*|DragonFly*)
Antoine Pitroucb402772011-01-02 20:51:34 +00002179 LDSHARED='$(CC) -shared'
2180 LDCXXSHARED='$(CXX) -shared';;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002181 OpenUNIX*|UnixWare*)
Tarek Ziadé00002952010-04-03 08:37:59 +00002182 if test "$GCC" = "yes" ; then
2183 LDSHARED='$(CC) -shared'
2184 LDCXXSHARED='$(CXX) -shared'
2185 else
2186 LDSHARED='$(CC) -G'
2187 LDCXXSHARED='$(CXX) -G'
Martin v. Löwisbec19582001-03-21 15:57:54 +00002188 fi;;
Tarek Ziadé00002952010-04-03 08:37:59 +00002189 SCO_SV*)
2190 LDSHARED='$(CC) -Wl,-G,-Bexport'
2191 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2192 CYGWIN*)
2193 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2194 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2195 atheos*)
2196 LDSHARED="gcc -shared"
2197 LDCXXSHARED="g++ -shared";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002198 *) LDSHARED="ld";;
2199 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002200fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002201AC_MSG_RESULT($LDSHARED)
Tarek Ziadé00002952010-04-03 08:37:59 +00002202LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002203BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +00002204# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002205# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002206AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002207if test -z "$CCSHARED"
2208then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002209 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +00002210 SunOS*) if test "$GCC" = yes;
Martin v. Löwiseb623572007-03-12 10:50:39 +00002211 then CCSHARED="-fPIC";
2212 elif test `uname -p` = sparc;
2213 then CCSHARED="-xcode=pic32";
2214 else CCSHARED="-Kpic";
2215 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +00002216 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +00002217 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +00002218 else CCSHARED="+z";
2219 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002220 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002221 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002222 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002223 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +00002224 if test "$GCC" = "yes"
2225 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002226 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +00002227 fi;;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002228 SCO_SV*)
2229 if test "$GCC" = "yes"
2230 then CCSHARED="-fPIC"
2231 else CCSHARED="-Kpic -belf"
2232 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002233 IRIX*/6*) case $CC in
2234 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +00002235 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002236 esac;;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002237 atheos*) CCSHARED="-fPIC";;
Guido van Rossumac405f61994-09-12 10:56:06 +00002238 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002239fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002240AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002241# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +00002242# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002243AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002244if test -z "$LINKFORSHARED"
2245then
Guido van Rossum6100aaf1997-04-29 21:48:51 +00002246 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +00002247 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +00002248 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +00002249 LINKFORSHARED="-Wl,-E -Wl,+s";;
2250# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +00002251 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002252 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +00002253 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002254 Darwin/*)
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002255 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2256 # which is
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002257 # not used by the core itself but which needs to be in the core so
2258 # that dynamically loaded extension modules have access to it.
Jack Jansen97e3f002003-02-23 22:59:01 +00002259 # -prebind is no longer used, because it actually seems to give a
2260 # slowdown in stead of a speedup, maybe due to the large number of
2261 # dynamic loads Python does.
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002262
2263 LINKFORSHARED="$extra_undefs"
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002264 if test "$enable_framework"
2265 then
Jack Jansenda49e192005-01-07 13:08:22 +00002266 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Jack Jansenb6e9cad2001-08-15 01:26:28 +00002267 fi
Raymond Hettingerec6eb362004-11-05 07:02:59 +00002268 LINKFORSHARED="$LINKFORSHARED";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +00002269 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Martin v. Löwis21ee4092002-09-30 16:19:48 +00002270 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +00002271 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis86d66262006-02-17 08:40:11 +00002272 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
Guido van Rossumdf693651999-01-07 21:50:41 +00002273 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2274 then
2275 LINKFORSHARED="-Wl,--export-dynamic"
2276 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002277 SunOS/5*) case $CC in
2278 *gcc*)
Martin v. Löwisa4548572002-04-18 14:51:36 +00002279 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +00002280 then
2281 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +00002282 fi;;
2283 esac;;
Jason Tishler30765592003-09-04 11:04:06 +00002284 CYGWIN*)
2285 if test $enable_shared = "no"
2286 then
2287 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2288 fi;;
Martin v. Löwis8c255e42008-05-23 15:06:50 +00002289 QNX*)
2290 # -Wl,-E causes the symbols to be added to the dynamic
2291 # symbol table so that they can be found when a module
2292 # is loaded. -N 2048K causes the stack size to be set
2293 # to 2048 kilobytes so that the stack doesn't overflow
2294 # when running test_compile.py.
2295 LINKFORSHARED='-Wl,-E -N 2048K';;
Guido van Rossumac405f61994-09-12 10:56:06 +00002296 esac
Guido van Rossumac405f61994-09-12 10:56:06 +00002297fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002298AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +00002299
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002300
Neil Schemenauer61c51152001-01-26 16:18:16 +00002301AC_SUBST(CFLAGSFORSHARED)
2302AC_MSG_CHECKING(CFLAGSFORSHARED)
2303if test ! "$LIBRARY" = "$LDLIBRARY"
2304then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +00002305 case $ac_sys_system in
2306 CYGWIN*)
2307 # Cygwin needs CCSHARED when building extension DLLs
2308 # but not when building the interpreter DLL.
2309 CFLAGSFORSHARED='';;
2310 *)
2311 CFLAGSFORSHARED='$(CCSHARED)'
2312 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +00002313fi
2314AC_MSG_RESULT($CFLAGSFORSHARED)
2315
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002316# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2317# library (with --enable-shared).
2318# For platforms on which shared libraries are not allowed to have unresolved
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002319# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2320# if it is not required, since it creates a dependency of the shared library
2321# to LIBS. This, in turn, means that applications linking the shared libpython
2322# don't need to link LIBS explicitly. The default should be only changed
2323# on systems where this approach causes problems.
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002324AC_SUBST(SHLIBS)
2325AC_MSG_CHECKING(SHLIBS)
2326case "$ac_sys_system" in
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002327 *)
Martin v. Löwisd6359c52002-08-04 12:38:50 +00002328 SHLIBS='$(LIBS)';;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002329esac
2330AC_MSG_RESULT($SHLIBS)
2331
2332
Guido van Rossum627b2d71993-12-24 10:39:16 +00002333# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +00002334AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2335AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Victor Stinner7c906672015-01-06 13:53:37 +01002336AC_CHECK_LIB(crypto, RAND_egd,
2337 AC_DEFINE(HAVE_RAND_EGD, 1,
2338 [Define if the libcrypto has RAND_egd]))
Martin v. Löwis519adae2003-09-20 10:47:47 +00002339
Skip Montanaro4d756af2008-12-01 01:55:22 +00002340# only check for sem_init if thread support is requested
Martin v. Löwis519adae2003-09-20 10:47:47 +00002341if test "$with_threads" = "yes" -o -z "$with_threads"; then
2342 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2343 # posix4 on Solaris 2.6
2344 # pthread (first!) on Linux
2345fi
2346
Martin v. Löwis19d17342003-06-14 21:03:05 +00002347# check if we need libintl for locale functions
2348AC_CHECK_LIB(intl, textdomain,
2349 AC_DEFINE(WITH_LIBINTL, 1,
2350 [Define to 1 if libintl is needed for locale functions.]))
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002351
2352# checks for system dependent C++ extensions support
2353case "$ac_sys_system" in
2354 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
Matthias Klosec511b472010-05-08 11:01:39 +00002355 AC_LINK_IFELSE([
Georg Brandl94800df2011-02-25 11:09:02 +00002356 AC_LANG_PROGRAM([[#include <load.h>]],
Matthias Klosec511b472010-05-08 11:01:39 +00002357 [[loadAndInit("", 0, "")]])
2358 ],[
2359 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002360 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2361 and you want support for AIX C++ shared extension modules.])
Matthias Klosec511b472010-05-08 11:01:39 +00002362 AC_MSG_RESULT(yes)
2363 ],[
2364 AC_MSG_RESULT(no)
2365 ]);;
Guido van Rossum0eefa3f1999-11-16 15:57:37 +00002366 *) ;;
2367esac
2368
Guido van Rossum70c7f481998-03-26 18:44:10 +00002369# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002370# BeOS' sockets are stashed in libnet.
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002371AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +00002372AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Skip Montanarob9949db2004-01-17 04:04:13 +00002373
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +00002374case "$ac_sys_system" in
2375BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +00002376AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2377;;
2378esac
Guido van Rossum70c7f481998-03-26 18:44:10 +00002379
Guido van Rossumc5a39031996-07-31 17:35:03 +00002380AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002381AC_ARG_WITH(libs,
Matthias Klose22520ea2010-05-08 10:14:46 +00002382 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002383[
Guido van Rossumc5a39031996-07-31 17:35:03 +00002384AC_MSG_RESULT($withval)
2385LIBS="$withval $LIBS"
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002386],
2387[AC_MSG_RESULT(no)])
Guido van Rossum627b2d71993-12-24 10:39:16 +00002388
Benjamin Peterson64e8f6e2014-12-15 00:00:23 -05002389PKG_PROG_PKG_CONFIG
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002390
Benjamin Peterson2c196742009-12-31 03:17:18 +00002391# Check for use of the system expat library
2392AC_MSG_CHECKING(for --with-system-expat)
2393AC_ARG_WITH(system_expat,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002394 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2395 [],
2396 [with_system_expat="no"])
Benjamin Peterson2c196742009-12-31 03:17:18 +00002397
2398AC_MSG_RESULT($with_system_expat)
2399
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002400# Check for use of the system libffi library
2401AC_MSG_CHECKING(for --with-system-ffi)
2402AC_ARG_WITH(system_ffi,
Benjamin Petersonf2d1b2a2010-10-31 16:53:53 +00002403 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2404 [],
2405 [with_system_ffi="no"])
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002406
Benjamin Petersone9e07bf2010-03-09 21:46:54 +00002407if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
Benjamin Peterson1c335e62010-01-01 15:16:29 +00002408 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2409else
2410 LIBFFI_INCLUDEDIR=""
2411fi
2412AC_SUBST(LIBFFI_INCLUDEDIR)
2413
Martin v. Löwis9176fc12006-04-11 11:12:43 +00002414AC_MSG_RESULT($with_system_ffi)
2415
Ned Deilya2a9f572013-10-25 00:30:10 -07002416# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2417AC_SUBST(TCLTK_INCLUDES)
2418AC_SUBST(TCLTK_LIBS)
2419AC_MSG_CHECKING(for --with-tcltk-includes)
2420AC_ARG_WITH(tcltk-includes,
2421 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2422 [],
2423 [with_tcltk_includes="default"])
2424AC_MSG_RESULT($with_tcltk_includes)
2425AC_MSG_CHECKING(for --with-tcltk-libs)
2426AC_ARG_WITH(tcltk-libs,
2427 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2428 [],
2429 [with_tcltk_libs="default"])
2430AC_MSG_RESULT($with_tcltk_libs)
2431if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2432then
2433 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2434 then
2435 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2436 fi
2437 TCLTK_INCLUDES=""
2438 TCLTK_LIBS=""
2439else
2440 TCLTK_INCLUDES="$with_tcltk_includes"
2441 TCLTK_LIBS="$with_tcltk_libs"
2442fi
2443
Matthias Klose10cbe482009-04-29 17:18:19 +00002444# Check for --with-dbmliborder
2445AC_MSG_CHECKING(for --with-dbmliborder)
2446AC_ARG_WITH(dbmliborder,
Matthias Klose22520ea2010-05-08 10:14:46 +00002447 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 +00002448[
2449if test x$with_dbmliborder = xyes
2450then
2451AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2452else
2453 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2454 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2455 then
2456 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2457 fi
2458 done
Matthias Klose61dbdb92009-04-29 20:09:50 +00002459fi])
2460AC_MSG_RESULT($with_dbmliborder)
Matthias Klose10cbe482009-04-29 17:18:19 +00002461
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002462# Determine if signalmodule should be used.
2463AC_SUBST(USE_SIGNAL_MODULE)
2464AC_SUBST(SIGNAL_OBJS)
2465AC_MSG_CHECKING(for --with-signal-module)
2466AC_ARG_WITH(signal-module,
Matthias Klose22520ea2010-05-08 10:14:46 +00002467 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002468
2469if test -z "$with_signal_module"
2470then with_signal_module="yes"
2471fi
2472AC_MSG_RESULT($with_signal_module)
2473
2474if test "${with_signal_module}" = "yes"; then
2475 USE_SIGNAL_MODULE=""
2476 SIGNAL_OBJS=""
2477else
2478 USE_SIGNAL_MODULE="#"
2479 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2480fi
2481
Guido van Rossum3d15bd82001-01-10 18:53:48 +00002482# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00002483AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002484USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00002485
Guido van Rossum54d93d41997-01-22 20:51:58 +00002486AC_MSG_CHECKING(for --with-dec-threads)
2487AC_SUBST(LDLAST)
2488AC_ARG_WITH(dec-threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002489 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002490[
Barry Warsawc0d24d82000-06-29 16:12:00 +00002491AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00002492LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00002493if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00002494 with_thread="$withval";
2495fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002496[AC_MSG_RESULT(no)])
Guido van Rossum54d93d41997-01-22 20:51:58 +00002497
Martin v. Löwis11437992002-04-12 09:54:03 +00002498# Templates for things AC_DEFINEd more than once.
2499# For a single AC_DEFINE, no template is needed.
2500AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2501AH_TEMPLATE(_REENTRANT,
2502 [Define to force use of thread-safe errno, h_errno, and other functions])
2503AH_TEMPLATE(WITH_THREAD,
2504 [Define if you want to compile in rudimentary thread support])
2505
Guido van Rossum54d93d41997-01-22 20:51:58 +00002506AC_MSG_CHECKING(for --with-threads)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002507dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawc0d24d82000-06-29 16:12:00 +00002508AC_ARG_WITH(threads,
Matthias Klose22520ea2010-05-08 10:14:46 +00002509 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
Guido van Rossum54d93d41997-01-22 20:51:58 +00002510
Barry Warsawc0d24d82000-06-29 16:12:00 +00002511# --with-thread is deprecated, but check for it anyway
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002512dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00002513AC_ARG_WITH(thread,
Matthias Klose22520ea2010-05-08 10:14:46 +00002514 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002515 [with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002516
2517if test -z "$with_threads"
2518then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002519fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00002520AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00002521
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002522AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002523if test "$with_threads" = "no"
2524then
2525 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002526elif test "$ac_cv_pthread_is_default" = yes
2527then
2528 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002529 # Defining _REENTRANT on system with POSIX threads should not hurt.
2530 AC_DEFINE(_REENTRANT)
2531 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002532 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00002533elif test "$ac_cv_kpthread" = "yes"
2534then
2535 CC="$CC -Kpthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002536 if test "$ac_cv_cxx_thread" = "yes"; then
2537 CXX="$CXX -Kpthread"
2538 fi
Martin v. Löwis130fb172001-07-19 11:00:41 +00002539 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002540 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002541 THREADOBJ="Python/thread.o"
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002542elif test "$ac_cv_kthread" = "yes"
2543then
2544 CC="$CC -Kthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002545 if test "$ac_cv_cxx_thread" = "yes"; then
2546 CXX="$CXX -Kthread"
2547 fi
Martin v. Löwis5f433f02003-05-05 05:05:30 +00002548 AC_DEFINE(WITH_THREAD)
2549 posix_threads=yes
2550 THREADOBJ="Python/thread.o"
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002551elif test "$ac_cv_pthread" = "yes"
2552then
2553 CC="$CC -pthread"
Martin v. Löwis519adae2003-09-20 10:47:47 +00002554 if test "$ac_cv_cxx_thread" = "yes"; then
2555 CXX="$CXX -pthread"
2556 fi
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002557 AC_DEFINE(WITH_THREAD)
2558 posix_threads=yes
2559 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00002560else
Martin v. Löwis130fb172001-07-19 11:00:41 +00002561 if test ! -z "$with_threads" -a -d "$with_threads"
2562 then LDFLAGS="$LDFLAGS -L$with_threads"
2563 fi
2564 if test ! -z "$withval" -a -d "$withval"
2565 then LDFLAGS="$LDFLAGS -L$withval"
2566 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002567
2568 # According to the POSIX spec, a pthreads implementation must
Matthias Klosea2542be2004-08-16 11:35:51 +00002569 # define _POSIX_THREADS in unistd.h. Some apparently don't
2570 # (e.g. gnu pth with pthread emulation)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002571 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2572 AC_EGREP_CPP(yes,
Neal Norwitz6eb37f02003-02-23 23:28:15 +00002573 [
2574#include <unistd.h>
2575#ifdef _POSIX_THREADS
2576yes
2577#endif
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002578 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2579 AC_MSG_RESULT($unistd_defines_pthreads)
2580
Martin v. Löwis130fb172001-07-19 11:00:41 +00002581 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002582 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2583 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002584 AC_DEFINE(HURD_C_THREADS, 1,
2585 [Define if you are using Mach cthreads directly under /include])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00002586 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002587 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002588 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2589 AC_DEFINE(C_THREADS)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002590 AC_DEFINE(MACH_C_THREADS, 1,
2591 [Define if you are using Mach cthreads under mach /])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002592 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002593 AC_MSG_CHECKING(for --with-pth)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002594 AC_ARG_WITH([pth],
Matthias Klose22520ea2010-05-08 10:14:46 +00002595 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002596 [AC_MSG_RESULT($withval)
2597 AC_DEFINE([WITH_THREAD])
2598 AC_DEFINE([HAVE_PTH], 1,
2599 [Define if you have GNU PTH threads.])
2600 LIBS="-lpth $LIBS"
2601 THREADOBJ="Python/thread.o"],
2602 [AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002603
2604 # Just looking for pthread_create in libpthread is not enough:
2605 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2606 # So we really have to include pthread.h, and then link.
2607 _libs=$LIBS
2608 LIBS="$LIBS -lpthread"
2609 AC_MSG_CHECKING([for pthread_create in -lpthread])
Stefan Krahae66ca62012-11-22 22:36:57 +01002610 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2611#include <stdio.h>
2612#include <pthread.h>
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002613
Matthias Klosec511b472010-05-08 11:01:39 +00002614void * start_routine (void *arg) { exit (0); }]], [[
2615pthread_create (NULL, NULL, start_routine, NULL)]])],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002616 AC_MSG_RESULT(yes)
2617 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002618 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002619 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00002620 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00002621 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002622 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002623 THREADOBJ="Python/thread.o"],[
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002624 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2625 AC_DEFINE(ATHEOS_THREADS, 1,
2626 [Define this if you have AtheOS threads.])
2627 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002628 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002629 AC_DEFINE(BEOS_THREADS, 1,
2630 [Define this if you have BeOS threads.])
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002631 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002632 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002633 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002634 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002635 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002636 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002637 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002638 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002639 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002640 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002641 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002642 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002643 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00002644 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002645 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00002646 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00002647 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00002648 USE_THREAD_MODULE="#"])
Skip Montanarof8712e52004-01-17 03:04:46 +00002649 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00002650
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002651 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2652 LIBS="$LIBS -lmpc"
2653 THREADOBJ="Python/thread.o"
2654 USE_THREAD_MODULE=""])
2655
2656 if test "$posix_threads" != "yes"; then
2657 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2658 LIBS="$LIBS -lthread"
2659 THREADOBJ="Python/thread.o"
2660 USE_THREAD_MODULE=""])
2661 fi
2662
2663 if test "$USE_THREAD_MODULE" != "#"
2664 then
2665 # If the above checks didn't disable threads, (at least) OSF1
2666 # needs this '-threads' argument during linking.
2667 case $ac_sys_system in
2668 OSF1) LDLAST=-threads;;
2669 esac
2670 fi
2671fi
2672
2673if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002674 if test "$unistd_defines_pthreads" = "no"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002675 AC_DEFINE(_POSIX_THREADS, 1,
2676 [Define if you have POSIX threads,
2677 and your system does not define that.])
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00002678 fi
2679
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002680 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2681 case $ac_sys_system/$ac_sys_release in
Charles-François Natali4929eb92011-07-21 19:41:04 +02002682 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002683 [Defined for Solaris 2.6 bug in pthread header.])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002684 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002685 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002686 [Define if the Posix semaphores do not work on your system])
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002687 ;;
Charles-François Natali4929eb92011-07-21 19:41:04 +02002688 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Matthias Klose5183ebd2010-04-24 16:38:36 +00002689 [Define if the Posix semaphores do not work on your system])
Christian Heimescba36bb2008-01-30 22:54:18 +00002690 ;;
Martin v. Löwisdfc33fd2003-01-21 10:14:41 +00002691 esac
2692
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002693 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2694 AC_CACHE_VAL(ac_cv_pthread_system_supported,
Stefan Krahae66ca62012-11-22 22:36:57 +01002695 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2696 #include <stdio.h>
2697 #include <pthread.h>
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002698 void *foo(void *parm) {
2699 return NULL;
2700 }
2701 main() {
2702 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002703 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002704 if (pthread_attr_init(&attr)) exit(-1);
2705 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00002706 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002707 exit(0);
Matthias Klosec511b472010-05-08 11:01:39 +00002708 }]])],
2709 [ac_cv_pthread_system_supported=yes],
2710 [ac_cv_pthread_system_supported=no],
2711 [ac_cv_pthread_system_supported=no])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002712 ])
2713 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2714 if test "$ac_cv_pthread_system_supported" = "yes"; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002715 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00002716 fi
Jason Tishlerfac083d2003-07-22 15:20:49 +00002717 AC_CHECK_FUNCS(pthread_sigmask,
2718 [case $ac_sys_system in
2719 CYGWIN*)
2720 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2721 [Define if pthread_sigmask() does not work on your system.])
2722 ;;
2723 esac])
Christian Heimes0d604cf2013-08-21 13:26:05 +02002724 AC_CHECK_FUNCS(pthread_atfork)
Barry Warsawc0d24d82000-06-29 16:12:00 +00002725fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002726
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00002727
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002728# Check for enable-ipv6
Martin v. Löwis11437992002-04-12 09:54:03 +00002729AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002730AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002731AC_ARG_ENABLE(ipv6,
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002732[ --enable-ipv6 Enable ipv6 (with ipv4) support
2733 --disable-ipv6 Disable ipv6 support],
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002734[ case "$enableval" in
2735 no)
2736 AC_MSG_RESULT(no)
2737 ipv6=no
2738 ;;
2739 *) AC_MSG_RESULT(yes)
2740 AC_DEFINE(ENABLE_IPV6)
2741 ipv6=yes
2742 ;;
2743 esac ],
2744
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002745[
2746dnl the check does not work on cross compilation case...
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002747 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002748#include <sys/types.h>
Charles-François Natalibe2b9072013-01-08 19:47:00 +01002749#include <sys/socket.h>]],
2750[[int domain = AF_INET6;]])],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002751 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00002752 ipv6=yes
2753],[
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002754 AC_MSG_RESULT(no)
2755 ipv6=no
Matthias Klosec511b472010-05-08 11:01:39 +00002756])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002757
2758if test "$ipv6" = "yes"; then
2759 AC_MSG_CHECKING(if RFC2553 API is available)
Matthias Klosec511b472010-05-08 11:01:39 +00002760 AC_COMPILE_IFELSE([
2761 AC_LANG_PROGRAM([[#include <sys/types.h>
2762#include <netinet/in.h>]],
2763 [[struct sockaddr_in6 x;
2764 x.sin6_scope_id;]])
2765 ],[
2766 AC_MSG_RESULT(yes)
2767 ipv6=yes
2768 ],[
2769 AC_MSG_RESULT(no, IPv6 disabled)
2770 ipv6=no
2771 ])
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00002772fi
2773
2774if test "$ipv6" = "yes"; then
2775 AC_DEFINE(ENABLE_IPV6)
2776fi
2777])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002778
2779ipv6type=unknown
2780ipv6lib=none
2781ipv6trylibc=no
2782
2783if test "$ipv6" = "yes"; then
2784 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00002785 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2786 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002787 case $i in
2788 inria)
2789 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002790 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002791#include <netinet/in.h>
2792#ifdef IPV6_INRIA_VERSION
2793yes
2794#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002795 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002796 ;;
2797 kame)
2798 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002799 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002800#include <netinet/in.h>
2801#ifdef __KAME__
2802yes
2803#endif],
2804 [ipv6type=$i;
2805 ipv6lib=inet6
2806 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002807 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002808 ;;
2809 linux-glibc)
2810 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002811 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002812#include <features.h>
2813#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2814yes
2815#endif],
2816 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002817 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002818 ;;
2819 linux-inet6)
2820 dnl http://www.v6.linux.or.jp/
2821 if test -d /usr/inet6; then
2822 ipv6type=$i
2823 ipv6lib=inet6
2824 ipv6libdir=/usr/inet6/lib
Skip Montanarodecc6a42003-01-01 20:07:49 +00002825 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002826 fi
2827 ;;
2828 solaris)
2829 if test -f /etc/netconfig; then
Antoine Pitrou31e85952011-01-03 18:57:14 +00002830 if $GREP -q tcp6 /etc/netconfig; then
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002831 ipv6type=$i
2832 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002833 fi
2834 fi
2835 ;;
2836 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002837 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002838#include <sys/param.h>
2839#ifdef _TOSHIBA_INET6
2840yes
2841#endif],
2842 [ipv6type=$i;
2843 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002844 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002845 ;;
2846 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002847 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002848#include </usr/local/v6/include/sys/v6config.h>
2849#ifdef __V6D__
2850yes
2851#endif],
2852 [ipv6type=$i;
2853 ipv6lib=v6;
2854 ipv6libdir=/usr/local/v6/lib;
Skip Montanarodecc6a42003-01-01 20:07:49 +00002855 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002856 ;;
2857 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00002858 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002859#include <sys/param.h>
2860#ifdef _ZETA_MINAMI_INET6
2861yes
2862#endif],
2863 [ipv6type=$i;
2864 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00002865 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00002866 ;;
2867 esac
2868 if test "$ipv6type" != "unknown"; then
2869 break
2870 fi
2871 done
2872 AC_MSG_RESULT($ipv6type)
2873fi
2874
2875if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2876 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2877 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2878 echo "using lib$ipv6lib"
2879 else
2880 if test $ipv6trylibc = "yes"; then
2881 echo "using libc"
2882 else
2883 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2884 echo "You need to fetch lib$ipv6lib.a from appropriate"
2885 echo 'ipv6 kit and compile beforehand.'
2886 exit 1
2887 fi
2888 fi
2889fi
2890
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002891AC_MSG_CHECKING(for OSX 10.5 SDK or later)
Matthias Klosec511b472010-05-08 11:01:39 +00002892AC_COMPILE_IFELSE([
Mark Dickinson0712b562010-05-08 19:13:21 +00002893 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
Matthias Klosec511b472010-05-08 11:01:39 +00002894],[
Matthias Klose5183ebd2010-04-24 16:38:36 +00002895 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
Matthias Klosec511b472010-05-08 11:01:39 +00002896 AC_MSG_RESULT(yes)
2897],[
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002898 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00002899])
Ronald Oussoren0d236eb2008-06-06 21:31:33 +00002900
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002901# Check for --with-doc-strings
2902AC_MSG_CHECKING(for --with-doc-strings)
2903AC_ARG_WITH(doc-strings,
Matthias Klose22520ea2010-05-08 10:14:46 +00002904 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +00002905
2906if test -z "$with_doc_strings"
2907then with_doc_strings="yes"
2908fi
2909if test "$with_doc_strings" != "no"
2910then
2911 AC_DEFINE(WITH_DOC_STRINGS, 1,
2912 [Define if you want documentation strings in extension modules])
2913fi
2914AC_MSG_RESULT($with_doc_strings)
2915
Neil Schemenauera35c6882001-02-27 04:45:05 +00002916# Check for Python-specific malloc support
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002917AC_MSG_CHECKING(for --with-tsc)
2918AC_ARG_WITH(tsc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002919 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
Martin v. Löwisf30d60e2004-06-08 08:17:44 +00002920if test "$withval" != no
2921then
2922 AC_DEFINE(WITH_TSC, 1,
2923 [Define to profile with the Pentium timestamp counter])
2924 AC_MSG_RESULT(yes)
2925else AC_MSG_RESULT(no)
2926fi],
2927[AC_MSG_RESULT(no)])
2928
2929# Check for Python-specific malloc support
Neil Schemenauera35c6882001-02-27 04:45:05 +00002930AC_MSG_CHECKING(for --with-pymalloc)
2931AC_ARG_WITH(pymalloc,
Matthias Klose22520ea2010-05-08 10:14:46 +00002932 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
Neil Schemenauer16c22972002-03-22 15:34:49 +00002933
2934if test -z "$with_pymalloc"
2935then with_pymalloc="yes"
2936fi
2937if test "$with_pymalloc" != "no"
2938then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002939 AC_DEFINE(WITH_PYMALLOC, 1,
2940 [Define if you want to compile in Python-specific mallocs])
Neil Schemenauer16c22972002-03-22 15:34:49 +00002941fi
2942AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00002943
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002944# Check for Valgrind support
2945AC_MSG_CHECKING([for --with-valgrind])
2946AC_ARG_WITH([valgrind],
Matthias Klose22520ea2010-05-08 10:14:46 +00002947 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
Benjamin Peterson91c12eb2009-12-03 02:52:39 +00002948 with_valgrind=no)
2949AC_MSG_RESULT([$with_valgrind])
2950if test "$with_valgrind" != no; then
2951 AC_CHECK_HEADER([valgrind/valgrind.h],
2952 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2953 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2954 )
2955fi
2956
Barry Warsawef82cd72000-06-30 16:21:01 +00002957# Check for --with-wctype-functions
2958AC_MSG_CHECKING(for --with-wctype-functions)
2959AC_ARG_WITH(wctype-functions,
Matthias Klose22520ea2010-05-08 10:14:46 +00002960 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00002961[
Barry Warsawef82cd72000-06-30 16:21:01 +00002962if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00002963then
2964 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2965 [Define if you want wctype.h functions to be used instead of the
2966 one supplied by Python itself. (see Include/unicodectype.h).])
2967 AC_MSG_RESULT(yes)
Barry Warsawef82cd72000-06-30 16:21:01 +00002968else AC_MSG_RESULT(no)
2969fi],
2970[AC_MSG_RESULT(no)])
2971
Guido van Rossum68242b51996-05-28 22:53:03 +00002972# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002973AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00002974DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00002975
Guido van Rossume97ee181999-12-20 21:27:22 +00002976# the dlopen() function means we might want to use dynload_shlib.o. some
2977# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00002978AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00002979
2980# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2981# loading of modules.
2982AC_SUBST(DYNLOADFILE)
2983AC_MSG_CHECKING(DYNLOADFILE)
2984if test -z "$DYNLOADFILE"
2985then
2986 case $ac_sys_system/$ac_sys_release in
Martin v. Löwisc19c5a62003-11-18 20:00:44 +00002987 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2988 if test "$ac_cv_func_dlopen" = yes
2989 then DYNLOADFILE="dynload_shlib.o"
2990 else DYNLOADFILE="dynload_aix.o"
2991 fi
2992 ;;
Guido van Rossume97ee181999-12-20 21:27:22 +00002993 BeOS*) DYNLOADFILE="dynload_beos.o";;
2994 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Anthony Baxter82201742006-04-09 15:07:40 +00002995 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2996 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
Martin v. Löwisf90ae202002-06-11 06:22:31 +00002997 atheos*) DYNLOADFILE="dynload_atheos.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00002998 *)
2999 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
3000 # out any dynamic loading
3001 if test "$ac_cv_func_dlopen" = yes
3002 then DYNLOADFILE="dynload_shlib.o"
3003 else DYNLOADFILE="dynload_stub.o"
3004 fi
3005 ;;
3006 esac
3007fi
3008AC_MSG_RESULT($DYNLOADFILE)
3009if test "$DYNLOADFILE" != "dynload_stub.o"
3010then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003011 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
3012 [Defined when any dynamic module loading is enabled.])
Guido van Rossume97ee181999-12-20 21:27:22 +00003013fi
3014
Jack Jansenc49e5b72001-06-19 15:00:23 +00003015# MACHDEP_OBJS can be set to platform-specific object files needed by Python
3016
3017AC_SUBST(MACHDEP_OBJS)
3018AC_MSG_CHECKING(MACHDEP_OBJS)
3019if test -z "$MACHDEP_OBJS"
3020then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003021 MACHDEP_OBJS=$extra_machdep_objs
3022else
3023 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00003024fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00003025AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00003026
Guido van Rossum627b2d71993-12-24 10:39:16 +00003027# checks for library functions
Martin v. Löwisaef18b12008-03-24 13:31:16 +00003028AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
3029 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
Martin v. Löwis438b5342002-12-27 10:16:42 +00003030 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
Benjamin Peterson27c269a2014-12-26 11:09:00 -06003031 getentropy \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003032 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
Benjamin Petersond16e01c2014-02-04 10:20:26 -05003033 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime mmap \
Martin v. Löwisa5f09072002-10-11 05:37:59 +00003034 mremap nice pathconf pause plock poll pthread_init \
Guido van Rossum162e38c2003-02-19 15:25:10 +00003035 putenv readlink realpath \
Jesse Noller355b1262009-04-02 00:03:28 +00003036 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
3037 setgid \
Martin v. Löwis4daacb12003-03-28 18:37:01 +00003038 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
Martin v. Löwis50ea4562009-11-27 13:56:01 +00003039 setlocale setregid setreuid setresuid setresgid \
3040 setsid setpgid setpgrp setuid setvbuf snprintf \
Skip Montanaro7e11a012004-02-07 12:55:46 +00003041 sigaction siginterrupt sigrelse strftime \
Michael W. Hudson34f20ea2002-05-27 15:08:24 +00003042 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Neal Norwitz05a45592006-03-20 06:30:08 +00003043 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003044
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003045# For some functions, having a definition is not sufficient, since
3046# we want to take their address.
3047AC_MSG_CHECKING(for chroot)
Matthias Klosec511b472010-05-08 11:01:39 +00003048AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
3049 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
3050 AC_MSG_RESULT(yes)],
3051 [AC_MSG_RESULT(no)
3052])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003053AC_MSG_CHECKING(for link)
Matthias Klosec511b472010-05-08 11:01:39 +00003054AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
3055 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
3056 AC_MSG_RESULT(yes)],
3057 [AC_MSG_RESULT(no)
3058])
Martin v. Löwisc8ad7cc2002-11-11 13:23:45 +00003059AC_MSG_CHECKING(for symlink)
Matthias Klosec511b472010-05-08 11:01:39 +00003060AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
3061 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
3062 AC_MSG_RESULT(yes)],
3063 [AC_MSG_RESULT(no)
3064])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003065AC_MSG_CHECKING(for fchdir)
Matthias Klosec511b472010-05-08 11:01:39 +00003066AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
3067 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
3068 AC_MSG_RESULT(yes)],
3069 [AC_MSG_RESULT(no)
3070])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003071AC_MSG_CHECKING(for fsync)
Matthias Klosec511b472010-05-08 11:01:39 +00003072AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
3073 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
3074 AC_MSG_RESULT(yes)],
3075 [AC_MSG_RESULT(no)
3076])
Martin v. Löwisa64988c2003-09-20 15:30:20 +00003077AC_MSG_CHECKING(for fdatasync)
Matthias Klosec511b472010-05-08 11:01:39 +00003078AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
3079 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
3080 AC_MSG_RESULT(yes)],
3081 [AC_MSG_RESULT(no)
3082])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003083AC_MSG_CHECKING(for epoll)
Matthias Klosec511b472010-05-08 11:01:39 +00003084AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
3085 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
3086 AC_MSG_RESULT(yes)],
3087 [AC_MSG_RESULT(no)
3088])
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003089AC_MSG_CHECKING(for kqueue)
Matthias Klosec511b472010-05-08 11:01:39 +00003090AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Christian Heimes0e9ab5f2008-03-21 23:49:44 +00003091#include <sys/types.h>
3092#include <sys/event.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003093 ]], [[int x=kqueue()]])],
3094 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
3095 AC_MSG_RESULT(yes)],
3096 [AC_MSG_RESULT(no)
3097])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003098# On some systems (eg. FreeBSD 5), we would find a definition of the
3099# functions ctermid_r, setgroups in the library, but no prototype
3100# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
3101# address to avoid compiler warnings and potential miscompilations
3102# because of the missing prototypes.
3103
3104AC_MSG_CHECKING(for ctermid_r)
Matthias Klosec511b472010-05-08 11:01:39 +00003105AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisd5843682002-11-21 20:41:28 +00003106#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003107]], [[void* p = ctermid_r]])],
3108 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
3109 AC_MSG_RESULT(yes)],
3110 [AC_MSG_RESULT(no)
3111])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003112
Antoine Pitroub170f172010-09-10 18:47:36 +00003113AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3114 [AC_COMPILE_IFELSE(
3115 [AC_LANG_PROGRAM(
3116 [#include <sys/file.h>],
3117 [void* p = flock]
3118 )],
3119 [ac_cv_flock_decl=yes],
3120 [ac_cv_flock_decl=no]
3121 )
Matthias Klosec511b472010-05-08 11:01:39 +00003122])
Antoine Pitroub170f172010-09-10 18:47:36 +00003123if test "x${ac_cv_flock_decl}" = xyes; then
3124 AC_CHECK_FUNCS(flock,,
3125 AC_CHECK_LIB(bsd,flock,
3126 [AC_DEFINE(HAVE_FLOCK)
3127 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3128 ])
3129 )
Antoine Pitrou85729812010-09-07 14:55:24 +00003130fi
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003131
3132AC_MSG_CHECKING(for getpagesize)
Matthias Klosec511b472010-05-08 11:01:39 +00003133AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003134#include <unistd.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003135]], [[void* p = getpagesize]])],
3136 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3137 AC_MSG_RESULT(yes)],
3138 [AC_MSG_RESULT(no)
3139])
Martin v. Löwisf26d63b2003-03-30 17:23:49 +00003140
Charles-François Natali93a11752011-11-27 13:01:35 +01003141AC_MSG_CHECKING(for broken unsetenv)
3142AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3143#include <stdlib.h>
3144]], [[int res = unsetenv("DUMMY")]])],
3145 [AC_MSG_RESULT(no)],
3146 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3147 AC_MSG_RESULT(yes)
3148])
3149
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003150dnl check for true
3151AC_CHECK_PROGS(TRUE, true, /bin/true)
3152
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003153dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3154dnl On others, they are in the C library, so we to take no action
Martin v. Löwis4ee6eef2003-05-26 05:37:51 +00003155AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
Martin v. Löwis95c419b2003-05-03 12:10:48 +00003156 AC_CHECK_LIB(resolv, inet_aton)
3157)
3158
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003159# On Tru64, chflags seems to be present, but calling it will
3160# exit Python
Gregory P. Smithbb213892009-11-02 01:37:37 +00003161AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003162AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003163#include <sys/stat.h>
3164#include <unistd.h>
3165int main(int argc, char*argv[])
3166{
3167 if(chflags(argv[0], 0) != 0)
3168 return 1;
3169 return 0;
3170}
Ned Deily43e10542011-06-27 23:41:53 -07003171]])],
Matthias Klosec511b472010-05-08 11:01:39 +00003172[ac_cv_have_chflags=yes],
3173[ac_cv_have_chflags=no],
3174[ac_cv_have_chflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003175])
3176if test "$ac_cv_have_chflags" = cross ; then
3177 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3178fi
3179if test "$ac_cv_have_chflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003180 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003181fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003182
Gregory P. Smithbb213892009-11-02 01:37:37 +00003183AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
Ned Deily43e10542011-06-27 23:41:53 -07003184AC_RUN_IFELSE([AC_LANG_SOURCE([[
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003185#include <sys/stat.h>
3186#include <unistd.h>
3187int main(int argc, char*argv[])
3188{
3189 if(lchflags(argv[0], 0) != 0)
3190 return 1;
3191 return 0;
3192}
Ned Deily43e10542011-06-27 23:41:53 -07003193]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
Gregory P. Smithbb213892009-11-02 01:37:37 +00003194])
3195if test "$ac_cv_have_lchflags" = cross ; then
3196 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3197fi
3198if test "$ac_cv_have_lchflags" = yes ; then
Ned Deily43e10542011-06-27 23:41:53 -07003199 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003200fi
Martin v. Löwisa51d5c82007-12-04 08:37:59 +00003201
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003202dnl Check if system zlib has *Copy() functions
Ronald Oussorenf8752642006-07-06 10:13:35 +00003203dnl
3204dnl On MacOSX the linker will search for dylibs on the entire linker path
3205dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3206dnl to revert to a more traditional unix behaviour and make it possible to
3207dnl override the system libz with a local static library of libz. Temporarily
3208dnl add that flag to our CFLAGS as well to ensure that we check the version
3209dnl of libz that will be used by setup.py.
3210dnl The -L/usr/local/lib is needed as wel to get the same compilation
3211dnl environment as setup.py (and leaving it out can cause configure to use the
3212dnl wrong version of the library)
3213case $ac_sys_system/$ac_sys_release in
3214Darwin/*)
3215 _CUR_CFLAGS="${CFLAGS}"
3216 _CUR_LDFLAGS="${LDFLAGS}"
3217 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3218 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3219 ;;
3220esac
3221
Matthias Klose5183ebd2010-04-24 16:38:36 +00003222AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
Neal Norwitz6e73aaa2006-06-12 03:33:09 +00003223
Ronald Oussorenf8752642006-07-06 10:13:35 +00003224case $ac_sys_system/$ac_sys_release in
3225Darwin/*)
3226 CFLAGS="${_CUR_CFLAGS}"
3227 LDFLAGS="${_CUR_LDFLAGS}"
3228 ;;
3229esac
3230
Martin v. Löwise9416172003-05-03 10:12:45 +00003231AC_MSG_CHECKING(for hstrerror)
Matthias Klosec511b472010-05-08 11:01:39 +00003232AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwise9416172003-05-03 10:12:45 +00003233#include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003234]], [[void* p = hstrerror; hstrerror(0)]])],
3235 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3236 AC_MSG_RESULT(yes)],
3237 [AC_MSG_RESULT(no)
3238])
Martin v. Löwise9416172003-05-03 10:12:45 +00003239
3240AC_MSG_CHECKING(for inet_aton)
Matthias Klosec511b472010-05-08 11:01:39 +00003241AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis86d66262006-02-17 08:40:11 +00003242#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003243#include <sys/socket.h>
3244#include <netinet/in.h>
3245#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003246]], [[void* p = inet_aton;inet_aton(0,0)]])],
3247 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3248 AC_MSG_RESULT(yes)],
3249 [AC_MSG_RESULT(no)
3250])
Martin v. Löwise9416172003-05-03 10:12:45 +00003251
3252AC_MSG_CHECKING(for inet_pton)
Matthias Klosec511b472010-05-08 11:01:39 +00003253AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003254#include <sys/types.h>
Martin v. Löwise9416172003-05-03 10:12:45 +00003255#include <sys/socket.h>
3256#include <netinet/in.h>
3257#include <arpa/inet.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003258]], [[void* p = inet_pton]])],
3259 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3260 AC_MSG_RESULT(yes)],
3261 [AC_MSG_RESULT(no)
3262])
Martin v. Löwise9416172003-05-03 10:12:45 +00003263
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003264# On some systems, setgroups is in unistd.h, on others, in grp.h
Martin v. Löwisd5843682002-11-21 20:41:28 +00003265AC_MSG_CHECKING(for setgroups)
Matthias Klosec511b472010-05-08 11:01:39 +00003266AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisf2e488d2003-05-05 22:00:11 +00003267#include <unistd.h>
Martin v. Löwisd6640d42003-07-06 09:29:52 +00003268#ifdef HAVE_GRP_H
3269#include <grp.h>
3270#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003271]], [[void* p = setgroups]])],
3272 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3273 AC_MSG_RESULT(yes)],
3274 [AC_MSG_RESULT(no)
3275])
Martin v. Löwisd5843682002-11-21 20:41:28 +00003276
Fred Drake8cef4cf2000-06-28 16:40:38 +00003277# check for openpty and forkpty
3278
Martin v. Löwisfd9a72a2006-01-08 10:07:33 +00003279AC_CHECK_FUNCS(openpty,,
3280 AC_CHECK_LIB(util,openpty,
3281 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3282 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3283 )
3284)
3285AC_CHECK_FUNCS(forkpty,,
3286 AC_CHECK_LIB(util,forkpty,
3287 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3288 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3289 )
3290)
Fred Drake8cef4cf2000-06-28 16:40:38 +00003291
Brett Cannonaa5778d2008-03-18 04:09:00 +00003292# Stuff for expat.
3293AC_CHECK_FUNCS(memmove)
3294
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00003295# check for long file support functions
3296AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3297
Brett Cannonaa5778d2008-03-18 04:09:00 +00003298AC_REPLACE_FUNCS(dup2 getcwd strdup)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003299AC_CHECK_FUNCS(getpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003300 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3301 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3302 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003303)
Jack Jansen150753c2003-03-29 22:07:47 +00003304AC_CHECK_FUNCS(setpgrp,
Matthias Klosec511b472010-05-08 11:01:39 +00003305 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3306 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3307 [])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003308)
3309AC_CHECK_FUNCS(gettimeofday,
Matthias Klosec511b472010-05-08 11:01:39 +00003310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3311 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3312 [],
3313 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3314 [Define if gettimeofday() does not have second (timezone) argument
3315 This is the case on Motorola V4 (R40V4.2)])
3316 ])
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003317)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003318
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003319AC_MSG_CHECKING(for major, minor, and makedev)
Matthias Klosec511b472010-05-08 11:01:39 +00003320AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Neal Norwitz6eb37f02003-02-23 23:28:15 +00003321#if defined(MAJOR_IN_MKDEV)
3322#include <sys/mkdev.h>
3323#elif defined(MAJOR_IN_SYSMACROS)
3324#include <sys/sysmacros.h>
3325#else
3326#include <sys/types.h>
3327#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003328]], [[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003329 makedev(major(0),minor(0));
Matthias Klosec511b472010-05-08 11:01:39 +00003330]])],[
Martin v. Löwisdbe3f762002-10-10 14:27:30 +00003331 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3332 [Define to 1 if you have the device macros.])
3333 AC_MSG_RESULT(yes)
3334],[
3335 AC_MSG_RESULT(no)
3336])
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003337
3338# On OSF/1 V5.1, getaddrinfo is available, but a define
3339# for [no]getaddrinfo in netdb.h.
3340AC_MSG_CHECKING(for getaddrinfo)
Matthias Klosec511b472010-05-08 11:01:39 +00003341AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003342#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003343#include <sys/socket.h>
3344#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00003345#include <stdio.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003346]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3347[have_getaddrinfo=yes],
3348[have_getaddrinfo=no])
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003349AC_MSG_RESULT($have_getaddrinfo)
3350if test $have_getaddrinfo = yes
3351then
3352 AC_MSG_CHECKING(getaddrinfo bug)
3353 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003354 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Stefan Krah0afe4e42012-11-22 23:56:51 +01003355#include <stdio.h>
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003356#include <sys/types.h>
3357#include <netdb.h>
3358#include <string.h>
3359#include <sys/socket.h>
3360#include <netinet/in.h>
3361
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003362int main()
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003363{
3364 int passive, gaierr, inet4 = 0, inet6 = 0;
3365 struct addrinfo hints, *ai, *aitop;
3366 char straddr[INET6_ADDRSTRLEN], strport[16];
3367
3368 for (passive = 0; passive <= 1; passive++) {
3369 memset(&hints, 0, sizeof(hints));
3370 hints.ai_family = AF_UNSPEC;
3371 hints.ai_flags = passive ? AI_PASSIVE : 0;
3372 hints.ai_socktype = SOCK_STREAM;
Hye-Shik Chang54f94392004-04-14 07:55:31 +00003373 hints.ai_protocol = IPPROTO_TCP;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003374 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3375 (void)gai_strerror(gaierr);
3376 goto bad;
3377 }
3378 for (ai = aitop; ai; ai = ai->ai_next) {
3379 if (ai->ai_addr == NULL ||
3380 ai->ai_addrlen == 0 ||
3381 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3382 straddr, sizeof(straddr), strport, sizeof(strport),
3383 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3384 goto bad;
3385 }
3386 switch (ai->ai_family) {
3387 case AF_INET:
3388 if (strcmp(strport, "54321") != 0) {
3389 goto bad;
3390 }
3391 if (passive) {
3392 if (strcmp(straddr, "0.0.0.0") != 0) {
3393 goto bad;
3394 }
3395 } else {
3396 if (strcmp(straddr, "127.0.0.1") != 0) {
3397 goto bad;
3398 }
3399 }
3400 inet4++;
3401 break;
3402 case AF_INET6:
3403 if (strcmp(strport, "54321") != 0) {
3404 goto bad;
3405 }
3406 if (passive) {
3407 if (strcmp(straddr, "::") != 0) {
3408 goto bad;
3409 }
3410 } else {
3411 if (strcmp(straddr, "::1") != 0) {
3412 goto bad;
3413 }
3414 }
3415 inet6++;
3416 break;
3417 case AF_UNSPEC:
3418 goto bad;
3419 break;
3420 default:
3421 /* another family support? */
3422 break;
3423 }
3424 }
3425 }
3426
3427 if (!(inet4 == 0 || inet4 == 2))
3428 goto bad;
3429 if (!(inet6 == 0 || inet6 == 2))
3430 goto bad;
3431
3432 if (aitop)
3433 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003434 return 0;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003435
3436 bad:
3437 if (aitop)
3438 freeaddrinfo(aitop);
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003439 return 1;
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003440}
Matthias Klosec511b472010-05-08 11:01:39 +00003441]]])],
3442[ac_cv_buggy_getaddrinfo=no],
3443[ac_cv_buggy_getaddrinfo=yes],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01003444[
3445if test "${enable_ipv6+set}" = set; then
3446 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3447else
3448 ac_cv_buggy_getaddrinfo=yes
3449fi]))
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003450fi
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003451
Benjamin Peterson75fed812010-11-01 01:47:19 +00003452AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3453
Mark Dickinson0ef0b912009-12-31 21:11:48 +00003454if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003455then
3456 if test $ipv6 = yes
3457 then
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003458 echo 'Fatal: You must get working getaddrinfo() function.'
3459 echo ' or you can specify "--disable-ipv6"'.
3460 exit 1
3461 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00003462else
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003463 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003464fi
Benjamin Peterson75fed812010-11-01 01:47:19 +00003465
Thomas Woutersb0db85a2001-08-08 10:39:03 +00003466AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003467
Guido van Rossum627b2d71993-12-24 10:39:16 +00003468# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003469AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00003470AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003471AC_STRUCT_TIMEZONE
Martin v. Löwis60a5d722002-10-16 20:28:25 +00003472AC_CHECK_MEMBERS([struct stat.st_rdev])
3473AC_CHECK_MEMBERS([struct stat.st_blksize])
Hye-Shik Chang5f937a72005-06-02 13:09:30 +00003474AC_CHECK_MEMBERS([struct stat.st_flags])
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00003475AC_CHECK_MEMBERS([struct stat.st_gen])
3476AC_CHECK_MEMBERS([struct stat.st_birthtime])
Martin Pantera45120d2016-03-18 02:36:41 +00003477AC_CHECK_MEMBERS([struct stat.st_blocks])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003478
3479AC_MSG_CHECKING(for time.h that defines altzone)
Matthias Klosec511b472010-05-08 11:01:39 +00003480AC_CACHE_VAL(ac_cv_header_time_altzone,[
3481 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3482 [ac_cv_header_time_altzone=yes],
3483 [ac_cv_header_time_altzone=no])
3484 ])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003485AC_MSG_RESULT($ac_cv_header_time_altzone)
3486if test $ac_cv_header_time_altzone = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003487 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003488fi
3489
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003490was_it_defined=no
3491AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Matthias Klosec511b472010-05-08 11:01:39 +00003492AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003493#include <sys/types.h>
3494#include <sys/select.h>
3495#include <sys/time.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003496]], [[;]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003497 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3498 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3499 (which you can't on SCO ODT 3.0).])
3500 was_it_defined=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003501],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003502AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00003503
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003504AC_MSG_CHECKING(for addrinfo)
3505AC_CACHE_VAL(ac_cv_struct_addrinfo,
Matthias Klosec511b472010-05-08 11:01:39 +00003506AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3507 [ac_cv_struct_addrinfo=yes],
3508 [ac_cv_struct_addrinfo=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003509AC_MSG_RESULT($ac_cv_struct_addrinfo)
3510if test $ac_cv_struct_addrinfo = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003511 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003512fi
3513
3514AC_MSG_CHECKING(for sockaddr_storage)
3515AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
Matthias Klosec511b472010-05-08 11:01:39 +00003516AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003517# include <sys/types.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003518# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3519 [ac_cv_struct_sockaddr_storage=yes],
3520 [ac_cv_struct_sockaddr_storage=no]))
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003521AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3522if test $ac_cv_struct_sockaddr_storage = yes; then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003523 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003524fi
3525
Guido van Rossum627b2d71993-12-24 10:39:16 +00003526# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003527
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003528AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003529AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003530
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003531works=no
3532AC_MSG_CHECKING(for working volatile)
Matthias Klosec511b472010-05-08 11:01:39 +00003533AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3534 [works=yes],
3535 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003536)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003537AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00003538
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003539works=no
3540AC_MSG_CHECKING(for working signed char)
Matthias Klosec511b472010-05-08 11:01:39 +00003541AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3542 [works=yes],
3543 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003544)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003545AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003546
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003547have_prototypes=no
3548AC_MSG_CHECKING(for prototypes)
Matthias Klosec511b472010-05-08 11:01:39 +00003549AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3550 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3551 [Define if your compiler supports function prototype])
3552 have_prototypes=yes],
3553 []
3554)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003555AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003556
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003557works=no
3558AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Matthias Klosec511b472010-05-08 11:01:39 +00003559AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003560#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00003561int foo(int x, ...) {
3562 va_list va;
3563 va_start(va, x);
3564 va_arg(va, int);
3565 va_arg(va, char *);
3566 va_arg(va, double);
3567 return 0;
3568}
Matthias Klosec511b472010-05-08 11:01:39 +00003569]], [[return foo(10, "", 3.14);]])],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003570 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3571 [Define if your compiler supports variable length function prototypes
3572 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3573 works=yes
Matthias Klosec511b472010-05-08 11:01:39 +00003574],[])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003575AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003576
Dave Cole331708b2004-08-09 04:51:41 +00003577# check for socketpair
3578AC_MSG_CHECKING(for socketpair)
Matthias Klosec511b472010-05-08 11:01:39 +00003579AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Dave Cole331708b2004-08-09 04:51:41 +00003580#include <sys/types.h>
3581#include <sys/socket.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003582]], [[void *x=socketpair]])],
3583 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3584 AC_MSG_RESULT(yes)],
3585 [AC_MSG_RESULT(no)]
Dave Cole331708b2004-08-09 04:51:41 +00003586)
3587
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003588# check if sockaddr has sa_len member
3589AC_MSG_CHECKING(if sockaddr has sa_len member)
Matthias Klosec511b472010-05-08 11:01:39 +00003590AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3591#include <sys/socket.h>]], [[struct sockaddr x;
3592x.sa_len = 0;]])],
3593 [AC_MSG_RESULT(yes)
3594 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3595 [AC_MSG_RESULT(no)]
3596)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00003597
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003598va_list_is_array=no
3599AC_MSG_CHECKING(whether va_list is an array)
Matthias Klosec511b472010-05-08 11:01:39 +00003600AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003601#ifdef HAVE_STDARG_PROTOTYPES
3602#include <stdarg.h>
3603#else
3604#include <varargs.h>
3605#endif
Matthias Klosec511b472010-05-08 11:01:39 +00003606]], [[va_list list1, list2; list1 = list2;]])],[],[
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003607 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3608 va_list_is_array=yes
3609])
Guido van Rossum5739e7e1995-01-20 16:50:53 +00003610AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003611
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003612# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
Martin v. Löwis11437992002-04-12 09:54:03 +00003613AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3614 [Define this if you have some version of gethostbyname_r()])
3615
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003616AC_CHECK_FUNC(gethostbyname_r, [
3617 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3618 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3619 OLD_CFLAGS=$CFLAGS
3620 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003621 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003622# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003623 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003624 char *name;
3625 struct hostent *he, *res;
3626 char buffer[2048];
3627 int buflen = 2048;
3628 int h_errnop;
3629
3630 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
Matthias Klosec511b472010-05-08 11:01:39 +00003631 ]])],[
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003632 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003633 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3634 [Define this if you have the 6-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003635 AC_MSG_RESULT(yes)
Matthias Klosec511b472010-05-08 11:01:39 +00003636 ],[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003637 AC_MSG_RESULT(no)
3638 AC_MSG_CHECKING([gethostbyname_r with 5 args])
Matthias Klosec511b472010-05-08 11:01:39 +00003639 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003640# include <netdb.h>
Matthias Klosec511b472010-05-08 11:01:39 +00003641 ]], [[
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003642 char *name;
3643 struct hostent *he;
Matthias Klosec511b472010-05-08 11:01:39 +00003644 char buffer[2048];
3645 int buflen = 2048;
3646 int h_errnop;
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003647
Matthias Klosec511b472010-05-08 11:01:39 +00003648 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3649 ]])],
3650 [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003651 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Matthias Klosec511b472010-05-08 11:01:39 +00003652 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3653 [Define this if you have the 5-arg version of gethostbyname_r().])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003654 AC_MSG_RESULT(yes)
3655 ], [
3656 AC_MSG_RESULT(no)
Matthias Klosec511b472010-05-08 11:01:39 +00003657 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3658 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3659# include <netdb.h>
3660 ]], [[
3661 char *name;
3662 struct hostent *he;
3663 struct hostent_data data;
3664
3665 (void) gethostbyname_r(name, he, &data);
3666 ]])],
3667 [
3668 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3669 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3670 [Define this if you have the 3-arg version of gethostbyname_r().])
3671 AC_MSG_RESULT(yes)
3672 ], [
3673 AC_MSG_RESULT(no)
3674 ])
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003675 ])
3676 ])
3677 CFLAGS=$OLD_CFLAGS
3678], [
Thomas Wouters3a584202000-08-05 23:28:51 +00003679 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003680])
3681AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3682AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3683AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00003684AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00003685AC_SUBST(HAVE_GETHOSTBYNAME)
3686
Guido van Rossum627b2d71993-12-24 10:39:16 +00003687# checks for system services
3688# (none yet)
3689
Guido van Rossum76be6ed1995-01-02 18:33:54 +00003690# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00003691AC_CHECK_FUNC(__fpu_control,
3692 [],
3693 [AC_CHECK_LIB(ieee, __fpu_control)
3694])
Guido van Rossum627b2d71993-12-24 10:39:16 +00003695
Guido van Rossum93274221997-05-09 02:42:00 +00003696# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00003697AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00003698AC_ARG_WITH(fpectl,
Matthias Klose22520ea2010-05-08 10:14:46 +00003699 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003700[
Guido van Rossum93274221997-05-09 02:42:00 +00003701if test "$withval" != no
Martin v. Löwisc45929e2002-04-06 10:10:49 +00003702then
3703 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3704 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3705 AC_MSG_RESULT(yes)
Guido van Rossum93274221997-05-09 02:42:00 +00003706else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00003707fi],
3708[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00003709
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003710# check for --with-libm=...
3711AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003712case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00003713Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00003714BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00003715*) LIBM=-lm
3716esac
Guido van Rossum93274221997-05-09 02:42:00 +00003717AC_MSG_CHECKING(for --with-libm=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003718AC_ARG_WITH(libm,
Matthias Klose22520ea2010-05-08 10:14:46 +00003719 AS_HELP_STRING([--with-libm=STRING], [math library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003720[
Guido van Rossum93274221997-05-09 02:42:00 +00003721if test "$withval" = no
3722then LIBM=
3723 AC_MSG_RESULT(force LIBM empty)
3724elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003725then LIBM=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003726 AC_MSG_RESULT(set LIBM="$withval")
3727else AC_MSG_ERROR([proper usage is --with-libm=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003728fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003729[AC_MSG_RESULT(default LIBM="$LIBM")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003730
3731# check for --with-libc=...
3732AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00003733AC_MSG_CHECKING(for --with-libc=STRING)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003734AC_ARG_WITH(libc,
Matthias Klose22520ea2010-05-08 10:14:46 +00003735 AS_HELP_STRING([--with-libc=STRING], [C library]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003736[
Guido van Rossum93274221997-05-09 02:42:00 +00003737if test "$withval" = no
3738then LIBC=
3739 AC_MSG_RESULT(force LIBC empty)
3740elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003741then LIBC=$withval
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003742 AC_MSG_RESULT(set LIBC="$withval")
3743else AC_MSG_ERROR([proper usage is --with-libc=STRING])
Guido van Rossum93274221997-05-09 02:42:00 +00003744fi],
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00003745[AC_MSG_RESULT(default LIBC="$LIBC")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00003746
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003747# **************************************************
3748# * Check for various properties of floating point *
3749# **************************************************
Mark Dickinson265d7382008-04-21 22:32:24 +00003750
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003751AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3752AC_CACHE_VAL(ac_cv_little_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003753AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003754#include <string.h>
3755int main() {
3756 double x = 9006104071832581.0;
3757 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3758 return 0;
3759 else
3760 return 1;
3761}
Matthias Klosec511b472010-05-08 11:01:39 +00003762]])],
3763[ac_cv_little_endian_double=yes],
3764[ac_cv_little_endian_double=no],
3765[ac_cv_little_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003766AC_MSG_RESULT($ac_cv_little_endian_double)
3767if test "$ac_cv_little_endian_double" = yes
3768then
3769 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3770 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3771 with the least significant byte first])
3772fi
3773
3774AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3775AC_CACHE_VAL(ac_cv_big_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003776AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003777#include <string.h>
3778int main() {
3779 double x = 9006104071832581.0;
3780 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3781 return 0;
3782 else
3783 return 1;
3784}
Matthias Klosec511b472010-05-08 11:01:39 +00003785]])],
3786[ac_cv_big_endian_double=yes],
3787[ac_cv_big_endian_double=no],
3788[ac_cv_big_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003789AC_MSG_RESULT($ac_cv_big_endian_double)
3790if test "$ac_cv_big_endian_double" = yes
3791then
3792 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3793 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3794 with the most significant byte first])
3795fi
3796
3797# Some ARM platforms use a mixed-endian representation for doubles.
3798# While Python doesn't currently have full support for these platforms
3799# (see e.g., issue 1762561), we can at least make sure that float <-> string
3800# conversions work.
3801AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3802AC_CACHE_VAL(ac_cv_mixed_endian_double, [
Matthias Klosec511b472010-05-08 11:01:39 +00003803AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003804#include <string.h>
3805int main() {
3806 double x = 9006104071832581.0;
3807 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3808 return 0;
3809 else
3810 return 1;
3811}
Matthias Klosec511b472010-05-08 11:01:39 +00003812]])],
3813[ac_cv_mixed_endian_double=yes],
3814[ac_cv_mixed_endian_double=no],
3815[ac_cv_mixed_endian_double=no])])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003816AC_MSG_RESULT($ac_cv_mixed_endian_double)
3817if test "$ac_cv_mixed_endian_double" = yes
3818then
3819 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3820 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3821 in ARM mixed-endian order (byte order 45670123)])
3822fi
3823
3824# The short float repr introduced in Python 3.1 requires the
3825# correctly-rounded string <-> double conversion functions from
3826# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3827# rounding; this is a problem on x86, where the x87 FPU has a default
Mark Dickinsona548dee2009-11-15 13:12:43 +00003828# rounding precision of 64 bits. For gcc/x86, we can fix this by
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003829# using inline assembler to get and set the x87 FPU control word.
Mark Dickinsona548dee2009-11-15 13:12:43 +00003830
3831# This inline assembler syntax may also work for suncc and icc,
3832# so we try it on all platforms.
3833
3834AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
Stefan Krah99e36b92015-07-03 15:30:54 +02003835AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
Mark Dickinsona548dee2009-11-15 13:12:43 +00003836 unsigned short cw;
3837 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3838 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
Matthias Klosec511b472010-05-08 11:01:39 +00003839]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
Mark Dickinsona548dee2009-11-15 13:12:43 +00003840AC_MSG_RESULT($have_gcc_asm_for_x87)
3841if test "$have_gcc_asm_for_x87" = yes
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003842then
Mark Dickinsona548dee2009-11-15 13:12:43 +00003843 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3844 [Define if we can use gcc inline assembler to get and set x87 control word])
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003845fi
Mark Dickinson7a3d8642008-04-22 00:54:27 +00003846
Mark Dickinson04b27232009-01-04 12:29:36 +00003847# Detect whether system arithmetic is subject to x87-style double
3848# rounding issues. The result of this test has little meaning on non
3849# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3850# mode is round-to-nearest and double rounding issues are present, and
3851# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3852AC_MSG_CHECKING(for x87-style double rounding)
Mark Dickinson99abd142009-10-24 13:44:16 +00003853# $BASECFLAGS may affect the result
3854ac_save_cc="$CC"
3855CC="$CC $BASECFLAGS"
Matthias Klosec511b472010-05-08 11:01:39 +00003856AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinson04b27232009-01-04 12:29:36 +00003857#include <stdlib.h>
3858#include <math.h>
3859int main() {
3860 volatile double x, y, z;
3861 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3862 x = 0.99999999999999989; /* 1-2**-53 */
3863 y = 1./x;
3864 if (y != 1.)
3865 exit(0);
3866 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3867 x = 1e16;
3868 y = 2.99999;
3869 z = x + y;
3870 if (z != 1e16+4.)
3871 exit(0);
3872 /* both tests show evidence of double rounding */
3873 exit(1);
3874}
Matthias Klosec511b472010-05-08 11:01:39 +00003875]])],
3876[ac_cv_x87_double_rounding=no],
3877[ac_cv_x87_double_rounding=yes],
3878[ac_cv_x87_double_rounding=no])
Mark Dickinson99abd142009-10-24 13:44:16 +00003879CC="$ac_save_cc"
Mark Dickinson04b27232009-01-04 12:29:36 +00003880AC_MSG_RESULT($ac_cv_x87_double_rounding)
3881if test "$ac_cv_x87_double_rounding" = yes
3882then
3883 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3884 [Define if arithmetic is subject to x87-style double rounding issue])
3885fi
3886
Mark Dickinson1d6e2e12009-10-24 13:28:38 +00003887# ************************************
3888# * Check for mathematical functions *
3889# ************************************
3890
3891LIBS_SAVE=$LIBS
3892LIBS="$LIBS $LIBM"
3893
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003894# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3895# -0. on some architectures.
3896AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3897AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00003898AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003899#include <math.h>
3900#include <stdlib.h>
3901int main() {
3902 /* return 0 if either negative zeros don't exist
3903 on this platform or if negative zeros exist
3904 and tanh(-0.) == -0. */
3905 if (atan2(0., -1.) == atan2(-0., -1.) ||
3906 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3907 else exit(1);
3908}
Matthias Klosec511b472010-05-08 11:01:39 +00003909]])],
3910[ac_cv_tanh_preserves_zero_sign=yes],
3911[ac_cv_tanh_preserves_zero_sign=no],
3912[ac_cv_tanh_preserves_zero_sign=no])])
Mark Dickinsonc63392c2009-11-28 13:13:13 +00003913AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3914if test "$ac_cv_tanh_preserves_zero_sign" = yes
3915then
3916 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3917 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3918fi
3919
3920AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3921AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3922AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3923
3924LIBS=$LIBS_SAVE
3925
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003926# For multiprocessing module, check that sem_open
3927# actually works. For FreeBSD versions <= 7.2,
3928# the kernel module that provides POSIX semaphores
3929# isn't loaded by default, so an attempt to call
3930# sem_open results in a 'Signal 12' error.
3931AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3932AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
Matthias Klosec511b472010-05-08 11:01:39 +00003933AC_RUN_IFELSE([AC_LANG_SOURCE([[
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003934#include <unistd.h>
3935#include <fcntl.h>
3936#include <stdio.h>
3937#include <semaphore.h>
3938#include <sys/stat.h>
3939
3940int main(void) {
3941 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3942 if (a == SEM_FAILED) {
3943 perror("sem_open");
3944 return 1;
3945 }
3946 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003947 sem_unlink("/autoconf");
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003948 return 0;
3949}
Matthias Klosec511b472010-05-08 11:01:39 +00003950]])],
3951[ac_cv_posix_semaphores_enabled=yes],
3952[ac_cv_posix_semaphores_enabled=no],
3953[ac_cv_posix_semaphores_enabled=yes])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003954)
3955AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3956if test $ac_cv_posix_semaphores_enabled = no
3957then
Mark Dickinson5afa6d42009-11-28 10:44:20 +00003958 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3959 [Define if POSIX semaphores aren't enabled on your system])
Mark Dickinsonc4920e82009-11-20 19:30:22 +00003960fi
3961
Jesse Noller355b1262009-04-02 00:03:28 +00003962# Multiprocessing check for broken sem_getvalue
3963AC_MSG_CHECKING(for broken sem_getvalue)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003964AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
Matthias Klosec511b472010-05-08 11:01:39 +00003965AC_RUN_IFELSE([AC_LANG_SOURCE([[
Jesse Noller355b1262009-04-02 00:03:28 +00003966#include <unistd.h>
3967#include <fcntl.h>
3968#include <stdio.h>
3969#include <semaphore.h>
3970#include <sys/stat.h>
3971
3972int main(void){
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003973 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
Jesse Noller355b1262009-04-02 00:03:28 +00003974 int count;
3975 int res;
3976 if(a==SEM_FAILED){
3977 perror("sem_open");
3978 return 1;
3979
3980 }
3981 res = sem_getvalue(a, &count);
3982 sem_close(a);
Mark Dickinson59dc89e2009-12-13 21:06:06 +00003983 sem_unlink("/autocftw");
Jesse Noller355b1262009-04-02 00:03:28 +00003984 return res==-1 ? 1 : 0;
3985}
Matthias Klosec511b472010-05-08 11:01:39 +00003986]])],
3987[ac_cv_broken_sem_getvalue=no],
3988[ac_cv_broken_sem_getvalue=yes],
3989[ac_cv_broken_sem_getvalue=yes])
Jesse Noller355b1262009-04-02 00:03:28 +00003990)
Alexandre Vassalotti00900892009-07-17 05:26:39 +00003991AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3992if test $ac_cv_broken_sem_getvalue = yes
3993then
3994 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3995 [define to 1 if your sem_getvalue is broken.])
3996fi
Mark Dickinson04b27232009-01-04 12:29:36 +00003997
Mark Dickinsonefc82f72009-03-20 15:51:55 +00003998# determine what size digit to use for Python's longs
3999AC_MSG_CHECKING([digit size for Python's longs])
4000AC_ARG_ENABLE(big-digits,
Matthias Klose22520ea2010-05-08 10:14:46 +00004001AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
Mark Dickinsonefc82f72009-03-20 15:51:55 +00004002[case $enable_big_digits in
4003yes)
4004 enable_big_digits=30 ;;
4005no)
4006 enable_big_digits=15 ;;
4007[15|30])
4008 ;;
4009*)
4010 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
4011esac
4012AC_MSG_RESULT($enable_big_digits)
4013AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
4014],
4015[AC_MSG_RESULT(no value specified)])
4016
Guido van Rossumef2255b2000-03-10 22:30:29 +00004017# check for wchar.h
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004018AC_CHECK_HEADER(wchar.h, [
4019 AC_DEFINE(HAVE_WCHAR_H, 1,
4020 [Define if the compiler provides a wchar.h header file.])
4021 wchar_h="yes"
4022],
Guido van Rossumef2255b2000-03-10 22:30:29 +00004023wchar_h="no"
4024)
4025
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004026# determine wchar_t size
4027if test "$wchar_h" = yes
4028then
Guido van Rossum67b26592001-10-20 14:21:45 +00004029 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004030fi
4031
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004032AC_MSG_CHECKING(for UCS-4 tcl)
4033have_ucs4_tcl=no
Matthias Klosec511b472010-05-08 11:01:39 +00004034AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004035#include <tcl.h>
4036#if TCL_UTF_MAX != 6
4037# error "NOT UCS4_TCL"
Matthias Klosec511b472010-05-08 11:01:39 +00004038#endif]], [[]])],[
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004039 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
4040 have_ucs4_tcl=yes
Matthias Klosec511b472010-05-08 11:01:39 +00004041],[])
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004042AC_MSG_RESULT($have_ucs4_tcl)
4043
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004044# check whether wchar_t is signed or not
4045if test "$wchar_h" = yes
4046then
4047 # check whether wchar_t is signed or not
4048 AC_MSG_CHECKING(whether wchar_t is signed)
4049 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
Matthias Klosec511b472010-05-08 11:01:39 +00004050 AC_RUN_IFELSE([AC_LANG_SOURCE([[
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004051 #include <wchar.h>
4052 int main()
4053 {
Martin v. Löwis44fe0e42006-04-11 07:15:30 +00004054 /* Success: exit code 0 */
4055 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004056 }
Matthias Klosec511b472010-05-08 11:01:39 +00004057 ]])],
4058 [ac_cv_wchar_t_signed=yes],
4059 [ac_cv_wchar_t_signed=no],
4060 [ac_cv_wchar_t_signed=yes])])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004061 AC_MSG_RESULT($ac_cv_wchar_t_signed)
4062fi
4063
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004064AC_MSG_CHECKING(what type to use for unicode)
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004065dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004066AC_ARG_ENABLE(unicode,
Benjamin Peterson66556b02010-05-25 02:23:32 +00004067 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
Martin v. Löwis3e2c6322002-10-29 10:07:43 +00004068 [],
4069 [enable_unicode=yes])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004070
4071if test $enable_unicode = yes
4072then
Martin v. Löwisfd917792001-06-27 20:22:04 +00004073 # Without any arguments, Py_UNICODE defaults to two-byte mode
Martin v. Löwisfa3bdea2003-09-04 18:50:54 +00004074 case "$have_ucs4_tcl" in
4075 yes) enable_unicode="ucs4"
4076 ;;
4077 *) enable_unicode="ucs2"
4078 ;;
4079 esac
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004080fi
4081
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004082AH_TEMPLATE(Py_UNICODE_SIZE,
4083 [Define as the size of the unicode type.])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004084case "$enable_unicode" in
4085ucs2) unicode_size="2"
4086 AC_DEFINE(Py_UNICODE_SIZE,2)
4087 ;;
4088ucs4) unicode_size="4"
4089 AC_DEFINE(Py_UNICODE_SIZE,4)
4090 ;;
Martin v. Löwised11a5d2012-05-20 10:42:17 +02004091no) ;; # To allow --disable-unicode
Ezio Melotti5820efb2010-02-27 00:05:42 +00004092*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004093esac
4094
Martin v. Löwis11437992002-04-12 09:54:03 +00004095AH_TEMPLATE(PY_UNICODE_TYPE,
4096 [Define as the integral type used for Unicode representation.])
Martin v. Löwis0036cba2002-04-12 09:58:45 +00004097
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004098AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004099if test "$enable_unicode" = "no"
4100then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004101 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004102 AC_MSG_RESULT(not used)
4103else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00004104 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004105 AC_DEFINE(Py_USING_UNICODE, 1,
4106 [Define if you want to have a Unicode type.])
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004107
4108 # wchar_t is only usable if it maps to an unsigned type
4109 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
Matthias Klose7dbeed72004-12-24 08:22:17 +00004110 -a "$ac_cv_wchar_t_signed" = "no"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004111 then
4112 PY_UNICODE_TYPE="wchar_t"
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004113 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4114 [Define if you have a useable wchar_t type defined in wchar.h; useable
Marc-André Lemburgd7160f82003-09-22 11:14:40 +00004115 means wchar_t must be an unsigned type with at least 16 bits. (see
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004116 Include/unicodeobject.h).])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00004117 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4118 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4119 then
4120 PY_UNICODE_TYPE="unsigned short"
4121 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4122 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4123 then
4124 PY_UNICODE_TYPE="unsigned long"
4125 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4126 else
4127 PY_UNICODE_TYPE="no type found"
4128 fi
4129 AC_MSG_RESULT($PY_UNICODE_TYPE)
4130fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00004131
4132# check for endianness
4133AC_C_BIGENDIAN
4134
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004135# Check whether right shifting a negative integer extends the sign bit
4136# or fills with zeros (like the Cray J90, according to Tim Peters).
4137AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00004138AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Matthias Klosec511b472010-05-08 11:01:39 +00004139AC_RUN_IFELSE([AC_LANG_SOURCE([[
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004140int main()
4141{
Vladimir Marangozova6180282000-07-12 05:05:06 +00004142 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004143}
Matthias Klosec511b472010-05-08 11:01:39 +00004144]])],
4145[ac_cv_rshift_extends_sign=yes],
4146[ac_cv_rshift_extends_sign=no],
4147[ac_cv_rshift_extends_sign=yes])])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004148AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4149if test "$ac_cv_rshift_extends_sign" = no
4150then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004151 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4152 [Define if i>>j for signed int i does not extend the sign bit
4153 when i < 0])
Vladimir Marangozova6180282000-07-12 05:05:06 +00004154fi
4155
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004156# check for getc_unlocked and related locking functions
4157AC_MSG_CHECKING(for getc_unlocked() and friends)
4158AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
Matthias Klosec511b472010-05-08 11:01:39 +00004159AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004160 FILE *f = fopen("/dev/null", "r");
4161 flockfile(f);
4162 getc_unlocked(f);
4163 funlockfile(f);
Matthias Klosec511b472010-05-08 11:01:39 +00004164]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004165AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4166if test "$ac_cv_have_getc_unlocked" = yes
4167then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004168 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4169 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
Guido van Rossumcadfaec2001-01-05 14:45:49 +00004170fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00004171
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004172# check where readline lives
Martin v. Löwis82bca632006-02-10 20:49:30 +00004173# save the value of LIBS so we don't actually link Python with readline
4174LIBS_no_readline=$LIBS
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004175
4176# On some systems we need to link readline to a termcap compatible
4177# library. NOTE: Keep the precedence of listed libraries synchronised
4178# with setup.py.
4179py_cv_lib_readline=no
4180AC_MSG_CHECKING([how to link readline libs])
4181for py_libtermcap in "" ncursesw ncurses curses termcap; do
4182 if test -z "$py_libtermcap"; then
4183 READLINE_LIBS="-lreadline"
4184 else
4185 READLINE_LIBS="-lreadline -l$py_libtermcap"
4186 fi
4187 LIBS="$READLINE_LIBS $LIBS_no_readline"
4188 AC_LINK_IFELSE(
4189 [AC_LANG_CALL([],[readline])],
4190 [py_cv_lib_readline=yes])
4191 if test $py_cv_lib_readline = yes; then
4192 break
4193 fi
4194done
4195# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4196#AC_SUBST([READLINE_LIBS])
Gregory P. Smith29ec7502008-09-07 19:18:16 +00004197if test $py_cv_lib_readline = no; then
Gregory P. Smith980b99b2008-09-07 05:15:18 +00004198 AC_MSG_RESULT([none])
4199else
4200 AC_MSG_RESULT([$READLINE_LIBS])
4201 AC_DEFINE(HAVE_LIBREADLINE, 1,
4202 [Define if you have the readline library (-lreadline).])
Neal Norwitzfe8e3d92006-01-07 21:07:20 +00004203fi
4204
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004205# check for readline 2.1
4206AC_CHECK_LIB(readline, rl_callback_handler_install,
4207 AC_DEFINE(HAVE_RL_CALLBACK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004208 [Define if you have readline 2.1]), ,$READLINE_LIBS)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004209
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004210# check for readline 2.2
Matthias Klosec511b472010-05-08 11:01:39 +00004211AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4212 [have_readline=yes],
4213 [have_readline=no]
4214)
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004215if test $have_readline = yes
4216then
4217 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4218 [readline/readline.h],
4219 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4220 [Define if you have readline 2.2]), )
Antoine Pitroud9ff74e2009-10-26 19:16:46 +00004221 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4222 [readline/readline.h],
4223 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4224 [Define if you have rl_completion_suppress_append]), )
Guido van Rossumfaf5e4d2002-12-30 16:25:41 +00004225fi
4226
Martin v. Löwis0daad592001-09-30 21:09:59 +00004227# check for readline 4.0
4228AC_CHECK_LIB(readline, rl_pre_input_hook,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004229 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004230 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis0daad592001-09-30 21:09:59 +00004231
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004232# also in 4.0
4233AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4234 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004235 [Define if you have readline 4.0]), ,$READLINE_LIBS)
Martin v. Löwis58bd49f2007-09-04 13:13:14 +00004236
Martin Pantera70c3232016-04-03 02:54:58 +00004237# also in 4.0, but not in editline
4238AC_CHECK_LIB(readline, rl_resize_terminal,
4239 AC_DEFINE(HAVE_RL_RESIZE_TERMINAL, 1,
4240 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4241
Guido van Rossum353ae582001-07-10 16:45:32 +00004242# check for readline 4.2
4243AC_CHECK_LIB(readline, rl_completion_matches,
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004244 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
Gregory P. Smithff7b2d52008-09-03 05:57:48 +00004245 [Define if you have readline 4.2]), ,$READLINE_LIBS)
Guido van Rossum353ae582001-07-10 16:45:32 +00004246
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004247# also in readline 4.2
Matthias Klosec511b472010-05-08 11:01:39 +00004248AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4249 [have_readline=yes],
4250 [have_readline=no]
4251)
Michael W. Hudson30ea2f22004-07-07 17:44:12 +00004252if test $have_readline = yes
4253then
4254 AC_EGREP_HEADER([extern int rl_catch_signals;],
4255 [readline/readline.h],
4256 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4257 [Define if you can turn off readline's signal handling.]), )
4258fi
4259
Martin v. Löwis82bca632006-02-10 20:49:30 +00004260# End of readline checks: restore LIBS
4261LIBS=$LIBS_no_readline
4262
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004263AC_MSG_CHECKING(for broken nice())
4264AC_CACHE_VAL(ac_cv_broken_nice, [
Matthias Klosec511b472010-05-08 11:01:39 +00004265AC_RUN_IFELSE([AC_LANG_SOURCE([[
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004266int main()
4267{
4268 int val1 = nice(1);
4269 if (val1 != -1 && val1 == nice(2))
4270 exit(0);
4271 exit(1);
4272}
Matthias Klosec511b472010-05-08 11:01:39 +00004273]])],
4274[ac_cv_broken_nice=yes],
4275[ac_cv_broken_nice=no],
4276[ac_cv_broken_nice=no])])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004277AC_MSG_RESULT($ac_cv_broken_nice)
4278if test "$ac_cv_broken_nice" = yes
4279then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004280 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4281 [Define if nice() returns success/failure instead of the new priority.])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00004282fi
4283
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004284AC_MSG_CHECKING(for broken poll())
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004285AC_CACHE_VAL(ac_cv_broken_poll,
Matthias Klosec511b472010-05-08 11:01:39 +00004286AC_RUN_IFELSE([AC_LANG_SOURCE([[
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004287#include <poll.h>
4288
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004289int main()
4290{
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004291 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004292 int poll_test;
4293
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004294 close (42);
4295
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004296 poll_test = poll(&poll_struct, 1, 0);
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004297 if (poll_test < 0)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004298 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004299 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004300 return 0;
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004301 else
Alexandre Vassalotti66da2632009-07-17 06:17:33 +00004302 return 1;
4303}
Matthias Klosec511b472010-05-08 11:01:39 +00004304]])],
4305[ac_cv_broken_poll=yes],
4306[ac_cv_broken_poll=no],
4307[ac_cv_broken_poll=no]))
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004308AC_MSG_RESULT($ac_cv_broken_poll)
4309if test "$ac_cv_broken_poll" = yes
4310then
4311 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4312 [Define if poll() sets errno on invalid file descriptors.])
4313fi
4314
Brett Cannon43802422005-02-10 20:48:03 +00004315# Before we can test tzset, we need to check if struct tm has a tm_zone
4316# (which is not required by ISO C or UNIX spec) and/or if we support
4317# tzname[]
4318AC_STRUCT_TIMEZONE
Nicholas Bastine62c5c82004-03-21 23:45:42 +00004319
Brett Cannon43802422005-02-10 20:48:03 +00004320# check tzset(3) exists and works like we expect it to
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004321AC_MSG_CHECKING(for working tzset())
4322AC_CACHE_VAL(ac_cv_working_tzset, [
Matthias Klosec511b472010-05-08 11:01:39 +00004323AC_RUN_IFELSE([AC_LANG_SOURCE([[
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004324#include <stdlib.h>
4325#include <time.h>
Brett Cannon18367812003-09-19 00:59:16 +00004326#include <string.h>
Brett Cannon43802422005-02-10 20:48:03 +00004327
4328#if HAVE_TZNAME
4329extern char *tzname[];
4330#endif
4331
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004332int main()
4333{
Brett Cannon18367812003-09-19 00:59:16 +00004334 /* Note that we need to ensure that not only does tzset(3)
4335 do 'something' with localtime, but it works as documented
4336 in the library reference and as expected by the test suite.
Brett Cannon43802422005-02-10 20:48:03 +00004337 This includes making sure that tzname is set properly if
4338 tm->tm_zone does not exist since it is the alternative way
4339 of getting timezone info.
Brett Cannon18367812003-09-19 00:59:16 +00004340
4341 Red Hat 6.2 doesn't understand the southern hemisphere
Brett Cannon43802422005-02-10 20:48:03 +00004342 after New Year's Day.
Brett Cannon18367812003-09-19 00:59:16 +00004343 */
4344
Brett Cannon43802422005-02-10 20:48:03 +00004345 time_t groundhogday = 1044144000; /* GMT-based */
Brett Cannon18367812003-09-19 00:59:16 +00004346 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4347
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004348 putenv("TZ=UTC+0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004349 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004350 if (localtime(&groundhogday)->tm_hour != 0)
4351 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004352#if HAVE_TZNAME
4353 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4354 if (strcmp(tzname[0], "UTC") ||
4355 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4356 exit(1);
4357#endif
Brett Cannon18367812003-09-19 00:59:16 +00004358
Neal Norwitz7f2588c2003-04-11 15:35:53 +00004359 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004360 tzset();
Brett Cannon18367812003-09-19 00:59:16 +00004361 if (localtime(&groundhogday)->tm_hour != 19)
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004362 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004363#if HAVE_TZNAME
4364 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4365 exit(1);
4366#endif
Brett Cannon18367812003-09-19 00:59:16 +00004367
4368 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4369 tzset();
4370 if (localtime(&groundhogday)->tm_hour != 11)
4371 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004372#if HAVE_TZNAME
4373 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4374 exit(1);
4375#endif
4376
4377#if HAVE_STRUCT_TM_TM_ZONE
Brett Cannon18367812003-09-19 00:59:16 +00004378 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4379 exit(1);
4380 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4381 exit(1);
Brett Cannon43802422005-02-10 20:48:03 +00004382#endif
Brett Cannon18367812003-09-19 00:59:16 +00004383
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004384 exit(0);
4385}
Matthias Klosec511b472010-05-08 11:01:39 +00004386]])],
4387[ac_cv_working_tzset=yes],
4388[ac_cv_working_tzset=no],
4389[ac_cv_working_tzset=no])])
Guido van Rossumd11b62e2003-03-14 21:51:36 +00004390AC_MSG_RESULT($ac_cv_working_tzset)
4391if test "$ac_cv_working_tzset" = yes
4392then
4393 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4394 [Define if tzset() actually switches the local timezone in a meaningful way.])
4395fi
4396
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004397# Look for subsecond timestamps in struct stat
4398AC_MSG_CHECKING(for tv_nsec in struct stat)
4399AC_CACHE_VAL(ac_cv_stat_tv_nsec,
Matthias Klosec511b472010-05-08 11:01:39 +00004400AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004401struct stat st;
4402st.st_mtim.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004403]])],
4404[ac_cv_stat_tv_nsec=yes],
4405[ac_cv_stat_tv_nsec=no]))
Martin v. Löwis94717ed2002-09-09 14:24:16 +00004406AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4407if test "$ac_cv_stat_tv_nsec" = yes
4408then
4409 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4410 [Define if you have struct stat.st_mtim.tv_nsec])
4411fi
4412
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004413# Look for BSD style subsecond timestamps in struct stat
4414AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4415AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
Matthias Klosec511b472010-05-08 11:01:39 +00004416AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004417struct stat st;
4418st.st_mtimespec.tv_nsec = 1;
Matthias Klosec511b472010-05-08 11:01:39 +00004419]])],
4420[ac_cv_stat_tv_nsec2=yes],
4421[ac_cv_stat_tv_nsec2=no]))
Martin v. Löwisebd9d5b2005-08-09 15:00:59 +00004422AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4423if test "$ac_cv_stat_tv_nsec2" = yes
4424then
4425 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4426 [Define if you have struct stat.st_mtimensec])
4427fi
4428
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004429# first curses configure check
4430ac_save_cppflags="$CPPFLAGS"
4431CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw"
4432
4433AC_CHECK_HEADERS(curses.h ncurses.h)
4434
4435# On Solaris, term.h requires curses.h
4436AC_CHECK_HEADERS(term.h,,,[
4437#ifdef HAVE_CURSES_H
4438#include <curses.h>
4439#endif
4440])
4441
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004442# On HP/UX 11.0, mvwdelch is a block with a return statement
4443AC_MSG_CHECKING(whether mvwdelch is an expression)
4444AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
Matthias Klosec511b472010-05-08 11:01:39 +00004445AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004446 int rtn;
4447 rtn = mvwdelch(0,0,0);
Matthias Klosec511b472010-05-08 11:01:39 +00004448]])],
4449[ac_cv_mvwdelch_is_expression=yes],
4450[ac_cv_mvwdelch_is_expression=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004451AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4452
4453if test "$ac_cv_mvwdelch_is_expression" = yes
4454then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004455 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4456 [Define if mvwdelch in curses.h is an expression.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004457fi
4458
4459AC_MSG_CHECKING(whether WINDOW has _flags)
4460AC_CACHE_VAL(ac_cv_window_has_flags,
Matthias Klosec511b472010-05-08 11:01:39 +00004461AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004462 WINDOW *w;
4463 w->_flags = 0;
Matthias Klosec511b472010-05-08 11:01:39 +00004464]])],
4465[ac_cv_window_has_flags=yes],
4466[ac_cv_window_has_flags=no]))
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004467AC_MSG_RESULT($ac_cv_window_has_flags)
4468
4469
4470if test "$ac_cv_window_has_flags" = yes
4471then
Martin v. Löwisc45929e2002-04-06 10:10:49 +00004472 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4473 [Define if WINDOW in curses.h offers a field _flags.])
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00004474fi
4475
Walter Dörwald4994d952006-06-19 08:07:50 +00004476AC_MSG_CHECKING(for is_term_resized)
Matthias Klosec511b472010-05-08 11:01:39 +00004477AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4478 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4479 AC_MSG_RESULT(yes)],
4480 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004481)
4482
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004483AC_MSG_CHECKING(for resize_term)
Matthias Klosec511b472010-05-08 11:01:39 +00004484AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4485 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4486 AC_MSG_RESULT(yes)],
4487 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004488)
4489
Walter Dörwald05fdbf12006-06-19 08:14:09 +00004490AC_MSG_CHECKING(for resizeterm)
Matthias Klosec511b472010-05-08 11:01:39 +00004491AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4492 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4493 AC_MSG_RESULT(yes)],
4494 [AC_MSG_RESULT(no)]
Walter Dörwald4994d952006-06-19 08:07:50 +00004495)
doko@ubuntu.comf27ec3e2014-04-17 20:11:19 +02004496# last curses configure check
4497CPPFLAGS=$ac_save_cppflags
Walter Dörwald4994d952006-06-19 08:07:50 +00004498
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004499AC_MSG_NOTICE([checking for device files])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004500
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004501dnl NOTE: Inform user how to proceed with files when cross compiling.
4502if test "x$cross_compiling" = xyes; then
4503 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4504 AC_MSG_CHECKING([for /dev/ptmx])
4505 AC_MSG_RESULT([not set])
4506 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4507 fi
4508 if test "${ac_cv_file__dev_ptc+set}" != set; then
4509 AC_MSG_CHECKING([for /dev/ptc])
4510 AC_MSG_RESULT([not set])
4511 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4512 fi
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004513fi
4514
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004515AC_CHECK_FILE(/dev/ptmx, [], [])
4516if test "x$ac_cv_file__dev_ptmx" = xyes; then
4517 AC_DEFINE(HAVE_DEV_PTMX, 1,
4518 [Define to 1 if you have the /dev/ptmx device file.])
4519fi
4520AC_CHECK_FILE(/dev/ptc, [], [])
4521if test "x$ac_cv_file__dev_ptc" = xyes; then
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004522 AC_DEFINE(HAVE_DEV_PTC, 1,
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004523 [Define to 1 if you have the /dev/ptc device file.])
Martin v. Löwisfefbc202006-10-17 18:59:23 +00004524fi
Neal Norwitz865400f2003-03-21 01:42:58 +00004525
Mark Dickinson82864d12009-11-15 16:18:58 +00004526if test "$have_long_long" = yes
4527then
4528 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4529 AC_CACHE_VAL(ac_cv_have_long_long_format,
Matthias Klosec511b472010-05-08 11:01:39 +00004530 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
Mark Dickinson82864d12009-11-15 16:18:58 +00004531 #include <stdio.h>
4532 #include <stddef.h>
4533 #include <string.h>
4534
4535 #ifdef HAVE_SYS_TYPES_H
4536 #include <sys/types.h>
4537 #endif
4538
4539 int main()
4540 {
4541 char buffer[256];
4542
4543 if (sprintf(buffer, "%lld", (long long)123) < 0)
4544 return 1;
4545 if (strcmp(buffer, "123"))
4546 return 1;
4547
4548 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4549 return 1;
4550 if (strcmp(buffer, "-123"))
4551 return 1;
4552
4553 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4554 return 1;
4555 if (strcmp(buffer, "123"))
4556 return 1;
4557
4558 return 0;
4559 }
Matthias Klosec511b472010-05-08 11:01:39 +00004560 ]]])],
4561 [ac_cv_have_long_long_format=yes],
4562 [ac_cv_have_long_long_format=no],
doko@python.orgd65e2ba2013-01-31 23:52:03 +01004563 [ac_cv_have_long_long_format="cross -- assuming no"
4564 if test x$GCC = xyes; then
4565 save_CFLAGS=$CFLAGS
4566 CFLAGS="$CFLAGS -Werror -Wformat"
4567 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4568 #include <stdio.h>
4569 #include <stddef.h>
4570 ]], [[
4571 char *buffer;
4572 sprintf(buffer, "%lld", (long long)123);
4573 sprintf(buffer, "%lld", (long long)-123);
4574 sprintf(buffer, "%llu", (unsigned long long)123);
4575 ]])],
4576 ac_cv_have_long_long_format=yes
4577 )
4578 CFLAGS=$save_CFLAGS
4579 fi])
Mark Dickinson82864d12009-11-15 16:18:58 +00004580 )
4581 AC_MSG_RESULT($ac_cv_have_long_long_format)
4582fi
4583
Mark Dickinson5ce84742009-12-31 20:48:04 +00004584if test "$ac_cv_have_long_long_format" = yes
Mark Dickinson82864d12009-11-15 16:18:58 +00004585then
4586 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4587 [Define to printf format modifier for long long type])
4588fi
4589
Ronald Oussoren315cd0c2009-11-19 16:25:21 +00004590if test $ac_sys_system = Darwin
4591then
4592 LIBS="$LIBS -framework CoreFoundation"
4593fi
4594
Mark Dickinson82864d12009-11-15 16:18:58 +00004595
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004596AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
Matthias Klosec511b472010-05-08 11:01:39 +00004597AC_RUN_IFELSE([AC_LANG_SOURCE([[
Alexandre Vassalottie7cf1182009-07-17 06:33:51 +00004598#include <stdio.h>
Brett Cannon09d12362006-05-11 05:11:33 +00004599#include <stddef.h>
4600#include <string.h>
4601
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004602#ifdef HAVE_SYS_TYPES_H
4603#include <sys/types.h>
4604#endif
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004605
4606#ifdef HAVE_SSIZE_T
4607typedef ssize_t Py_ssize_t;
4608#elif SIZEOF_VOID_P == SIZEOF_LONG
4609typedef long Py_ssize_t;
4610#else
4611typedef int Py_ssize_t;
4612#endif
Brett Cannon09d12362006-05-11 05:11:33 +00004613
Christian Heimesdb3d6cb2007-12-16 21:39:43 +00004614int main()
4615{
4616 char buffer[256];
4617
Brett Cannon09d12362006-05-11 05:11:33 +00004618 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4619 return 1;
4620
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004621 if (strcmp(buffer, "123"))
Brett Cannon09d12362006-05-11 05:11:33 +00004622 return 1;
Neal Norwitz4a8fbdb2006-09-22 08:16:26 +00004623
4624 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4625 return 1;
4626
4627 if (strcmp(buffer, "-123"))
4628 return 1;
4629
Brett Cannon09d12362006-05-11 05:11:33 +00004630 return 0;
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004631}
Matthias Klosec511b472010-05-08 11:01:39 +00004632]])],
4633[ac_cv_have_size_t_format=yes],
4634[ac_cv_have_size_t_format=no],
4635[ac_cv_have_size_t_format="cross -- assuming yes"
4636])])
Gregory P. Smithd8cb2d92009-11-02 02:02:38 +00004637if test "$ac_cv_have_size_t_format" != no ; then
Alexandre Vassalotti00900892009-07-17 05:26:39 +00004638 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4639 [Define to printf format modifier for Py_ssize_t])
4640fi
Brett Cannon09d12362006-05-11 05:11:33 +00004641
Martin v. Löwis01c04012002-11-11 14:58:44 +00004642AC_CHECK_TYPE(socklen_t,,
4643 AC_DEFINE(socklen_t,int,
Matthias Klose5183ebd2010-04-24 16:38:36 +00004644 [Define to `int' if <sys/socket.h> does not define.]),[
Martin v. Löwis01c04012002-11-11 14:58:44 +00004645#ifdef HAVE_SYS_TYPES_H
4646#include <sys/types.h>
4647#endif
Guido van Rossum95713eb2000-05-18 20:53:31 +00004648#ifdef HAVE_SYS_SOCKET_H
4649#include <sys/socket.h>
4650#endif
Martin v. Löwis01c04012002-11-11 14:58:44 +00004651])
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004652
R. David Murray1d9d16e2010-10-16 00:43:13 +00004653case $ac_sys_system in
4654AIX*)
4655 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4656esac
4657
4658
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00004659AC_SUBST(THREADHEADERS)
4660
4661for h in `(cd $srcdir;echo Python/thread_*.h)`
4662do
4663 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4664done
4665
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004666AC_SUBST(SRCDIRS)
Neal Norwitzd24499d2005-12-18 21:36:39 +00004667SRCDIRS="Parser Grammar Objects Python Modules Mac"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00004668AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004669for dir in $SRCDIRS; do
4670 if test ! -d $dir; then
4671 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00004672 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004673done
Benjamin Peterson2c992a02015-05-28 12:45:31 -05004674
4675# BEGIN_COMPUTED_GOTO
4676# Check for --with-computed-gotos
4677AC_MSG_CHECKING(for --with-computed-gotos)
4678AC_ARG_WITH(computed-gotos,
4679 AS_HELP_STRING([--with(out)-computed-gotos],
4680 [Use computed gotos in evaluation loop (enabled by default on supported compilers)]),
4681[
4682if test "$withval" = yes
4683then
4684 AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4685 [Define if you want to use computed gotos in ceval.c.])
4686 AC_MSG_RESULT(yes)
4687fi
4688if test "$withval" = no
4689then
4690 AC_DEFINE(USE_COMPUTED_GOTOS, 0,
4691 [Define if you want to use computed gotos in ceval.c.])
4692 AC_MSG_RESULT(no)
4693fi
4694],
4695[AC_MSG_RESULT(no value specified)])
4696
4697AC_MSG_CHECKING(whether $CC supports computed gotos)
4698AC_CACHE_VAL(ac_cv_computed_gotos,
4699AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4700int main(int argc, char **argv)
4701{
4702 static void *targets[1] = { &&LABEL1 };
4703 goto LABEL2;
4704LABEL1:
4705 return 0;
4706LABEL2:
4707 goto *targets[0];
4708 return 1;
4709}
4710]]])],
4711[ac_cv_computed_gotos=yes],
4712[ac_cv_computed_gotos=no],
4713[if test "${with_computed_gotos+set}" = set; then
4714 ac_cv_computed_gotos="$with_computed_gotos -- configured --with(out)-computed-gotos"
4715 else
4716 ac_cv_computed_gotos=no
4717 fi]))
4718AC_MSG_RESULT($ac_cv_computed_gotos)
4719case "$ac_cv_computed_gotos" in yes*)
4720 AC_DEFINE(HAVE_COMPUTED_GOTOS, 1,
4721 [Define if the C compiler supports computed gotos.])
4722esac
4723# END_COMPUTED_GOTO
4724
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00004725AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00004726
Ned Deily3f1d0b32014-11-20 02:11:03 -08004727# ensurepip option
4728AC_MSG_CHECKING(for ensurepip)
4729AC_ARG_WITH(ensurepip,
4730 [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@],
4731 ["install" or "upgrade" using bundled pip, default is "no"])],
4732 [],
4733 [with_ensurepip=no])
4734AS_CASE($with_ensurepip,
4735 [yes|upgrade],[ENSUREPIP=upgrade],
4736 [install],[ENSUREPIP=install],
4737 [no],[ENSUREPIP=no],
4738 [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])])
4739AC_MSG_RESULT($ENSUREPIP)
4740AC_SUBST(ENSUREPIP)
4741
Guido van Rossum627b2d71993-12-24 10:39:16 +00004742# generate output files
Antoine Pitrouf2caeed2009-05-24 20:23:57 +00004743AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
Antoine Pitrouaabdceb2010-09-10 20:03:17 +00004744AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
Martin v. Löwis88afe662002-10-26 13:47:44 +00004745AC_OUTPUT
Neil Schemenauer61c51152001-01-26 16:18:16 +00004746
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004747echo "creating Modules/Setup"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004748if test ! -f Modules/Setup
4749then
4750 cp $srcdir/Modules/Setup.dist Modules/Setup
4751fi
4752
Martin v. Löwisf7afe952006-04-14 15:16:15 +00004753echo "creating Modules/Setup.local"
Neil Schemenauer61c51152001-01-26 16:18:16 +00004754if test ! -f Modules/Setup.local
4755then
4756 echo "# Edit this file for local setup changes" >Modules/Setup.local
4757fi
4758
4759echo "creating Makefile"
4760$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4761 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00004762 Modules/Setup.local Modules/Setup
Skip Montanaro7221d932007-08-22 19:02:16 +00004763
4764case $ac_sys_system in
4765BeOS)
4766 AC_MSG_WARN([
4767
4768 Support for BeOS is deprecated as of Python 2.6.
4769 See PEP 11 for the gory details.
4770 ])
4771 ;;
4772*) ;;
4773esac
4774
Neil Schemenauer66252162001-02-19 04:47:42 +00004775mv config.c Modules