source: python/trunk/configure.ac

Last change on this file was 1538, checked in by Silvan Scherrer, 7 years ago

adjust getaddrinfo and friends to latest libcx

  • Property svn:eol-style set to native
File size: 131.4 KB
Line 
1dnl ***********************************************
2dnl * Please run autoreconf to test your changes! *
3dnl ***********************************************
4
5# Set VERSION so we only need to edit in one place (i.e., here)
6m4_define(PYTHON_VERSION, 2.7)
7
8AC_PREREQ(2.65)
9
10AC_REVISION($Revision$)
11AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
12AC_CONFIG_SRCDIR([Include/object.h])
13AC_CONFIG_HEADER(pyconfig.h)
14
15AC_CANONICAL_HOST
16AC_SUBST(build)
17AC_SUBST(host)
18
19if test "$cross_compiling" = yes; then
20 AC_MSG_CHECKING([for python interpreter for cross build])
21 if test -z "$PYTHON_FOR_BUILD"; then
22 for interp in python$PACKAGE_VERSION python2 python; do
23 which $interp >/dev/null 2>&1 || continue
24 if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then
25 break
26 fi
27 interp=
28 done
29 if test x$interp = x; then
30 AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
31 fi
32 AC_MSG_RESULT($interp)
33 PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp
34 fi
35elif test "$cross_compiling" = maybe; then
36 AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
37else
38 PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
39fi
40AC_SUBST(PYTHON_FOR_BUILD)
41
42dnl Ensure that if prefix is specified, it does not end in a slash. If
43dnl it does, we get path names containing '//' which is both ugly and
44dnl can cause trouble.
45
46dnl Last slash shouldn't be stripped if prefix=/
47if test "$prefix" != "/"; then
48 prefix=`echo "$prefix" | sed -e 's/\/$//g'`
49fi
50
51dnl This is for stuff that absolutely must end up in pyconfig.h.
52dnl Please use pyport.h instead, if possible.
53AH_TOP([
54#ifndef Py_PYCONFIG_H
55#define Py_PYCONFIG_H
56])
57AH_BOTTOM([
58/* Define the macros needed if on a UnixWare 7.x system. */
59#if defined(__USLC__) && defined(__SCO_VERSION__)
60#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
61#endif
62
63#endif /*Py_PYCONFIG_H*/
64])
65
66# We don't use PACKAGE_ variables, and they cause conflicts
67# with other autoconf-based packages that include Python.h
68grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
69rm confdefs.h
70mv confdefs.h.new confdefs.h
71
72AC_SUBST(VERSION)
73VERSION=PYTHON_VERSION
74
75AC_SUBST(SOVERSION)
76SOVERSION=1.0
77
78# The later defininition of _XOPEN_SOURCE disables certain features
79# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
80AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
81
82# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
83# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
84# them.
85AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
86
87# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
88# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
89# them.
90AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
91
92# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
93# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
94AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
95
96# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
97# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
98# them.
99AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
100
101
102define_xopen_source=yes
103
104# Arguments passed to configure.
105AC_SUBST(CONFIG_ARGS)
106CONFIG_ARGS="$ac_configure_args"
107
108AC_MSG_CHECKING([for --enable-universalsdk])
109AC_ARG_ENABLE(universalsdk,
110 AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
111[
112 case $enableval in
113 yes)
114 enableval=/Developer/SDKs/MacOSX10.4u.sdk
115 if test ! -d "${enableval}"
116 then
117 enableval=/
118 fi
119 ;;
120 esac
121 case $enableval in
122 no)
123 UNIVERSALSDK=
124 enable_universalsdk=
125 ;;
126 *)
127 UNIVERSALSDK=$enableval
128 if test ! -d "${UNIVERSALSDK}"
129 then
130 AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
131 fi
132 ;;
133 esac
134
135],[
136 UNIVERSALSDK=
137 enable_universalsdk=
138])
139if test -n "${UNIVERSALSDK}"
140then
141 AC_MSG_RESULT(${UNIVERSALSDK})
142else
143 AC_MSG_RESULT(no)
144fi
145AC_SUBST(UNIVERSALSDK)
146
147AC_SUBST(ARCH_RUN_32BIT)
148ARCH_RUN_32BIT=""
149
150UNIVERSAL_ARCHS="32-bit"
151AC_SUBST(LIPO_32BIT_FLAGS)
152AC_MSG_CHECKING(for --with-universal-archs)
153AC_ARG_WITH(universal-archs,
154 AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
155[
156 AC_MSG_RESULT($withval)
157 UNIVERSAL_ARCHS="$withval"
158 if test "${enable_universalsdk}" ; then
159 :
160 else
161 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
162 fi
163],
164[
165 AC_MSG_RESULT(32-bit)
166])
167
168
169
170AC_ARG_WITH(framework-name,
171 AS_HELP_STRING([--with-framework-name=FRAMEWORK],
172 [specify an alternate name of the framework built with --enable-framework]),
173[
174 if test "${enable_framework}"; then
175 :
176 else
177 AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
178 fi
179 PYTHONFRAMEWORK=${withval}
180 PYTHONFRAMEWORKDIR=${withval}.framework
181 PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
182 ],[
183 PYTHONFRAMEWORK=Python
184 PYTHONFRAMEWORKDIR=Python.framework
185 PYTHONFRAMEWORKIDENTIFIER=org.python.python
186])
187dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
188AC_ARG_ENABLE(framework,
189 AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
190[
191 case $enableval in
192 yes)
193 enableval=/Library/Frameworks
194 esac
195 case $enableval in
196 no)
197 PYTHONFRAMEWORK=
198 PYTHONFRAMEWORKDIR=no-framework
199 PYTHONFRAMEWORKPREFIX=
200 PYTHONFRAMEWORKINSTALLDIR=
201 FRAMEWORKINSTALLFIRST=
202 FRAMEWORKINSTALLLAST=
203 FRAMEWORKALTINSTALLFIRST=
204 FRAMEWORKALTINSTALLLAST=
205 if test "x${prefix}" = "xNONE"; then
206 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
207 else
208 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
209 fi
210 enable_framework=
211 ;;
212 *)
213 PYTHONFRAMEWORKPREFIX="${enableval}"
214 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
215 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
216 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
217 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
218 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
219 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
220
221 if test "x${prefix}" = "xNONE" ; then
222 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
223
224 else
225 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
226 fi
227
228 case "${enableval}" in
229 /System*)
230 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
231 if test "${prefix}" = "NONE" ; then
232 # See below
233 FRAMEWORKUNIXTOOLSPREFIX="/usr"
234 fi
235 ;;
236
237 /Library*)
238 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
239 ;;
240
241 */Library/Frameworks)
242 MDIR="`dirname "${enableval}"`"
243 MDIR="`dirname "${MDIR}"`"
244 FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
245
246 if test "${prefix}" = "NONE"; then
247 # User hasn't specified the
248 # --prefix option, but wants to install
249 # the framework in a non-default location,
250 # ensure that the compatibility links get
251 # installed relative to that prefix as well
252 # instead of in /usr/local.
253 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
254 fi
255 ;;
256
257 *)
258 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
259 ;;
260 esac
261
262 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
263
264 # Add files for Mac specific code to the list of output
265 # files:
266 AC_CONFIG_FILES(Mac/Makefile)
267 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
268 AC_CONFIG_FILES(Mac/IDLE/Makefile)
269 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
270 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
271 esac
272 ],[
273 PYTHONFRAMEWORK=
274 PYTHONFRAMEWORKDIR=no-framework
275 PYTHONFRAMEWORKPREFIX=
276 PYTHONFRAMEWORKINSTALLDIR=
277 FRAMEWORKINSTALLFIRST=
278 FRAMEWORKINSTALLLAST=
279 FRAMEWORKALTINSTALLFIRST=
280 FRAMEWORKALTINSTALLLAST=
281 if test "x${prefix}" = "xNONE" ; then
282 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
283 else
284 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
285 fi
286 enable_framework=
287
288])
289AC_SUBST(PYTHONFRAMEWORK)
290AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
291AC_SUBST(PYTHONFRAMEWORKDIR)
292AC_SUBST(PYTHONFRAMEWORKPREFIX)
293AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
294AC_SUBST(FRAMEWORKINSTALLFIRST)
295AC_SUBST(FRAMEWORKINSTALLLAST)
296AC_SUBST(FRAMEWORKALTINSTALLFIRST)
297AC_SUBST(FRAMEWORKALTINSTALLLAST)
298AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
299AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
300
301##AC_ARG_WITH(dyld,
302## AS_HELP_STRING([--with-dyld],
303## [Use (OpenStep|Rhapsody) dynamic linker]))
304##
305# Set name for machine-dependent library files
306AC_SUBST(MACHDEP)
307AC_MSG_CHECKING(MACHDEP)
308if test -z "$MACHDEP"
309then
310 # avoid using uname for cross builds
311 if test "$cross_compiling" = yes; then
312 # ac_sys_system and ac_sys_release are only used for setting
313 # `define_xopen_source' in the case statement below. For the
314 # current supported cross builds, this macro is not adjusted.
315 case "$host" in
316 *-*-linux*)
317 ac_sys_system=Linux
318 ;;
319 *-*-cygwin*)
320 ac_sys_system=Cygwin
321 ;;
322 *)
323 # for now, limit cross builds to known configurations
324 MACHDEP="unknown"
325 AC_MSG_ERROR([cross build not supported for $host])
326 esac
327 ac_sys_release=
328 else
329 ac_sys_system=`uname -s`
330 if test "$ac_sys_system" = "AIX" \
331 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
332 ac_sys_release=`uname -v`
333 else
334 ac_sys_release=`uname -r`
335 fi
336 fi
337 ac_md_system=`echo $ac_sys_system |
338 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
339 ac_md_release=`echo $ac_sys_release |
340 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
341 MACHDEP="$ac_md_system$ac_md_release"
342
343 case $MACHDEP in
344 linux*) MACHDEP="linux2";;
345 cygwin*) MACHDEP="cygwin";;
346 darwin*) MACHDEP="darwin";;
347 atheos*) MACHDEP="atheos";;
348 irix646) MACHDEP="irix6";;
349 os2*|OS/2*|emx*) MACHDEP="os2knix";;
350 '') MACHDEP="unknown";;
351 esac
352fi
353
354AC_SUBST(_PYTHON_HOST_PLATFORM)
355if test "$cross_compiling" = yes; then
356 case "$host" in
357 *-*-linux*)
358 case "$host_cpu" in
359 arm*)
360 _host_cpu=arm
361 ;;
362 *)
363 _host_cpu=$host_cpu
364 esac
365 ;;
366 *-*-cygwin*)
367 _host_cpu=
368 ;;
369 *)
370 # for now, limit cross builds to known configurations
371 MACHDEP="unknown"
372 AC_MSG_ERROR([cross build not supported for $host])
373 esac
374 _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}"
375fi
376
377# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
378# disable features if it is defined, without any means to access these
379# features as extensions. For these systems, we skip the definition of
380# _XOPEN_SOURCE. Before adding a system to the list to gain access to
381# some feature, make sure there is no alternative way to access this
382# feature. Also, when using wildcards, make sure you have verified the
383# need for not defining _XOPEN_SOURCE on all systems matching the
384# wildcard, and that the wildcard does not include future systems
385# (which may remove their limitations).
386dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
387case $ac_sys_system/$ac_sys_release in
388 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
389 # even though select is a POSIX function. Reported by J. Ribbens.
390 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
391 # In addition, Stefan Krah confirms that issue #1244610 exists through
392 # OpenBSD 4.6, but is fixed in 4.7.
393 OpenBSD/2.* | OpenBSD/3.* | OpenBSD/4.@<:@0123456@:>@)
394 define_xopen_source=no
395 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
396 # also defined. This can be overridden by defining _BSD_SOURCE
397 # As this has a different meaning on Linux, only define it on OpenBSD
398 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
399 ;;
400 OpenBSD/*)
401 # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
402 # also defined. This can be overridden by defining _BSD_SOURCE
403 # As this has a different meaning on Linux, only define it on OpenBSD
404 AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
405 ;;
406 # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
407 # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
408 # Marc Recht
409 NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
410 define_xopen_source=no;;
411 # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
412 # request to enable features supported by the standard as a request
413 # to disable features not supported by the standard. The best way
414 # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
415 # entirely and define __EXTENSIONS__ instead.
416 SunOS/*)
417 define_xopen_source=no;;
418 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
419 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
420 # Reconfirmed for 7.1.4 by Martin v. Loewis.
421 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
422 define_xopen_source=no;;
423 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
424 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
425 SCO_SV/3.2)
426 define_xopen_source=no;;
427 # On FreeBSD 4, the math functions C89 does not cover are never defined
428 # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
429 FreeBSD/4.*)
430 define_xopen_source=no;;
431 # On MacOS X 10.2, a bug in ncurses.h means that it craps out if
432 # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
433 # identifies itself as Darwin/7.*
434 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
435 # disables platform specific features beyond repair.
436 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
437 # has no effect, don't bother defining them
438 Darwin/@<:@6789@:>@.*)
439 define_xopen_source=no;;
440 Darwin/1@<:@0-9@:>@.*)
441 define_xopen_source=no;;
442 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
443 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
444 # or has another value. By not (re)defining it, the defaults come in place.
445 AIX/4)
446 define_xopen_source=no;;
447 AIX/5)
448 if test `uname -r` -eq 1; then
449 define_xopen_source=no
450 fi
451 ;;
452 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
453 # defining NI_NUMERICHOST.
454 QNX/6.3.2)
455 define_xopen_source=no
456 ;;
457
458esac
459
460if test $define_xopen_source = yes
461then
462 AC_DEFINE(_XOPEN_SOURCE, 600,
463 Define to the level of X/Open that your system supports)
464
465 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
466 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
467 # several APIs are not declared. Since this is also needed in some
468 # cases for HP-UX, we define it globally.
469 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
470 Define to activate Unix95-and-earlier features)
471
472 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
473
474fi
475
476#
477# SGI compilers allow the specification of the both the ABI and the
478# ISA on the command line. Depending on the values of these switches,
479# different and often incompatable code will be generated.
480#
481# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
482# thus supply support for various ABI/ISA combinations. The MACHDEP
483# variable is also adjusted.
484#
485AC_SUBST(SGI_ABI)
486if test ! -z "$SGI_ABI"
487then
488 CC="cc $SGI_ABI"
489 LDFLAGS="$SGI_ABI $LDFLAGS"
490 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
491fi
492AC_MSG_RESULT($MACHDEP)
493
494# And add extra plat-mac for darwin
495AC_SUBST(EXTRAPLATDIR)
496AC_SUBST(EXTRAMACHDEPPATH)
497AC_MSG_CHECKING(EXTRAPLATDIR)
498if test -z "$EXTRAPLATDIR"
499then
500 case $MACHDEP in
501 darwin)
502 EXTRAPLATDIR="\$(PLATMACDIRS)"
503 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
504 ;;
505 *)
506 EXTRAPLATDIR=""
507 EXTRAMACHDEPPATH=""
508 ;;
509 esac
510fi
511AC_MSG_RESULT($EXTRAPLATDIR)
512
513# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
514# it may influence the way we can build extensions, so distutils
515# needs to check it
516AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
517AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
518CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
519EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
520
521# checks for alternative programs
522
523# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
524# for debug/optimization stuff. BASECFLAGS is for flags that are required
525# just to get things to compile and link. Users are free to override OPT
526# when running configure or make. The build should not break if they do.
527# BASECFLAGS should generally not be messed with, however.
528
529# XXX shouldn't some/most/all of this code be merged with the stuff later
530# on that fiddles with OPT and BASECFLAGS?
531AC_MSG_CHECKING(for --without-gcc)
532AC_ARG_WITH(gcc,
533 AS_HELP_STRING([--without-gcc], [never use gcc]),
534[
535 case $withval in
536 no) CC=${CC:-cc}
537 without_gcc=yes;;
538 yes) CC=gcc
539 without_gcc=no;;
540 *) CC=$withval
541 without_gcc=$withval;;
542 esac], [
543 case $ac_sys_system in
544 AIX*) CC=${CC:-xlc_r}
545 without_gcc=;;
546 BeOS*)
547 case $BE_HOST_CPU in
548 ppc)
549 CC=mwcc
550 without_gcc=yes
551 BASECFLAGS="$BASECFLAGS -export pragma"
552 OPT="$OPT -O"
553 LDFLAGS="$LDFLAGS -nodup"
554 ;;
555 x86)
556 CC=gcc
557 without_gcc=no
558 OPT="$OPT -O"
559 ;;
560 *)
561 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
562 ;;
563 esac
564 AR="\$(srcdir)/Modules/ar_beos"
565 RANLIB=:
566 ;;
567 *) without_gcc=no;;
568 esac])
569AC_MSG_RESULT($without_gcc)
570
571# If the user switches compilers, we can't believe the cache
572if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
573then
574 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
575(it is also a good idea to do 'make clean' before compiling)])
576fi
577
578if test "$MACHDEP" = "irix6" && test "$CC" != "gcc"; then
579 # Normally, MIPSpro CC treats #error directives as warnings, which means
580 # a successful exit code is returned (0). This is a problem because IRIX
581 # has a bunch of system headers with this guard at the top:
582 #
583 # #ifndef __c99
584 # #error This header file is to be used only for c99 mode compilations
585 # #else
586 #
587 # When autoconf tests for such a header, like stdint.h, this happens:
588 #
589 # configure:4619: cc -c conftest.c >&5
590 # cc-1035 cc: WARNING File = /usr/include/stdint.h, Line = 5
591 # #error directive: This header file is to be used only for c99 mode
592 # compilations
593 #
594 # #error This header file is to be used only for c99 mode compilations
595 # ^
596 #
597 # configure:4619: $? = 0
598 # configure:4619: result: yes
599 #
600 # Therefore, we use `-diag_error 1035` to have the compiler treat the
601 # warning as an error, which causes cc to return a non-zero result,
602 # which autoconf can interpret correctly.
603 CFLAGS="$CFLAGS -diag_error 1035"
604 # Whilst we're here, we might as well make sure CXX defaults to something
605 # sensible if we're not using gcc.
606 if test -z "$CXX"; then
607 CXX="CC"
608 fi
609fi
610
611# If the user set CFLAGS, use this instead of the automatically
612# determined setting
613preset_cflags="$CFLAGS"
614AC_PROG_CC
615if test ! -z "$preset_cflags"
616then
617 CFLAGS=$preset_cflags
618fi
619
620AC_SUBST(CXX)
621AC_SUBST(MAINCC)
622AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
623AC_ARG_WITH(cxx_main,
624 AS_HELP_STRING([--with-cxx-main=<compiler>],
625 [compile main() and link python executable with C++ compiler]),
626[
627
628 case $withval in
629 no) with_cxx_main=no
630 MAINCC='$(CC)';;
631 yes) with_cxx_main=yes
632 MAINCC='$(CXX)';;
633 *) with_cxx_main=yes
634 MAINCC=$withval
635 if test -z "$CXX"
636 then
637 CXX=$withval
638 fi;;
639 esac], [
640 with_cxx_main=no
641 MAINCC='$(CC)'
642])
643AC_MSG_RESULT($with_cxx_main)
644
645preset_cxx="$CXX"
646if test -z "$CXX"
647then
648 case "$CC" in
649 gcc) AC_PATH_TOOL(CXX, [g++], [g++], [notfound]) ;;
650 cc) AC_PATH_TOOL(CXX, [c++], [c++], [notfound]) ;;
651 esac
652 if test "$CXX" = "notfound"
653 then
654 CXX=""
655 fi
656fi
657if test -z "$CXX"
658then
659 AC_CHECK_TOOLS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
660 if test "$CXX" = "notfound"
661 then
662 CXX=""
663 fi
664fi
665if test "$preset_cxx" != "$CXX"
666then
667 AC_MSG_WARN([
668
669 By default, distutils will build C++ extension modules with "$CXX".
670 If this is not intended, then set CXX on the configure command line.
671 ])
672fi
673
674MULTIARCH=$($CC --print-multiarch 2>/dev/null)
675AC_SUBST(MULTIARCH)
676
677
678# checks for UNIX variants that set C preprocessor variables
679AC_USE_SYSTEM_EXTENSIONS
680
681# Check for unsupported systems
682case $ac_sys_system/$ac_sys_release in
683atheos*|Linux*/1*)
684 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
685 echo See README for details.
686 exit 1;;
687esac
688
689AC_EXEEXT
690AC_MSG_CHECKING(for --with-suffix)
691AC_ARG_WITH(suffix,
692 AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
693[
694 case $withval in
695 no) EXEEXT=;;
696 yes) EXEEXT=.exe;;
697 *) EXEEXT=$withval;;
698 esac])
699AC_MSG_RESULT($EXEEXT)
700
701# Test whether we're running on a non-case-sensitive system, in which
702# case we give a warning if no ext is given
703AC_SUBST(BUILDEXEEXT)
704AC_MSG_CHECKING(for case-insensitive build directory)
705if test ! -d CaseSensitiveTestDir; then
706mkdir CaseSensitiveTestDir
707fi
708
709if test -d casesensitivetestdir
710then
711 AC_MSG_RESULT(yes)
712 BUILDEXEEXT=.exe
713else
714 AC_MSG_RESULT(no)
715 BUILDEXEEXT=$EXEEXT
716fi
717rmdir CaseSensitiveTestDir
718
719case $MACHDEP in
720bsdos*)
721 case $CC in
722 gcc) CC="$CC -D_HAVE_BSDI";;
723 esac;;
724esac
725
726case $ac_sys_system in
727hp*|HP*)
728 case $CC in
729 cc|*/cc) CC="$CC -Ae";;
730 esac;;
731SunOS*)
732 # Some functions have a prototype only with that define, e.g. confstr
733 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
734 ;;
735esac
736
737
738AC_SUBST(LIBRARY)
739AC_MSG_CHECKING(LIBRARY)
740if test -z "$LIBRARY"
741then
742 LIBRARY='libpython$(VERSION).a'
743fi
744AC_MSG_RESULT($LIBRARY)
745
746# LDLIBRARY is the name of the library to link against (as opposed to the
747# name of the library into which to insert object files). BLDLIBRARY is also
748# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
749# is blank as the main program is not linked directly against LDLIBRARY.
750# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
751# systems without shared libraries, LDLIBRARY is the same as LIBRARY
752# (defined in the Makefiles). On Cygwin and OS/2 LDLIBRARY is the import
753# library, DLLLIBRARY is the shared (i.e., DLL) library.
754#
755# RUNSHARED is used to run shared python without installed libraries
756#
757# INSTSONAME is the name of the shared library that will be use to install
758# on the system - some systems like version suffix, others don't
759AC_SUBST(LDLIBRARY)
760AC_SUBST(DLLLIBRARY)
761AC_SUBST(BLDLIBRARY)
762AC_SUBST(LDLIBRARYDIR)
763AC_SUBST(INSTSONAME)
764AC_SUBST(RUNSHARED)
765AC_SUBST(CONDENSED_VERSION)
766LDLIBRARY="$LIBRARY"
767BLDLIBRARY='$(LDLIBRARY)'
768INSTSONAME='$(LDLIBRARY)'
769DLLLIBRARY=''
770LDLIBRARYDIR=''
771RUNSHARED=''
772CONDENSED_VERSION=''
773
774# LINKCC is the command that links the python executable -- default is $(CC).
775# If CXX is set, and if it is needed to link a main function that was
776# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
777# python might then depend on the C++ runtime
778# This is altered for AIX in order to build the export list before
779# linking.
780AC_SUBST(LINKCC)
781AC_MSG_CHECKING(LINKCC)
782if test -z "$LINKCC"
783then
784 LINKCC='$(PURIFY) $(MAINCC)'
785 case $ac_sys_system in
786 AIX*)
787 exp_extra="\"\""
788 if test $ac_sys_release -ge 5 -o \
789 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
790 exp_extra="."
791 fi
792 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
793 QNX*)
794 # qcc must be used because the other compilers do not
795 # support -N.
796 LINKCC=qcc;;
797 esac
798fi
799AC_MSG_RESULT($LINKCC)
800
801# GNULD is set to "yes" if the GNU linker is used. If this goes wrong
802# make sure we default having it set to "no": this is used by
803# distutils.unixccompiler to know if it should add --enable-new-dtags
804# to linker command lines, and failing to detect GNU ld simply results
805# in the same bahaviour as before.
806AC_SUBST(GNULD)
807AC_MSG_CHECKING(for GNU ld)
808ac_prog=ld
809if test "$GCC" = yes; then
810 ac_prog=`$CC -print-prog-name=ld`
811fi
812case `"$ac_prog" -V 2>&1 < /dev/null` in
813 *GNU*)
814 GNULD=yes;;
815 *)
816 GNULD=no;;
817esac
818AC_MSG_RESULT($GNULD)
819
820AC_MSG_CHECKING(for --enable-shared)
821AC_ARG_ENABLE(shared,
822 AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
823
824if test -z "$enable_shared"
825then
826 case $ac_sys_system in
827 CYGWIN* | atheos* | *OS/2* | *emx* | *os2*)
828 enable_shared="yes";;
829 *)
830 enable_shared="no";;
831 esac
832fi
833AC_MSG_RESULT($enable_shared)
834
835AC_MSG_CHECKING(for --enable-profiling)
836AC_ARG_ENABLE(profiling,
837 AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]))
838if test "x$enable_profiling" = xyes; then
839 ac_save_cc="$CC"
840 CC="$CC -pg"
841 AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
842 [],
843 [enable_profiling=no])
844 CC="$ac_save_cc"
845else
846 enable_profiling=no
847fi
848AC_MSG_RESULT($enable_profiling)
849
850if test "x$enable_profiling" = xyes; then
851 BASECFLAGS="-pg $BASECFLAGS"
852 LDFLAGS="-pg $LDFLAGS"
853fi
854
855AC_MSG_CHECKING(LDLIBRARY)
856
857# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
858# library that we build, but we do not want to link against it (we
859# will find it with a -framework option). For this reason there is an
860# extra variable BLDLIBRARY against which Python and the extension
861# modules are linked, BLDLIBRARY. This is normally the same as
862# LDLIBRARY, but empty for MacOSX framework builds.
863if test "$enable_framework"
864then
865 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
866 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
867 BLDLIBRARY=''
868else
869 BLDLIBRARY='$(LDLIBRARY)'
870fi
871
872# Other platforms follow
873if test $enable_shared = "yes"; then
874 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
875 case $ac_sys_system in
876 BeOS*)
877 LDLIBRARY='libpython$(VERSION).so'
878 ;;
879 CYGWIN*)
880 LDLIBRARY='libpython$(VERSION).dll.a'
881 DLLLIBRARY='libpython$(VERSION).dll'
882 ;;
883 SunOS*)
884 LDLIBRARY='libpython$(VERSION).so'
885 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
886 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
887 INSTSONAME="$LDLIBRARY".$SOVERSION
888 ;;
889 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
890 LDLIBRARY='libpython$(VERSION).so'
891 BLDLIBRARY='-L. -lpython$(VERSION)'
892 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
893 case $ac_sys_system in
894 FreeBSD*)
895 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
896 ;;
897 esac
898 INSTSONAME="$LDLIBRARY".$SOVERSION
899 ;;
900 hp*|HP*)
901 case `uname -m` in
902 ia64)
903 LDLIBRARY='libpython$(VERSION).so'
904 ;;
905 *)
906 LDLIBRARY='libpython$(VERSION).sl'
907 ;;
908 esac
909 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
910 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
911 ;;
912 OSF*)
913 LDLIBRARY='libpython$(VERSION).so'
914 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
915 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
916 ;;
917 atheos*)
918 LDLIBRARY='libpython$(VERSION).so'
919 BLDLIBRARY='-L. -lpython$(VERSION)'
920 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
921 ;;
922 Darwin*)
923 LDLIBRARY='libpython$(VERSION).dylib'
924 BLDLIBRARY='-L. -lpython$(VERSION)'
925 RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
926 ;;
927 AIX*)
928 LDLIBRARY='libpython$(VERSION).so'
929 RUNSHARED=LIBPATH=`pwd`:${LIBPATH}
930 ;;
931 OS/2*|os2*|*emx*)
932 LDLIBRARY='python$(VERSION)_dll.a'
933 BLDLIBRARY='-L. -lpython$(VERSION)'
934 RUNSHARED=BEGINLIBPATH="'`pwd`;$BEGINLIBPATH'"
935 CONDENSED_VERSION=`echo "${VERSION}" | tr -d .,`
936 DLLLIBRARY='python$(CONDENSED_VERSION).dll'
937 ;;
938
939 esac
940else # shared is disabled
941 case $ac_sys_system in
942 CYGWIN*)
943 BLDLIBRARY='$(LIBRARY)'
944 LDLIBRARY='libpython$(VERSION).dll.a'
945 ;;
946 esac
947fi
948
949if test "$cross_compiling" = yes; then
950 RUNSHARED=
951fi
952
953AC_MSG_RESULT($LDLIBRARY)
954
955AC_PROG_RANLIB
956AC_SUBST(AR)
957AC_CHECK_TOOLS(AR, ar aal, ar)
958
959# tweak ARFLAGS only if the user didn't set it on the command line
960AC_SUBST(ARFLAGS)
961if test -z "$ARFLAGS"
962then
963 ARFLAGS="rc"
964fi
965
966AC_SUBST(SVNVERSION)
967AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
968if test $SVNVERSION = found
969then
970 SVNVERSION="svnversion \$(srcdir)"
971else
972 SVNVERSION="echo Unversioned directory"
973fi
974
975AC_SUBST(BASECPPFLAGS)
976if test "$abs_srcdir" != "$abs_builddir"; then
977 # If we're building out-of-tree make sure Include (in the current dir)
978 # gets picked up before its $srcdir counterpart in order for Python-ast.h
979 # and graminit.h to get picked up from the correct directory.
980 # (A side effect of this is that these resources will automatically be
981 # regenerated when building out-of-tree, regardless of whether or not
982 # the $srcdir counterpart is up-to-date. This is an acceptable trade
983 # off.)
984 BASECPPFLAGS="-IInclude"
985else
986 BASECPPFLAGS=""
987fi
988
989AC_SUBST(HGVERSION)
990AC_SUBST(HGTAG)
991AC_SUBST(HGBRANCH)
992AC_CHECK_PROG(HAS_HG, hg, found, not-found)
993if test $HAS_HG = found
994then
995 HGVERSION="hg id -i \$(srcdir)"
996 HGTAG="hg id -t \$(srcdir)"
997 HGBRANCH="hg id -b \$(srcdir)"
998else
999 HGVERSION=""
1000 HGTAG=""
1001 HGBRANCH=""
1002fi
1003
1004case $MACHDEP in
1005bsdos*|hp*|HP*)
1006 # install -d does not work on BSDI or HP-UX
1007 if test -z "$INSTALL"
1008 then
1009 INSTALL="${srcdir}/install-sh -c"
1010 fi
1011esac
1012AC_PROG_INSTALL
1013AC_PROG_MKDIR_P
1014
1015# Not every filesystem supports hard links
1016AC_SUBST(LN)
1017if test -z "$LN" ; then
1018 case $ac_sys_system in
1019 BeOS*) LN="ln -s";;
1020 CYGWIN*) LN="ln -s";;
1021 OS/2*|os2*|*emx*) LN="ln -s";;
1022 atheos*) LN="ln -s";;
1023 *) LN=ln;;
1024 esac
1025fi
1026
1027# Check for --with-pydebug
1028AC_MSG_CHECKING(for --with-pydebug)
1029AC_ARG_WITH(pydebug,
1030 AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
1031[
1032if test "$withval" != no
1033then
1034 AC_DEFINE(Py_DEBUG, 1,
1035 [Define if you want to build an interpreter with many run-time checks.])
1036 AC_MSG_RESULT(yes);
1037 Py_DEBUG='true'
1038else AC_MSG_RESULT(no); Py_DEBUG='false'
1039fi],
1040[AC_MSG_RESULT(no)])
1041
1042# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
1043# merged with this chunk of code?
1044
1045# Optimizer/debugger flags
1046# ------------------------
1047# (The following bit of code is complicated enough - please keep things
1048# indented properly. Just pretend you're editing Python code. ;-)
1049
1050# There are two parallel sets of case statements below, one that checks to
1051# see if OPT was set and one that does BASECFLAGS setting based upon
1052# compiler and platform. BASECFLAGS tweaks need to be made even if the
1053# user set OPT.
1054
1055# tweak OPT based on compiler and platform, only if the user didn't set
1056# it on the command line
1057AC_SUBST(OPT)
1058if test "${OPT-unset}" = "unset"
1059then
1060 case $GCC in
1061 yes)
1062 if test "$CC" != 'g++' ; then
1063 STRICT_PROTO="-Wstrict-prototypes"
1064 fi
1065 # For gcc 4.x we need to use -fwrapv so lets check if its supported
1066 if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
1067 WRAP="-fwrapv"
1068 fi
1069
1070 # Clang also needs -fwrapv
1071 case $CC in
1072 *clang*) WRAP="-fwrapv"
1073 ;;
1074 esac
1075
1076 case $ac_cv_prog_cc_g in
1077 yes)
1078 if test "$Py_DEBUG" = 'true' ; then
1079 # Optimization messes up debuggers, so turn it off for
1080 # debug builds.
1081 OPT="-g -O0 -Wall $STRICT_PROTO"
1082 else
1083 OPT="-g $WRAP -O2 -Wall $STRICT_PROTO"
1084 fi
1085 ;;
1086 *)
1087 OPT="-O2 -Wall $STRICT_PROTO"
1088 ;;
1089 esac
1090 case $ac_sys_system in
1091 SCO_SV*) OPT="$OPT -m486 -DSCO5"
1092 ;;
1093 esac
1094 ;;
1095
1096 *)
1097 OPT="-O"
1098 ;;
1099 esac
1100fi
1101
1102AC_SUBST(BASECFLAGS)
1103
1104# The -arch flags for universal builds on OSX
1105UNIVERSAL_ARCH_FLAGS=
1106AC_SUBST(UNIVERSAL_ARCH_FLAGS)
1107
1108# tweak BASECFLAGS based on compiler and platform
1109case $GCC in
1110yes)
1111 # Python violates C99 rules, by casting between incompatible
1112 # pointer types. GCC may generate bad code as a result of that,
1113 # so use -fno-strict-aliasing if supported.
1114 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
1115 ac_save_cc="$CC"
1116 CC="$CC -fno-strict-aliasing"
1117 AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
1118 AC_COMPILE_IFELSE(
1119 [AC_LANG_PROGRAM([[]], [[]])],
1120 [ac_cv_no_strict_aliasing_ok=yes],
1121 [ac_cv_no_strict_aliasing_ok=no]))
1122 CC="$ac_save_cc"
1123 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
1124 if test $ac_cv_no_strict_aliasing_ok = yes
1125 then
1126 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
1127 fi
1128
1129 # if using gcc on alpha, use -mieee to get (near) full IEEE 754
1130 # support. Without this, treatment of subnormals doesn't follow
1131 # the standard.
1132 case $host in
1133 alpha*)
1134 BASECFLAGS="$BASECFLAGS -mieee"
1135 ;;
1136 esac
1137
1138 case $ac_sys_system in
1139 SCO_SV*)
1140 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
1141 ;;
1142 # is there any other compiler on Darwin besides gcc?
1143 Darwin*)
1144 # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
1145 # used to be here, but non-Apple gcc doesn't accept them.
1146 if test "${CC}" = gcc
1147 then
1148 AC_MSG_CHECKING(which compiler should be used)
1149 case "${UNIVERSALSDK}" in
1150 */MacOSX10.4u.sdk)
1151 # Build using 10.4 SDK, force usage of gcc when the
1152 # compiler is gcc, otherwise the user will get very
1153 # confusing error messages when building on OSX 10.6
1154 CC=gcc-4.0
1155 CPP=cpp-4.0
1156 ;;
1157 esac
1158 AC_MSG_RESULT($CC)
1159 fi
1160
1161 # Calculate the right deployment target for this build.
1162 #
1163 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1164 if test ${cur_target} '>' 10.2; then
1165 cur_target=10.3
1166 if test ${enable_universalsdk}; then
1167 if test "${UNIVERSAL_ARCHS}" = "all"; then
1168 # Ensure that the default platform for a
1169 # 4-way universal build is OSX 10.5,
1170 # that's the first OS release where
1171 # 4-way builds make sense.
1172 cur_target='10.5'
1173
1174 elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1175 cur_target='10.5'
1176
1177 elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1178 cur_target='10.5'
1179
1180 elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1181 cur_target='10.5'
1182 fi
1183 else
1184 if test `/usr/bin/arch` = "i386"; then
1185 # On Intel macs default to a deployment
1186 # target of 10.4, that's the first OSX
1187 # release with Intel support.
1188 cur_target="10.4"
1189 fi
1190 fi
1191 fi
1192 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1193
1194 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
1195 # environment with a value that is the same as what we'll use
1196 # in the Makefile to ensure that we'll get the same compiler
1197 # environment during configure and build time.
1198 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1199 export MACOSX_DEPLOYMENT_TARGET
1200 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1201
1202 if test "${enable_universalsdk}"; then
1203 UNIVERSAL_ARCH_FLAGS=""
1204 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1205 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1206 ARCH_RUN_32BIT=""
1207 LIPO_32BIT_FLAGS=""
1208
1209 elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1210 UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1211 LIPO_32BIT_FLAGS=""
1212 ARCH_RUN_32BIT="true"
1213
1214 elif test "$UNIVERSAL_ARCHS" = "all" ; then
1215 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1216 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1217 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1218
1219 elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1220 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1221 LIPO_32BIT_FLAGS="-extract i386"
1222 ARCH_RUN_32BIT="/usr/bin/arch -i386"
1223
1224 elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1225 UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1226 LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1227 ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1228
1229 else
1230 AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1231
1232 fi
1233
1234
1235 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1236 if test "${UNIVERSALSDK}" != "/"
1237 then
1238 CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1239 LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1240 CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
1241 fi
1242
1243 fi
1244
1245
1246 ;;
1247 OSF*)
1248 BASECFLAGS="$BASECFLAGS -mieee"
1249 ;;
1250 esac
1251 ;;
1252
1253*)
1254 case $ac_sys_system in
1255 OpenUNIX*|UnixWare*)
1256 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1257 ;;
1258 OSF*)
1259 BASECFLAGS="$BASECFLAGS -ieee -std"
1260 ;;
1261 SCO_SV*)
1262 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1263 ;;
1264 esac
1265 ;;
1266esac
1267
1268if test "$Py_DEBUG" = 'true'; then
1269 :
1270else
1271 OPT="-DNDEBUG $OPT"
1272fi
1273
1274if test "$ac_arch_flags"
1275then
1276 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
1277fi
1278
1279# disable check for icc since it seems to pass, but generates a warning
1280if test "$CC" = icc
1281then
1282 ac_cv_opt_olimit_ok=no
1283fi
1284
1285AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1286AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1287[ac_save_cc="$CC"
1288CC="$CC -OPT:Olimit=0"
1289AC_COMPILE_IFELSE(
1290 [AC_LANG_PROGRAM([[]], [[]])],
1291 [ac_cv_opt_olimit_ok=yes],
1292 [ac_cv_opt_olimit_ok=no]
1293 )
1294CC="$ac_save_cc"])
1295AC_MSG_RESULT($ac_cv_opt_olimit_ok)
1296if test $ac_cv_opt_olimit_ok = yes; then
1297 case $ac_sys_system in
1298 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1299 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
1300 # environment?
1301 Darwin*)
1302 ;;
1303 # XXX thankfully this useless troublemaker of a flag has been
1304 # eradicated in the 3.x line. For now, make sure it isn't picked
1305 # up by any of our other platforms that use CC.
1306 AIX*|SunOS*|HP-UX*|IRIX*)
1307 ;;
1308 *)
1309 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1310 ;;
1311 esac
1312else
1313 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1314 AC_CACHE_VAL(ac_cv_olimit_ok,
1315 [ac_save_cc="$CC"
1316 CC="$CC -Olimit 1500"
1317 AC_COMPILE_IFELSE(
1318 [AC_LANG_PROGRAM([[]], [[]])],
1319 [ac_cv_olimit_ok=yes],
1320 [ac_cv_olimit_ok=no]
1321 )
1322 CC="$ac_save_cc"])
1323 AC_MSG_RESULT($ac_cv_olimit_ok)
1324 if test $ac_cv_olimit_ok = yes; then
1325 case $ac_sys_system in
1326 # Issue #16534: On HP-UX ac_cv_olimit_ok=yes is a false positive.
1327 HP-UX*)
1328 ;;
1329 *)
1330 BASECFLAGS="$BASECFLAGS -Olimit 1500"
1331 ;;
1332 esac
1333 fi
1334fi
1335
1336# Check whether GCC supports PyArg_ParseTuple format
1337if test "$GCC" = "yes"
1338then
1339 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1340 save_CFLAGS=$CFLAGS
1341 CFLAGS="$CFLAGS -Werror -Wformat"
1342 AC_COMPILE_IFELSE([
1343 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1344 ],[
1345 AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1346 [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1347 AC_MSG_RESULT(yes)
1348 ],[
1349 AC_MSG_RESULT(no)
1350 ])
1351 CFLAGS=$save_CFLAGS
1352fi
1353
1354# On some compilers, pthreads are available without further options
1355# (e.g. MacOS X). On some of these systems, the compiler will not
1356# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1357# So we have to see first whether pthreads are available without
1358# options before we can check whether -Kpthread improves anything.
1359AC_MSG_CHECKING(whether pthreads are available without options)
1360AC_CACHE_VAL(ac_cv_pthread_is_default,
1361[AC_RUN_IFELSE([AC_LANG_SOURCE([[
1362#include <stdio.h>
1363#include <pthread.h>
1364
1365void* routine(void* p){return NULL;}
1366
1367int main(){
1368 pthread_t p;
1369 if(pthread_create(&p,NULL,routine,NULL)!=0)
1370 return 1;
1371 (void)pthread_detach(p);
1372 return 0;
1373}
1374]])],[
1375 ac_cv_pthread_is_default=yes
1376 ac_cv_kthread=no
1377 ac_cv_pthread=no
1378],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
1379])
1380AC_MSG_RESULT($ac_cv_pthread_is_default)
1381
1382
1383if test $ac_cv_pthread_is_default = yes
1384then
1385 ac_cv_kpthread=no
1386else
1387# -Kpthread, if available, provides the right #defines
1388# and linker options to make pthread_create available
1389# Some compilers won't report that they do not support -Kpthread,
1390# so we need to run a program to see whether it really made the
1391# function available.
1392AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1393AC_CACHE_VAL(ac_cv_kpthread,
1394[ac_save_cc="$CC"
1395CC="$CC -Kpthread"
1396AC_RUN_IFELSE([AC_LANG_SOURCE([[
1397#include <stdio.h>
1398#include <pthread.h>
1399
1400void* routine(void* p){return NULL;}
1401
1402int main(){
1403 pthread_t p;
1404 if(pthread_create(&p,NULL,routine,NULL)!=0)
1405 return 1;
1406 (void)pthread_detach(p);
1407 return 0;
1408}
1409]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
1410CC="$ac_save_cc"])
1411AC_MSG_RESULT($ac_cv_kpthread)
1412fi
1413
1414if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
1415then
1416# -Kthread, if available, provides the right #defines
1417# and linker options to make pthread_create available
1418# Some compilers won't report that they do not support -Kthread,
1419# so we need to run a program to see whether it really made the
1420# function available.
1421AC_MSG_CHECKING(whether $CC accepts -Kthread)
1422AC_CACHE_VAL(ac_cv_kthread,
1423[ac_save_cc="$CC"
1424CC="$CC -Kthread"
1425AC_RUN_IFELSE([AC_LANG_SOURCE([[
1426#include <stdio.h>
1427#include <pthread.h>
1428
1429void* routine(void* p){return NULL;}
1430
1431int main(){
1432 pthread_t p;
1433 if(pthread_create(&p,NULL,routine,NULL)!=0)
1434 return 1;
1435 (void)pthread_detach(p);
1436 return 0;
1437}
1438]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
1439CC="$ac_save_cc"])
1440AC_MSG_RESULT($ac_cv_kthread)
1441fi
1442
1443if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
1444then
1445# -pthread, if available, provides the right #defines
1446# and linker options to make pthread_create available
1447# Some compilers won't report that they do not support -pthread,
1448# so we need to run a program to see whether it really made the
1449# function available.
1450AC_MSG_CHECKING(whether $CC accepts -pthread)
1451AC_CACHE_VAL(ac_cv_pthread,
1452[ac_save_cc="$CC"
1453CC="$CC -pthread"
1454AC_RUN_IFELSE([AC_LANG_SOURCE([[
1455#include <stdio.h>
1456#include <pthread.h>
1457
1458void* routine(void* p){return NULL;}
1459
1460int main(){
1461 pthread_t p;
1462 if(pthread_create(&p,NULL,routine,NULL)!=0)
1463 return 1;
1464 (void)pthread_detach(p);
1465 return 0;
1466}
1467]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
1468CC="$ac_save_cc"])
1469AC_MSG_RESULT($ac_cv_pthread)
1470fi
1471
1472# If we have set a CC compiler flag for thread support then
1473# check if it works for CXX, too.
1474ac_cv_cxx_thread=no
1475if test ! -z "$CXX"
1476then
1477AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1478ac_save_cxx="$CXX"
1479
1480if test "$ac_cv_kpthread" = "yes"
1481then
1482 CXX="$CXX -Kpthread"
1483 ac_cv_cxx_thread=yes
1484elif test "$ac_cv_kthread" = "yes"
1485then
1486 CXX="$CXX -Kthread"
1487 ac_cv_cxx_thread=yes
1488elif test "$ac_cv_pthread" = "yes"
1489then
1490 CXX="$CXX -pthread"
1491 ac_cv_cxx_thread=yes
1492fi
1493
1494if test $ac_cv_cxx_thread = yes
1495then
1496 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1497 $CXX -c conftest.$ac_ext 2>&5
1498 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1499 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1500 then
1501 ac_cv_cxx_thread=yes
1502 else
1503 ac_cv_cxx_thread=no
1504 fi
1505 rm -fr conftest*
1506fi
1507AC_MSG_RESULT($ac_cv_cxx_thread)
1508fi
1509CXX="$ac_save_cxx"
1510
1511dnl # check for ANSI or K&R ("traditional") preprocessor
1512dnl AC_MSG_CHECKING(for C preprocessor type)
1513dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1514dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1515dnl int foo;
1516dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1517dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
1518dnl AC_MSG_RESULT($cpp_type)
1519
1520# checks for header files
1521AC_HEADER_STDC
1522AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1523fcntl.h grp.h \
1524ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
1525shadow.h signal.h stdint.h stropts.h termios.h thread.h \
1526unistd.h utime.h \
1527sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1528sys/lock.h sys/mkdev.h sys/modem.h \
1529sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
1530sys/termio.h sys/time.h \
1531sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
1532sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
1533bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h)
1534AC_HEADER_DIRENT
1535AC_HEADER_MAJOR
1536
1537# On Solaris, term.h requires curses.h
1538AC_CHECK_HEADERS(term.h,,,[
1539#ifdef HAVE_CURSES_H
1540#include <curses.h>
1541#endif
1542])
1543
1544# On Linux, netlink.h requires asm/types.h
1545AC_CHECK_HEADERS(linux/netlink.h,,,[
1546#ifdef HAVE_ASM_TYPES_H
1547#include <asm/types.h>
1548#endif
1549#ifdef HAVE_SYS_SOCKET_H
1550#include <sys/socket.h>
1551#endif
1552])
1553
1554# checks for typedefs
1555was_it_defined=no
1556AC_MSG_CHECKING(for clock_t in time.h)
1557AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1558 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1559])
1560AC_MSG_RESULT($was_it_defined)
1561
1562# Check whether using makedev requires defining _OSF_SOURCE
1563AC_MSG_CHECKING(for makedev)
1564AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1565#if defined(MAJOR_IN_MKDEV)
1566#include <sys/mkdev.h>
1567#elif defined(MAJOR_IN_SYSMACROS)
1568#include <sys/sysmacros.h>
1569#else
1570#include <sys/types.h>
1571#endif ]], [[ makedev(0, 0) ]])],
1572[ac_cv_has_makedev=yes],
1573[ac_cv_has_makedev=no])
1574if test "$ac_cv_has_makedev" = "no"; then
1575 # we didn't link, try if _OSF_SOURCE will allow us to link
1576 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1577#define _OSF_SOURCE 1
1578#include <sys/types.h>
1579 ]], [[ makedev(0, 0) ]])],
1580[ac_cv_has_makedev=yes],
1581[ac_cv_has_makedev=no])
1582 if test "$ac_cv_has_makedev" = "yes"; then
1583 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1584 fi
1585fi
1586AC_MSG_RESULT($ac_cv_has_makedev)
1587if test "$ac_cv_has_makedev" = "yes"; then
1588 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1589fi
1590
1591# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1592# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1593# defined, but the compiler does not support pragma redefine_extname,
1594# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1595# structures (such as rlimit64) without declaring them. As a
1596# work-around, disable LFS on such configurations
1597
1598use_lfs=yes
1599AC_MSG_CHECKING(Solaris LFS bug)
1600AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1601#define _LARGEFILE_SOURCE 1
1602#define _FILE_OFFSET_BITS 64
1603#include <sys/resource.h>
1604]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
1605AC_MSG_RESULT($sol_lfs_bug)
1606if test "$sol_lfs_bug" = "yes"; then
1607 use_lfs=no
1608fi
1609
1610if test "$use_lfs" = "yes"; then
1611# Two defines needed to enable largefile support on various platforms
1612# These may affect some typedefs
1613case $ac_sys_system/$ac_sys_release in
1614AIX*)
1615 AC_DEFINE(_LARGE_FILES, 1,
1616 [This must be defined on AIX systems to enable large file support.])
1617 ;;
1618esac
1619AC_DEFINE(_LARGEFILE_SOURCE, 1,
1620[This must be defined on some systems to enable large file support.])
1621AC_DEFINE(_FILE_OFFSET_BITS, 64,
1622[This must be set to 64 on some systems to enable large file support.])
1623fi
1624
1625# Add some code to confdefs.h so that the test for off_t works on SCO
1626cat >> confdefs.h <<\EOF
1627#if defined(SCO_DS)
1628#undef _OFF_T
1629#endif
1630EOF
1631
1632# Type availability checks
1633AC_TYPE_MODE_T
1634AC_TYPE_OFF_T
1635AC_TYPE_PID_T
1636AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
1637AC_TYPE_SIZE_T
1638AC_TYPE_UID_T
1639
1640# There are two separate checks for each of the exact-width integer types we
1641# need. First we check whether the type is available using the usual
1642# AC_CHECK_TYPE macro with the default includes (which includes <inttypes.h>
1643# and <stdint.h> where available). We then also use the special type checks of
1644# the form AC_TYPE_UINT32_T, which in the case that uint32_t is not available
1645# directly, #define's uint32_t to be a suitable type.
1646
1647AC_CHECK_TYPE(uint32_t,
1648 AC_DEFINE(HAVE_UINT32_T, 1, [Define if your compiler provides uint32_t.]),,)
1649AC_TYPE_UINT32_T
1650
1651AC_CHECK_TYPE(uint64_t,
1652 AC_DEFINE(HAVE_UINT64_T, 1, [Define if your compiler provides uint64_t.]),,)
1653AC_TYPE_UINT64_T
1654
1655AC_CHECK_TYPE(int32_t,
1656 AC_DEFINE(HAVE_INT32_T, 1, [Define if your compiler provides int32_t.]),,)
1657AC_TYPE_INT32_T
1658
1659AC_CHECK_TYPE(int64_t,
1660 AC_DEFINE(HAVE_INT64_T, 1, [Define if your compiler provides int64_t.]),,)
1661AC_TYPE_INT64_T
1662
1663AC_CHECK_TYPE(ssize_t,
1664 AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
1665
1666# Sizes of various common basic types
1667# ANSI C requires sizeof(char) == 1, so no need to check it
1668AC_CHECK_SIZEOF(int, 4)
1669AC_CHECK_SIZEOF(long, 4)
1670AC_CHECK_SIZEOF(void *, 4)
1671AC_CHECK_SIZEOF(short, 2)
1672AC_CHECK_SIZEOF(float, 4)
1673AC_CHECK_SIZEOF(double, 8)
1674AC_CHECK_SIZEOF(fpos_t, 4)
1675AC_CHECK_SIZEOF(size_t, 4)
1676AC_CHECK_SIZEOF(pid_t, 4)
1677
1678AC_MSG_CHECKING(for long long support)
1679have_long_long=no
1680AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
1681 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1682 have_long_long=yes
1683],[])
1684AC_MSG_RESULT($have_long_long)
1685if test "$have_long_long" = yes ; then
1686AC_CHECK_SIZEOF(long long, 8)
1687fi
1688
1689AC_MSG_CHECKING(for long double support)
1690have_long_double=no
1691AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
1692 AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1693 have_long_double=yes
1694],[])
1695AC_MSG_RESULT($have_long_double)
1696if test "$have_long_double" = yes ; then
1697AC_CHECK_SIZEOF(long double, 12)
1698fi
1699
1700AC_MSG_CHECKING(for _Bool support)
1701have_c99_bool=no
1702AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
1703 AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
1704 have_c99_bool=yes
1705],[])
1706AC_MSG_RESULT($have_c99_bool)
1707if test "$have_c99_bool" = yes ; then
1708AC_CHECK_SIZEOF(_Bool, 1)
1709fi
1710
1711AC_CHECK_TYPES(uintptr_t,
1712 [AC_CHECK_SIZEOF(uintptr_t, 4)],
1713 [], [#ifdef HAVE_STDINT_H
1714 #include <stdint.h>
1715 #endif
1716 #ifdef HAVE_INTTYPES_H
1717 #include <inttypes.h>
1718 #endif])
1719
1720AC_CHECK_SIZEOF(off_t, [], [
1721#ifdef HAVE_SYS_TYPES_H
1722#include <sys/types.h>
1723#endif
1724])
1725
1726AC_MSG_CHECKING(whether to enable large file support)
1727if test "$have_long_long" = yes
1728then
1729if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1730 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1731 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1732 [Defined to enable large file support when an off_t is bigger than a long
1733 and long long is available and at least as big as an off_t. You may need
1734 to add some flags for configuration and compilation to enable this mode.
1735 (For Solaris and Linux, the necessary defines are already defined.)])
1736 AC_MSG_RESULT(yes)
1737else
1738 AC_MSG_RESULT(no)
1739fi
1740else
1741 AC_MSG_RESULT(no)
1742fi
1743
1744AC_CHECK_SIZEOF(time_t, [], [
1745#ifdef HAVE_SYS_TYPES_H
1746#include <sys/types.h>
1747#endif
1748#ifdef HAVE_TIME_H
1749#include <time.h>
1750#endif
1751])
1752
1753# if have pthread_t then define SIZEOF_PTHREAD_T
1754ac_save_cc="$CC"
1755if test "$ac_cv_kpthread" = "yes"
1756then CC="$CC -Kpthread"
1757elif test "$ac_cv_kthread" = "yes"
1758then CC="$CC -Kthread"
1759elif test "$ac_cv_pthread" = "yes"
1760then CC="$CC -pthread"
1761fi
1762AC_MSG_CHECKING(for pthread_t)
1763have_pthread_t=no
1764AC_COMPILE_IFELSE([
1765 AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1766],[have_pthread_t=yes],[])
1767AC_MSG_RESULT($have_pthread_t)
1768if test "$have_pthread_t" = yes ; then
1769 AC_CHECK_SIZEOF(pthread_t, [], [
1770#ifdef HAVE_PTHREAD_H
1771#include <pthread.h>
1772#endif
1773 ])
1774fi
1775CC="$ac_save_cc"
1776
1777AC_MSG_CHECKING(for --enable-toolbox-glue)
1778AC_ARG_ENABLE(toolbox-glue,
1779 AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
1780
1781if test -z "$enable_toolbox_glue"
1782then
1783 case $ac_sys_system/$ac_sys_release in
1784 Darwin/*)
1785 enable_toolbox_glue="yes";;
1786 *)
1787 enable_toolbox_glue="no";;
1788 esac
1789fi
1790case "$enable_toolbox_glue" in
1791yes)
1792 extra_machdep_objs="Python/mactoolboxglue.o"
1793 extra_undefs="-u _PyMac_Error"
1794 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1795 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1796 ;;
1797*)
1798 extra_machdep_objs=""
1799 extra_undefs=""
1800 ;;
1801esac
1802AC_MSG_RESULT($enable_toolbox_glue)
1803
1804
1805AC_SUBST(OTHER_LIBTOOL_OPT)
1806case $ac_sys_system/$ac_sys_release in
1807 Darwin/@<:@01567@:>@\..*)
1808 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1809 ;;
1810 Darwin/*)
1811 OTHER_LIBTOOL_OPT=""
1812 ;;
1813esac
1814
1815
1816AC_SUBST(LIBTOOL_CRUFT)
1817case $ac_sys_system/$ac_sys_release in
1818 Darwin/@<:@01567@:>@\..*)
1819 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1820 if test "${enable_universalsdk}"; then
1821 :
1822 else
1823 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
1824 fi
1825 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1826 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1827 Darwin/*)
1828 gcc_version=`gcc -dumpversion`
1829 if test ${gcc_version} '<' 4.0
1830 then
1831 LIBTOOL_CRUFT="-lcc_dynamic"
1832 else
1833 LIBTOOL_CRUFT=""
1834 fi
1835 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1836 #include <unistd.h>
1837 int main(int argc, char*argv[])
1838 {
1839 if (sizeof(long) == 4) {
1840 return 0;
1841 } else {
1842 return 1;
1843 }
1844 }
1845 ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
1846
1847 if test "${ac_osx_32bit}" = "yes"; then
1848 case `/usr/bin/arch` in
1849 i386)
1850 MACOSX_DEFAULT_ARCH="i386"
1851 ;;
1852 ppc)
1853 MACOSX_DEFAULT_ARCH="ppc"
1854 ;;
1855 *)
1856 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1857 ;;
1858 esac
1859 else
1860 case `/usr/bin/arch` in
1861 i386)
1862 MACOSX_DEFAULT_ARCH="x86_64"
1863 ;;
1864 ppc)
1865 MACOSX_DEFAULT_ARCH="ppc64"
1866 ;;
1867 *)
1868 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1869 ;;
1870 esac
1871
1872 #ARCH_RUN_32BIT="true"
1873 fi
1874
1875 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
1876 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1877 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1878esac
1879
1880AC_MSG_CHECKING(for --enable-framework)
1881if test "$enable_framework"
1882then
1883 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1884 # -F. is needed to allow linking to the framework while
1885 # in the build location.
1886 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1887 [Define if you want to produce an OpenStep/Rhapsody framework
1888 (shared library plus accessory files).])
1889 AC_MSG_RESULT(yes)
1890 if test $enable_shared = "yes"
1891 then
1892 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
1893 fi
1894else
1895 AC_MSG_RESULT(no)
1896fi
1897
1898AC_MSG_CHECKING(for dyld)
1899case $ac_sys_system/$ac_sys_release in
1900 Darwin/*)
1901 AC_DEFINE(WITH_DYLD, 1,
1902 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1903 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1904 linker (rld). Dyld is necessary to support frameworks.])
1905 AC_MSG_RESULT(always on for Darwin)
1906 ;;
1907 *)
1908 AC_MSG_RESULT(no)
1909 ;;
1910esac
1911
1912# Set info about shared libraries.
1913AC_SUBST(SO)
1914AC_SUBST(LDSHARED)
1915AC_SUBST(LDCXXSHARED)
1916AC_SUBST(BLDSHARED)
1917AC_SUBST(CCSHARED)
1918AC_SUBST(LINKFORSHARED)
1919# SO is the extension of shared libraries `(including the dot!)
1920# -- usually .so, .sl on HP-UX, .dll on Cygwin and OS/2
1921AC_MSG_CHECKING(SO)
1922if test -z "$SO"
1923then
1924 case $ac_sys_system in
1925 hp*|HP*)
1926 case `uname -m` in
1927 ia64) SO=.so;;
1928 *) SO=.sl;;
1929 esac
1930 ;;
1931 CYGWIN*) SO=.dll;;
1932 OS/2*|os2*|*emx*) SO=.dll;;
1933 *) SO=.so;;
1934 esac
1935else
1936 # this might also be a termcap variable, see #610332
1937 echo
1938 echo '====================================================================='
1939 echo '+ +'
1940 echo '+ WARNING: You have set SO in your environment. +'
1941 echo '+ Do you really mean to change the extension for shared libraries? +'
1942 echo '+ Continuing in 10 seconds to let you to ponder. +'
1943 echo '+ +'
1944 echo '====================================================================='
1945 sleep 10
1946fi
1947AC_MSG_RESULT($SO)
1948
1949AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
1950# LDSHARED is the ld *command* used to create shared library
1951# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1952# (Shared libraries in this instance are shared modules to be loaded into
1953# Python, as opposed to building Python itself as a shared library.)
1954AC_MSG_CHECKING(LDSHARED)
1955if test -z "$LDSHARED"
1956then
1957 case $ac_sys_system/$ac_sys_release in
1958 AIX*)
1959 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:\$(srcdir)/Modules/python.exp"
1960 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1961 ;;
1962 BeOS*)
1963 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1964 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1965 ;;
1966 IRIX/5*) LDSHARED="ld -shared";;
1967 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1968 SunOS/5*)
1969 if test "$GCC" = "yes" ; then
1970 LDSHARED='$(CC) -shared'
1971 LDCXXSHARED='$(CXX) -shared'
1972 else
1973 LDSHARED='$(CC) -G'
1974 LDCXXSHARED='$(CXX) -G'
1975 fi ;;
1976 hp*|HP*)
1977 if test "$GCC" = "yes" ; then
1978 LDSHARED='$(CC) -shared'
1979 LDCXXSHARED='$(CXX) -shared'
1980 else
1981 LDSHARED='ld -b'
1982 fi ;;
1983 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1984 Darwin/1.3*)
1985 LDSHARED='$(CC) -bundle'
1986 LDCXXSHARED='$(CXX) -bundle'
1987 if test "$enable_framework" ; then
1988 # Link against the framework. All externals should be defined.
1989 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1990 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1991 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1992 else
1993 # No framework. Ignore undefined symbols, assuming they come from Python
1994 LDSHARED="$LDSHARED -undefined suppress"
1995 LDCXXSHARED="$LDCXXSHARED -undefined suppress"
1996 fi ;;
1997 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1998 LDSHARED='$(CC) -bundle'
1999 LDCXXSHARED='$(CXX) -bundle'
2000 if test "$enable_framework" ; then
2001 # Link against the framework. All externals should be defined.
2002 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2003 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2004 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2005 else
2006 # No framework, use the Python app as bundle-loader
2007 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2008 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
2009 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
2010 fi ;;
2011 Darwin/*)
2012 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
2013 # This allows an extension to be used in any Python
2014
2015 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
2016 then
2017 if test "${enable_universalsdk}"; then
2018 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
2019 fi
2020 LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
2021 LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
2022 BLDSHARED="$LDSHARED"
2023 else
2024 LDSHARED='$(CC) -bundle'
2025 LDCXXSHARED='$(CXX) -bundle'
2026 if test "$enable_framework" ; then
2027 # Link against the framework. All externals should be defined.
2028 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2029 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2030 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2031 else
2032 # No framework, use the Python app as bundle-loader
2033 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
2034 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
2035 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
2036 fi
2037 fi
2038 ;;
2039 Linux*|GNU*|QNX*)
2040 LDSHARED='$(CC) -shared'
2041 LDCXXSHARED='$(CXX) -shared';;
2042 BSD/OS*/4*)
2043 LDSHARED="gcc -shared"
2044 LDCXXSHARED="g++ -shared";;
2045 FreeBSD*)
2046 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2047 then
2048 LDSHARED='$(CC) -shared'
2049 LDCXXSHARED='$(CXX) -shared'
2050 else
2051 LDSHARED="ld -Bshareable"
2052 fi;;
2053 OpenBSD*)
2054 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2055 then
2056 LDSHARED='$(CC) -shared $(CCSHARED)'
2057 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
2058 else
2059 case `uname -r` in
2060 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
2061 LDSHARED="ld -Bshareable ${LDFLAGS}"
2062 ;;
2063 *)
2064 LDSHARED='$(CC) -shared $(CCSHARED)'
2065 LDCXXSHARED='$(CXX) -shared $(CCSHARED)'
2066 ;;
2067 esac
2068 fi;;
2069 NetBSD*|DragonFly*)
2070 LDSHARED='$(CC) -shared'
2071 LDCXXSHARED='$(CXX) -shared';;
2072 OpenUNIX*|UnixWare*)
2073 if test "$GCC" = "yes" ; then
2074 LDSHARED='$(CC) -shared'
2075 LDCXXSHARED='$(CXX) -shared'
2076 else
2077 LDSHARED='$(CC) -G'
2078 LDCXXSHARED='$(CXX) -G'
2079 fi;;
2080 SCO_SV*)
2081 LDSHARED='$(CC) -Wl,-G,-Bexport'
2082 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
2083 CYGWIN*)
2084 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
2085 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
2086 atheos*)
2087 LDSHARED="gcc -shared"
2088 LDCXXSHARED="g++ -shared";;
2089 OS/2*|os2*|*emx*)
2090 LDSHARED='$(CC) -Zdll'
2091 LDCXXSHARED='$(CXX) -Zdll';;
2092 *) LDSHARED="ld";;
2093 esac
2094fi
2095AC_MSG_RESULT($LDSHARED)
2096LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
2097BLDSHARED=${BLDSHARED-$LDSHARED}
2098# CCSHARED are the C *flags* used to create objects to go into a shared
2099# library (module) -- this is only needed for a few systems
2100AC_MSG_CHECKING(CCSHARED)
2101if test -z "$CCSHARED"
2102then
2103 case $ac_sys_system/$ac_sys_release in
2104 SunOS*) if test "$GCC" = yes;
2105 then CCSHARED="-fPIC";
2106 elif test `uname -p` = sparc;
2107 then CCSHARED="-xcode=pic32";
2108 else CCSHARED="-Kpic";
2109 fi;;
2110 hp*|HP*) if test "$GCC" = yes;
2111 then CCSHARED="-fPIC";
2112 else CCSHARED="+z";
2113 fi;;
2114 Linux*|GNU*) CCSHARED="-fPIC";;
2115 BSD/OS*/4*) CCSHARED="-fpic";;
2116 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
2117 OpenUNIX*|UnixWare*)
2118 if test "$GCC" = "yes"
2119 then CCSHARED="-fPIC"
2120 else CCSHARED="-KPIC"
2121 fi;;
2122 SCO_SV*)
2123 if test "$GCC" = "yes"
2124 then CCSHARED="-fPIC"
2125 else CCSHARED="-Kpic -belf"
2126 fi;;
2127 IRIX*/6*) case $CC in
2128 *gcc*) CCSHARED="-shared";;
2129 *) CCSHARED="";;
2130 esac;;
2131 atheos*) CCSHARED="-fPIC";;
2132 esac
2133fi
2134AC_MSG_RESULT($CCSHARED)
2135# LINKFORSHARED are the flags passed to the $(CC) command that links
2136# the python executable -- this is only needed for a few systems
2137AC_MSG_CHECKING(LINKFORSHARED)
2138if test -z "$LINKFORSHARED"
2139then
2140 case $ac_sys_system/$ac_sys_release in
2141 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
2142 hp*|HP*)
2143 LINKFORSHARED="-Wl,-E -Wl,+s";;
2144# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
2145 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
2146 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
2147 # -u libsys_s pulls in all symbols in libsys
2148 Darwin/*)
2149 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
2150 # which is
2151 # not used by the core itself but which needs to be in the core so
2152 # that dynamically loaded extension modules have access to it.
2153 # -prebind is no longer used, because it actually seems to give a
2154 # slowdown in stead of a speedup, maybe due to the large number of
2155 # dynamic loads Python does.
2156
2157 LINKFORSHARED="$extra_undefs"
2158 if test "$enable_framework"
2159 then
2160 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
2161 fi
2162 LINKFORSHARED="$LINKFORSHARED";;
2163 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
2164 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
2165 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
2166 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
2167 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
2168 then
2169 LINKFORSHARED="-Wl,--export-dynamic"
2170 fi;;
2171 SunOS/5*) case $CC in
2172 *gcc*)
2173 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
2174 then
2175 LINKFORSHARED="-Xlinker --export-dynamic"
2176 fi;;
2177 esac;;
2178 CYGWIN*)
2179 if test $enable_shared = "no"
2180 then
2181 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
2182 fi;;
2183 QNX*)
2184 # -Wl,-E causes the symbols to be added to the dynamic
2185 # symbol table so that they can be found when a module
2186 # is loaded. -N 2048K causes the stack size to be set
2187 # to 2048 kilobytes so that the stack doesn't overflow
2188 # when running test_compile.py.
2189 LINKFORSHARED='-Wl,-E -N 2048K';;
2190 esac
2191fi
2192AC_MSG_RESULT($LINKFORSHARED)
2193
2194
2195AC_SUBST(CFLAGSFORSHARED)
2196AC_MSG_CHECKING(CFLAGSFORSHARED)
2197if test ! "$LIBRARY" = "$LDLIBRARY"
2198then
2199 case $ac_sys_system in
2200 CYGWIN*)
2201 # Cygwin needs CCSHARED when building extension DLLs
2202 # but not when building the interpreter DLL.
2203 CFLAGSFORSHARED='';;
2204 *)
2205 CFLAGSFORSHARED='$(CCSHARED)'
2206 esac
2207fi
2208AC_MSG_RESULT($CFLAGSFORSHARED)
2209
2210# SHLIBS are libraries (except -lc and -lm) to link to the python shared
2211# library (with --enable-shared).
2212# For platforms on which shared libraries are not allowed to have unresolved
2213# symbols, this must be set to $(LIBS) (expanded by make). We do this even
2214# if it is not required, since it creates a dependency of the shared library
2215# to LIBS. This, in turn, means that applications linking the shared libpython
2216# don't need to link LIBS explicitly. The default should be only changed
2217# on systems where this approach causes problems.
2218AC_SUBST(SHLIBS)
2219AC_MSG_CHECKING(SHLIBS)
2220case "$ac_sys_system" in
2221 *)
2222 SHLIBS='$(LIBS)';;
2223esac
2224AC_MSG_RESULT($SHLIBS)
2225
2226
2227# checks for libraries
2228AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
2229AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
2230
2231# only check for sem_init if thread support is requested
2232if test "$with_threads" = "yes" -o -z "$with_threads"; then
2233 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2234 # posix4 on Solaris 2.6
2235 # pthread (first!) on Linux
2236fi
2237
2238# check if we need libintl for locale functions
2239AC_CHECK_LIB(intl, textdomain,
2240 AC_DEFINE(WITH_LIBINTL, 1,
2241 [Define to 1 if libintl is needed for locale functions.]))
2242
2243# checks for system dependent C++ extensions support
2244case "$ac_sys_system" in
2245 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
2246 AC_LINK_IFELSE([
2247 AC_LANG_PROGRAM([[#include <load.h>]],
2248 [[loadAndInit("", 0, "")]])
2249 ],[
2250 AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
2251 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2252 and you want support for AIX C++ shared extension modules.])
2253 AC_MSG_RESULT(yes)
2254 ],[
2255 AC_MSG_RESULT(no)
2256 ]);;
2257 *) ;;
2258esac
2259
2260# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
2261# BeOS' sockets are stashed in libnet.
2262AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
2263AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
2264
2265case "$ac_sys_system" in
2266BeOS*)
2267AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2268;;
2269esac
2270
2271AC_MSG_CHECKING(for --with-libs)
2272AC_ARG_WITH(libs,
2273 AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
2274[
2275AC_MSG_RESULT($withval)
2276LIBS="$withval $LIBS"
2277],
2278[AC_MSG_RESULT(no)])
2279
2280AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2281
2282# Check for use of the system expat library
2283AC_MSG_CHECKING(for --with-system-expat)
2284AC_ARG_WITH(system_expat,
2285 AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]),
2286 [],
2287 [with_system_expat="no"])
2288
2289AC_MSG_RESULT($with_system_expat)
2290
2291# Check for use of the system libffi library
2292AC_MSG_CHECKING(for --with-system-ffi)
2293AC_ARG_WITH(system_ffi,
2294 AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]),
2295 [],
2296 [with_system_ffi="no"])
2297
2298if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
2299 LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2300else
2301 LIBFFI_INCLUDEDIR=""
2302fi
2303AC_SUBST(LIBFFI_INCLUDEDIR)
2304
2305AC_MSG_RESULT($with_system_ffi)
2306
2307# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
2308AC_SUBST(TCLTK_INCLUDES)
2309AC_SUBST(TCLTK_LIBS)
2310AC_MSG_CHECKING(for --with-tcltk-includes)
2311AC_ARG_WITH(tcltk-includes,
2312 AS_HELP_STRING([--with-tcltk-includes='-I...'], [override search for Tcl and Tk include files]),
2313 [],
2314 [with_tcltk_includes="default"])
2315AC_MSG_RESULT($with_tcltk_includes)
2316AC_MSG_CHECKING(for --with-tcltk-libs)
2317AC_ARG_WITH(tcltk-libs,
2318 AS_HELP_STRING([--with-tcltk-libs='-L...'], [override search for Tcl and Tk libs]),
2319 [],
2320 [with_tcltk_libs="default"])
2321AC_MSG_RESULT($with_tcltk_libs)
2322if test "x$with_tcltk_includes" = xdefault || test "x$with_tcltk_libs" = xdefault
2323then
2324 if test "x$with_tcltk_includes" != "x$with_tcltk_libs"
2325 then
2326 AC_MSG_ERROR([use both --with-tcltk-includes='...' and --with-tcltk-libs='...' or neither])
2327 fi
2328 TCLTK_INCLUDES=""
2329 TCLTK_LIBS=""
2330else
2331 TCLTK_INCLUDES="$with_tcltk_includes"
2332 TCLTK_LIBS="$with_tcltk_libs"
2333fi
2334
2335# Check for --with-dbmliborder
2336AC_MSG_CHECKING(for --with-dbmliborder)
2337AC_ARG_WITH(dbmliborder,
2338 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'.]),
2339[
2340if test x$with_dbmliborder = xyes
2341then
2342AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2343else
2344 for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2345 if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2346 then
2347 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2348 fi
2349 done
2350fi])
2351AC_MSG_RESULT($with_dbmliborder)
2352
2353# Determine if signalmodule should be used.
2354AC_SUBST(USE_SIGNAL_MODULE)
2355AC_SUBST(SIGNAL_OBJS)
2356AC_MSG_CHECKING(for --with-signal-module)
2357AC_ARG_WITH(signal-module,
2358 AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
2359
2360if test -z "$with_signal_module"
2361then with_signal_module="yes"
2362fi
2363AC_MSG_RESULT($with_signal_module)
2364
2365if test "${with_signal_module}" = "yes"; then
2366 USE_SIGNAL_MODULE=""
2367 SIGNAL_OBJS=""
2368else
2369 USE_SIGNAL_MODULE="#"
2370 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2371fi
2372
2373# This is used to generate Setup.config
2374AC_SUBST(USE_THREAD_MODULE)
2375USE_THREAD_MODULE=""
2376
2377AC_MSG_CHECKING(for --with-dec-threads)
2378AC_SUBST(LDLAST)
2379AC_ARG_WITH(dec-threads,
2380 AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
2381[
2382AC_MSG_RESULT($withval)
2383LDLAST=-threads
2384if test "${with_thread+set}" != set; then
2385 with_thread="$withval";
2386fi],
2387[AC_MSG_RESULT(no)])
2388
2389# Templates for things AC_DEFINEd more than once.
2390# For a single AC_DEFINE, no template is needed.
2391AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2392AH_TEMPLATE(_REENTRANT,
2393 [Define to force use of thread-safe errno, h_errno, and other functions])
2394AH_TEMPLATE(WITH_THREAD,
2395 [Define if you want to compile in rudimentary thread support])
2396
2397AC_MSG_CHECKING(for --with-threads)
2398dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2399AC_ARG_WITH(threads,
2400 AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
2401
2402# --with-thread is deprecated, but check for it anyway
2403dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2404AC_ARG_WITH(thread,
2405 AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
2406 [with_threads=$with_thread])
2407
2408if test -z "$with_threads"
2409then with_threads="yes"
2410fi
2411AC_MSG_RESULT($with_threads)
2412
2413AC_SUBST(THREADOBJ)
2414if test "$with_threads" = "no"
2415then
2416 USE_THREAD_MODULE="#"
2417elif test "$ac_cv_pthread_is_default" = yes
2418then
2419 AC_DEFINE(WITH_THREAD)
2420 # Defining _REENTRANT on system with POSIX threads should not hurt.
2421 AC_DEFINE(_REENTRANT)
2422 posix_threads=yes
2423 THREADOBJ="Python/thread.o"
2424elif test "$ac_cv_kpthread" = "yes"
2425then
2426 CC="$CC -Kpthread"
2427 if test "$ac_cv_cxx_thread" = "yes"; then
2428 CXX="$CXX -Kpthread"
2429 fi
2430 AC_DEFINE(WITH_THREAD)
2431 posix_threads=yes
2432 THREADOBJ="Python/thread.o"
2433elif test "$ac_cv_kthread" = "yes"
2434then
2435 CC="$CC -Kthread"
2436 if test "$ac_cv_cxx_thread" = "yes"; then
2437 CXX="$CXX -Kthread"
2438 fi
2439 AC_DEFINE(WITH_THREAD)
2440 posix_threads=yes
2441 THREADOBJ="Python/thread.o"
2442elif test "$ac_cv_pthread" = "yes"
2443then
2444 CC="$CC -pthread"
2445 if test "$ac_cv_cxx_thread" = "yes"; then
2446 CXX="$CXX -pthread"
2447 fi
2448 AC_DEFINE(WITH_THREAD)
2449 posix_threads=yes
2450 THREADOBJ="Python/thread.o"
2451else
2452 if test ! -z "$with_threads" -a -d "$with_threads"
2453 then LDFLAGS="$LDFLAGS -L$with_threads"
2454 fi
2455 if test ! -z "$withval" -a -d "$withval"
2456 then LDFLAGS="$LDFLAGS -L$withval"
2457 fi
2458
2459 # According to the POSIX spec, a pthreads implementation must
2460 # define _POSIX_THREADS in unistd.h. Some apparently don't
2461 # (e.g. gnu pth with pthread emulation)
2462 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2463 AC_EGREP_CPP(yes,
2464 [
2465#include <unistd.h>
2466#ifdef _POSIX_THREADS
2467yes
2468#endif
2469 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2470 AC_MSG_RESULT($unistd_defines_pthreads)
2471
2472 AC_DEFINE(_REENTRANT)
2473 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2474 AC_DEFINE(C_THREADS)
2475 AC_DEFINE(HURD_C_THREADS, 1,
2476 [Define if you are using Mach cthreads directly under /include])
2477 LIBS="$LIBS -lthreads"
2478 THREADOBJ="Python/thread.o"],[
2479 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2480 AC_DEFINE(C_THREADS)
2481 AC_DEFINE(MACH_C_THREADS, 1,
2482 [Define if you are using Mach cthreads under mach /])
2483 THREADOBJ="Python/thread.o"],[
2484 AC_MSG_CHECKING(for --with-pth)
2485 AC_ARG_WITH([pth],
2486 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
2487 [AC_MSG_RESULT($withval)
2488 AC_DEFINE([WITH_THREAD])
2489 AC_DEFINE([HAVE_PTH], 1,
2490 [Define if you have GNU PTH threads.])
2491 LIBS="-lpth $LIBS"
2492 THREADOBJ="Python/thread.o"],
2493 [AC_MSG_RESULT(no)
2494
2495 # Just looking for pthread_create in libpthread is not enough:
2496 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2497 # So we really have to include pthread.h, and then link.
2498 _libs=$LIBS
2499 LIBS="$LIBS -lpthread"
2500 AC_MSG_CHECKING([for pthread_create in -lpthread])
2501 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2502#include <stdio.h>
2503#include <pthread.h>
2504
2505void * start_routine (void *arg) { exit (0); }]], [[
2506pthread_create (NULL, NULL, start_routine, NULL)]])],[
2507 AC_MSG_RESULT(yes)
2508 AC_DEFINE(WITH_THREAD)
2509 posix_threads=yes
2510 THREADOBJ="Python/thread.o"],[
2511 LIBS=$_libs
2512 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
2513 posix_threads=yes
2514 THREADOBJ="Python/thread.o"],[
2515 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2516 AC_DEFINE(ATHEOS_THREADS, 1,
2517 [Define this if you have AtheOS threads.])
2518 THREADOBJ="Python/thread.o"],[
2519 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
2520 AC_DEFINE(BEOS_THREADS, 1,
2521 [Define this if you have BeOS threads.])
2522 THREADOBJ="Python/thread.o"],[
2523 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
2524 posix_threads=yes
2525 LIBS="$LIBS -lpthreads"
2526 THREADOBJ="Python/thread.o"], [
2527 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
2528 posix_threads=yes
2529 LIBS="$LIBS -lc_r"
2530 THREADOBJ="Python/thread.o"], [
2531 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
2532 posix_threads=yes
2533 LIBS="$LIBS -lpthread"
2534 THREADOBJ="Python/thread.o"], [
2535 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
2536 posix_threads=yes
2537 LIBS="$LIBS -lcma"
2538 THREADOBJ="Python/thread.o"],[
2539 USE_THREAD_MODULE="#"])
2540 ])])])])])])])])])])
2541
2542 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2543 LIBS="$LIBS -lmpc"
2544 THREADOBJ="Python/thread.o"
2545 USE_THREAD_MODULE=""])
2546
2547 if test "$posix_threads" != "yes"; then
2548 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2549 LIBS="$LIBS -lthread"
2550 THREADOBJ="Python/thread.o"
2551 USE_THREAD_MODULE=""])
2552 fi
2553
2554 if test "$USE_THREAD_MODULE" != "#"
2555 then
2556 # If the above checks didn't disable threads, (at least) OSF1
2557 # needs this '-threads' argument during linking.
2558 case $ac_sys_system in
2559 OSF1) LDLAST=-threads;;
2560 esac
2561 fi
2562fi
2563
2564if test "$posix_threads" = "yes"; then
2565 if test "$unistd_defines_pthreads" = "no"; then
2566 AC_DEFINE(_POSIX_THREADS, 1,
2567 [Define if you have POSIX threads,
2568 and your system does not define that.])
2569 fi
2570
2571 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2572 case $ac_sys_system/$ac_sys_release in
2573 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2574 [Defined for Solaris 2.6 bug in pthread header.])
2575 ;;
2576 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2577 [Define if the Posix semaphores do not work on your system])
2578 ;;
2579 AIX/*) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2580 [Define if the Posix semaphores do not work on your system])
2581 ;;
2582 esac
2583
2584 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2585 AC_CACHE_VAL(ac_cv_pthread_system_supported,
2586 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
2587 #include <stdio.h>
2588 #include <pthread.h>
2589 void *foo(void *parm) {
2590 return NULL;
2591 }
2592 main() {
2593 pthread_attr_t attr;
2594 pthread_t id;
2595 if (pthread_attr_init(&attr)) exit(-1);
2596 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
2597 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
2598 exit(0);
2599 }]])],
2600 [ac_cv_pthread_system_supported=yes],
2601 [ac_cv_pthread_system_supported=no],
2602 [ac_cv_pthread_system_supported=no])
2603 ])
2604 AC_MSG_RESULT($ac_cv_pthread_system_supported)
2605 if test "$ac_cv_pthread_system_supported" = "yes"; then
2606 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
2607 fi
2608 AC_CHECK_FUNCS(pthread_sigmask,
2609 [case $ac_sys_system in
2610 CYGWIN*)
2611 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2612 [Define if pthread_sigmask() does not work on your system.])
2613 ;;
2614 esac])
2615 AC_CHECK_FUNCS(pthread_atfork)
2616fi
2617
2618
2619# Check for enable-ipv6
2620AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
2621AC_MSG_CHECKING([if --enable-ipv6 is specified])
2622AC_ARG_ENABLE(ipv6,
2623[ --enable-ipv6 Enable ipv6 (with ipv4) support
2624 --disable-ipv6 Disable ipv6 support],
2625[ case "$enableval" in
2626 no)
2627 AC_MSG_RESULT(no)
2628 ipv6=no
2629 ;;
2630 *) AC_MSG_RESULT(yes)
2631 AC_DEFINE(ENABLE_IPV6)
2632 ipv6=yes
2633 ;;
2634 esac ],
2635
2636[
2637dnl the check does not work on cross compilation case...
2638 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* AF_INET6 available check */
2639#include <sys/types.h>
2640#include <sys/socket.h>]],
2641[[int domain = AF_INET6;]])],[
2642 AC_MSG_RESULT(yes)
2643 ipv6=yes
2644],[
2645 AC_MSG_RESULT(no)
2646 ipv6=no
2647])
2648
2649if test "$ipv6" = "yes"; then
2650 AC_MSG_CHECKING(if RFC2553 API is available)
2651 AC_COMPILE_IFELSE([
2652 AC_LANG_PROGRAM([[#include <sys/types.h>
2653#include <netinet/in.h>]],
2654 [[struct sockaddr_in6 x;
2655 x.sin6_scope_id;]])
2656 ],[
2657 AC_MSG_RESULT(yes)
2658 ipv6=yes
2659 ],[
2660 AC_MSG_RESULT(no, IPv6 disabled)
2661 ipv6=no
2662 ])
2663fi
2664
2665if test "$ipv6" = "yes"; then
2666 AC_DEFINE(ENABLE_IPV6)
2667fi
2668])
2669
2670ipv6type=unknown
2671ipv6lib=none
2672ipv6trylibc=no
2673
2674if test "$ipv6" = "yes"; then
2675 AC_MSG_CHECKING([ipv6 stack type])
2676 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2677 do
2678 case $i in
2679 inria)
2680 dnl http://www.kame.net/
2681 AC_EGREP_CPP(yes, [
2682#include <netinet/in.h>
2683#ifdef IPV6_INRIA_VERSION
2684yes
2685#endif],
2686 [ipv6type=$i])
2687 ;;
2688 kame)
2689 dnl http://www.kame.net/
2690 AC_EGREP_CPP(yes, [
2691#include <netinet/in.h>
2692#ifdef __KAME__
2693yes
2694#endif],
2695 [ipv6type=$i;
2696 ipv6lib=inet6
2697 ipv6libdir=/usr/local/v6/lib
2698 ipv6trylibc=yes])
2699 ;;
2700 linux-glibc)
2701 dnl http://www.v6.linux.or.jp/
2702 AC_EGREP_CPP(yes, [
2703#include <features.h>
2704#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2705yes
2706#endif],
2707 [ipv6type=$i;
2708 ipv6trylibc=yes])
2709 ;;
2710 linux-inet6)
2711 dnl http://www.v6.linux.or.jp/
2712 if test -d /usr/inet6; then
2713 ipv6type=$i
2714 ipv6lib=inet6
2715 ipv6libdir=/usr/inet6/lib
2716 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
2717 fi
2718 ;;
2719 solaris)
2720 if test -f /etc/netconfig; then
2721 if $GREP -q tcp6 /etc/netconfig; then
2722 ipv6type=$i
2723 ipv6trylibc=yes
2724 fi
2725 fi
2726 ;;
2727 toshiba)
2728 AC_EGREP_CPP(yes, [
2729#include <sys/param.h>
2730#ifdef _TOSHIBA_INET6
2731yes
2732#endif],
2733 [ipv6type=$i;
2734 ipv6lib=inet6;
2735 ipv6libdir=/usr/local/v6/lib])
2736 ;;
2737 v6d)
2738 AC_EGREP_CPP(yes, [
2739#include </usr/local/v6/include/sys/v6config.h>
2740#ifdef __V6D__
2741yes
2742#endif],
2743 [ipv6type=$i;
2744 ipv6lib=v6;
2745 ipv6libdir=/usr/local/v6/lib;
2746 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
2747 ;;
2748 zeta)
2749 AC_EGREP_CPP(yes, [
2750#include <sys/param.h>
2751#ifdef _ZETA_MINAMI_INET6
2752yes
2753#endif],
2754 [ipv6type=$i;
2755 ipv6lib=inet6;
2756 ipv6libdir=/usr/local/v6/lib])
2757 ;;
2758 esac
2759 if test "$ipv6type" != "unknown"; then
2760 break
2761 fi
2762 done
2763 AC_MSG_RESULT($ipv6type)
2764fi
2765
2766if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2767 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2768 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2769 echo "using lib$ipv6lib"
2770 else
2771 if test $ipv6trylibc = "yes"; then
2772 echo "using libc"
2773 else
2774 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2775 echo "You need to fetch lib$ipv6lib.a from appropriate"
2776 echo 'ipv6 kit and compile beforehand.'
2777 exit 1
2778 fi
2779 fi
2780fi
2781
2782AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2783AC_COMPILE_IFELSE([
2784 AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
2785],[
2786 AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
2787 AC_MSG_RESULT(yes)
2788],[
2789 AC_MSG_RESULT(no)
2790])
2791
2792# Check for --with-doc-strings
2793AC_MSG_CHECKING(for --with-doc-strings)
2794AC_ARG_WITH(doc-strings,
2795 AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
2796
2797if test -z "$with_doc_strings"
2798then with_doc_strings="yes"
2799fi
2800if test "$with_doc_strings" != "no"
2801then
2802 AC_DEFINE(WITH_DOC_STRINGS, 1,
2803 [Define if you want documentation strings in extension modules])
2804fi
2805AC_MSG_RESULT($with_doc_strings)
2806
2807# Check for Python-specific malloc support
2808AC_MSG_CHECKING(for --with-tsc)
2809AC_ARG_WITH(tsc,
2810 AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
2811if test "$withval" != no
2812then
2813 AC_DEFINE(WITH_TSC, 1,
2814 [Define to profile with the Pentium timestamp counter])
2815 AC_MSG_RESULT(yes)
2816else AC_MSG_RESULT(no)
2817fi],
2818[AC_MSG_RESULT(no)])
2819
2820# Check for Python-specific malloc support
2821AC_MSG_CHECKING(for --with-pymalloc)
2822AC_ARG_WITH(pymalloc,
2823 AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
2824
2825if test -z "$with_pymalloc"
2826then with_pymalloc="yes"
2827fi
2828if test "$with_pymalloc" != "no"
2829then
2830 AC_DEFINE(WITH_PYMALLOC, 1,
2831 [Define if you want to compile in Python-specific mallocs])
2832fi
2833AC_MSG_RESULT($with_pymalloc)
2834
2835# Check for Valgrind support
2836AC_MSG_CHECKING([for --with-valgrind])
2837AC_ARG_WITH([valgrind],
2838 AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2839 with_valgrind=no)
2840AC_MSG_RESULT([$with_valgrind])
2841if test "$with_valgrind" != no; then
2842 AC_CHECK_HEADER([valgrind/valgrind.h],
2843 [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2844 [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2845 )
2846fi
2847
2848# Check for --with-wctype-functions
2849AC_MSG_CHECKING(for --with-wctype-functions)
2850AC_ARG_WITH(wctype-functions,
2851 AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
2852[
2853if test "$withval" != no
2854then
2855 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2856 [Define if you want wctype.h functions to be used instead of the
2857 one supplied by Python itself. (see Include/unicodectype.h).])
2858 AC_MSG_RESULT(yes)
2859else AC_MSG_RESULT(no)
2860fi],
2861[AC_MSG_RESULT(no)])
2862
2863# -I${DLINCLDIR} is added to the compile rule for importdl.o
2864AC_SUBST(DLINCLDIR)
2865DLINCLDIR=.
2866
2867# the dlopen() function means we might want to use dynload_shlib.o. some
2868# platforms, such as AIX, have dlopen(), but don't want to use it.
2869AC_CHECK_FUNCS(dlopen)
2870
2871# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2872# loading of modules.
2873AC_SUBST(DYNLOADFILE)
2874AC_MSG_CHECKING(DYNLOADFILE)
2875if test -z "$DYNLOADFILE"
2876then
2877 case $ac_sys_system/$ac_sys_release in
2878 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2879 if test "$ac_cv_func_dlopen" = yes
2880 then DYNLOADFILE="dynload_shlib.o"
2881 else DYNLOADFILE="dynload_aix.o"
2882 fi
2883 ;;
2884 BeOS*) DYNLOADFILE="dynload_beos.o";;
2885 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2886 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2887 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
2888 atheos*) DYNLOADFILE="dynload_atheos.o";;
2889 *)
2890 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2891 # out any dynamic loading
2892 if test "$ac_cv_func_dlopen" = yes
2893 then DYNLOADFILE="dynload_shlib.o"
2894 else DYNLOADFILE="dynload_stub.o"
2895 fi
2896 ;;
2897 esac
2898fi
2899AC_MSG_RESULT($DYNLOADFILE)
2900if test "$DYNLOADFILE" != "dynload_stub.o"
2901then
2902 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2903 [Defined when any dynamic module loading is enabled.])
2904fi
2905
2906# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2907
2908AC_SUBST(MACHDEP_OBJS)
2909AC_MSG_CHECKING(MACHDEP_OBJS)
2910if test -z "$MACHDEP_OBJS"
2911then
2912 MACHDEP_OBJS=$extra_machdep_objs
2913else
2914 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2915fi
2916AC_MSG_RESULT(MACHDEP_OBJS)
2917
2918# checks for library functions
2919AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2920 clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
2921 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2922 getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
2923 initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
2924 mremap nice pathconf pause plock poll pthread_init \
2925 putenv readlink realpath \
2926 select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2927 setgid \
2928 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2929 setlocale setregid setreuid setresuid setresgid \
2930 setsid setpgid setpgrp setuid setvbuf snprintf \
2931 sigaction siginterrupt sigrelse strftime \
2932 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2933 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
2934
2935# For some functions, having a definition is not sufficient, since
2936# we want to take their address.
2937AC_MSG_CHECKING(for chroot)
2938AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2939 [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2940 AC_MSG_RESULT(yes)],
2941 [AC_MSG_RESULT(no)
2942])
2943AC_MSG_CHECKING(for link)
2944AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2945 [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2946 AC_MSG_RESULT(yes)],
2947 [AC_MSG_RESULT(no)
2948])
2949AC_MSG_CHECKING(for symlink)
2950AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2951 [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2952 AC_MSG_RESULT(yes)],
2953 [AC_MSG_RESULT(no)
2954])
2955AC_MSG_CHECKING(for fchdir)
2956AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2957 [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2958 AC_MSG_RESULT(yes)],
2959 [AC_MSG_RESULT(no)
2960])
2961AC_MSG_CHECKING(for fsync)
2962AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2963 [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2964 AC_MSG_RESULT(yes)],
2965 [AC_MSG_RESULT(no)
2966])
2967AC_MSG_CHECKING(for fdatasync)
2968AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2969 [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2970 AC_MSG_RESULT(yes)],
2971 [AC_MSG_RESULT(no)
2972])
2973AC_MSG_CHECKING(for epoll)
2974AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2975 [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2976 AC_MSG_RESULT(yes)],
2977 [AC_MSG_RESULT(no)
2978])
2979AC_MSG_CHECKING(for kqueue)
2980AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2981#include <sys/types.h>
2982#include <sys/event.h>
2983 ]], [[int x=kqueue()]])],
2984 [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2985 AC_MSG_RESULT(yes)],
2986 [AC_MSG_RESULT(no)
2987])
2988# On some systems (eg. FreeBSD 5), we would find a definition of the
2989# functions ctermid_r, setgroups in the library, but no prototype
2990# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2991# address to avoid compiler warnings and potential miscompilations
2992# because of the missing prototypes.
2993
2994AC_MSG_CHECKING(for ctermid_r)
2995AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2996#include <stdio.h>
2997]], [[void* p = ctermid_r]])],
2998 [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2999 AC_MSG_RESULT(yes)],
3000 [AC_MSG_RESULT(no)
3001])
3002
3003AC_CACHE_CHECK([for flock declaration], [ac_cv_flock_decl],
3004 [AC_COMPILE_IFELSE(
3005 [AC_LANG_PROGRAM(
3006 [#include <sys/file.h>],
3007 [void* p = flock]
3008 )],
3009 [ac_cv_flock_decl=yes],
3010 [ac_cv_flock_decl=no]
3011 )
3012])
3013if test "x${ac_cv_flock_decl}" = xyes; then
3014 AC_CHECK_FUNCS(flock,,
3015 AC_CHECK_LIB(bsd,flock,
3016 [AC_DEFINE(HAVE_FLOCK)
3017 AC_DEFINE(FLOCK_NEEDS_LIBBSD, 1, Define if flock needs to be linked with bsd library.)
3018 ])
3019 )
3020fi
3021
3022AC_MSG_CHECKING(for getpagesize)
3023AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3024#include <unistd.h>
3025]], [[void* p = getpagesize]])],
3026 [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
3027 AC_MSG_RESULT(yes)],
3028 [AC_MSG_RESULT(no)
3029])
3030
3031AC_MSG_CHECKING(for broken unsetenv)
3032AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3033#include <stdlib.h>
3034]], [[int res = unsetenv("DUMMY")]])],
3035 [AC_MSG_RESULT(no)],
3036 [AC_DEFINE(HAVE_BROKEN_UNSETENV, 1, Define if `unsetenv` does not return an int.)
3037 AC_MSG_RESULT(yes)
3038])
3039
3040dnl check for true
3041AC_CHECK_PROGS(TRUE, true, /bin/true)
3042
3043dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
3044dnl On others, they are in the C library, so we to take no action
3045AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
3046 AC_CHECK_LIB(resolv, inet_aton)
3047)
3048
3049# On Tru64, chflags seems to be present, but calling it will
3050# exit Python
3051AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
3052AC_RUN_IFELSE([AC_LANG_SOURCE([[
3053#include <sys/stat.h>
3054#include <unistd.h>
3055int main(int argc, char*argv[])
3056{
3057 if(chflags(argv[0], 0) != 0)
3058 return 1;
3059 return 0;
3060}
3061]])],
3062[ac_cv_have_chflags=yes],
3063[ac_cv_have_chflags=no],
3064[ac_cv_have_chflags=cross])
3065])
3066if test "$ac_cv_have_chflags" = cross ; then
3067 AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
3068fi
3069if test "$ac_cv_have_chflags" = yes ; then
3070 AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the 'chflags' function.])
3071fi
3072
3073AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
3074AC_RUN_IFELSE([AC_LANG_SOURCE([[
3075#include <sys/stat.h>
3076#include <unistd.h>
3077int main(int argc, char*argv[])
3078{
3079 if(lchflags(argv[0], 0) != 0)
3080 return 1;
3081 return 0;
3082}
3083]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
3084])
3085if test "$ac_cv_have_lchflags" = cross ; then
3086 AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
3087fi
3088if test "$ac_cv_have_lchflags" = yes ; then
3089 AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
3090fi
3091
3092dnl Check if system zlib has *Copy() functions
3093dnl
3094dnl On MacOSX the linker will search for dylibs on the entire linker path
3095dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
3096dnl to revert to a more traditional unix behaviour and make it possible to
3097dnl override the system libz with a local static library of libz. Temporarily
3098dnl add that flag to our CFLAGS as well to ensure that we check the version
3099dnl of libz that will be used by setup.py.
3100dnl The -L/usr/local/lib is needed as wel to get the same compilation
3101dnl environment as setup.py (and leaving it out can cause configure to use the
3102dnl wrong version of the library)
3103case $ac_sys_system/$ac_sys_release in
3104Darwin/*)
3105 _CUR_CFLAGS="${CFLAGS}"
3106 _CUR_LDFLAGS="${LDFLAGS}"
3107 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
3108 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
3109 ;;
3110esac
3111
3112AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
3113
3114case $ac_sys_system/$ac_sys_release in
3115Darwin/*)
3116 CFLAGS="${_CUR_CFLAGS}"
3117 LDFLAGS="${_CUR_LDFLAGS}"
3118 ;;
3119esac
3120
3121AC_MSG_CHECKING(for hstrerror)
3122AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3123#include <netdb.h>
3124]], [[void* p = hstrerror; hstrerror(0)]])],
3125 [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
3126 AC_MSG_RESULT(yes)],
3127 [AC_MSG_RESULT(no)
3128])
3129
3130AC_MSG_CHECKING(for inet_aton)
3131AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3132#include <sys/types.h>
3133#include <sys/socket.h>
3134#include <netinet/in.h>
3135#include <arpa/inet.h>
3136]], [[void* p = inet_aton;inet_aton(0,0)]])],
3137 [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
3138 AC_MSG_RESULT(yes)],
3139 [AC_MSG_RESULT(no)
3140])
3141
3142AC_MSG_CHECKING(for inet_pton)
3143AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3144#include <sys/types.h>
3145#include <sys/socket.h>
3146#include <netinet/in.h>
3147#include <arpa/inet.h>
3148]], [[void* p = inet_pton]])],
3149 [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
3150 AC_MSG_RESULT(yes)],
3151 [AC_MSG_RESULT(no)
3152])
3153
3154# On some systems, setgroups is in unistd.h, on others, in grp.h
3155AC_MSG_CHECKING(for setgroups)
3156AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3157#include <unistd.h>
3158#ifdef HAVE_GRP_H
3159#include <grp.h>
3160#endif
3161]], [[void* p = setgroups]])],
3162 [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
3163 AC_MSG_RESULT(yes)],
3164 [AC_MSG_RESULT(no)
3165])
3166
3167# check for openpty and forkpty
3168
3169AC_CHECK_FUNCS(openpty,,
3170 AC_CHECK_LIB(util,openpty,
3171 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
3172 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
3173 )
3174)
3175AC_CHECK_FUNCS(forkpty,,
3176 AC_CHECK_LIB(util,forkpty,
3177 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
3178 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
3179 )
3180)
3181
3182# Stuff for expat.
3183AC_CHECK_FUNCS(memmove)
3184
3185# check for long file support functions
3186AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
3187
3188AC_REPLACE_FUNCS(dup2 getcwd strdup)
3189AC_CHECK_FUNCS(getpgrp,
3190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
3191 [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
3192 [])
3193)
3194AC_CHECK_FUNCS(setpgrp,
3195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
3196 [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
3197 [])
3198)
3199AC_CHECK_FUNCS(gettimeofday,
3200 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
3201 [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
3202 [],
3203 [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
3204 [Define if gettimeofday() does not have second (timezone) argument
3205 This is the case on Motorola V4 (R40V4.2)])
3206 ])
3207)
3208
3209AC_MSG_CHECKING(for major, minor, and makedev)
3210AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3211#if defined(MAJOR_IN_MKDEV)
3212#include <sys/mkdev.h>
3213#elif defined(MAJOR_IN_SYSMACROS)
3214#include <sys/sysmacros.h>
3215#else
3216#include <sys/types.h>
3217#endif
3218]], [[
3219 makedev(major(0),minor(0));
3220]])],[
3221 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
3222 [Define to 1 if you have the device macros.])
3223 AC_MSG_RESULT(yes)
3224],[
3225 AC_MSG_RESULT(no)
3226])
3227
3228# On OSF/1 V5.1, getaddrinfo is available, but a define
3229# for [no]getaddrinfo in netdb.h.
3230AC_MSG_CHECKING(for getaddrinfo)
3231AC_LINK_IFELSE([AC_LANG_PROGRAM([[
3232#include <sys/types.h>
3233#include <sys/socket.h>
3234#include <netdb.h>
3235#include <stdio.h>
3236]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
3237[have_getaddrinfo=yes],
3238[have_getaddrinfo=no])
3239AC_MSG_RESULT($have_getaddrinfo)
3240if test $have_getaddrinfo = yes
3241then
3242 AC_MSG_CHECKING(getaddrinfo bug)
3243 AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
3244 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
3245#include <stdio.h>
3246#include <sys/types.h>
3247#include <netdb.h>
3248#include <string.h>
3249#include <sys/socket.h>
3250#include <netinet/in.h>
3251#ifdef __OS2__
3252#include <libcx/net.h>
3253#endif
3254
3255int main()
3256{
3257 int passive, gaierr, inet4 = 0, inet6 = 0;
3258 struct addrinfo hints, *ai, *aitop;
3259#ifndef __OS2__
3260 char straddr[INET6_ADDRSTRLEN], strport[16];
3261#else
3262 char straddr[NI_MAXHOST], strport[NI_MAXSERV];
3263#endif
3264
3265 for (passive = 0; passive <= 1; passive++) {
3266 memset(&hints, 0, sizeof(hints));
3267 hints.ai_family = AF_UNSPEC;
3268 hints.ai_flags = passive ? AI_PASSIVE : 0;
3269 hints.ai_socktype = SOCK_STREAM;
3270 hints.ai_protocol = IPPROTO_TCP;
3271 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3272 (void)gai_strerror(gaierr);
3273 goto bad;
3274 }
3275 for (ai = aitop; ai; ai = ai->ai_next) {
3276 if (ai->ai_addr == NULL ||
3277 ai->ai_addrlen == 0 ||
3278 getnameinfo(ai->ai_addr, ai->ai_addrlen,
3279 straddr, sizeof(straddr), strport, sizeof(strport),
3280 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3281 goto bad;
3282 }
3283 switch (ai->ai_family) {
3284 case AF_INET:
3285 if (strcmp(strport, "54321") != 0) {
3286 goto bad;
3287 }
3288 if (passive) {
3289 if (strcmp(straddr, "0.0.0.0") != 0) {
3290 goto bad;
3291 }
3292 } else {
3293 if (strcmp(straddr, "127.0.0.1") != 0) {
3294 goto bad;
3295 }
3296 }
3297 inet4++;
3298 break;
3299#ifndef __OS2__
3300 case AF_INET6:
3301 if (strcmp(strport, "54321") != 0) {
3302 goto bad;
3303 }
3304 if (passive) {
3305 if (strcmp(straddr, "::") != 0) {
3306 goto bad;
3307 }
3308 } else {
3309 if (strcmp(straddr, "::1") != 0) {
3310 goto bad;
3311 }
3312 }
3313 inet6++;
3314 break;
3315#endif
3316 case AF_UNSPEC:
3317 goto bad;
3318 break;
3319 default:
3320 /* another family support? */
3321 break;
3322 }
3323 }
3324 }
3325
3326 if (!(inet4 == 0 || inet4 == 2))
3327 goto bad;
3328 if (!(inet6 == 0 || inet6 == 2))
3329 goto bad;
3330
3331 if (aitop)
3332 freeaddrinfo(aitop);
3333 return 0;
3334
3335 bad:
3336 if (aitop)
3337 freeaddrinfo(aitop);
3338 return 1;
3339}
3340]]])],
3341[ac_cv_buggy_getaddrinfo=no],
3342[ac_cv_buggy_getaddrinfo=yes],
3343[
3344if test "${enable_ipv6+set}" = set; then
3345 ac_cv_buggy_getaddrinfo="no -- configured with --(en|dis)able-ipv6"
3346else
3347 ac_cv_buggy_getaddrinfo=yes
3348fi]))
3349fi
3350
3351AC_MSG_RESULT($ac_cv_buggy_getaddrinfo)
3352
3353if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
3354then
3355 if test $ipv6 = yes
3356 then
3357 echo 'Fatal: You must get working getaddrinfo() function.'
3358 echo ' or you can specify "--disable-ipv6"'.
3359 exit 1
3360 fi
3361else
3362 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
3363fi
3364
3365AC_CHECK_FUNCS(getnameinfo)
3366
3367# checks for structures
3368AC_HEADER_TIME
3369AC_STRUCT_TM
3370AC_STRUCT_TIMEZONE
3371AC_CHECK_MEMBERS([struct stat.st_rdev])
3372AC_CHECK_MEMBERS([struct stat.st_blksize])
3373AC_CHECK_MEMBERS([struct stat.st_flags])
3374AC_CHECK_MEMBERS([struct stat.st_gen])
3375AC_CHECK_MEMBERS([struct stat.st_birthtime])
3376AC_STRUCT_ST_BLOCKS
3377
3378AC_MSG_CHECKING(for time.h that defines altzone)
3379AC_CACHE_VAL(ac_cv_header_time_altzone,[
3380 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3381 [ac_cv_header_time_altzone=yes],
3382 [ac_cv_header_time_altzone=no])
3383 ])
3384AC_MSG_RESULT($ac_cv_header_time_altzone)
3385if test $ac_cv_header_time_altzone = yes; then
3386 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
3387fi
3388
3389was_it_defined=no
3390AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
3391AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3392#include <sys/types.h>
3393#include <sys/select.h>
3394#include <sys/time.h>
3395]], [[;]])],[
3396 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3397 [Define if you can safely include both <sys/select.h> and <sys/time.h>
3398 (which you can't on SCO ODT 3.0).])
3399 was_it_defined=yes
3400],[])
3401AC_MSG_RESULT($was_it_defined)
3402
3403AC_MSG_CHECKING(for addrinfo)
3404AC_CACHE_VAL(ac_cv_struct_addrinfo,
3405AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3406 #include <netdb.h>
3407 #ifdef __OS2__
3408 #include <libcx/net.h>
3409 #endif
3410 ]], [[struct addrinfo a]])],
3411 [ac_cv_struct_addrinfo=yes],
3412 [ac_cv_struct_addrinfo=no]))
3413AC_MSG_RESULT($ac_cv_struct_addrinfo)
3414if test $ac_cv_struct_addrinfo = yes; then
3415 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
3416fi
3417
3418AC_MSG_CHECKING(for sockaddr_storage)
3419AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
3420AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3421# include <sys/types.h>
3422# include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3423 [ac_cv_struct_sockaddr_storage=yes],
3424 [ac_cv_struct_sockaddr_storage=no]))
3425AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3426if test $ac_cv_struct_sockaddr_storage = yes; then
3427 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
3428fi
3429
3430# checks for compiler characteristics
3431
3432AC_C_CHAR_UNSIGNED
3433AC_C_CONST
3434
3435works=no
3436AC_MSG_CHECKING(for working volatile)
3437AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3438 [works=yes],
3439 [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
3440)
3441AC_MSG_RESULT($works)
3442
3443works=no
3444AC_MSG_CHECKING(for working signed char)
3445AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3446 [works=yes],
3447 [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
3448)
3449AC_MSG_RESULT($works)
3450
3451have_prototypes=no
3452AC_MSG_CHECKING(for prototypes)
3453AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3454 [AC_DEFINE(HAVE_PROTOTYPES, 1,
3455 [Define if your compiler supports function prototype])
3456 have_prototypes=yes],
3457 []
3458)
3459AC_MSG_RESULT($have_prototypes)
3460
3461works=no
3462AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
3463AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3464#include <stdarg.h>
3465int foo(int x, ...) {
3466 va_list va;
3467 va_start(va, x);
3468 va_arg(va, int);
3469 va_arg(va, char *);
3470 va_arg(va, double);
3471 return 0;
3472}
3473]], [[return foo(10, "", 3.14);]])],[
3474 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3475 [Define if your compiler supports variable length function prototypes
3476 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
3477 works=yes
3478],[])
3479AC_MSG_RESULT($works)
3480
3481# check for socketpair
3482AC_MSG_CHECKING(for socketpair)
3483AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3484#include <sys/types.h>
3485#include <sys/socket.h>
3486]], [[void *x=socketpair]])],
3487 [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3488 AC_MSG_RESULT(yes)],
3489 [AC_MSG_RESULT(no)]
3490)
3491
3492# check if sockaddr has sa_len member
3493AC_MSG_CHECKING(if sockaddr has sa_len member)
3494AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3495#include <sys/socket.h>]], [[struct sockaddr x;
3496x.sa_len = 0;]])],
3497 [AC_MSG_RESULT(yes)
3498 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3499 [AC_MSG_RESULT(no)]
3500)
3501
3502va_list_is_array=no
3503AC_MSG_CHECKING(whether va_list is an array)
3504AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3505#ifdef HAVE_STDARG_PROTOTYPES
3506#include <stdarg.h>
3507#else
3508#include <varargs.h>
3509#endif
3510]], [[va_list list1, list2; list1 = list2;]])],[],[
3511 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
3512 va_list_is_array=yes
3513])
3514AC_MSG_RESULT($va_list_is_array)
3515
3516# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
3517AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3518 [Define this if you have some version of gethostbyname_r()])
3519
3520AC_CHECK_FUNC(gethostbyname_r, [
3521 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3522 AC_MSG_CHECKING([gethostbyname_r with 6 args])
3523 OLD_CFLAGS=$CFLAGS
3524 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3525 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3526# include <netdb.h>
3527 ]], [[
3528 char *name;
3529 struct hostent *he, *res;
3530 char buffer[2048];
3531 int buflen = 2048;
3532 int h_errnop;
3533
3534 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3535 ]])],[
3536 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3537 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3538 [Define this if you have the 6-arg version of gethostbyname_r().])
3539 AC_MSG_RESULT(yes)
3540 ],[
3541 AC_MSG_RESULT(no)
3542 AC_MSG_CHECKING([gethostbyname_r with 5 args])
3543 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3544# include <netdb.h>
3545 ]], [[
3546 char *name;
3547 struct hostent *he;
3548 char buffer[2048];
3549 int buflen = 2048;
3550 int h_errnop;
3551
3552 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3553 ]])],
3554 [
3555 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3556 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3557 [Define this if you have the 5-arg version of gethostbyname_r().])
3558 AC_MSG_RESULT(yes)
3559 ], [
3560 AC_MSG_RESULT(no)
3561 AC_MSG_CHECKING([gethostbyname_r with 3 args])
3562 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3563# include <netdb.h>
3564 ]], [[
3565 char *name;
3566 struct hostent *he;
3567 struct hostent_data data;
3568
3569 (void) gethostbyname_r(name, he, &data);
3570 ]])],
3571 [
3572 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3573 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3574 [Define this if you have the 3-arg version of gethostbyname_r().])
3575 AC_MSG_RESULT(yes)
3576 ], [
3577 AC_MSG_RESULT(no)
3578 ])
3579 ])
3580 ])
3581 CFLAGS=$OLD_CFLAGS
3582], [
3583 AC_CHECK_FUNCS(gethostbyname)
3584])
3585AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3586AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3587AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
3588AC_SUBST(HAVE_GETHOSTBYNAME_R)
3589AC_SUBST(HAVE_GETHOSTBYNAME)
3590
3591# checks for system services
3592# (none yet)
3593
3594# Linux requires this for correct f.p. operations
3595AC_CHECK_FUNC(__fpu_control,
3596 [],
3597 [AC_CHECK_LIB(ieee, __fpu_control)
3598])
3599
3600# Check for --with-fpectl
3601AC_MSG_CHECKING(for --with-fpectl)
3602AC_ARG_WITH(fpectl,
3603 AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
3604[
3605if test "$withval" != no
3606then
3607 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3608 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
3609 AC_MSG_RESULT(yes)
3610else AC_MSG_RESULT(no)
3611fi],
3612[AC_MSG_RESULT(no)])
3613
3614# check for --with-libm=...
3615AC_SUBST(LIBM)
3616case $ac_sys_system in
3617Darwin) ;;
3618BeOS) ;;
3619*) LIBM=-lm
3620esac
3621AC_MSG_CHECKING(for --with-libm=STRING)
3622AC_ARG_WITH(libm,
3623 AS_HELP_STRING([--with-libm=STRING], [math library]),
3624[
3625if test "$withval" = no
3626then LIBM=
3627 AC_MSG_RESULT(force LIBM empty)
3628elif test "$withval" != yes
3629then LIBM=$withval
3630 AC_MSG_RESULT(set LIBM="$withval")
3631else AC_MSG_ERROR([proper usage is --with-libm=STRING])
3632fi],
3633[AC_MSG_RESULT(default LIBM="$LIBM")])
3634
3635# check for --with-libc=...
3636AC_SUBST(LIBC)
3637AC_MSG_CHECKING(for --with-libc=STRING)
3638AC_ARG_WITH(libc,
3639 AS_HELP_STRING([--with-libc=STRING], [C library]),
3640[
3641if test "$withval" = no
3642then LIBC=
3643 AC_MSG_RESULT(force LIBC empty)
3644elif test "$withval" != yes
3645then LIBC=$withval
3646 AC_MSG_RESULT(set LIBC="$withval")
3647else AC_MSG_ERROR([proper usage is --with-libc=STRING])
3648fi],
3649[AC_MSG_RESULT(default LIBC="$LIBC")])
3650
3651# **************************************************
3652# * Check for various properties of floating point *
3653# **************************************************
3654
3655AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3656AC_CACHE_VAL(ac_cv_little_endian_double, [
3657AC_RUN_IFELSE([AC_LANG_SOURCE([[
3658#include <string.h>
3659int main() {
3660 double x = 9006104071832581.0;
3661 if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3662 return 0;
3663 else
3664 return 1;
3665}
3666]])],
3667[ac_cv_little_endian_double=yes],
3668[ac_cv_little_endian_double=no],
3669[ac_cv_little_endian_double=no])])
3670AC_MSG_RESULT($ac_cv_little_endian_double)
3671if test "$ac_cv_little_endian_double" = yes
3672then
3673 AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3674 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3675 with the least significant byte first])
3676fi
3677
3678AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3679AC_CACHE_VAL(ac_cv_big_endian_double, [
3680AC_RUN_IFELSE([AC_LANG_SOURCE([[
3681#include <string.h>
3682int main() {
3683 double x = 9006104071832581.0;
3684 if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3685 return 0;
3686 else
3687 return 1;
3688}
3689]])],
3690[ac_cv_big_endian_double=yes],
3691[ac_cv_big_endian_double=no],
3692[ac_cv_big_endian_double=no])])
3693AC_MSG_RESULT($ac_cv_big_endian_double)
3694if test "$ac_cv_big_endian_double" = yes
3695then
3696 AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3697 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3698 with the most significant byte first])
3699fi
3700
3701# Some ARM platforms use a mixed-endian representation for doubles.
3702# While Python doesn't currently have full support for these platforms
3703# (see e.g., issue 1762561), we can at least make sure that float <-> string
3704# conversions work.
3705AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3706AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3707AC_RUN_IFELSE([AC_LANG_SOURCE([[
3708#include <string.h>
3709int main() {
3710 double x = 9006104071832581.0;
3711 if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3712 return 0;
3713 else
3714 return 1;
3715}
3716]])],
3717[ac_cv_mixed_endian_double=yes],
3718[ac_cv_mixed_endian_double=no],
3719[ac_cv_mixed_endian_double=no])])
3720AC_MSG_RESULT($ac_cv_mixed_endian_double)
3721if test "$ac_cv_mixed_endian_double" = yes
3722then
3723 AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3724 [Define if C doubles are 64-bit IEEE 754 binary format, stored
3725 in ARM mixed-endian order (byte order 45670123)])
3726fi
3727
3728# The short float repr introduced in Python 3.1 requires the
3729# correctly-rounded string <-> double conversion functions from
3730# Python/dtoa.c, which in turn require that the FPU uses 53-bit
3731# rounding; this is a problem on x86, where the x87 FPU has a default
3732# rounding precision of 64 bits. For gcc/x86, we can fix this by
3733# using inline assembler to get and set the x87 FPU control word.
3734
3735# This inline assembler syntax may also work for suncc and icc,
3736# so we try it on all platforms.
3737
3738AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3739AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3740 unsigned short cw;
3741 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3742 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3743]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
3744AC_MSG_RESULT($have_gcc_asm_for_x87)
3745if test "$have_gcc_asm_for_x87" = yes
3746then
3747 AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3748 [Define if we can use gcc inline assembler to get and set x87 control word])
3749fi
3750
3751# Detect whether system arithmetic is subject to x87-style double
3752# rounding issues. The result of this test has little meaning on non
3753# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
3754# mode is round-to-nearest and double rounding issues are present, and
3755# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
3756AC_MSG_CHECKING(for x87-style double rounding)
3757# $BASECFLAGS may affect the result
3758ac_save_cc="$CC"
3759CC="$CC $BASECFLAGS"
3760AC_RUN_IFELSE([AC_LANG_SOURCE([[
3761#include <stdlib.h>
3762#include <math.h>
3763int main() {
3764 volatile double x, y, z;
3765 /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3766 x = 0.99999999999999989; /* 1-2**-53 */
3767 y = 1./x;
3768 if (y != 1.)
3769 exit(0);
3770 /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3771 x = 1e16;
3772 y = 2.99999;
3773 z = x + y;
3774 if (z != 1e16+4.)
3775 exit(0);
3776 /* both tests show evidence of double rounding */
3777 exit(1);
3778}
3779]])],
3780[ac_cv_x87_double_rounding=no],
3781[ac_cv_x87_double_rounding=yes],
3782[ac_cv_x87_double_rounding=no])
3783CC="$ac_save_cc"
3784AC_MSG_RESULT($ac_cv_x87_double_rounding)
3785if test "$ac_cv_x87_double_rounding" = yes
3786then
3787 AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3788 [Define if arithmetic is subject to x87-style double rounding issue])
3789fi
3790
3791# ************************************
3792# * Check for mathematical functions *
3793# ************************************
3794
3795LIBS_SAVE=$LIBS
3796LIBS="$LIBS $LIBM"
3797
3798# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3799# -0. on some architectures.
3800AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3801AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3802AC_RUN_IFELSE([AC_LANG_SOURCE([[
3803#include <math.h>
3804#include <stdlib.h>
3805int main() {
3806 /* return 0 if either negative zeros don't exist
3807 on this platform or if negative zeros exist
3808 and tanh(-0.) == -0. */
3809 if (atan2(0., -1.) == atan2(-0., -1.) ||
3810 atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3811 else exit(1);
3812}
3813]])],
3814[ac_cv_tanh_preserves_zero_sign=yes],
3815[ac_cv_tanh_preserves_zero_sign=no],
3816[ac_cv_tanh_preserves_zero_sign=no])])
3817AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3818if test "$ac_cv_tanh_preserves_zero_sign" = yes
3819then
3820 AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3821 [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3822fi
3823
3824AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3825AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3826AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3827
3828LIBS=$LIBS_SAVE
3829
3830# For multiprocessing module, check that sem_open
3831# actually works. For FreeBSD versions <= 7.2,
3832# the kernel module that provides POSIX semaphores
3833# isn't loaded by default, so an attempt to call
3834# sem_open results in a 'Signal 12' error.
3835AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3836AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3837AC_RUN_IFELSE([AC_LANG_SOURCE([[
3838#include <unistd.h>
3839#include <fcntl.h>
3840#include <stdio.h>
3841#include <semaphore.h>
3842#include <sys/stat.h>
3843
3844int main(void) {
3845 sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3846 if (a == SEM_FAILED) {
3847 perror("sem_open");
3848 return 1;
3849 }
3850 sem_close(a);
3851 sem_unlink("/autoconf");
3852 return 0;
3853}
3854]])],
3855[ac_cv_posix_semaphores_enabled=yes],
3856[ac_cv_posix_semaphores_enabled=no],
3857[ac_cv_posix_semaphores_enabled=yes])
3858)
3859AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3860if test $ac_cv_posix_semaphores_enabled = no
3861then
3862 AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3863 [Define if POSIX semaphores aren't enabled on your system])
3864fi
3865
3866# Multiprocessing check for broken sem_getvalue
3867AC_MSG_CHECKING(for broken sem_getvalue)
3868AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
3869AC_RUN_IFELSE([AC_LANG_SOURCE([[
3870#include <unistd.h>
3871#include <fcntl.h>
3872#include <stdio.h>
3873#include <semaphore.h>
3874#include <sys/stat.h>
3875
3876int main(void){
3877 sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
3878 int count;
3879 int res;
3880 if(a==SEM_FAILED){
3881 perror("sem_open");
3882 return 1;
3883
3884 }
3885 res = sem_getvalue(a, &count);
3886 sem_close(a);
3887 sem_unlink("/autocftw");
3888 return res==-1 ? 1 : 0;
3889}
3890]])],
3891[ac_cv_broken_sem_getvalue=no],
3892[ac_cv_broken_sem_getvalue=yes],
3893[ac_cv_broken_sem_getvalue=yes])
3894)
3895AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3896if test $ac_cv_broken_sem_getvalue = yes
3897then
3898 AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3899 [define to 1 if your sem_getvalue is broken.])
3900fi
3901
3902# determine what size digit to use for Python's longs
3903AC_MSG_CHECKING([digit size for Python's longs])
3904AC_ARG_ENABLE(big-digits,
3905AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3906[case $enable_big_digits in
3907yes)
3908 enable_big_digits=30 ;;
3909no)
3910 enable_big_digits=15 ;;
3911[15|30])
3912 ;;
3913*)
3914 AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3915esac
3916AC_MSG_RESULT($enable_big_digits)
3917AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3918],
3919[AC_MSG_RESULT(no value specified)])
3920
3921# check for wchar.h
3922AC_CHECK_HEADER(wchar.h, [
3923 AC_DEFINE(HAVE_WCHAR_H, 1,
3924 [Define if the compiler provides a wchar.h header file.])
3925 wchar_h="yes"
3926],
3927wchar_h="no"
3928)
3929
3930# determine wchar_t size
3931if test "$wchar_h" = yes
3932then
3933 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
3934fi
3935
3936AC_MSG_CHECKING(for UCS-4 tcl)
3937have_ucs4_tcl=no
3938AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3939#include <tcl.h>
3940#if TCL_UTF_MAX != 6
3941# error "NOT UCS4_TCL"
3942#endif]], [[]])],[
3943 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3944 have_ucs4_tcl=yes
3945],[])
3946AC_MSG_RESULT($have_ucs4_tcl)
3947
3948# check whether wchar_t is signed or not
3949if test "$wchar_h" = yes
3950then
3951 # check whether wchar_t is signed or not
3952 AC_MSG_CHECKING(whether wchar_t is signed)
3953 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3954 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3955 #include <wchar.h>
3956 int main()
3957 {
3958 /* Success: exit code 0 */
3959 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
3960 }
3961 ]])],
3962 [ac_cv_wchar_t_signed=yes],
3963 [ac_cv_wchar_t_signed=no],
3964 [ac_cv_wchar_t_signed=yes])])
3965 AC_MSG_RESULT($ac_cv_wchar_t_signed)
3966fi
3967
3968AC_MSG_CHECKING(what type to use for unicode)
3969dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3970AC_ARG_ENABLE(unicode,
3971 AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
3972 [],
3973 [enable_unicode=yes])
3974
3975if test $enable_unicode = yes
3976then
3977 # Without any arguments, Py_UNICODE defaults to two-byte mode
3978 case "$have_ucs4_tcl" in
3979 yes) enable_unicode="ucs4"
3980 ;;
3981 *) enable_unicode="ucs2"
3982 ;;
3983 esac
3984fi
3985
3986AH_TEMPLATE(Py_UNICODE_SIZE,
3987 [Define as the size of the unicode type.])
3988case "$enable_unicode" in
3989ucs2) unicode_size="2"
3990 AC_DEFINE(Py_UNICODE_SIZE,2)
3991 ;;
3992ucs4) unicode_size="4"
3993 AC_DEFINE(Py_UNICODE_SIZE,4)
3994 ;;
3995no) ;; # To allow --disable-unicode
3996*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
3997esac
3998
3999AH_TEMPLATE(PY_UNICODE_TYPE,
4000 [Define as the integral type used for Unicode representation.])
4001
4002AC_SUBST(UNICODE_OBJS)
4003if test "$enable_unicode" = "no"
4004then
4005 UNICODE_OBJS=""
4006 AC_MSG_RESULT(not used)
4007else
4008 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
4009 AC_DEFINE(Py_USING_UNICODE, 1,
4010 [Define if you want to have a Unicode type.])
4011
4012 # wchar_t is only usable if it maps to an unsigned type
4013 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
4014 -a "$ac_cv_wchar_t_signed" = "no"
4015 then
4016 PY_UNICODE_TYPE="wchar_t"
4017 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
4018 [Define if you have a useable wchar_t type defined in wchar.h; useable
4019 means wchar_t must be an unsigned type with at least 16 bits. (see
4020 Include/unicodeobject.h).])
4021 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
4022 elif test "$ac_cv_sizeof_short" = "$unicode_size"
4023 then
4024 PY_UNICODE_TYPE="unsigned short"
4025 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
4026 elif test "$ac_cv_sizeof_long" = "$unicode_size"
4027 then
4028 PY_UNICODE_TYPE="unsigned long"
4029 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
4030 else
4031 PY_UNICODE_TYPE="no type found"
4032 fi
4033 AC_MSG_RESULT($PY_UNICODE_TYPE)
4034fi
4035
4036# check for endianness
4037AC_C_BIGENDIAN
4038
4039# Check whether right shifting a negative integer extends the sign bit
4040# or fills with zeros (like the Cray J90, according to Tim Peters).
4041AC_MSG_CHECKING(whether right shift extends the sign bit)
4042AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
4043AC_RUN_IFELSE([AC_LANG_SOURCE([[
4044int main()
4045{
4046 exit(((-1)>>3 == -1) ? 0 : 1);
4047}
4048]])],
4049[ac_cv_rshift_extends_sign=yes],
4050[ac_cv_rshift_extends_sign=no],
4051[ac_cv_rshift_extends_sign=yes])])
4052AC_MSG_RESULT($ac_cv_rshift_extends_sign)
4053if test "$ac_cv_rshift_extends_sign" = no
4054then
4055 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
4056 [Define if i>>j for signed int i does not extend the sign bit
4057 when i < 0])
4058fi
4059
4060# check for getc_unlocked and related locking functions
4061AC_MSG_CHECKING(for getc_unlocked() and friends)
4062AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
4063AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
4064 FILE *f = fopen("/dev/null", "r");
4065 flockfile(f);
4066 getc_unlocked(f);
4067 funlockfile(f);
4068]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
4069AC_MSG_RESULT($ac_cv_have_getc_unlocked)
4070if test "$ac_cv_have_getc_unlocked" = yes
4071then
4072 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
4073 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
4074fi
4075
4076# check where readline lives
4077# save the value of LIBS so we don't actually link Python with readline
4078LIBS_no_readline=$LIBS
4079
4080# On some systems we need to link readline to a termcap compatible
4081# library. NOTE: Keep the precedence of listed libraries synchronised
4082# with setup.py.
4083py_cv_lib_readline=no
4084AC_MSG_CHECKING([how to link readline libs])
4085for py_libtermcap in "" ncursesw ncurses curses termcap; do
4086 if test -z "$py_libtermcap"; then
4087 READLINE_LIBS="-lreadline"
4088 else
4089 READLINE_LIBS="-lreadline -l$py_libtermcap"
4090 fi
4091 LIBS="$READLINE_LIBS $LIBS_no_readline"
4092 AC_LINK_IFELSE(
4093 [AC_LANG_CALL([],[readline])],
4094 [py_cv_lib_readline=yes])
4095 if test $py_cv_lib_readline = yes; then
4096 break
4097 fi
4098done
4099# Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
4100#AC_SUBST([READLINE_LIBS])
4101if test $py_cv_lib_readline = no; then
4102 AC_MSG_RESULT([none])
4103else
4104 AC_MSG_RESULT([$READLINE_LIBS])
4105 AC_DEFINE(HAVE_LIBREADLINE, 1,
4106 [Define if you have the readline library (-lreadline).])
4107fi
4108
4109# check for readline 2.1
4110AC_CHECK_LIB(readline, rl_callback_handler_install,
4111 AC_DEFINE(HAVE_RL_CALLBACK, 1,
4112 [Define if you have readline 2.1]), ,$READLINE_LIBS)
4113
4114# check for readline 2.2
4115AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4116 [have_readline=yes],
4117 [have_readline=no]
4118)
4119if test $have_readline = yes
4120then
4121 AC_EGREP_HEADER([extern int rl_completion_append_character;],
4122 [readline/readline.h],
4123 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
4124 [Define if you have readline 2.2]), )
4125 AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
4126 [readline/readline.h],
4127 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
4128 [Define if you have rl_completion_suppress_append]), )
4129fi
4130
4131# check for readline 4.0
4132AC_CHECK_LIB(readline, rl_pre_input_hook,
4133 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
4134 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4135
4136# also in 4.0
4137AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
4138 AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
4139 [Define if you have readline 4.0]), ,$READLINE_LIBS)
4140
4141# check for readline 4.2
4142AC_CHECK_LIB(readline, rl_completion_matches,
4143 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
4144 [Define if you have readline 4.2]), ,$READLINE_LIBS)
4145
4146# also in readline 4.2
4147AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
4148 [have_readline=yes],
4149 [have_readline=no]
4150)
4151if test $have_readline = yes
4152then
4153 AC_EGREP_HEADER([extern int rl_catch_signals;],
4154 [readline/readline.h],
4155 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
4156 [Define if you can turn off readline's signal handling.]), )
4157fi
4158
4159# End of readline checks: restore LIBS
4160LIBS=$LIBS_no_readline
4161
4162AC_MSG_CHECKING(for broken nice())
4163AC_CACHE_VAL(ac_cv_broken_nice, [
4164AC_RUN_IFELSE([AC_LANG_SOURCE([[
4165int main()
4166{
4167 int val1 = nice(1);
4168 if (val1 != -1 && val1 == nice(2))
4169 exit(0);
4170 exit(1);
4171}
4172]])],
4173[ac_cv_broken_nice=yes],
4174[ac_cv_broken_nice=no],
4175[ac_cv_broken_nice=no])])
4176AC_MSG_RESULT($ac_cv_broken_nice)
4177if test "$ac_cv_broken_nice" = yes
4178then
4179 AC_DEFINE(HAVE_BROKEN_NICE, 1,
4180 [Define if nice() returns success/failure instead of the new priority.])
4181fi
4182
4183AC_MSG_CHECKING(for broken poll())
4184AC_CACHE_VAL(ac_cv_broken_poll,
4185AC_RUN_IFELSE([AC_LANG_SOURCE([[
4186#include <poll.h>
4187
4188int main()
4189{
4190 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
4191 int poll_test;
4192
4193 close (42);
4194
4195 poll_test = poll(&poll_struct, 1, 0);
4196 if (poll_test < 0)
4197 return 0;
4198 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
4199 return 0;
4200 else
4201 return 1;
4202}
4203]])],
4204[ac_cv_broken_poll=yes],
4205[ac_cv_broken_poll=no],
4206[ac_cv_broken_poll=no]))
4207AC_MSG_RESULT($ac_cv_broken_poll)
4208if test "$ac_cv_broken_poll" = yes
4209then
4210 AC_DEFINE(HAVE_BROKEN_POLL, 1,
4211 [Define if poll() sets errno on invalid file descriptors.])
4212fi
4213
4214# Before we can test tzset, we need to check if struct tm has a tm_zone
4215# (which is not required by ISO C or UNIX spec) and/or if we support
4216# tzname[]
4217AC_STRUCT_TIMEZONE
4218
4219# check tzset(3) exists and works like we expect it to
4220AC_MSG_CHECKING(for working tzset())
4221AC_CACHE_VAL(ac_cv_working_tzset, [
4222AC_RUN_IFELSE([AC_LANG_SOURCE([[
4223#include <stdlib.h>
4224#include <time.h>
4225#include <string.h>
4226
4227#if HAVE_TZNAME
4228extern char *tzname[];
4229#endif
4230
4231int main()
4232{
4233 /* Note that we need to ensure that not only does tzset(3)
4234 do 'something' with localtime, but it works as documented
4235 in the library reference and as expected by the test suite.
4236 This includes making sure that tzname is set properly if
4237 tm->tm_zone does not exist since it is the alternative way
4238 of getting timezone info.
4239
4240 Red Hat 6.2 doesn't understand the southern hemisphere
4241 after New Year's Day.
4242 */
4243
4244 time_t groundhogday = 1044144000; /* GMT-based */
4245 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
4246
4247 putenv("TZ=UTC+0");
4248 tzset();
4249 if (localtime(&groundhogday)->tm_hour != 0)
4250 exit(1);
4251#if HAVE_TZNAME
4252 /* For UTC, tzname[1] is sometimes "", sometimes " " */
4253 if (strcmp(tzname[0], "UTC") ||
4254 (tzname[1][0] != 0 && tzname[1][0] != ' '))
4255 exit(1);
4256#endif
4257
4258 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
4259 tzset();
4260 if (localtime(&groundhogday)->tm_hour != 19)
4261 exit(1);
4262#if HAVE_TZNAME
4263 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
4264 exit(1);
4265#endif
4266
4267 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
4268 tzset();
4269 if (localtime(&groundhogday)->tm_hour != 11)
4270 exit(1);
4271#if HAVE_TZNAME
4272 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4273 exit(1);
4274#endif
4275
4276#if HAVE_STRUCT_TM_TM_ZONE
4277 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4278 exit(1);
4279 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4280 exit(1);
4281#endif
4282
4283 exit(0);
4284}
4285]])],
4286[ac_cv_working_tzset=yes],
4287[ac_cv_working_tzset=no],
4288[ac_cv_working_tzset=no])])
4289AC_MSG_RESULT($ac_cv_working_tzset)
4290if test "$ac_cv_working_tzset" = yes
4291then
4292 AC_DEFINE(HAVE_WORKING_TZSET, 1,
4293 [Define if tzset() actually switches the local timezone in a meaningful way.])
4294fi
4295
4296# Look for subsecond timestamps in struct stat
4297AC_MSG_CHECKING(for tv_nsec in struct stat)
4298AC_CACHE_VAL(ac_cv_stat_tv_nsec,
4299AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
4300struct stat st;
4301st.st_mtim.tv_nsec = 1;
4302]])],
4303[ac_cv_stat_tv_nsec=yes],
4304[ac_cv_stat_tv_nsec=no]))
4305AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4306if test "$ac_cv_stat_tv_nsec" = yes
4307then
4308 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4309 [Define if you have struct stat.st_mtim.tv_nsec])
4310fi
4311
4312# Look for BSD style subsecond timestamps in struct stat
4313AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4314AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
4315AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
4316struct stat st;
4317st.st_mtimespec.tv_nsec = 1;
4318]])],
4319[ac_cv_stat_tv_nsec2=yes],
4320[ac_cv_stat_tv_nsec2=no]))
4321AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4322if test "$ac_cv_stat_tv_nsec2" = yes
4323then
4324 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4325 [Define if you have struct stat.st_mtimensec])
4326fi
4327
4328# On HP/UX 11.0, mvwdelch is a block with a return statement
4329AC_MSG_CHECKING(whether mvwdelch is an expression)
4330AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
4331AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4332 int rtn;
4333 rtn = mvwdelch(0,0,0);
4334]])],
4335[ac_cv_mvwdelch_is_expression=yes],
4336[ac_cv_mvwdelch_is_expression=no]))
4337AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4338
4339if test "$ac_cv_mvwdelch_is_expression" = yes
4340then
4341 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4342 [Define if mvwdelch in curses.h is an expression.])
4343fi
4344
4345AC_MSG_CHECKING(whether WINDOW has _flags)
4346AC_CACHE_VAL(ac_cv_window_has_flags,
4347AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4348 WINDOW *w;
4349 w->_flags = 0;
4350]])],
4351[ac_cv_window_has_flags=yes],
4352[ac_cv_window_has_flags=no]))
4353AC_MSG_RESULT($ac_cv_window_has_flags)
4354
4355
4356if test "$ac_cv_window_has_flags" = yes
4357then
4358 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
4359 [Define if WINDOW in curses.h offers a field _flags.])
4360fi
4361
4362AC_MSG_CHECKING(for is_term_resized)
4363AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4364 [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4365 AC_MSG_RESULT(yes)],
4366 [AC_MSG_RESULT(no)]
4367)
4368
4369AC_MSG_CHECKING(for resize_term)
4370AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4371 [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4372 AC_MSG_RESULT(yes)],
4373 [AC_MSG_RESULT(no)]
4374)
4375
4376AC_MSG_CHECKING(for resizeterm)
4377AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4378 [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4379 AC_MSG_RESULT(yes)],
4380 [AC_MSG_RESULT(no)]
4381)
4382
4383AC_MSG_NOTICE([checking for device files])
4384
4385dnl NOTE: Inform user how to proceed with files when cross compiling.
4386if test "x$cross_compiling" = xyes; then
4387 if test "${ac_cv_file__dev_ptmx+set}" != set; then
4388 AC_MSG_CHECKING([for /dev/ptmx])
4389 AC_MSG_RESULT([not set])
4390 AC_MSG_ERROR([set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling])
4391 fi
4392 if test "${ac_cv_file__dev_ptc+set}" != set; then
4393 AC_MSG_CHECKING([for /dev/ptc])
4394 AC_MSG_RESULT([not set])
4395 AC_MSG_ERROR([set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling])
4396 fi
4397fi
4398
4399AC_CHECK_FILE(/dev/ptmx, [], [])
4400if test "x$ac_cv_file__dev_ptmx" = xyes; then
4401 AC_DEFINE(HAVE_DEV_PTMX, 1,
4402 [Define to 1 if you have the /dev/ptmx device file.])
4403fi
4404AC_CHECK_FILE(/dev/ptc, [], [])
4405if test "x$ac_cv_file__dev_ptc" = xyes; then
4406 AC_DEFINE(HAVE_DEV_PTC, 1,
4407 [Define to 1 if you have the /dev/ptc device file.])
4408fi
4409
4410if test "$have_long_long" = yes
4411then
4412 AC_MSG_CHECKING(for %lld and %llu printf() format support)
4413 AC_CACHE_VAL(ac_cv_have_long_long_format,
4414 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4415 #include <stdio.h>
4416 #include <stddef.h>
4417 #include <string.h>
4418
4419 #ifdef HAVE_SYS_TYPES_H
4420 #include <sys/types.h>
4421 #endif
4422
4423 int main()
4424 {
4425 char buffer[256];
4426
4427 if (sprintf(buffer, "%lld", (long long)123) < 0)
4428 return 1;
4429 if (strcmp(buffer, "123"))
4430 return 1;
4431
4432 if (sprintf(buffer, "%lld", (long long)-123) < 0)
4433 return 1;
4434 if (strcmp(buffer, "-123"))
4435 return 1;
4436
4437 if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4438 return 1;
4439 if (strcmp(buffer, "123"))
4440 return 1;
4441
4442 return 0;
4443 }
4444 ]]])],
4445 [ac_cv_have_long_long_format=yes],
4446 [ac_cv_have_long_long_format=no],
4447 [ac_cv_have_long_long_format="cross -- assuming no"
4448 if test x$GCC = xyes; then
4449 save_CFLAGS=$CFLAGS
4450 CFLAGS="$CFLAGS -Werror -Wformat"
4451 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4452 #include <stdio.h>
4453 #include <stddef.h>
4454 ]], [[
4455 char *buffer;
4456 sprintf(buffer, "%lld", (long long)123);
4457 sprintf(buffer, "%lld", (long long)-123);
4458 sprintf(buffer, "%llu", (unsigned long long)123);
4459 ]])],
4460 ac_cv_have_long_long_format=yes
4461 )
4462 CFLAGS=$save_CFLAGS
4463 fi])
4464 )
4465 AC_MSG_RESULT($ac_cv_have_long_long_format)
4466fi
4467
4468if test "$ac_cv_have_long_long_format" = yes
4469then
4470 AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4471 [Define to printf format modifier for long long type])
4472fi
4473
4474if test $ac_sys_system = Darwin
4475then
4476 LIBS="$LIBS -framework CoreFoundation"
4477fi
4478
4479
4480AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4481AC_RUN_IFELSE([AC_LANG_SOURCE([[
4482#include <stdio.h>
4483#include <stddef.h>
4484#include <string.h>
4485
4486#ifdef HAVE_SYS_TYPES_H
4487#include <sys/types.h>
4488#endif
4489
4490#ifdef HAVE_SSIZE_T
4491typedef ssize_t Py_ssize_t;
4492#elif SIZEOF_VOID_P == SIZEOF_LONG
4493typedef long Py_ssize_t;
4494#else
4495typedef int Py_ssize_t;
4496#endif
4497
4498int main()
4499{
4500 char buffer[256];
4501
4502 if(sprintf(buffer, "%zd", (size_t)123) < 0)
4503 return 1;
4504
4505 if (strcmp(buffer, "123"))
4506 return 1;
4507
4508 if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4509 return 1;
4510
4511 if (strcmp(buffer, "-123"))
4512 return 1;
4513
4514 return 0;
4515}
4516]])],
4517[ac_cv_have_size_t_format=yes],
4518[ac_cv_have_size_t_format=no],
4519[ac_cv_have_size_t_format="cross -- assuming yes"
4520])])
4521if test "$ac_cv_have_size_t_format" != no ; then
4522 AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4523 [Define to printf format modifier for Py_ssize_t])
4524fi
4525
4526AC_CHECK_TYPE(socklen_t,,
4527 AC_DEFINE(socklen_t,int,
4528 [Define to `int' if <sys/socket.h> does not define.]),[
4529#ifdef HAVE_SYS_TYPES_H
4530#include <sys/types.h>
4531#endif
4532#ifdef HAVE_SYS_SOCKET_H
4533#include <sys/socket.h>
4534#endif
4535#ifdef __OS2__
4536#include <libcx/net.h>
4537#endif
4538])
4539
4540case $ac_sys_system in
4541AIX*)
4542 AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4543esac
4544
4545case $host_os in
4546os2-emx)
4547 AC_DEFINE(PYOS_OS2, 1, [Define to 1 when building on OS/2.])
4548 AC_DEFINE(PYCC_GCC, 1, [Define to 1 when building on OS/2 with GCC.])
4549 ;;
4550esac
4551
4552AC_SUBST(THREADHEADERS)
4553
4554for h in `(cd $srcdir;echo Python/thread_*.h)`
4555do
4556 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4557done
4558
4559AC_SUBST(SRCDIRS)
4560SRCDIRS="Parser Grammar Objects Python Modules Mac"
4561AC_MSG_CHECKING(for build directories)
4562for dir in $SRCDIRS; do
4563 if test ! -d $dir; then
4564 mkdir $dir
4565 fi
4566done
4567AC_MSG_RESULT(done)
4568
4569# generate output files
4570AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
4571AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])
4572AC_OUTPUT
4573
4574echo "creating Modules/Setup"
4575if test ! -f Modules/Setup
4576then
4577 cp $srcdir/Modules/Setup.dist Modules/Setup
4578fi
4579
4580echo "creating Modules/Setup.local"
4581if test ! -f Modules/Setup.local
4582then
4583 echo "# Edit this file for local setup changes" >Modules/Setup.local
4584fi
4585
4586echo "creating Makefile"
4587$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4588 -s Modules Modules/Setup.config \
4589 Modules/Setup.local Modules/Setup
4590
4591case $ac_sys_system in
4592BeOS)
4593 AC_MSG_WARN([
4594
4595 Support for BeOS is deprecated as of Python 2.6.
4596 See PEP 11 for the gory details.
4597 ])
4598 ;;
4599*) ;;
4600esac
4601
4602mv config.c Modules
Note: See TracBrowser for help on using the repository browser.