Refined section on logging to one file from multiple processes.
[python.git] / configure.in
blob77bf364862aaece61e26bf0a7215d3f4a7ec9804
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 ARCH_RUN_32BIT=
113 AC_SUBST(ARCH_RUN_32BIT)
115 UNIVERSAL_ARCHS="32-bit"
116 AC_MSG_CHECKING(for --with-universal-archs)
117 AC_ARG_WITH(universal-archs,
118     AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit" or "all")),
120         AC_MSG_RESULT($withval)
121         UNIVERSAL_ARCHS="$withval"
124         AC_MSG_RESULT(32-bit)
129 AC_ARG_WITH(framework-name,
130               AC_HELP_STRING(--with-framework-name=FRAMEWORK, 
131                              specify an alternate name of the framework built with --enable-framework),
133     PYTHONFRAMEWORK=${withval}
134     PYTHONFRAMEWORKDIR=${withval}.framework
135     PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
136     ],[
137     PYTHONFRAMEWORK=Python
138     PYTHONFRAMEWORKDIR=Python.framework
139     PYTHONFRAMEWORKIDENTIFIER=org.python.python
141 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
142 AC_ARG_ENABLE(framework,
143               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
145         case $enableval in
146         yes) 
147                 enableval=/Library/Frameworks
148         esac
149         case $enableval in
150         no)
151                 PYTHONFRAMEWORK=
152                 PYTHONFRAMEWORKDIR=no-framework
153                 PYTHONFRAMEWORKPREFIX=
154                 PYTHONFRAMEWORKINSTALLDIR=
155                 FRAMEWORKINSTALLFIRST=
156                 FRAMEWORKINSTALLLAST=
157                 FRAMEWORKALTINSTALLFIRST=
158                 FRAMEWORKALTINSTALLLAST=
159                 if test "x${prefix}" = "xNONE"; then
160                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
161                 else
162                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
163                 fi
164                 enable_framework=
165                 ;;
166         *)
167                 PYTHONFRAMEWORKPREFIX=$enableval
168                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
169                 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
170                 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
171                 if test "$UNIVERSAL_ARCHS" = "all"
172                 then
173                         FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkinstallunixtools4way"
174                         FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkaltinstallunixtools4way"
175                 else
176                         FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
177                         FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
178                 fi
180                 if test "x${prefix}" = "xNONE" ; then
181                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
182                 else
183                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
184                 fi
185                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
187                 # Add files for Mac specific code to the list of output
188                 # files:
189                 AC_CONFIG_FILES(Mac/Makefile)
190                 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
191                 AC_CONFIG_FILES(Mac/IDLE/Makefile)
192                 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
193                 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
194         esac
195         ],[
196         PYTHONFRAMEWORK=
197         PYTHONFRAMEWORKDIR=no-framework
198         PYTHONFRAMEWORKPREFIX=
199         PYTHONFRAMEWORKINSTALLDIR=
200         FRAMEWORKINSTALLFIRST=
201         FRAMEWORKINSTALLLAST=
202         FRAMEWORKALTINSTALLFIRST=
203         FRAMEWORKALTINSTALLLAST=
204         if test "x${prefix}" = "xNONE" ; then
205                 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
206         else
207                 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
208         fi
209         enable_framework=
211         if test "$UNIVERSAL_ARCHS" = "all" 
212         then
213                 FRAMEWORKINSTALLLAST=update4wayuniversal
214                 FRAMEWORKALTINSTALLLAST=update4wayuniversal
215         fi
217 AC_SUBST(PYTHONFRAMEWORK)
218 AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
219 AC_SUBST(PYTHONFRAMEWORKDIR)
220 AC_SUBST(PYTHONFRAMEWORKPREFIX)
221 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
222 AC_SUBST(FRAMEWORKINSTALLFIRST)
223 AC_SUBST(FRAMEWORKINSTALLLAST)
224 AC_SUBST(FRAMEWORKALTINSTALLFIRST)
225 AC_SUBST(FRAMEWORKALTINSTALLLAST)
226 AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
228 ##AC_ARG_WITH(dyld,
229 ##            AC_HELP_STRING(--with-dyld,
230 ##                           Use (OpenStep|Rhapsody) dynamic linker))
232 # Set name for machine-dependent library files
233 AC_SUBST(MACHDEP)
234 AC_MSG_CHECKING(MACHDEP)
235 if test -z "$MACHDEP"
236 then
237         ac_sys_system=`uname -s`
238         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
239         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
240                 ac_sys_release=`uname -v`
241         else
242                 ac_sys_release=`uname -r`
243         fi
244         ac_md_system=`echo $ac_sys_system |
245                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
246         ac_md_release=`echo $ac_sys_release |
247                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
248         MACHDEP="$ac_md_system$ac_md_release"
250         case $MACHDEP in
251         cygwin*) MACHDEP="cygwin";;
252         darwin*) MACHDEP="darwin";;
253         atheos*) MACHDEP="atheos";;
254         irix646) MACHDEP="irix6";;
255         '')     MACHDEP="unknown";;
256         esac
258         
259 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
260 # disable features if it is defined, without any means to access these
261 # features as extensions. For these systems, we skip the definition of
262 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
263 # some feature, make sure there is no alternative way to access this
264 # feature. Also, when using wildcards, make sure you have verified the
265 # need for not defining _XOPEN_SOURCE on all systems matching the
266 # wildcard, and that the wildcard does not include future systems
267 # (which may remove their limitations).
268 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
269 case $ac_sys_system/$ac_sys_release in
270   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
271   # even though select is a POSIX function. Reported by J. Ribbens.
272   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
273   OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123@:>@) 
274     define_xopen_source=no
275     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
276     # also defined. This can be overridden by defining _BSD_SOURCE
277     # As this has a different meaning on Linux, only define it on OpenBSD
278     AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
279     ;;
280   # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
281   # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
282   # Marc Recht
283   NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
284     define_xopen_source=no;;
285   # On Solaris 2.6, sys/wait.h is inconsistent in the usage
286   # of union __?sigval. Reported by Stuart Bishop.
287   SunOS/5.6)
288     define_xopen_source=no;;
289   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
290   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
291   # Reconfirmed for 7.1.4 by Martin v. Loewis.
292   OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
293     define_xopen_source=no;;
294   # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
295   # but used in struct sockaddr.sa_family. Reported by Tim Rice.
296   SCO_SV/3.2)
297     define_xopen_source=no;;
298   # On FreeBSD 4, the math functions C89 does not cover are never defined
299   # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
300   FreeBSD/4.*)
301     define_xopen_source=no;;
302   # On MacOS X 10.2, a bug in ncurses.h means that it craps out if 
303   # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
304   # identifies itself as Darwin/7.*
305   # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
306   # disables platform specific features beyond repair.
307   # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE 
308   # has no effect, don't bother defining them
309   Darwin/@<:@6789@:>@.*)
310     define_xopen_source=no;;
311   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
312   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
313   # or has another value. By not (re)defining it, the defaults come in place.
314   AIX/4)
315     define_xopen_source=no;;
316   AIX/5)
317     if test `uname -r` -eq 1; then
318       define_xopen_source=no
319     fi
320     ;;
321   # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
322   # defining NI_NUMERICHOST.
323   QNX/6.3.2)
324     define_xopen_source=no
325     ;;
327 esac
329 if test $define_xopen_source = yes
330 then
331   # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
332   # defined precisely as g++ defines it
333   # Furthermore, on Solaris 10, XPG6 requires the use of a C99
334   # compiler
335   case $ac_sys_system/$ac_sys_release in
336     SunOS/5.8|SunOS/5.9|SunOS/5.10)
337       AC_DEFINE(_XOPEN_SOURCE, 500, 
338                 Define to the level of X/Open that your system supports)
339       ;;
340     *)
341       AC_DEFINE(_XOPEN_SOURCE, 600, 
342                 Define to the level of X/Open that your system supports)
343       ;;
344   esac
346   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
347   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
348   # several APIs are not declared. Since this is also needed in some
349   # cases for HP-UX, we define it globally.
350   # except for Solaris 10, where it must not be defined, 
351   # as it implies XPG4.2
352   case $ac_sys_system/$ac_sys_release in
353     SunOS/5.10)
354       ;;
355     *)
356       AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
357                 Define to activate Unix95-and-earlier features)
358       ;;
359   esac
361   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
362   
366 # SGI compilers allow the specification of the both the ABI and the
367 # ISA on the command line.  Depending on the values of these switches,
368 # different and often incompatable code will be generated.
370 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
371 # thus supply support for various ABI/ISA combinations.  The MACHDEP
372 # variable is also adjusted.
374 AC_SUBST(SGI_ABI)
375 if test ! -z "$SGI_ABI"
376 then
377         CC="cc $SGI_ABI"
378         LDFLAGS="$SGI_ABI $LDFLAGS"
379         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
381 AC_MSG_RESULT($MACHDEP)
383 # And add extra plat-mac for darwin
384 AC_SUBST(EXTRAPLATDIR)
385 AC_SUBST(EXTRAMACHDEPPATH)
386 AC_MSG_CHECKING(EXTRAPLATDIR)
387 if test -z "$EXTRAPLATDIR"
388 then
389         case $MACHDEP in
390         darwin) 
391                 EXTRAPLATDIR="\$(PLATMACDIRS)"
392                 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
393                 ;;
394         *) 
395                 EXTRAPLATDIR=""
396                 EXTRAMACHDEPPATH=""
397                 ;;
398         esac
400 AC_MSG_RESULT($EXTRAPLATDIR)
402 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
403 # it may influence the way we can build extensions, so distutils
404 # needs to check it
405 AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
406 AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
407 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
408 EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
410 AC_MSG_CHECKING(machine type as reported by uname -m)
411 ac_sys_machine=`uname -m`
412 AC_MSG_RESULT($ac_sys_machine)
414 # checks for alternative programs
416 # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
417 # for debug/optimization stuff.  BASECFLAGS is for flags that are required
418 # just to get things to compile and link.  Users are free to override OPT
419 # when running configure or make.  The build should not break if they do.
420 # BASECFLAGS should generally not be messed with, however.
422 # XXX shouldn't some/most/all of this code be merged with the stuff later
423 # on that fiddles with OPT and BASECFLAGS?
424 AC_MSG_CHECKING(for --without-gcc)
425 AC_ARG_WITH(gcc,
426             AC_HELP_STRING(--without-gcc,never use gcc),
428         case $withval in
429         no)     CC=${CC:-cc}
430                 without_gcc=yes;;
431         yes)    CC=gcc
432                 without_gcc=no;;
433         *)      CC=$withval
434                 without_gcc=$withval;;
435         esac], [
436         case $ac_sys_system in
437         AIX*)   CC=cc_r
438                 without_gcc=;;
439         BeOS*)
440                 case $BE_HOST_CPU in
441                 ppc)
442                         CC=mwcc
443                         without_gcc=yes
444                         BASECFLAGS="$BASECFLAGS -export pragma"
445                         OPT="$OPT -O"
446                         LDFLAGS="$LDFLAGS -nodup"
447                         ;;
448                 x86)
449                         CC=gcc
450                         without_gcc=no
451                         OPT="$OPT -O"
452                         ;;
453                 *)
454                         AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
455                         ;;
456                 esac
457                 AR="\$(srcdir)/Modules/ar_beos"
458                 RANLIB=:
459                 ;;
460     Monterey*)
461         RANLIB=:
462         without_gcc=;;
463         *)      without_gcc=no;;
464         esac])
465 AC_MSG_RESULT($without_gcc)
467 # If the user switches compilers, we can't believe the cache
468 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
469 then
470   AC_MSG_ERROR([cached CC is different -- throw away $cache_file
471 (it is also a good idea to do 'make clean' before compiling)])
474 AC_PROG_CC
476 AC_SUBST(CXX)
477 AC_SUBST(MAINCC)
478 AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
479 AC_ARG_WITH(cxx_main,
480             AC_HELP_STRING([--with-cxx-main=<compiler>],
481                            [compile main() and link python executable with C++ compiler]),
483         
484         case $withval in
485         no)     with_cxx_main=no
486                 MAINCC='$(CC)';;
487         yes)    with_cxx_main=yes
488                 MAINCC='$(CXX)';;
489         *)      with_cxx_main=yes
490                 MAINCC=$withval
491                 if test -z "$CXX"
492                 then
493                         CXX=$withval
494                 fi;;
495         esac], [
496         with_cxx_main=no
497         MAINCC='$(CC)'
499 AC_MSG_RESULT($with_cxx_main)
501 preset_cxx="$CXX"
502 if test -z "$CXX"
503 then
504         case "$CC" in
505         gcc)    AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
506         cc)     AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
507         esac
508         if test "$CXX" = "notfound"
509         then
510                 CXX=""
511         fi
513 if test -z "$CXX"
514 then
515         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
516         if test "$CXX" = "notfound"
517         then
518                 CXX=""
519         fi
521 if test "$preset_cxx" != "$CXX"
522 then
523         AC_MSG_WARN([
525   By default, distutils will build C++ extension modules with "$CXX".
526   If this is not intended, then set CXX on the configure command line.
527   ])
531 # checks for UNIX variants that set C preprocessor variables
532 AC_AIX
534 # Check for unsupported systems
535 case $ac_sys_system/$ac_sys_release in
536 atheos*|Linux*/1*)
537    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
538    echo See README for details.
539    exit 1;;
540 esac
542 AC_EXEEXT
543 AC_MSG_CHECKING(for --with-suffix)
544 AC_ARG_WITH(suffix,
545             AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
547         case $withval in
548         no)     EXEEXT=;;
549         yes)    EXEEXT=.exe;;
550         *)      EXEEXT=$withval;;
551         esac])
552 AC_MSG_RESULT($EXEEXT)
554 # Test whether we're running on a non-case-sensitive system, in which
555 # case we give a warning if no ext is given
556 AC_SUBST(BUILDEXEEXT)
557 AC_MSG_CHECKING(for case-insensitive build directory)
558 if test ! -d CaseSensitiveTestDir; then
559 mkdir CaseSensitiveTestDir
562 if test -d casesensitivetestdir
563 then
564     AC_MSG_RESULT(yes)
565     BUILDEXEEXT=.exe
566 else
567         AC_MSG_RESULT(no)
568         BUILDEXEEXT=$EXEEXT
570 rmdir CaseSensitiveTestDir
572 case $MACHDEP in
573 bsdos*)
574     case $CC in
575     gcc) CC="$CC -D_HAVE_BSDI";;
576     esac;;
577 esac
579 case $ac_sys_system in
580 hp*|HP*)
581     case $CC in
582     cc|*/cc) CC="$CC -Ae";;
583     esac;;
584 Monterey*)
585     case $CC in
586     cc) CC="$CC -Wl,-Bexport";;
587     esac;;
588 SunOS*)
589     # Some functions have a prototype only with that define, e.g. confstr
590     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
591     ;;
592 esac
595 AC_SUBST(LIBRARY)
596 AC_MSG_CHECKING(LIBRARY)
597 if test -z "$LIBRARY"
598 then
599         LIBRARY='libpython$(VERSION).a'
601 AC_MSG_RESULT($LIBRARY)
603 # LDLIBRARY is the name of the library to link against (as opposed to the
604 # name of the library into which to insert object files). BLDLIBRARY is also
605 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
606 # is blank as the main program is not linked directly against LDLIBRARY.
607 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
608 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
609 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
610 # DLLLIBRARY is the shared (i.e., DLL) library.
612 # RUNSHARED is used to run shared python without installed libraries
614 # INSTSONAME is the name of the shared library that will be use to install
615 # on the system - some systems like version suffix, others don't
616 AC_SUBST(LDLIBRARY)
617 AC_SUBST(DLLLIBRARY)
618 AC_SUBST(BLDLIBRARY)
619 AC_SUBST(LDLIBRARYDIR)
620 AC_SUBST(INSTSONAME)
621 AC_SUBST(RUNSHARED)
622 LDLIBRARY="$LIBRARY"
623 BLDLIBRARY='$(LDLIBRARY)'
624 INSTSONAME='$(LDLIBRARY)'
625 DLLLIBRARY=''
626 LDLIBRARYDIR=''
627 RUNSHARED=''
629 # LINKCC is the command that links the python executable -- default is $(CC).
630 # If CXX is set, and if it is needed to link a main function that was
631 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
632 # python might then depend on the C++ runtime
633 # This is altered for AIX in order to build the export list before 
634 # linking.
635 AC_SUBST(LINKCC)
636 AC_MSG_CHECKING(LINKCC)
637 if test -z "$LINKCC"
638 then
639         LINKCC='$(PURIFY) $(MAINCC)'
640         case $ac_sys_system in
641         AIX*)
642            exp_extra="\"\""
643            if test $ac_sys_release -ge 5 -o \
644                    $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
645                exp_extra="."
646            fi
647            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
648         Monterey64*)
649            LINKCC="$LINKCC -L/usr/lib/ia64l64";;
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
904     # The current (beta) Monterey compiler dies with optimizations
905     # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
906     case $ac_sys_system in
907         Monterey*)
908             OPT=""
909             ;;
910     esac
914 AC_SUBST(BASECFLAGS)
916 # The -arch flags for universal builds on OSX
917 UNIVERSAL_ARCH_FLAGS=
918 AC_SUBST(UNIVERSAL_ARCH_FLAGS)
920 # tweak BASECFLAGS based on compiler and platform
921 case $GCC in
922 yes)
923     # Python violates C99 rules, by casting between incompatible
924     # pointer types. GCC may generate bad code as a result of that,
925     # so use -fno-strict-aliasing if supported.
926     AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
927      ac_save_cc="$CC"
928      CC="$CC -fno-strict-aliasing"
929      AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
930      AC_TRY_RUN([int main() { return 0; }],
931      ac_cv_no_strict_aliasing_ok=yes,
932      ac_cv_no_strict_aliasing_ok=no,
933      ac_cv_no_strict_aliasing_ok=no))
934      CC="$ac_save_cc"
935     AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
936     if test $ac_cv_no_strict_aliasing_ok = yes
937     then
938       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
939     fi
941     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
942     # support.  Without this, treatment of subnormals doesn't follow
943     # the standard.
944     case $ac_sys_machine in
945          alpha*)
946                 BASECFLAGS="$BASECFLAGS -mieee"
947                 ;;
948     esac
950     case $ac_sys_system in
951         SCO_SV*)
952             BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
953             ;;
954         # is there any other compiler on Darwin besides gcc?
955         Darwin*)
956             # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
957             # used to be here, but non-Apple gcc doesn't accept them.
960             if test "${enable_universalsdk}"; then
961                 UNIVERSAL_ARCH_FLAGS=""
962                 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
963                    UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
964                    ARCH_RUN_32BIT=""
966                  elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
967                    UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
969                  elif test "$UNIVERSAL_ARCHS" = "all" ; then
970                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
971                    ARCH_RUN_32BIT="arch -i386 -ppc"
973                  else
974                    AC_MSG_ERROR([proper usage is --with-universalarch=32-bit|64-bit|all])
976                  fi
979                 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
980                 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
981                 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
982                         CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
983                 fi
984             fi
986             # Calculate the right deployment target for this build.
987             #
988             cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
989             if test ${cur_target} '>' 10.2; then
990                     cur_target=10.3
991             fi
992             if test "${UNIVERSAL_ARCHS}" = "all"; then
993                     # Ensure that the default platform for a 4-way
994                     # universal build is OSX 10.5, that's the first
995                     # OS release where 4-way builds make sense.
996                     cur_target='10.5'
997             fi
998             CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
999             
1000             # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
1001             # environment with a value that is the same as what we'll use
1002             # in the Makefile to ensure that we'll get the same compiler
1003             # environment during configure and build time.
1004             MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1005             export MACOSX_DEPLOYMENT_TARGET
1006             EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1008             ;;
1009         OSF*)
1010             BASECFLAGS="$BASECFLAGS -mieee"
1011             ;;
1012     esac
1013     ;;
1016     case $ac_sys_system in
1017     OpenUNIX*|UnixWare*)
1018         BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1019         ;;
1020     OSF*)
1021         BASECFLAGS="$BASECFLAGS -ieee -std"
1022         ;;
1023     SCO_SV*)
1024         BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1025         ;;
1026     esac
1027     ;;
1028 esac
1030 if test "$Py_DEBUG" = 'true'; then
1031   :
1032 else
1033   OPT="-DNDEBUG $OPT"
1036 if test "$ac_arch_flags"
1037 then
1038         BASECFLAGS="$BASECFLAGS $ac_arch_flags"
1041 # disable check for icc since it seems to pass, but generates a warning
1042 if test "$CC" = icc
1043 then
1044   ac_cv_opt_olimit_ok=no
1047 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1048 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1049 [ac_save_cc="$CC"
1050 CC="$CC -OPT:Olimit=0"
1051 AC_TRY_RUN([int main() { return 0; }],
1052   ac_cv_opt_olimit_ok=yes,
1053   ac_cv_opt_olimit_ok=no,
1054   ac_cv_opt_olimit_ok=no)
1055 CC="$ac_save_cc"])
1056 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
1057 if test $ac_cv_opt_olimit_ok = yes; then
1058     case $ac_sys_system in
1059         # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1060         # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
1061         # environment?
1062         Darwin*)
1063             ;;
1064         *)
1065             BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1066             ;;
1067     esac
1068 else
1069   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1070   AC_CACHE_VAL(ac_cv_olimit_ok,
1071   [ac_save_cc="$CC"
1072   CC="$CC -Olimit 1500"
1073   AC_TRY_RUN([int main() { return 0; }],
1074     ac_cv_olimit_ok=yes,
1075     ac_cv_olimit_ok=no,
1076     ac_cv_olimit_ok=no)
1077   CC="$ac_save_cc"])
1078   AC_MSG_RESULT($ac_cv_olimit_ok)
1079   if test $ac_cv_olimit_ok = yes; then
1080     BASECFLAGS="$BASECFLAGS -Olimit 1500"
1081   fi
1084 # Check whether GCC supports PyArg_ParseTuple format
1085 if test "$GCC" = "yes"
1086 then
1087   AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1088   save_CFLAGS=$CFLAGS
1089   CFLAGS="$CFLAGS -Werror"
1090   AC_TRY_COMPILE([
1091     void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1092   ],,
1093   AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1094   AC_MSG_RESULT(yes),
1095   AC_MSG_RESULT(no)
1096   )
1097   CFLAGS=$save_CFLAGS
1100 # On some compilers, pthreads are available without further options
1101 # (e.g. MacOS X). On some of these systems, the compiler will not
1102 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1103 # So we have to see first whether pthreads are available without
1104 # options before we can check whether -Kpthread improves anything.
1105 AC_MSG_CHECKING(whether pthreads are available without options)
1106 AC_CACHE_VAL(ac_cv_pthread_is_default,
1107 [AC_TRY_RUN([
1108 #include <pthread.h>
1110 void* routine(void* p){return NULL;}
1112 int main(){
1113   pthread_t p;
1114   if(pthread_create(&p,NULL,routine,NULL)!=0)
1115     return 1;
1116   (void)pthread_detach(p);
1117   return 0;
1121   ac_cv_pthread_is_default=yes
1122   ac_cv_kthread=no
1123   ac_cv_pthread=no
1125   ac_cv_pthread_is_default=no,
1126   ac_cv_pthread_is_default=no)
1128 AC_MSG_RESULT($ac_cv_pthread_is_default)
1131 if test $ac_cv_pthread_is_default = yes 
1132 then
1133   ac_cv_kpthread=no
1134 else
1135 # -Kpthread, if available, provides the right #defines
1136 # and linker options to make pthread_create available
1137 # Some compilers won't report that they do not support -Kpthread,
1138 # so we need to run a program to see whether it really made the
1139 # function available.
1140 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1141 AC_CACHE_VAL(ac_cv_kpthread,
1142 [ac_save_cc="$CC"
1143 CC="$CC -Kpthread"
1144 AC_TRY_RUN([
1145 #include <pthread.h>
1147 void* routine(void* p){return NULL;}
1149 int main(){
1150   pthread_t p;
1151   if(pthread_create(&p,NULL,routine,NULL)!=0)
1152     return 1;
1153   (void)pthread_detach(p);
1154   return 0;
1157   ac_cv_kpthread=yes,
1158   ac_cv_kpthread=no,
1159   ac_cv_kpthread=no)
1160 CC="$ac_save_cc"])
1161 AC_MSG_RESULT($ac_cv_kpthread)
1164 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
1165 then
1166 # -Kthread, if available, provides the right #defines
1167 # and linker options to make pthread_create available
1168 # Some compilers won't report that they do not support -Kthread,
1169 # so we need to run a program to see whether it really made the
1170 # function available.
1171 AC_MSG_CHECKING(whether $CC accepts -Kthread)
1172 AC_CACHE_VAL(ac_cv_kthread,
1173 [ac_save_cc="$CC"
1174 CC="$CC -Kthread"
1175 AC_TRY_RUN([
1176 #include <pthread.h>
1178 void* routine(void* p){return NULL;}
1180 int main(){
1181   pthread_t p;
1182   if(pthread_create(&p,NULL,routine,NULL)!=0)
1183     return 1;
1184   (void)pthread_detach(p);
1185   return 0;
1188   ac_cv_kthread=yes,
1189   ac_cv_kthread=no,
1190   ac_cv_kthread=no)
1191 CC="$ac_save_cc"])
1192 AC_MSG_RESULT($ac_cv_kthread)
1195 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
1196 then
1197 # -pthread, if available, provides the right #defines
1198 # and linker options to make pthread_create available
1199 # Some compilers won't report that they do not support -pthread,
1200 # so we need to run a program to see whether it really made the
1201 # function available.
1202 AC_MSG_CHECKING(whether $CC accepts -pthread)
1203 AC_CACHE_VAL(ac_cv_thread,
1204 [ac_save_cc="$CC"
1205 CC="$CC -pthread"
1206 AC_TRY_RUN([
1207 #include <pthread.h>
1209 void* routine(void* p){return NULL;}
1211 int main(){
1212   pthread_t p;
1213   if(pthread_create(&p,NULL,routine,NULL)!=0)
1214     return 1;
1215   (void)pthread_detach(p);
1216   return 0;
1219   ac_cv_pthread=yes,
1220   ac_cv_pthread=no,
1221   ac_cv_pthread=no)
1222 CC="$ac_save_cc"])
1223 AC_MSG_RESULT($ac_cv_pthread)
1226 # If we have set a CC compiler flag for thread support then
1227 # check if it works for CXX, too.
1228 ac_cv_cxx_thread=no
1229 if test ! -z "$CXX"
1230 then
1231 AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1232 ac_save_cxx="$CXX"
1234 if test "$ac_cv_kpthread" = "yes"
1235 then
1236   CXX="$CXX -Kpthread"  
1237   ac_cv_cxx_thread=yes
1238 elif test "$ac_cv_kthread" = "yes"
1239 then
1240   CXX="$CXX -Kthread"
1241   ac_cv_cxx_thread=yes
1242 elif test "$ac_cv_pthread" = "yes"
1243 then 
1244   CXX="$CXX -pthread"
1245   ac_cv_cxx_thread=yes
1248 if test $ac_cv_cxx_thread = yes
1249 then
1250   echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1251   $CXX -c conftest.$ac_ext 2>&5
1252   if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1253      && test -s conftest$ac_exeext && ./conftest$ac_exeext
1254   then
1255     ac_cv_cxx_thread=yes
1256   else
1257     ac_cv_cxx_thread=no
1258   fi
1259   rm -fr conftest*
1261 AC_MSG_RESULT($ac_cv_cxx_thread)
1263 CXX="$ac_save_cxx"
1265 dnl # check for ANSI or K&R ("traditional") preprocessor
1266 dnl AC_MSG_CHECKING(for C preprocessor type)
1267 dnl AC_TRY_COMPILE([
1268 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1269 dnl int foo;
1270 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1271 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1272 dnl AC_MSG_RESULT($cpp_type)
1274 # checks for header files
1275 AC_HEADER_STDC
1276 AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1277 fcntl.h grp.h \
1278 ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
1279 shadow.h signal.h stdint.h stropts.h termios.h thread.h \
1280 unistd.h utime.h \
1281 sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1282 sys/lock.h sys/mkdev.h sys/modem.h \
1283 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
1284 sys/termio.h sys/time.h \
1285 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
1286 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
1287 bluetooth/bluetooth.h linux/tipc.h)
1288 AC_HEADER_DIRENT
1289 AC_HEADER_MAJOR
1291 # On Solaris, term.h requires curses.h
1292 AC_CHECK_HEADERS(term.h,,,[
1293 #ifdef HAVE_CURSES_H
1294 #include <curses.h>
1295 #endif
1298 # On Linux, netlink.h requires asm/types.h
1299 AC_CHECK_HEADERS(linux/netlink.h,,,[
1300 #ifdef HAVE_ASM_TYPES_H
1301 #include <asm/types.h>
1302 #endif
1303 #ifdef HAVE_SYS_SOCKET_H
1304 #include <sys/socket.h>
1305 #endif
1308 # checks for typedefs
1309 was_it_defined=no
1310 AC_MSG_CHECKING(for clock_t in time.h)
1311 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1312     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1314 AC_MSG_RESULT($was_it_defined)
1316 # Check whether using makedev requires defining _OSF_SOURCE
1317 AC_MSG_CHECKING(for makedev)
1318 AC_TRY_LINK([#include <sys/types.h> ],
1319             [ makedev(0, 0) ],
1320             ac_cv_has_makedev=yes,
1321             ac_cv_has_makedev=no)
1322 if test "$ac_cv_has_makedev" = "no"; then
1323     # we didn't link, try if _OSF_SOURCE will allow us to link
1324     AC_TRY_LINK([
1325 #define _OSF_SOURCE 1
1326 #include <sys/types.h>
1327     ],
1328     [ makedev(0, 0) ],
1329     ac_cv_has_makedev=yes,
1330     ac_cv_has_makedev=no)
1331     if test "$ac_cv_has_makedev" = "yes"; then
1332         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1333     fi
1335 AC_MSG_RESULT($ac_cv_has_makedev)
1336 if test "$ac_cv_has_makedev" = "yes"; then
1337     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1340 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1341 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1342 # defined, but the compiler does not support pragma redefine_extname,
1343 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1344 # structures (such as rlimit64) without declaring them. As a
1345 # work-around, disable LFS on such configurations
1347 use_lfs=yes
1348 AC_MSG_CHECKING(Solaris LFS bug)
1349 AC_TRY_COMPILE([
1350 #define _LARGEFILE_SOURCE 1
1351 #define _FILE_OFFSET_BITS 64
1352 #include <sys/resource.h>
1353 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1354 AC_MSG_RESULT($sol_lfs_bug)
1355 if test "$sol_lfs_bug" = "yes"; then
1356   use_lfs=no
1359 if test "$use_lfs" = "yes"; then
1360 # Two defines needed to enable largefile support on various platforms
1361 # These may affect some typedefs
1362 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
1363 [This must be defined on some systems to enable large file support.])
1364 AC_DEFINE(_FILE_OFFSET_BITS, 64,
1365 [This must be set to 64 on some systems to enable large file support.])
1368 # Add some code to confdefs.h so that the test for off_t works on SCO
1369 cat >> confdefs.h <<\EOF
1370 #if defined(SCO_DS)
1371 #undef _OFF_T
1372 #endif
1375 # Type availability checks
1376 AC_TYPE_MODE_T
1377 AC_TYPE_OFF_T
1378 AC_TYPE_PID_T
1379 AC_TYPE_SIGNAL
1380 AC_TYPE_SIZE_T
1381 AC_TYPE_UID_T
1382 AC_TYPE_UINT32_T
1383 AC_TYPE_UINT64_T
1384 AC_TYPE_INT32_T
1385 AC_TYPE_INT64_T
1386 AC_CHECK_TYPE(ssize_t,
1387   AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
1389 # Sizes of various common basic types
1390 # ANSI C requires sizeof(char) == 1, so no need to check it
1391 AC_CHECK_SIZEOF(int, 4)
1392 AC_CHECK_SIZEOF(long, 4)
1393 AC_CHECK_SIZEOF(void *, 4)
1394 AC_CHECK_SIZEOF(short, 2)
1395 AC_CHECK_SIZEOF(float, 4)
1396 AC_CHECK_SIZEOF(double, 8)
1397 AC_CHECK_SIZEOF(fpos_t, 4)
1398 AC_CHECK_SIZEOF(size_t, 4)
1399 AC_CHECK_SIZEOF(pid_t, 4)
1401 AC_MSG_CHECKING(for long long support)
1402 have_long_long=no
1403 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1404   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
1405   have_long_long=yes
1407 AC_MSG_RESULT($have_long_long)
1408 if test "$have_long_long" = yes ; then
1409 AC_CHECK_SIZEOF(long long, 8)
1412 AC_MSG_CHECKING(for long double support)
1413 have_long_double=no
1414 AC_TRY_COMPILE([], [long double x; x = (long double)0.;], [
1415   AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1416   have_long_double=yes
1418 AC_MSG_RESULT($have_long_double)
1419 if test "$have_long_double" = yes ; then
1420 AC_CHECK_SIZEOF(long double, 12)
1423 AC_MSG_CHECKING(for _Bool support)
1424 have_c99_bool=no
1425 AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1426   AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) 
1427   have_c99_bool=yes
1429 AC_MSG_RESULT($have_c99_bool)
1430 if test "$have_c99_bool" = yes ; then
1431 AC_CHECK_SIZEOF(_Bool, 1)
1434 AC_CHECK_TYPES(uintptr_t, 
1435    [AC_CHECK_SIZEOF(uintptr_t, 4)], 
1436    [], [#ifdef HAVE_STDINT_H
1437         #include <stdint.h>
1438         #endif])
1440 AC_CHECK_SIZEOF(off_t, [], [
1441 #ifdef HAVE_SYS_TYPES_H
1442 #include <sys/types.h>
1443 #endif
1446 AC_MSG_CHECKING(whether to enable large file support)
1447 if test "$have_long_long" = yes -a \
1448         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1449         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1450   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
1451   [Defined to enable large file support when an off_t is bigger than a long
1452    and long long is available and at least as big as an off_t. You may need
1453    to add some flags for configuration and compilation to enable this mode.
1454    (For Solaris and Linux, the necessary defines are already defined.)])
1455   AC_MSG_RESULT(yes)
1456 else
1457   AC_MSG_RESULT(no)
1460 AC_CHECK_SIZEOF(time_t, [], [
1461 #ifdef HAVE_SYS_TYPES_H
1462 #include <sys/types.h>
1463 #endif
1464 #ifdef HAVE_TIME_H
1465 #include <time.h>
1466 #endif
1469 # if have pthread_t then define SIZEOF_PTHREAD_T
1470 ac_save_cc="$CC"
1471 if test "$ac_cv_kpthread" = "yes"
1472 then CC="$CC -Kpthread"
1473 elif test "$ac_cv_kthread" = "yes"
1474 then CC="$CC -Kthread"
1475 elif test "$ac_cv_pthread" = "yes"
1476 then CC="$CC -pthread"
1478 AC_MSG_CHECKING(for pthread_t)
1479 have_pthread_t=no
1480 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
1481 AC_MSG_RESULT($have_pthread_t)
1482 if test "$have_pthread_t" = yes ; then
1483   AC_CHECK_SIZEOF(pthread_t, [], [
1484 #ifdef HAVE_PTHREAD_H
1485 #include <pthread.h>
1486 #endif
1487   ])
1489 CC="$ac_save_cc"
1491 AC_MSG_CHECKING(for --enable-toolbox-glue)
1492 AC_ARG_ENABLE(toolbox-glue,
1493               AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
1495 if test -z "$enable_toolbox_glue"
1496 then 
1497         case $ac_sys_system/$ac_sys_release in
1498         Darwin/*)
1499                 enable_toolbox_glue="yes";;
1500         *)
1501                 enable_toolbox_glue="no";;
1502         esac
1504 case "$enable_toolbox_glue" in
1505 yes)
1506         extra_machdep_objs="Python/mactoolboxglue.o"
1507         extra_undefs="-u _PyMac_Error"
1508         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1509          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1510         ;;
1512         extra_machdep_objs=""
1513         extra_undefs=""
1514         ;;
1515 esac
1516 AC_MSG_RESULT($enable_toolbox_glue)
1519 AC_SUBST(OTHER_LIBTOOL_OPT)
1520 case $ac_sys_system/$ac_sys_release in
1521   Darwin/@<:@01567@:>@\..*) 
1522     OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1523     ;;
1524   Darwin/*)
1525     OTHER_LIBTOOL_OPT=""
1526     ;;
1527 esac
1529 AC_SUBST(LIBTOOL_CRUFT)
1530 case $ac_sys_system/$ac_sys_release in
1531   Darwin/@<:@01567@:>@\..*) 
1532     LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1533     if test "${enable_universalsdk}"; then
1534             :
1535     else
1536         LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
1537     fi
1538     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1539     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1540   Darwin/*)
1541     gcc_version=`gcc -v 2>&1 |  grep version | cut -d\  -f3`
1542     if test ${gcc_version} '<' 4.0
1543         then
1544             LIBTOOL_CRUFT="-lcc_dynamic"
1545         else 
1546             LIBTOOL_CRUFT=""
1547     fi
1548     LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only `arch`"
1549     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1550     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1551 esac
1553 AC_MSG_CHECKING(for --enable-framework)
1554 if test "$enable_framework"
1555 then
1556         BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1557         # -F. is needed to allow linking to the framework while 
1558         # in the build location.
1559         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
1560          [Define if you want to produce an OpenStep/Rhapsody framework
1561          (shared library plus accessory files).])
1562         AC_MSG_RESULT(yes)
1563         if test $enable_shared = "yes"
1564         then
1565                 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1566         fi
1567 else
1568         AC_MSG_RESULT(no)
1571 AC_MSG_CHECKING(for dyld)
1572 case $ac_sys_system/$ac_sys_release in
1573   Darwin/*)
1574         AC_DEFINE(WITH_DYLD, 1, 
1575         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1576          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1577          linker (rld). Dyld is necessary to support frameworks.])
1578         AC_MSG_RESULT(always on for Darwin)
1579         ;;
1580   *)
1581         AC_MSG_RESULT(no)
1582         ;;
1583 esac
1585 # Set info about shared libraries.
1586 AC_SUBST(SO)
1587 AC_SUBST(LDSHARED)
1588 AC_SUBST(BLDSHARED)
1589 AC_SUBST(CCSHARED)
1590 AC_SUBST(LINKFORSHARED)
1591 # SO is the extension of shared libraries `(including the dot!)
1592 # -- usually .so, .sl on HP-UX, .dll on Cygwin
1593 AC_MSG_CHECKING(SO)
1594 if test -z "$SO"
1595 then
1596         case $ac_sys_system in
1597         hp*|HP*)
1598                 case `uname -m` in
1599                         ia64) SO=.so;;
1600                         *)    SO=.sl;;
1601                 esac
1602                 ;;
1603         CYGWIN*)   SO=.dll;;
1604         *)         SO=.so;;
1605         esac
1606 else
1607         # this might also be a termcap variable, see #610332
1608         echo
1609         echo '====================================================================='
1610         echo '+                                                                   +'
1611         echo '+ WARNING: You have set SO in your environment.                     +'
1612         echo '+ Do you really mean to change the extension for shared libraries?  +'
1613         echo '+ Continuing in 10 seconds to let you to ponder.                    +'
1614         echo '+                                                                   +'
1615         echo '====================================================================='
1616         sleep 10
1618 AC_MSG_RESULT($SO)
1620 AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
1621 # LDSHARED is the ld *command* used to create shared library
1622 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1623 # (Shared libraries in this instance are shared modules to be loaded into
1624 # Python, as opposed to building Python itself as a shared library.)
1625 AC_MSG_CHECKING(LDSHARED)
1626 if test -z "$LDSHARED"
1627 then
1628         case $ac_sys_system/$ac_sys_release in
1629         AIX*)
1630                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1631                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1632                 ;;
1633         BeOS*)
1634                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1635                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1636                 ;;
1637         IRIX/5*) LDSHARED="ld -shared";;
1638         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1639         SunOS/5*) 
1640                 if test "$GCC" = "yes"
1641                 then LDSHARED='$(CC) -shared'
1642                 else LDSHARED='$(CC) -G';
1643                 fi ;;
1644         hp*|HP*)
1645                 if test "$GCC" = "yes"
1646                 then LDSHARED='$(CC) -shared'
1647                 else LDSHARED='ld -b';
1648                 fi ;;
1649         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1650         Darwin/1.3*)
1651                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1652                 if test "$enable_framework" ; then
1653                         # Link against the framework. All externals should be defined.
1654                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1655                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1656                 else
1657                         # No framework. Ignore undefined symbols, assuming they come from Python
1658                         LDSHARED="$LDSHARED -undefined suppress"
1659                 fi ;;
1660         Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1661                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1662                 if test "$enable_framework" ; then
1663                         # Link against the framework. All externals should be defined.
1664                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1665                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1666                 else
1667                         # No framework, use the Python app as bundle-loader
1668                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1669                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1670                 fi ;;
1671         Darwin/*)
1672                 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1673                 # This allows an extension to be used in any Python
1675                 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
1676                 then
1677                         if test "${enable_universalsdk}"; then
1678                                 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1679                         fi
1680                         LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1681                         BLDSHARED="$LDSHARED"
1682                 else
1683                         LDSHARED='$(CC) $(LDFLAGS) -bundle'
1684                         if test "$enable_framework" ; then
1685                                 # Link against the framework. All externals should be defined.
1686                                 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1687                                 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1688                         else
1689                                 # No framework, use the Python app as bundle-loader
1690                                 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1691                                 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1692                         fi
1693                 fi
1694                 ;;
1695         Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
1696         BSD/OS*/4*) LDSHARED="gcc -shared";;
1697         FreeBSD*)
1698                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1699                 then
1700                         LDSHARED="$CC -shared ${LDFLAGS}"
1701                 else
1702                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1703                 fi;;
1704         OpenBSD*)
1705                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1706                 then
1707                                 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1708                 else
1709                                 case `uname -r` in
1710                                 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1711                                    LDSHARED="ld -Bshareable ${LDFLAGS}"
1712                                    ;;
1713                                 *)
1714                                    LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1715                                    ;;
1716                                 esac
1717                 fi;;
1718         NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
1719         OpenUNIX*|UnixWare*)
1720                 if test "$GCC" = "yes"
1721                 then LDSHARED='$(CC) -shared'
1722                 else LDSHARED='$(CC) -G'
1723                 fi;;
1724         SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1725         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
1726         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1727         atheos*) LDSHARED="gcc -shared";;
1728         *)      LDSHARED="ld";;
1729         esac
1731 AC_MSG_RESULT($LDSHARED)
1732 BLDSHARED=${BLDSHARED-$LDSHARED}
1733 # CCSHARED are the C *flags* used to create objects to go into a shared
1734 # library (module) -- this is only needed for a few systems
1735 AC_MSG_CHECKING(CCSHARED)
1736 if test -z "$CCSHARED"
1737 then
1738         case $ac_sys_system/$ac_sys_release in
1739         SunOS*) if test "$GCC" = yes;
1740                 then CCSHARED="-fPIC";
1741                 elif test `uname -p` = sparc;
1742                 then CCSHARED="-xcode=pic32";
1743                 else CCSHARED="-Kpic";
1744                 fi;;
1745         hp*|HP*) if test "$GCC" = yes;
1746                  then CCSHARED="-fPIC";
1747                  else CCSHARED="+z";
1748                  fi;;
1749         Linux*|GNU*) CCSHARED="-fPIC";;
1750         BSD/OS*/4*) CCSHARED="-fpic";;
1751         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
1752         OpenUNIX*|UnixWare*)
1753                 if test "$GCC" = "yes"
1754                 then CCSHARED="-fPIC"
1755                 else CCSHARED="-KPIC"
1756                 fi;;
1757         SCO_SV*)
1758                 if test "$GCC" = "yes"
1759                 then CCSHARED="-fPIC"
1760                 else CCSHARED="-Kpic -belf"
1761                 fi;;
1762         Monterey*) CCSHARED="-G";;
1763         IRIX*/6*)  case $CC in
1764                    *gcc*) CCSHARED="-shared";;
1765                    *) CCSHARED="";;
1766                    esac;;
1767         atheos*) CCSHARED="-fPIC";;
1768         esac
1770 AC_MSG_RESULT($CCSHARED)
1771 # LINKFORSHARED are the flags passed to the $(CC) command that links
1772 # the python executable -- this is only needed for a few systems
1773 AC_MSG_CHECKING(LINKFORSHARED)
1774 if test -z "$LINKFORSHARED"
1775 then
1776         case $ac_sys_system/$ac_sys_release in
1777         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1778         hp*|HP*)
1779             LINKFORSHARED="-Wl,-E -Wl,+s";;
1780 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1781         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1782         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1783         # -u libsys_s pulls in all symbols in libsys
1784         Darwin/*) 
1785                 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1786                 # which is
1787                 # not used by the core itself but which needs to be in the core so
1788                 # that dynamically loaded extension modules have access to it.
1789                 # -prebind is no longer used, because it actually seems to give a
1790                 # slowdown in stead of a speedup, maybe due to the large number of
1791                 # dynamic loads Python does.
1793                 LINKFORSHARED="$extra_undefs"
1794                 if test "$enable_framework"
1795                 then
1796                         LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1797                 fi
1798                 LINKFORSHARED="$LINKFORSHARED";;
1799         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1800         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1801         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1802         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) 
1803                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1804                 then
1805                         LINKFORSHARED="-Wl,--export-dynamic"
1806                 fi;;
1807         SunOS/5*) case $CC in
1808                   *gcc*)
1809                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1810                     then
1811                         LINKFORSHARED="-Xlinker --export-dynamic"
1812                     fi;;
1813                   esac;;
1814         CYGWIN*)
1815                 if test $enable_shared = "no"
1816                 then
1817                         LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1818                 fi;;
1819         QNX*)
1820                 # -Wl,-E causes the symbols to be added to the dynamic
1821                 # symbol table so that they can be found when a module
1822                 # is loaded.  -N 2048K causes the stack size to be set
1823                 # to 2048 kilobytes so that the stack doesn't overflow
1824                 # when running test_compile.py.
1825                 LINKFORSHARED='-Wl,-E -N 2048K';;
1826         esac
1828 AC_MSG_RESULT($LINKFORSHARED)
1831 AC_SUBST(CFLAGSFORSHARED)
1832 AC_MSG_CHECKING(CFLAGSFORSHARED)
1833 if test ! "$LIBRARY" = "$LDLIBRARY"
1834 then
1835         case $ac_sys_system in
1836         CYGWIN*)
1837                 # Cygwin needs CCSHARED when building extension DLLs
1838                 # but not when building the interpreter DLL.
1839                 CFLAGSFORSHARED='';;
1840         *)
1841                 CFLAGSFORSHARED='$(CCSHARED)'
1842         esac
1844 AC_MSG_RESULT($CFLAGSFORSHARED)
1846 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1847 # library (with --enable-shared).
1848 # For platforms on which shared libraries are not allowed to have unresolved
1849 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1850 # if it is not required, since it creates a dependency of the shared library
1851 # to LIBS. This, in turn, means that applications linking the shared libpython
1852 # don't need to link LIBS explicitly. The default should be only changed
1853 # on systems where this approach causes problems.
1854 AC_SUBST(SHLIBS)
1855 AC_MSG_CHECKING(SHLIBS)
1856 case "$ac_sys_system" in
1857         *)
1858                 SHLIBS='$(LIBS)';;
1859 esac
1860 AC_MSG_RESULT($SHLIBS)
1863 # checks for libraries
1864 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1865 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1867 # only check for sem_init if thread support is requested
1868 if test "$with_threads" = "yes" -o -z "$with_threads"; then
1869     AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1870                                                 # posix4 on Solaris 2.6
1871                                                 # pthread (first!) on Linux
1874 # check if we need libintl for locale functions
1875 AC_CHECK_LIB(intl, textdomain,
1876         AC_DEFINE(WITH_LIBINTL, 1,
1877         [Define to 1 if libintl is needed for locale functions.]))
1879 # checks for system dependent C++ extensions support
1880 case "$ac_sys_system" in
1881         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1882                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1883                             [loadAndInit("", 0, "")],
1884                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1885                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1886                        and you want support for AIX C++ shared extension modules.])
1887                              AC_MSG_RESULT(yes)],
1888                             [AC_MSG_RESULT(no)]);;
1889         *) ;;
1890 esac
1892 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1893 # BeOS' sockets are stashed in libnet.
1894 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1895 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1897 case "$ac_sys_system" in
1898 BeOS*)
1899 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1901 esac
1903 AC_MSG_CHECKING(for --with-libs)
1904 AC_ARG_WITH(libs,
1905             AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1907 AC_MSG_RESULT($withval)
1908 LIBS="$withval $LIBS"
1910 [AC_MSG_RESULT(no)])
1912 # Check for use of the system libffi library
1913 AC_MSG_CHECKING(for --with-system-ffi)
1914 AC_ARG_WITH(system_ffi,
1915             AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1917 AC_MSG_RESULT($with_system_ffi)
1919 # Check for --with-dbmliborder
1920 AC_MSG_CHECKING(for --with-dbmliborder)
1921 AC_ARG_WITH(dbmliborder,
1922             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'.]),
1924 if test x$with_dbmliborder = xyes
1925 then
1926 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1927 else
1928   for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1929     if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1930     then
1931       AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1932     fi
1933   done
1934 fi])
1935 AC_MSG_RESULT($with_dbmliborder)
1937 # Determine if signalmodule should be used.
1938 AC_SUBST(USE_SIGNAL_MODULE)
1939 AC_SUBST(SIGNAL_OBJS)
1940 AC_MSG_CHECKING(for --with-signal-module)
1941 AC_ARG_WITH(signal-module,
1942             AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1944 if test -z "$with_signal_module"
1945 then with_signal_module="yes"
1947 AC_MSG_RESULT($with_signal_module)
1949 if test "${with_signal_module}" = "yes"; then
1950         USE_SIGNAL_MODULE=""
1951         SIGNAL_OBJS=""
1952 else
1953         USE_SIGNAL_MODULE="#"
1954         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1957 # This is used to generate Setup.config
1958 AC_SUBST(USE_THREAD_MODULE)
1959 USE_THREAD_MODULE=""
1961 AC_MSG_CHECKING(for --with-dec-threads)
1962 AC_SUBST(LDLAST)
1963 AC_ARG_WITH(dec-threads,
1964             AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1966 AC_MSG_RESULT($withval)
1967 LDLAST=-threads
1968 if test "${with_thread+set}" != set; then
1969    with_thread="$withval";
1970 fi],
1971 [AC_MSG_RESULT(no)])
1973 # Templates for things AC_DEFINEd more than once.
1974 # For a single AC_DEFINE, no template is needed.
1975 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1976 AH_TEMPLATE(_REENTRANT,
1977   [Define to force use of thread-safe errno, h_errno, and other functions])
1978 AH_TEMPLATE(WITH_THREAD,
1979   [Define if you want to compile in rudimentary thread support])
1981 AC_MSG_CHECKING(for --with-threads)
1982 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1983 AC_ARG_WITH(threads,
1984             AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
1986 # --with-thread is deprecated, but check for it anyway
1987 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1988 AC_ARG_WITH(thread,
1989             AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1990             [with_threads=$with_thread])
1992 if test -z "$with_threads"
1993 then with_threads="yes"
1995 AC_MSG_RESULT($with_threads)
1997 AC_SUBST(THREADOBJ)
1998 if test "$with_threads" = "no"
1999 then
2000     USE_THREAD_MODULE="#"
2001 elif test "$ac_cv_pthread_is_default" = yes
2002 then
2003     AC_DEFINE(WITH_THREAD)
2004     # Defining _REENTRANT on system with POSIX threads should not hurt.
2005     AC_DEFINE(_REENTRANT)
2006     posix_threads=yes
2007     THREADOBJ="Python/thread.o"    
2008 elif test "$ac_cv_kpthread" = "yes"
2009 then
2010     CC="$CC -Kpthread"
2011     if test "$ac_cv_cxx_thread" = "yes"; then
2012         CXX="$CXX -Kpthread"
2013     fi
2014     AC_DEFINE(WITH_THREAD)
2015     posix_threads=yes
2016     THREADOBJ="Python/thread.o"
2017 elif test "$ac_cv_kthread" = "yes"
2018 then
2019     CC="$CC -Kthread"
2020     if test "$ac_cv_cxx_thread" = "yes"; then
2021         CXX="$CXX -Kthread"
2022     fi
2023     AC_DEFINE(WITH_THREAD)
2024     posix_threads=yes
2025     THREADOBJ="Python/thread.o"
2026 elif test "$ac_cv_pthread" = "yes"
2027 then
2028     CC="$CC -pthread"
2029     if test "$ac_cv_cxx_thread" = "yes"; then
2030         CXX="$CXX -pthread"
2031     fi
2032     AC_DEFINE(WITH_THREAD)
2033     posix_threads=yes
2034     THREADOBJ="Python/thread.o"
2035 else
2036     if test ! -z "$with_threads" -a -d "$with_threads"
2037     then LDFLAGS="$LDFLAGS -L$with_threads"
2038     fi
2039     if test ! -z "$withval" -a -d "$withval"
2040     then LDFLAGS="$LDFLAGS -L$withval"
2041     fi
2043     # According to the POSIX spec, a pthreads implementation must
2044     # define _POSIX_THREADS in unistd.h. Some apparently don't
2045     # (e.g. gnu pth with pthread emulation)
2046     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2047     AC_EGREP_CPP(yes,
2048     [
2049 #include <unistd.h>
2050 #ifdef _POSIX_THREADS
2052 #endif
2053     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2054     AC_MSG_RESULT($unistd_defines_pthreads)
2056     AC_DEFINE(_REENTRANT)
2057     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2058     AC_DEFINE(C_THREADS)
2059     AC_DEFINE(HURD_C_THREADS, 1,
2060     [Define if you are using Mach cthreads directly under /include])
2061     LIBS="$LIBS -lthreads"
2062     THREADOBJ="Python/thread.o"],[
2063     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2064     AC_DEFINE(C_THREADS)
2065     AC_DEFINE(MACH_C_THREADS, 1,
2066     [Define if you are using Mach cthreads under mach /])
2067     THREADOBJ="Python/thread.o"],[
2068     AC_MSG_CHECKING(for --with-pth)
2069     AC_ARG_WITH([pth],
2070                 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2071                 [AC_MSG_RESULT($withval)
2072                   AC_DEFINE([WITH_THREAD])
2073                   AC_DEFINE([HAVE_PTH], 1,
2074                             [Define if you have GNU PTH threads.])
2075                   LIBS="-lpth $LIBS"
2076                   THREADOBJ="Python/thread.o"],
2077                 [AC_MSG_RESULT(no)
2079     # Just looking for pthread_create in libpthread is not enough:
2080     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2081     # So we really have to include pthread.h, and then link.
2082     _libs=$LIBS
2083     LIBS="$LIBS -lpthread"
2084     AC_MSG_CHECKING([for pthread_create in -lpthread])
2085     AC_TRY_LINK([#include <pthread.h>
2087 void * start_routine (void *arg) { exit (0); }], [
2088 pthread_create (NULL, NULL, start_routine, NULL)], [
2089     AC_MSG_RESULT(yes)
2090     AC_DEFINE(WITH_THREAD)
2091     posix_threads=yes
2092     THREADOBJ="Python/thread.o"],[
2093     LIBS=$_libs
2094     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
2095     posix_threads=yes
2096     THREADOBJ="Python/thread.o"],[
2097     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2098     AC_DEFINE(ATHEOS_THREADS, 1,
2099     [Define this if you have AtheOS threads.])
2100     THREADOBJ="Python/thread.o"],[
2101     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
2102     AC_DEFINE(BEOS_THREADS, 1,
2103     [Define this if you have BeOS threads.])
2104     THREADOBJ="Python/thread.o"],[
2105     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
2106     posix_threads=yes
2107     LIBS="$LIBS -lpthreads"
2108     THREADOBJ="Python/thread.o"], [
2109     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
2110     posix_threads=yes
2111     LIBS="$LIBS -lc_r"
2112     THREADOBJ="Python/thread.o"], [
2113     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
2114     posix_threads=yes
2115     LIBS="$LIBS -lpthread"
2116     THREADOBJ="Python/thread.o"], [
2117     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
2118     posix_threads=yes
2119     LIBS="$LIBS -lcma"
2120     THREADOBJ="Python/thread.o"],[
2121     USE_THREAD_MODULE="#"])
2122     ])])])])])])])])])])
2124     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2125     LIBS="$LIBS -lmpc"
2126     THREADOBJ="Python/thread.o"
2127     USE_THREAD_MODULE=""])
2129     if test "$posix_threads" != "yes"; then     
2130       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2131       LIBS="$LIBS -lthread"
2132       THREADOBJ="Python/thread.o"
2133       USE_THREAD_MODULE=""])
2134     fi
2136     if test "$USE_THREAD_MODULE" != "#"
2137     then
2138         # If the above checks didn't disable threads, (at least) OSF1
2139         # needs this '-threads' argument during linking.
2140         case $ac_sys_system in
2141         OSF1) LDLAST=-threads;;
2142         esac
2143     fi
2146 if test "$posix_threads" = "yes"; then
2147       if test "$unistd_defines_pthreads" = "no"; then
2148          AC_DEFINE(_POSIX_THREADS, 1,
2149          [Define if you have POSIX threads, 
2150           and your system does not define that.])
2151       fi
2153       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2154       case  $ac_sys_system/$ac_sys_release in
2155   SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2156                        Defined for Solaris 2.6 bug in pthread header.)
2157                        ;;
2158       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2159                        Define if the Posix semaphores do not work on your system)
2160                        ;;
2161       AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2162                        Define if the Posix semaphores do not work on your system)
2163                        ;;
2164       esac
2166       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2167       AC_CACHE_VAL(ac_cv_pthread_system_supported,
2168       [AC_TRY_RUN([#include <pthread.h>
2169       void *foo(void *parm) {
2170         return NULL;
2171       }
2172       main() {
2173         pthread_attr_t attr;
2174         pthread_t id;
2175         if (pthread_attr_init(&attr)) exit(-1);
2176         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
2177         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
2178         exit(0);
2179       }],
2180       ac_cv_pthread_system_supported=yes,
2181       ac_cv_pthread_system_supported=no,
2182       ac_cv_pthread_system_supported=no)
2183       ])
2184       AC_MSG_RESULT($ac_cv_pthread_system_supported)
2185       if test "$ac_cv_pthread_system_supported" = "yes"; then
2186         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
2187       fi
2188       AC_CHECK_FUNCS(pthread_sigmask,
2189         [case $ac_sys_system in
2190         CYGWIN*)
2191           AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2192             [Define if pthread_sigmask() does not work on your system.])
2193             ;;
2194         esac])
2198 # Check for enable-ipv6
2199 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
2200 AC_MSG_CHECKING([if --enable-ipv6 is specified])
2201 AC_ARG_ENABLE(ipv6,
2202 [  --enable-ipv6           Enable ipv6 (with ipv4) support
2203   --disable-ipv6          Disable ipv6 support],
2204 [ case "$enableval" in
2205   no)
2206        AC_MSG_RESULT(no)
2207        ipv6=no
2208        ;;
2209   *)   AC_MSG_RESULT(yes)
2210        AC_DEFINE(ENABLE_IPV6)
2211        ipv6=yes
2212        ;;
2213   esac ],
2216 dnl the check does not work on cross compilation case...
2217   AC_TRY_RUN([ /* AF_INET6 available check */
2218 #include <sys/types.h>
2219 #include <sys/socket.h>
2220 main()
2222  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2223    exit(1);
2224  else
2225    exit(0);
2228   AC_MSG_RESULT(yes)
2229   ipv6=yes,
2230   AC_MSG_RESULT(no)
2231   ipv6=no,
2232   AC_MSG_RESULT(no)
2233   ipv6=no
2236 if test "$ipv6" = "yes"; then
2237         AC_MSG_CHECKING(if RFC2553 API is available)
2238         AC_TRY_COMPILE([#include <sys/types.h>
2239 #include <netinet/in.h>],
2240         [struct sockaddr_in6 x;
2241 x.sin6_scope_id;],
2242                 AC_MSG_RESULT(yes)
2243                 ipv6=yes,
2244                 AC_MSG_RESULT(no, IPv6 disabled)
2245                 ipv6=no)
2248 if test "$ipv6" = "yes"; then
2249         AC_DEFINE(ENABLE_IPV6)
2253 ipv6type=unknown
2254 ipv6lib=none
2255 ipv6trylibc=no
2257 if test "$ipv6" = "yes"; then
2258         AC_MSG_CHECKING([ipv6 stack type])
2259         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2260         do
2261                 case $i in
2262                 inria)
2263                         dnl http://www.kame.net/
2264                         AC_EGREP_CPP(yes, [
2265 #include <netinet/in.h>
2266 #ifdef IPV6_INRIA_VERSION
2268 #endif],
2269                                 [ipv6type=$i])
2270                         ;;
2271                 kame)
2272                         dnl http://www.kame.net/
2273                         AC_EGREP_CPP(yes, [
2274 #include <netinet/in.h>
2275 #ifdef __KAME__
2277 #endif],
2278                                 [ipv6type=$i;
2279                                 ipv6lib=inet6
2280                                 ipv6libdir=/usr/local/v6/lib
2281                                 ipv6trylibc=yes])
2282                         ;;
2283                 linux-glibc)
2284                         dnl http://www.v6.linux.or.jp/
2285                         AC_EGREP_CPP(yes, [
2286 #include <features.h>
2287 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2289 #endif],
2290                                 [ipv6type=$i;
2291                                 ipv6trylibc=yes])
2292                         ;;
2293                 linux-inet6)
2294                         dnl http://www.v6.linux.or.jp/
2295                         if test -d /usr/inet6; then
2296                                 ipv6type=$i
2297                                 ipv6lib=inet6
2298                                 ipv6libdir=/usr/inet6/lib
2299                                 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
2300                         fi
2301                         ;;
2302                 solaris)
2303                         if test -f /etc/netconfig; then
2304                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2305                                 ipv6type=$i
2306                                 ipv6trylibc=yes
2307                           fi
2308                         fi
2309                         ;;
2310                 toshiba)
2311                         AC_EGREP_CPP(yes, [
2312 #include <sys/param.h>
2313 #ifdef _TOSHIBA_INET6
2315 #endif],
2316                                 [ipv6type=$i;
2317                                 ipv6lib=inet6;
2318                                 ipv6libdir=/usr/local/v6/lib])
2319                         ;;
2320                 v6d)
2321                         AC_EGREP_CPP(yes, [
2322 #include </usr/local/v6/include/sys/v6config.h>
2323 #ifdef __V6D__
2325 #endif],
2326                                 [ipv6type=$i;
2327                                 ipv6lib=v6;
2328                                 ipv6libdir=/usr/local/v6/lib;
2329                                 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
2330                         ;;
2331                 zeta)
2332                         AC_EGREP_CPP(yes, [
2333 #include <sys/param.h>
2334 #ifdef _ZETA_MINAMI_INET6
2336 #endif],
2337                                 [ipv6type=$i;
2338                                 ipv6lib=inet6;
2339                                 ipv6libdir=/usr/local/v6/lib])
2340                         ;;
2341                 esac
2342                 if test "$ipv6type" != "unknown"; then
2343                         break
2344                 fi
2345         done
2346         AC_MSG_RESULT($ipv6type)
2349 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2350         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2351                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2352                 echo "using lib$ipv6lib"
2353         else
2354                 if test $ipv6trylibc = "yes"; then
2355                         echo "using libc"
2356                 else
2357                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
2358                         echo "You need to fetch lib$ipv6lib.a from appropriate"
2359                         echo 'ipv6 kit and compile beforehand.'
2360                         exit 1
2361                 fi
2362         fi
2365 AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2366 AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2367   AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2368   AC_MSG_RESULT(yes),
2369   AC_MSG_RESULT(no)
2372 # Check for --with-doc-strings
2373 AC_MSG_CHECKING(for --with-doc-strings)
2374 AC_ARG_WITH(doc-strings,
2375             AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
2377 if test -z "$with_doc_strings"
2378 then with_doc_strings="yes"
2380 if test "$with_doc_strings" != "no"
2381 then
2382     AC_DEFINE(WITH_DOC_STRINGS, 1,
2383       [Define if you want documentation strings in extension modules])
2385 AC_MSG_RESULT($with_doc_strings)
2387 # Check for Python-specific malloc support
2388 AC_MSG_CHECKING(for --with-tsc)
2389 AC_ARG_WITH(tsc,
2390 [  --with(out)-tsc         enable/disable timestamp counter profile], [
2391 if test "$withval" != no
2392 then 
2393   AC_DEFINE(WITH_TSC, 1, 
2394     [Define to profile with the Pentium timestamp counter]) 
2395     AC_MSG_RESULT(yes)
2396 else AC_MSG_RESULT(no)
2397 fi],
2398 [AC_MSG_RESULT(no)])
2400 # Check for Python-specific malloc support
2401 AC_MSG_CHECKING(for --with-pymalloc)
2402 AC_ARG_WITH(pymalloc,
2403             AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
2405 if test -z "$with_pymalloc"
2406 then with_pymalloc="yes"
2408 if test "$with_pymalloc" != "no"
2409 then
2410     AC_DEFINE(WITH_PYMALLOC, 1, 
2411      [Define if you want to compile in Python-specific mallocs])
2413 AC_MSG_RESULT($with_pymalloc)
2415 # Check for --with-wctype-functions
2416 AC_MSG_CHECKING(for --with-wctype-functions)
2417 AC_ARG_WITH(wctype-functions, 
2418             AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2420 if test "$withval" != no
2421 then 
2422   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2423   [Define if you want wctype.h functions to be used instead of the
2424    one supplied by Python itself. (see Include/unicodectype.h).]) 
2425   AC_MSG_RESULT(yes)
2426 else AC_MSG_RESULT(no)
2427 fi],
2428 [AC_MSG_RESULT(no)])
2430 # -I${DLINCLDIR} is added to the compile rule for importdl.o
2431 AC_SUBST(DLINCLDIR)
2432 DLINCLDIR=.
2434 # the dlopen() function means we might want to use dynload_shlib.o. some
2435 # platforms, such as AIX, have dlopen(), but don't want to use it.
2436 AC_CHECK_FUNCS(dlopen)
2438 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2439 # loading of modules.
2440 AC_SUBST(DYNLOADFILE)
2441 AC_MSG_CHECKING(DYNLOADFILE)
2442 if test -z "$DYNLOADFILE"
2443 then
2444         case $ac_sys_system/$ac_sys_release in
2445         AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2446         if test "$ac_cv_func_dlopen" = yes
2447         then DYNLOADFILE="dynload_shlib.o"
2448         else DYNLOADFILE="dynload_aix.o"
2449         fi
2450         ;;
2451         BeOS*) DYNLOADFILE="dynload_beos.o";;
2452         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2453         # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2454         Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
2455         atheos*) DYNLOADFILE="dynload_atheos.o";;
2456         *)
2457         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2458         # out any dynamic loading
2459         if test "$ac_cv_func_dlopen" = yes
2460         then DYNLOADFILE="dynload_shlib.o"
2461         else DYNLOADFILE="dynload_stub.o"
2462         fi
2463         ;;
2464         esac
2466 AC_MSG_RESULT($DYNLOADFILE)
2467 if test "$DYNLOADFILE" != "dynload_stub.o"
2468 then
2469         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2470         [Defined when any dynamic module loading is enabled.])
2473 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
2475 AC_SUBST(MACHDEP_OBJS)
2476 AC_MSG_CHECKING(MACHDEP_OBJS)
2477 if test -z "$MACHDEP_OBJS"
2478 then
2479         MACHDEP_OBJS=$extra_machdep_objs
2480 else
2481         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2483 AC_MSG_RESULT(MACHDEP_OBJS)
2485 # checks for library functions
2486 AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2487  clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
2488  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2489  getpriority getpwent getspnam getspent getsid getwd \
2490  kill killpg lchmod lchown lstat mkfifo mknod mktime \
2491  mremap nice pathconf pause plock poll pthread_init \
2492  putenv readlink realpath \
2493  select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2494  setgid \
2495  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2496  sigaction siginterrupt sigrelse strftime \
2497  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2498  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
2500 # For some functions, having a definition is not sufficient, since
2501 # we want to take their address.
2502 AC_MSG_CHECKING(for chroot)
2503 AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2504   AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2505   AC_MSG_RESULT(yes),
2506   AC_MSG_RESULT(no)
2508 AC_MSG_CHECKING(for link)
2509 AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2510   AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2511   AC_MSG_RESULT(yes),
2512   AC_MSG_RESULT(no)
2514 AC_MSG_CHECKING(for symlink)
2515 AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2516   AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2517   AC_MSG_RESULT(yes),
2518   AC_MSG_RESULT(no)
2520 AC_MSG_CHECKING(for fchdir)
2521 AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2522   AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2523   AC_MSG_RESULT(yes),
2524   AC_MSG_RESULT(no)
2526 AC_MSG_CHECKING(for fsync)
2527 AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
2528   AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2529   AC_MSG_RESULT(yes),
2530   AC_MSG_RESULT(no)
2532 AC_MSG_CHECKING(for fdatasync)
2533 AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2534   AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2535   AC_MSG_RESULT(yes),
2536   AC_MSG_RESULT(no)
2538 AC_MSG_CHECKING(for epoll)
2539 AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2540   AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2541   AC_MSG_RESULT(yes),
2542   AC_MSG_RESULT(no)
2544 AC_MSG_CHECKING(for kqueue)
2545 AC_TRY_COMPILE([
2546 #include <sys/types.h>
2547 #include <sys/event.h>
2548     ], int x=kqueue(),
2549   AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2550   AC_MSG_RESULT(yes),
2551   AC_MSG_RESULT(no)
2553 # On some systems (eg. FreeBSD 5), we would find a definition of the
2554 # functions ctermid_r, setgroups in the library, but no prototype
2555 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2556 # address to avoid compiler warnings and potential miscompilations
2557 # because of the missing prototypes.
2559 AC_MSG_CHECKING(for ctermid_r)
2560 AC_TRY_COMPILE([
2561 #include "confdefs.h" 
2562 #include <stdio.h>
2563 ], void* p = ctermid_r,
2564   AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2565   AC_MSG_RESULT(yes),
2566   AC_MSG_RESULT(no)
2569 AC_MSG_CHECKING(for flock)
2570 AC_TRY_COMPILE([
2571 #include "confdefs.h" 
2572 #include <sys/file.h>
2573 ], void* p = flock,
2574   AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2575   AC_MSG_RESULT(yes),
2576   AC_MSG_RESULT(no)
2579 AC_MSG_CHECKING(for getpagesize)
2580 AC_TRY_COMPILE([
2581 #include "confdefs.h" 
2582 #include <unistd.h>
2583 ], void* p = getpagesize,
2584   AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2585   AC_MSG_RESULT(yes),
2586   AC_MSG_RESULT(no)
2589 dnl check for true
2590 AC_CHECK_PROGS(TRUE, true, /bin/true)
2592 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2593 dnl On others, they are in the C library, so we to take no action
2594 AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2595   AC_CHECK_LIB(resolv, inet_aton)
2598 # On Tru64, chflags seems to be present, but calling it will
2599 # exit Python
2600 AC_MSG_CHECKING(for chflags)
2601 AC_CACHE_VAL(ac_cv_have_chflags,
2602 AC_TRY_RUN([[
2603 #include <sys/stat.h>
2604 #include <unistd.h>
2605 int main(int argc, char*argv[])
2607   if(chflags(argv[0], 0) != 0)
2608     return 1;
2609   return 0;
2611 ]], ac_cv_have_chflags=yes,
2612    ac_cv_have_chflags=no,
2613    ac_cv_have_chflags=no)
2615 AC_MSG_RESULT($ac_cv_have_chflags)
2616 if test $ac_cv_have_chflags = yes
2617 then
2618   AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2621 AC_MSG_CHECKING(for lchflags)
2622 AC_CACHE_VAL(ac_cv_have_lchflags,
2623 AC_TRY_RUN([[
2624 #include <sys/stat.h>
2625 #include <unistd.h>
2626 int main(int argc, char*argv[])
2628   if(lchflags(argv[0], 0) != 0)
2629     return 1;
2630   return 0;
2632 ]], ac_cv_have_lchflags=yes,
2633    ac_cv_have_lchflags=no,
2634    ac_cv_have_lchflags=no)
2636 AC_MSG_RESULT($ac_cv_have_lchflags)
2637 if test $ac_cv_have_lchflags = yes
2638 then
2639   AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2642 dnl Check if system zlib has *Copy() functions
2644 dnl On MacOSX the linker will search for dylibs on the entire linker path
2645 dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2646 dnl to revert to a more traditional unix behaviour and make it possible to
2647 dnl override the system libz with a local static library of libz. Temporarily
2648 dnl add that flag to our CFLAGS as well to ensure that we check the version
2649 dnl of libz that will be used by setup.py. 
2650 dnl The -L/usr/local/lib is needed as wel to get the same compilation 
2651 dnl environment as setup.py (and leaving it out can cause configure to use the
2652 dnl wrong version of the library)
2653 case $ac_sys_system/$ac_sys_release in
2654 Darwin/*) 
2655         _CUR_CFLAGS="${CFLAGS}"
2656         _CUR_LDFLAGS="${LDFLAGS}"
2657         CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2658         LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2659         ;;
2660 esac
2662 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2664 case $ac_sys_system/$ac_sys_release in
2665 Darwin/*) 
2666         CFLAGS="${_CUR_CFLAGS}"
2667         LDFLAGS="${_CUR_LDFLAGS}"
2668         ;;
2669 esac
2671 AC_MSG_CHECKING(for hstrerror)
2672 AC_TRY_LINK([
2673 #include "confdefs.h" 
2674 #include <netdb.h>
2675 ], void* p = hstrerror; hstrerror(0),
2676   AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2677   AC_MSG_RESULT(yes),
2678   AC_MSG_RESULT(no)
2681 AC_MSG_CHECKING(for inet_aton)
2682 AC_TRY_LINK([
2683 #include "confdefs.h" 
2684 #include <sys/types.h>
2685 #include <sys/socket.h>
2686 #include <netinet/in.h>
2687 #include <arpa/inet.h>
2688 ], void* p = inet_aton;inet_aton(0,0),
2689   AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2690   AC_MSG_RESULT(yes),
2691   AC_MSG_RESULT(no)
2694 AC_MSG_CHECKING(for inet_pton)
2695 AC_TRY_COMPILE([
2696 #include "confdefs.h" 
2697 #include <sys/types.h>
2698 #include <sys/socket.h>
2699 #include <netinet/in.h>
2700 #include <arpa/inet.h>
2701 ], void* p = inet_pton,
2702   AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2703   AC_MSG_RESULT(yes),
2704   AC_MSG_RESULT(no)
2707 # On some systems, setgroups is in unistd.h, on others, in grp.h
2708 AC_MSG_CHECKING(for setgroups)
2709 AC_TRY_COMPILE([
2710 #include "confdefs.h" 
2711 #include <unistd.h>
2712 #ifdef HAVE_GRP_H
2713 #include <grp.h>
2714 #endif
2715 ], 
2716 void* p = setgroups,
2717   AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2718   AC_MSG_RESULT(yes),
2719   AC_MSG_RESULT(no)
2722 # check for openpty and forkpty
2724 AC_CHECK_FUNCS(openpty,, 
2725    AC_CHECK_LIB(util,openpty,
2726      [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2727      AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2728    )
2730 AC_CHECK_FUNCS(forkpty,, 
2731    AC_CHECK_LIB(util,forkpty, 
2732      [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2733      AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2734    )
2737 # Stuff for expat.
2738 AC_CHECK_FUNCS(memmove)
2740 # check for long file support functions
2741 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2743 AC_REPLACE_FUNCS(dup2 getcwd strdup)
2744 AC_CHECK_FUNCS(getpgrp, 
2745   AC_TRY_COMPILE([#include <unistd.h>], 
2746    [getpgrp(0);], 
2747    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2748    [Define if getpgrp() must be called as getpgrp(0).])
2751 AC_CHECK_FUNCS(setpgrp,
2752   AC_TRY_COMPILE([#include <unistd.h>],
2753     [setpgrp(0,0);],
2754     AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2755     [Define if setpgrp() must be called as setpgrp(0, 0).])
2756   )
2758 AC_CHECK_FUNCS(gettimeofday, 
2759   AC_TRY_COMPILE([#include <sys/time.h>], 
2760     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2761     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2762     [Define if gettimeofday() does not have second (timezone) argument
2763      This is the case on Motorola V4 (R40V4.2)])
2764   )
2767 AC_MSG_CHECKING(for major, minor, and makedev)
2768 AC_TRY_LINK([
2769 #if defined(MAJOR_IN_MKDEV)
2770 #include <sys/mkdev.h>
2771 #elif defined(MAJOR_IN_SYSMACROS)
2772 #include <sys/sysmacros.h>
2773 #else
2774 #include <sys/types.h>
2775 #endif
2777   makedev(major(0),minor(0));
2779   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2780             [Define to 1 if you have the device macros.])
2781   AC_MSG_RESULT(yes)
2783   AC_MSG_RESULT(no)
2786 # On OSF/1 V5.1, getaddrinfo is available, but a define
2787 # for [no]getaddrinfo in netdb.h. 
2788 AC_MSG_CHECKING(for getaddrinfo)
2789 AC_TRY_LINK([
2790 #include <sys/types.h>
2791 #include <sys/socket.h>
2792 #include <netdb.h>
2793 #include <stdio.h>
2794 ], [getaddrinfo(NULL, NULL, NULL, NULL);],
2795 have_getaddrinfo=yes,
2796 have_getaddrinfo=no)
2797 AC_MSG_RESULT($have_getaddrinfo)
2798 if test $have_getaddrinfo = yes
2799 then
2800   AC_MSG_CHECKING(getaddrinfo bug)
2801   AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2802   AC_TRY_RUN([[
2803 #include <sys/types.h>
2804 #include <netdb.h>
2805 #include <string.h>
2806 #include <sys/socket.h>
2807 #include <netinet/in.h>
2809 int main()
2811   int passive, gaierr, inet4 = 0, inet6 = 0;
2812   struct addrinfo hints, *ai, *aitop;
2813   char straddr[INET6_ADDRSTRLEN], strport[16];
2815   for (passive = 0; passive <= 1; passive++) {
2816     memset(&hints, 0, sizeof(hints));
2817     hints.ai_family = AF_UNSPEC;
2818     hints.ai_flags = passive ? AI_PASSIVE : 0;
2819     hints.ai_socktype = SOCK_STREAM;
2820     hints.ai_protocol = IPPROTO_TCP;
2821     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2822       (void)gai_strerror(gaierr);
2823       goto bad;
2824     }
2825     for (ai = aitop; ai; ai = ai->ai_next) {
2826       if (ai->ai_addr == NULL ||
2827           ai->ai_addrlen == 0 ||
2828           getnameinfo(ai->ai_addr, ai->ai_addrlen,
2829                       straddr, sizeof(straddr), strport, sizeof(strport),
2830                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2831         goto bad;
2832       }
2833       switch (ai->ai_family) {
2834       case AF_INET:
2835         if (strcmp(strport, "54321") != 0) {
2836           goto bad;
2837         }
2838         if (passive) {
2839           if (strcmp(straddr, "0.0.0.0") != 0) {
2840             goto bad;
2841           }
2842         } else {
2843           if (strcmp(straddr, "127.0.0.1") != 0) {
2844             goto bad;
2845           }
2846         }
2847         inet4++;
2848         break;
2849       case AF_INET6:
2850         if (strcmp(strport, "54321") != 0) {
2851           goto bad;
2852         }
2853         if (passive) {
2854           if (strcmp(straddr, "::") != 0) {
2855             goto bad;
2856           }
2857         } else {
2858           if (strcmp(straddr, "::1") != 0) {
2859             goto bad;
2860           }
2861         }
2862         inet6++;
2863         break;
2864       case AF_UNSPEC:
2865         goto bad;
2866         break;
2867       default:
2868         /* another family support? */
2869         break;
2870       }
2871     }
2872   }
2874   if (!(inet4 == 0 || inet4 == 2))
2875     goto bad;
2876   if (!(inet6 == 0 || inet6 == 2))
2877     goto bad;
2879   if (aitop)
2880     freeaddrinfo(aitop);
2881   return 0;
2883  bad:
2884   if (aitop)
2885     freeaddrinfo(aitop);
2886   return 1;
2888 ]], ac_cv_buggy_getaddrinfo=no,
2889     ac_cv_buggy_getaddrinfo=yes,
2890     ac_cv_buggy_getaddrinfo=yes))
2893 if test $have_getaddrinfo = no -o $ac_cv_buggy_getaddrinfo = yes
2894 then
2895         if test $ipv6 = yes
2896         then
2897                 echo 'Fatal: You must get working getaddrinfo() function.'
2898                 echo '       or you can specify "--disable-ipv6"'.
2899                 exit 1
2900         fi
2901 else
2902         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2904 AC_CHECK_FUNCS(getnameinfo)
2906 # checks for structures
2907 AC_HEADER_TIME
2908 AC_STRUCT_TM
2909 AC_STRUCT_TIMEZONE
2910 AC_CHECK_MEMBERS([struct stat.st_rdev])
2911 AC_CHECK_MEMBERS([struct stat.st_blksize])
2912 AC_CHECK_MEMBERS([struct stat.st_flags])
2913 AC_CHECK_MEMBERS([struct stat.st_gen])
2914 AC_CHECK_MEMBERS([struct stat.st_birthtime])
2915 AC_STRUCT_ST_BLOCKS
2917 AC_MSG_CHECKING(for time.h that defines altzone)
2918 AC_CACHE_VAL(ac_cv_header_time_altzone,
2919 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2920   ac_cv_header_time_altzone=yes,
2921   ac_cv_header_time_altzone=no)])
2922 AC_MSG_RESULT($ac_cv_header_time_altzone)
2923 if test $ac_cv_header_time_altzone = yes; then
2924   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2927 was_it_defined=no
2928 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2929 AC_TRY_COMPILE([
2930 #include <sys/types.h>
2931 #include <sys/select.h>
2932 #include <sys/time.h>
2933 ], [;], [
2934   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2935   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
2936    (which you can't on SCO ODT 3.0).]) 
2937   was_it_defined=yes
2939 AC_MSG_RESULT($was_it_defined)
2941 AC_MSG_CHECKING(for addrinfo)
2942 AC_CACHE_VAL(ac_cv_struct_addrinfo,
2943 AC_TRY_COMPILE([
2944 #               include <netdb.h>],
2945         [struct addrinfo a],
2946         ac_cv_struct_addrinfo=yes,
2947         ac_cv_struct_addrinfo=no))
2948 AC_MSG_RESULT($ac_cv_struct_addrinfo)
2949 if test $ac_cv_struct_addrinfo = yes; then
2950         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
2953 AC_MSG_CHECKING(for sockaddr_storage)
2954 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2955 AC_TRY_COMPILE([
2956 #               include <sys/types.h>
2957 #               include <sys/socket.h>],
2958         [struct sockaddr_storage s],
2959         ac_cv_struct_sockaddr_storage=yes,
2960         ac_cv_struct_sockaddr_storage=no))
2961 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2962 if test $ac_cv_struct_sockaddr_storage = yes; then
2963         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
2966 # checks for compiler characteristics
2968 AC_C_CHAR_UNSIGNED
2969 AC_C_CONST
2971 works=no
2972 AC_MSG_CHECKING(for working volatile)
2973 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
2974   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2976 AC_MSG_RESULT($works)
2978 works=no
2979 AC_MSG_CHECKING(for working signed char)
2980 AC_TRY_COMPILE([], [signed char c;], works=yes, 
2981   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2983 AC_MSG_RESULT($works)
2985 have_prototypes=no
2986 AC_MSG_CHECKING(for prototypes)
2987 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2988   AC_DEFINE(HAVE_PROTOTYPES, 1, 
2989    [Define if your compiler supports function prototype]) 
2990   have_prototypes=yes
2992 AC_MSG_RESULT($have_prototypes)
2994 works=no
2995 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
2996 AC_TRY_COMPILE([
2997 #include <stdarg.h>
2998 int foo(int x, ...) {
2999         va_list va;
3000         va_start(va, x);
3001         va_arg(va, int);
3002         va_arg(va, char *);
3003         va_arg(va, double);
3004         return 0;
3006 ], [return foo(10, "", 3.14);], [
3007   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3008    [Define if your compiler supports variable length function prototypes
3009    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
3010   works=yes
3012 AC_MSG_RESULT($works)
3014 # check for socketpair
3015 AC_MSG_CHECKING(for socketpair)
3016 AC_TRY_COMPILE([
3017 #include <sys/types.h>
3018 #include <sys/socket.h>
3019 ], void *x=socketpair,
3020   AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3021   AC_MSG_RESULT(yes),
3022   AC_MSG_RESULT(no)
3025 # check if sockaddr has sa_len member
3026 AC_MSG_CHECKING(if sockaddr has sa_len member)
3027 AC_TRY_COMPILE([#include <sys/types.h>
3028 #include <sys/socket.h>],
3029 [struct sockaddr x;
3030 x.sa_len = 0;],
3031         AC_MSG_RESULT(yes)
3032         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
3033         AC_MSG_RESULT(no))
3035 va_list_is_array=no
3036 AC_MSG_CHECKING(whether va_list is an array)
3037 AC_TRY_COMPILE([
3038 #ifdef HAVE_STDARG_PROTOTYPES
3039 #include <stdarg.h>
3040 #else
3041 #include <varargs.h>
3042 #endif
3043 ], [va_list list1, list2; list1 = list2;], , [
3044  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
3045  va_list_is_array=yes
3047 AC_MSG_RESULT($va_list_is_array)
3049 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
3050 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3051   [Define this if you have some version of gethostbyname_r()])
3053 AC_CHECK_FUNC(gethostbyname_r, [
3054   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3055   AC_MSG_CHECKING([gethostbyname_r with 6 args])
3056   OLD_CFLAGS=$CFLAGS
3057   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3058   AC_TRY_COMPILE([
3059 #   include <netdb.h>
3060   ], [
3061     char *name;
3062     struct hostent *he, *res;
3063     char buffer[2048];
3064     int buflen = 2048;
3065     int h_errnop;
3067     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3068   ], [
3069     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3070     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3071     [Define this if you have the 6-arg version of gethostbyname_r().])
3072     AC_MSG_RESULT(yes)
3073   ], [
3074     AC_MSG_RESULT(no)
3075     AC_MSG_CHECKING([gethostbyname_r with 5 args])
3076     AC_TRY_COMPILE([
3077 #     include <netdb.h>
3078     ], [
3079       char *name;
3080       struct hostent *he;
3081       char buffer[2048];
3082       int buflen = 2048;
3083       int h_errnop;
3085       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3086     ], [
3087       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3088       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3089       [Define this if you have the 5-arg version of gethostbyname_r().])
3090       AC_MSG_RESULT(yes)
3091     ], [
3092       AC_MSG_RESULT(no)
3093       AC_MSG_CHECKING([gethostbyname_r with 3 args])
3094       AC_TRY_COMPILE([
3095 #       include <netdb.h>
3096       ], [
3097         char *name;
3098         struct hostent *he;
3099         struct hostent_data data;
3101         (void) gethostbyname_r(name, he, &data);
3102       ], [
3103         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3104         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3105         [Define this if you have the 3-arg version of gethostbyname_r().])
3106         AC_MSG_RESULT(yes)
3107       ], [
3108         AC_MSG_RESULT(no)
3109       ])
3110     ])
3111   ])
3112   CFLAGS=$OLD_CFLAGS
3113 ], [
3114   AC_CHECK_FUNCS(gethostbyname)
3116 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3117 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3118 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
3119 AC_SUBST(HAVE_GETHOSTBYNAME_R)
3120 AC_SUBST(HAVE_GETHOSTBYNAME)
3122 # checks for system services
3123 # (none yet)
3125 # Linux requires this for correct f.p. operations
3126 AC_CHECK_FUNC(__fpu_control,
3127   [],
3128   [AC_CHECK_LIB(ieee, __fpu_control)
3131 # Check for --with-fpectl
3132 AC_MSG_CHECKING(for --with-fpectl)
3133 AC_ARG_WITH(fpectl,
3134             AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3136 if test "$withval" != no
3137 then 
3138   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3139   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
3140   AC_MSG_RESULT(yes)
3141 else AC_MSG_RESULT(no)
3142 fi],
3143 [AC_MSG_RESULT(no)])
3145 # check for --with-libm=...
3146 AC_SUBST(LIBM)
3147 case $ac_sys_system in
3148 Darwin) ;;
3149 BeOS) ;;
3150 *) LIBM=-lm
3151 esac
3152 AC_MSG_CHECKING(for --with-libm=STRING)
3153 AC_ARG_WITH(libm,
3154             AC_HELP_STRING(--with-libm=STRING, math library),
3156 if test "$withval" = no
3157 then LIBM=
3158      AC_MSG_RESULT(force LIBM empty)
3159 elif test "$withval" != yes
3160 then LIBM=$withval
3161      AC_MSG_RESULT(set LIBM="$withval")
3162 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
3163 fi],
3164 [AC_MSG_RESULT(default LIBM="$LIBM")])
3166 # check for --with-libc=...
3167 AC_SUBST(LIBC)
3168 AC_MSG_CHECKING(for --with-libc=STRING)
3169 AC_ARG_WITH(libc,
3170             AC_HELP_STRING(--with-libc=STRING, C library),
3172 if test "$withval" = no
3173 then LIBC=
3174      AC_MSG_RESULT(force LIBC empty)
3175 elif test "$withval" != yes
3176 then LIBC=$withval
3177      AC_MSG_RESULT(set LIBC="$withval")
3178 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
3179 fi],
3180 [AC_MSG_RESULT(default LIBC="$LIBC")])
3182 # ************************************
3183 # * Check for mathematical functions *
3184 # ************************************
3186 LIBS_SAVE=$LIBS
3187 LIBS="$LIBS $LIBM"
3189 # Detect whether system arithmetic is subject to x87-style double
3190 # rounding issues.  The result of this test has little meaning on non
3191 # IEEE 754 platforms.  On IEEE 754, test should return 1 if rounding
3192 # mode is round-to-nearest and double rounding issues are present, and
3193 # 0 otherwise.  See http://bugs.python.org/issue2937 for more info.
3194 AC_MSG_CHECKING(for x87-style double rounding)
3195 AC_CACHE_VAL(ac_cv_x87_double_rounding, [
3196 AC_TRY_RUN([
3197 #include <stdlib.h>
3198 #include <math.h>
3199 int main() {
3200     volatile double x, y, z;
3201     /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3202     x = 0.99999999999999989; /* 1-2**-53 */
3203     y = 1./x;
3204     if (y != 1.)
3205         exit(0);
3206     /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3207     x = 1e16;
3208     y = 2.99999;
3209     z = x + y;
3210     if (z != 1e16+4.)
3211         exit(0);
3212     /* both tests show evidence of double rounding */
3213     exit(1);
3216 ac_cv_x87_double_rounding=no,
3217 ac_cv_x87_double_rounding=yes,
3218 ac_cv_x87_double_rounding=no)])
3219 AC_MSG_RESULT($ac_cv_x87_double_rounding)
3220 if test "$ac_cv_x87_double_rounding" = yes
3221 then
3222   AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3223   [Define if arithmetic is subject to x87-style double rounding issue])
3226 # Multiprocessing check for broken sem_getvalue
3227 AC_MSG_CHECKING(for broken sem_getvalue)
3228 AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
3229 AC_TRY_RUN([
3230 #include <unistd.h>
3231 #include <fcntl.h>
3232 #include <stdio.h>
3233 #include <semaphore.h>
3234 #include <sys/stat.h>
3236 int main(void){
3237   sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3238   int count;
3239   int res;
3240   if(a==SEM_FAILED){
3241     perror("sem_open");
3242     return 1;
3244   }
3245   res = sem_getvalue(a, &count);
3246   sem_close(a);
3247   return res==-1 ? 1 : 0;
3249 ], ac_cv_broken_sem_getvalue=no,
3250    ac_cv_broken_sem_getvalue=yes,
3251    ac_cv_broken_sem_getvalue=yes)
3253 AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3254 if test $ac_cv_broken_sem_getvalue = yes
3255 then
3256   AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3257   [define to 1 if your sem_getvalue is broken.])
3260 # On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3261 # -0. on some architectures.
3262 AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3263 AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3264 AC_TRY_RUN([
3265 #include <math.h>
3266 #include <stdlib.h>
3267 int main() {
3268     /* return 0 if either negative zeros don't exist
3269        on this platform or if negative zeros exist
3270        and tanh(-0.) == -0. */
3271   if (atan2(0., -1.) == atan2(-0., -1.) ||
3272       atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3273   else exit(1);
3276 ac_cv_tanh_preserves_zero_sign=yes,
3277 ac_cv_tanh_preserves_zero_sign=no,
3278 ac_cv_tanh_preserves_zero_sign=no)])
3279 AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3280 if test "$ac_cv_tanh_preserves_zero_sign" = yes
3281 then
3282   AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3283   [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3286 AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p round])
3287 AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3289 LIBS=$LIBS_SAVE
3291 # determine what size digit to use for Python's longs
3292 AC_MSG_CHECKING([digit size for Python's longs])
3293 AC_ARG_ENABLE(big-digits,
3294 AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3295 [case $enable_big_digits in
3296 yes)
3297   enable_big_digits=30 ;;
3299   enable_big_digits=15 ;;
3300 [15|30])
3301   ;;
3303   AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3304 esac
3305 AC_MSG_RESULT($enable_big_digits)
3306 AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3308 [AC_MSG_RESULT(no value specified)])
3310 # check for wchar.h
3311 AC_CHECK_HEADER(wchar.h, [
3312   AC_DEFINE(HAVE_WCHAR_H, 1, 
3313   [Define if the compiler provides a wchar.h header file.]) 
3314   wchar_h="yes"
3316 wchar_h="no"
3319 # determine wchar_t size
3320 if test "$wchar_h" = yes
3321 then
3322   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
3325 AC_MSG_CHECKING(for UCS-4 tcl)
3326 have_ucs4_tcl=no
3327 AC_TRY_COMPILE([
3328 #include <tcl.h>
3329 #if TCL_UTF_MAX != 6
3330 # error "NOT UCS4_TCL"
3331 #endif], [], [
3332   AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3333   have_ucs4_tcl=yes
3335 AC_MSG_RESULT($have_ucs4_tcl)
3337 # check whether wchar_t is signed or not
3338 if test "$wchar_h" = yes
3339 then
3340   # check whether wchar_t is signed or not
3341   AC_MSG_CHECKING(whether wchar_t is signed)
3342   AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3343   AC_TRY_RUN([
3344   #include <wchar.h>
3345   int main()
3346   {
3347         /* Success: exit code 0 */
3348         exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
3349   }
3350   ],
3351   ac_cv_wchar_t_signed=yes,
3352   ac_cv_wchar_t_signed=no,
3353   ac_cv_wchar_t_signed=yes)])
3354   AC_MSG_RESULT($ac_cv_wchar_t_signed)
3356   
3357 AC_MSG_CHECKING(what type to use for unicode)
3358 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3359 AC_ARG_ENABLE(unicode, 
3360               AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
3361               [],
3362               [enable_unicode=yes])
3364 if test $enable_unicode = yes
3365 then
3366   # Without any arguments, Py_UNICODE defaults to two-byte mode
3367   case "$have_ucs4_tcl" in
3368   yes) enable_unicode="ucs4"
3369        ;;
3370   *)   enable_unicode="ucs2"
3371        ;;
3372   esac
3375 AH_TEMPLATE(Py_UNICODE_SIZE,
3376   [Define as the size of the unicode type.])
3377 case "$enable_unicode" in
3378 ucs2) unicode_size="2"
3379       AC_DEFINE(Py_UNICODE_SIZE,2)
3380       ;;
3381 ucs4) unicode_size="4"
3382       AC_DEFINE(Py_UNICODE_SIZE,4)
3383       ;;
3384 esac
3386 AH_TEMPLATE(PY_UNICODE_TYPE,
3387   [Define as the integral type used for Unicode representation.])
3389 AC_SUBST(UNICODE_OBJS)
3390 if test "$enable_unicode" = "no"
3391 then
3392   UNICODE_OBJS=""
3393   AC_MSG_RESULT(not used)
3394 else
3395   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
3396   AC_DEFINE(Py_USING_UNICODE, 1,
3397   [Define if you want to have a Unicode type.])
3399   # wchar_t is only usable if it maps to an unsigned type
3400   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
3401           -a "$ac_cv_wchar_t_signed" = "no"
3402   then
3403     PY_UNICODE_TYPE="wchar_t"
3404     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3405     [Define if you have a useable wchar_t type defined in wchar.h; useable
3406      means wchar_t must be an unsigned type with at least 16 bits. (see
3407      Include/unicodeobject.h).])
3408     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3409   elif test "$ac_cv_sizeof_short" = "$unicode_size"
3410   then
3411        PY_UNICODE_TYPE="unsigned short"
3412        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3413   elif test "$ac_cv_sizeof_long" = "$unicode_size"
3414   then
3415        PY_UNICODE_TYPE="unsigned long"
3416        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3417   else
3418        PY_UNICODE_TYPE="no type found"
3419   fi
3420   AC_MSG_RESULT($PY_UNICODE_TYPE)
3423 # check for endianness
3424 AC_C_BIGENDIAN
3426 # Check whether right shifting a negative integer extends the sign bit
3427 # or fills with zeros (like the Cray J90, according to Tim Peters).
3428 AC_MSG_CHECKING(whether right shift extends the sign bit)
3429 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
3430 AC_TRY_RUN([
3431 int main()
3433         exit(((-1)>>3 == -1) ? 0 : 1);
3436 ac_cv_rshift_extends_sign=yes,
3437 ac_cv_rshift_extends_sign=no,
3438 ac_cv_rshift_extends_sign=yes)])
3439 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3440 if test "$ac_cv_rshift_extends_sign" = no
3441 then
3442   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3443   [Define if i>>j for signed int i does not extend the sign bit
3444    when i < 0])
3447 # check for getc_unlocked and related locking functions
3448 AC_MSG_CHECKING(for getc_unlocked() and friends)
3449 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3450 AC_TRY_LINK([#include <stdio.h>],[
3451         FILE *f = fopen("/dev/null", "r");
3452         flockfile(f);
3453         getc_unlocked(f);
3454         funlockfile(f);
3455 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3456 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3457 if test "$ac_cv_have_getc_unlocked" = yes
3458 then
3459   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3460   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
3463 # check where readline lives
3464 # save the value of LIBS so we don't actually link Python with readline
3465 LIBS_no_readline=$LIBS
3467 # On some systems we need to link readline to a termcap compatible
3468 # library.  NOTE: Keep the precedence of listed libraries synchronised
3469 # with setup.py.
3470 py_cv_lib_readline=no
3471 AC_MSG_CHECKING([how to link readline libs])
3472 for py_libtermcap in "" ncursesw ncurses curses termcap; do
3473   if test -z "$py_libtermcap"; then
3474     READLINE_LIBS="-lreadline"
3475   else
3476     READLINE_LIBS="-lreadline -l$py_libtermcap"
3477   fi
3478   LIBS="$READLINE_LIBS $LIBS_no_readline"
3479   AC_LINK_IFELSE(
3480     [AC_LANG_CALL([],[readline])],
3481     [py_cv_lib_readline=yes])
3482   if test $py_cv_lib_readline = yes; then
3483     break
3484   fi
3485 done
3486 # Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3487 #AC_SUBST([READLINE_LIBS])
3488 if test $py_cv_lib_readline = no; then
3489   AC_MSG_RESULT([none])
3490 else
3491   AC_MSG_RESULT([$READLINE_LIBS])
3492   AC_DEFINE(HAVE_LIBREADLINE, 1,
3493     [Define if you have the readline library (-lreadline).])
3496 # check for readline 2.1
3497 AC_CHECK_LIB(readline, rl_callback_handler_install,
3498         AC_DEFINE(HAVE_RL_CALLBACK, 1,
3499         [Define if you have readline 2.1]), ,$READLINE_LIBS)
3501 # check for readline 2.2
3502 AC_TRY_CPP([#include <readline/readline.h>],
3503 have_readline=yes, have_readline=no)
3504 if test $have_readline = yes
3505 then
3506   AC_EGREP_HEADER([extern int rl_completion_append_character;],
3507   [readline/readline.h],
3508   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3509   [Define if you have readline 2.2]), )
3512 # check for readline 4.0
3513 AC_CHECK_LIB(readline, rl_pre_input_hook,
3514         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
3515         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3517 # also in 4.0
3518 AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3519         AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
3520         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3522 # check for readline 4.2
3523 AC_CHECK_LIB(readline, rl_completion_matches,
3524         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
3525         [Define if you have readline 4.2]), ,$READLINE_LIBS)
3527 # also in readline 4.2
3528 AC_TRY_CPP([#include <readline/readline.h>],
3529 have_readline=yes, have_readline=no)
3530 if test $have_readline = yes
3531 then
3532   AC_EGREP_HEADER([extern int rl_catch_signals;],
3533   [readline/readline.h],
3534   AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3535   [Define if you can turn off readline's signal handling.]), )
3538 # End of readline checks: restore LIBS
3539 LIBS=$LIBS_no_readline
3541 AC_MSG_CHECKING(for broken nice())
3542 AC_CACHE_VAL(ac_cv_broken_nice, [
3543 AC_TRY_RUN([
3544 int main()
3546         int val1 = nice(1);
3547         if (val1 != -1 && val1 == nice(2))
3548                 exit(0);
3549         exit(1);
3552 ac_cv_broken_nice=yes,
3553 ac_cv_broken_nice=no,
3554 ac_cv_broken_nice=no)])
3555 AC_MSG_RESULT($ac_cv_broken_nice)
3556 if test "$ac_cv_broken_nice" = yes
3557 then
3558   AC_DEFINE(HAVE_BROKEN_NICE, 1,
3559   [Define if nice() returns success/failure instead of the new priority.])
3562 AC_MSG_CHECKING(for broken poll())
3563 AC_CACHE_VAL(ac_cv_broken_poll,
3564 AC_TRY_RUN([
3565 #include <poll.h>
3567 int main()
3569     struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3570     int poll_test;
3572     close (42);
3574     poll_test = poll(&poll_struct, 1, 0);
3575     if (poll_test < 0)
3576         return 0;
3577     else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3578         return 0;
3579     else
3580         return 1;
3583 ac_cv_broken_poll=yes,
3584 ac_cv_broken_poll=no,
3585 ac_cv_broken_poll=no))
3586 AC_MSG_RESULT($ac_cv_broken_poll)
3587 if test "$ac_cv_broken_poll" = yes
3588 then
3589   AC_DEFINE(HAVE_BROKEN_POLL, 1,
3590       [Define if poll() sets errno on invalid file descriptors.])
3593 # Before we can test tzset, we need to check if struct tm has a tm_zone 
3594 # (which is not required by ISO C or UNIX spec) and/or if we support
3595 # tzname[]
3596 AC_STRUCT_TIMEZONE
3598 # check tzset(3) exists and works like we expect it to
3599 AC_MSG_CHECKING(for working tzset())
3600 AC_CACHE_VAL(ac_cv_working_tzset, [
3601 AC_TRY_RUN([
3602 #include <stdlib.h>
3603 #include <time.h>
3604 #include <string.h>
3606 #if HAVE_TZNAME
3607 extern char *tzname[];
3608 #endif
3610 int main()
3612         /* Note that we need to ensure that not only does tzset(3)
3613            do 'something' with localtime, but it works as documented
3614            in the library reference and as expected by the test suite.
3615            This includes making sure that tzname is set properly if
3616            tm->tm_zone does not exist since it is the alternative way
3617            of getting timezone info.
3619            Red Hat 6.2 doesn't understand the southern hemisphere 
3620            after New Year's Day.
3621         */
3623         time_t groundhogday = 1044144000; /* GMT-based */
3624         time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3626         putenv("TZ=UTC+0");
3627         tzset();
3628         if (localtime(&groundhogday)->tm_hour != 0)
3629             exit(1);
3630 #if HAVE_TZNAME
3631         /* For UTC, tzname[1] is sometimes "", sometimes "   " */
3632         if (strcmp(tzname[0], "UTC") || 
3633                 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3634             exit(1);
3635 #endif
3637         putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
3638         tzset();
3639         if (localtime(&groundhogday)->tm_hour != 19)
3640             exit(1);
3641 #if HAVE_TZNAME
3642         if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3643             exit(1);
3644 #endif
3646         putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3647         tzset();
3648         if (localtime(&groundhogday)->tm_hour != 11)
3649             exit(1);
3650 #if HAVE_TZNAME
3651         if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3652             exit(1);
3653 #endif
3655 #if HAVE_STRUCT_TM_TM_ZONE
3656         if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3657             exit(1);
3658         if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3659             exit(1);
3660 #endif
3662         exit(0);
3665 ac_cv_working_tzset=yes,
3666 ac_cv_working_tzset=no,
3667 ac_cv_working_tzset=no)])
3668 AC_MSG_RESULT($ac_cv_working_tzset)
3669 if test "$ac_cv_working_tzset" = yes
3670 then
3671   AC_DEFINE(HAVE_WORKING_TZSET, 1,
3672   [Define if tzset() actually switches the local timezone in a meaningful way.])
3675 # Look for subsecond timestamps in struct stat
3676 AC_MSG_CHECKING(for tv_nsec in struct stat)
3677 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3678 AC_TRY_COMPILE([#include <sys/stat.h>], [
3679 struct stat st;
3680 st.st_mtim.tv_nsec = 1;
3682 ac_cv_stat_tv_nsec=yes,
3683 ac_cv_stat_tv_nsec=no,
3684 ac_cv_stat_tv_nsec=no))
3685 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3686 if test "$ac_cv_stat_tv_nsec" = yes
3687 then
3688   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3689   [Define if you have struct stat.st_mtim.tv_nsec])
3692 # Look for BSD style subsecond timestamps in struct stat
3693 AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3694 AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3695 AC_TRY_COMPILE([#include <sys/stat.h>], [
3696 struct stat st;
3697 st.st_mtimespec.tv_nsec = 1;
3699 ac_cv_stat_tv_nsec2=yes,
3700 ac_cv_stat_tv_nsec2=no,
3701 ac_cv_stat_tv_nsec2=no))
3702 AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3703 if test "$ac_cv_stat_tv_nsec2" = yes
3704 then
3705   AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3706   [Define if you have struct stat.st_mtimensec])
3709 # On HP/UX 11.0, mvwdelch is a block with a return statement
3710 AC_MSG_CHECKING(whether mvwdelch is an expression)
3711 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3712 AC_TRY_COMPILE([#include <curses.h>], [
3713   int rtn;
3714   rtn = mvwdelch(0,0,0);
3715 ], ac_cv_mvwdelch_is_expression=yes,
3716    ac_cv_mvwdelch_is_expression=no,
3717    ac_cv_mvwdelch_is_expression=yes))
3718 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3720 if test "$ac_cv_mvwdelch_is_expression" = yes
3721 then
3722   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3723   [Define if mvwdelch in curses.h is an expression.])
3726 AC_MSG_CHECKING(whether WINDOW has _flags)
3727 AC_CACHE_VAL(ac_cv_window_has_flags,
3728 AC_TRY_COMPILE([#include <curses.h>], [
3729   WINDOW *w;
3730   w->_flags = 0;
3731 ], ac_cv_window_has_flags=yes,
3732    ac_cv_window_has_flags=no,
3733    ac_cv_window_has_flags=no))
3734 AC_MSG_RESULT($ac_cv_window_has_flags)
3737 if test "$ac_cv_window_has_flags" = yes
3738 then
3739   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
3740   [Define if WINDOW in curses.h offers a field _flags.])
3743 AC_MSG_CHECKING(for is_term_resized)
3744 AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3745   AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3746   AC_MSG_RESULT(yes),
3747   AC_MSG_RESULT(no)
3750 AC_MSG_CHECKING(for resize_term)
3751 AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3752   AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3753   AC_MSG_RESULT(yes),
3754   AC_MSG_RESULT(no)
3757 AC_MSG_CHECKING(for resizeterm)
3758 AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3759   AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3760   AC_MSG_RESULT(yes),
3761   AC_MSG_RESULT(no)
3764 AC_MSG_CHECKING(for /dev/ptmx)
3766 if test -r /dev/ptmx
3767 then
3768   AC_MSG_RESULT(yes)
3769   AC_DEFINE(HAVE_DEV_PTMX, 1,
3770   [Define if we have /dev/ptmx.])
3771 else
3772   AC_MSG_RESULT(no)
3775 AC_MSG_CHECKING(for /dev/ptc)
3777 if test -r /dev/ptc
3778 then
3779   AC_MSG_RESULT(yes)
3780   AC_DEFINE(HAVE_DEV_PTC, 1,
3781   [Define if we have /dev/ptc.])
3782 else
3783   AC_MSG_RESULT(no)
3786 AC_MSG_CHECKING(for %zd printf() format support)
3787 AC_CACHE_VAL(ac_cv_have_size_t_format,
3788 AC_TRY_RUN([[
3789 #include <stdio.h>
3790 #include <stddef.h>
3791 #include <string.h>
3793 #ifdef HAVE_SYS_TYPES_H
3794 #include <sys/types.h>
3795 #endif
3797 #ifdef HAVE_SSIZE_T
3798 typedef ssize_t Py_ssize_t;
3799 #elif SIZEOF_VOID_P == SIZEOF_LONG
3800 typedef long Py_ssize_t;
3801 #else
3802 typedef int Py_ssize_t;
3803 #endif
3805 int main()
3807     char buffer[256];
3809     if(sprintf(buffer, "%zd", (size_t)123) < 0)
3810         return 1;
3812     if (strcmp(buffer, "123"))
3813         return 1;
3815     if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3816         return 1;
3818     if (strcmp(buffer, "-123"))
3819         return 1;
3821     return 0;
3823 ]], ac_cv_have_size_t_format=yes,
3824     ac_cv_have_size_t_format=no,
3825     ac_cv_have_size_t_format=no)
3827 AC_MSG_RESULT($ac_cv_have_size_t_format)
3828 if test $ac_cv_have_size_t_format = yes
3829 then
3830   AC_DEFINE(PY_FORMAT_SIZE_T, "z",
3831   [Define to printf format modifier for Py_ssize_t])
3834 AC_CHECK_TYPE(socklen_t,,
3835   AC_DEFINE(socklen_t,int,
3836             Define to `int' if <sys/socket.h> does not define.),[
3837 #ifdef HAVE_SYS_TYPES_H
3838 #include <sys/types.h>
3839 #endif
3840 #ifdef HAVE_SYS_SOCKET_H
3841 #include <sys/socket.h>
3842 #endif
3845 AC_SUBST(THREADHEADERS)
3847 for h in `(cd $srcdir;echo Python/thread_*.h)`
3849   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3850 done
3852 AC_SUBST(SRCDIRS)
3853 SRCDIRS="Parser Grammar Objects Python Modules Mac"
3854 AC_MSG_CHECKING(for build directories)
3855 for dir in $SRCDIRS; do
3856     if test ! -d $dir; then
3857         mkdir $dir
3858     fi
3859 done
3860 AC_MSG_RESULT(done)
3862 # generate output files
3863 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
3864 AC_OUTPUT
3866 echo "creating Modules/Setup"
3867 if test ! -f Modules/Setup
3868 then
3869         cp $srcdir/Modules/Setup.dist Modules/Setup
3872 echo "creating Modules/Setup.local"
3873 if test ! -f Modules/Setup.local
3874 then
3875         echo "# Edit this file for local setup changes" >Modules/Setup.local
3878 echo "creating Makefile"
3879 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3880                         -s Modules Modules/Setup.config \
3881                         Modules/Setup.local Modules/Setup
3883 case $ac_sys_system in
3884 BeOS)
3885         AC_MSG_WARN([
3887   Support for BeOS is deprecated as of Python 2.6.
3888   See PEP 11 for the gory details.
3889   ])
3890   ;;
3891 *) ;;
3892 esac
3894 mv config.c Modules