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