Exception handling now raises KeyboardInterrupt and SystemExit rather than passing...
[python.git] / configure.in
blob15a2a06bf76d93b34433202d6fbd625cf0056f8a
1 dnl Process this file with autoconf 2.0 or later to make a configure script.
3 # Set VERSION so we only need to edit in one place (i.e., here)
4 m4_define(PYTHON_VERSION, 2.5)
6 AC_REVISION($Revision$)
7 AC_PREREQ(2.53)
8 AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs)
9 AC_CONFIG_SRCDIR([Include/object.h])
10 AC_CONFIG_HEADER(pyconfig.h)
12 dnl This is for stuff that absolutely must end up in pyconfig.h.
13 dnl Please use pyport.h instead, if possible.
14 AH_TOP([
15 #ifndef Py_PYCONFIG_H
16 #define Py_PYCONFIG_H
18 AH_BOTTOM([
19 /* Define the macros needed if on a UnixWare 7.x system. */
20 #if defined(__USLC__) && defined(__SCO_VERSION__)
21 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
22 #endif
24 #endif /*Py_PYCONFIG_H*/
27 # We don't use PACKAGE_ variables, and they cause conflicts
28 # with other autoconf-based packages that include Python.h
29 grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
30 rm confdefs.h
31 mv confdefs.h.new confdefs.h
33 AC_SUBST(VERSION)
34 VERSION=PYTHON_VERSION
36 AC_SUBST(SOVERSION)
37 SOVERSION=1.0
39 # The later defininition of _XOPEN_SOURCE disables certain features
40 # on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
41 AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
43 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
44 # certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
45 # them.
46 AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
48 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
49 # certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
50 # them.
51 AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
53 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
54 # u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
55 AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
57 define_xopen_source=yes
59 # Arguments passed to configure.
60 AC_SUBST(CONFIG_ARGS)
61 CONFIG_ARGS="$ac_configure_args"
63 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
64 AC_ARG_ENABLE(framework,
65               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
67         case $enableval in
68         yes) 
69                 enableval=/Library/Frameworks
70         esac
71         case $enableval in
72         no)
73                 PYTHONFRAMEWORK=
74                 PYTHONFRAMEWORKDIR=no-framework
75                 PYTHONFRAMEWORKPREFIX=
76                 PYTHONFRAMEWORKINSTALLDIR=
77                 enable_framework=
78                 ;;
79         *)
80                 PYTHONFRAMEWORK=Python
81                 PYTHONFRAMEWORKDIR=Python.framework
82                 PYTHONFRAMEWORKPREFIX=$enableval
83                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
84                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
85         esac
86         ],[
87         PYTHONFRAMEWORK=
88         PYTHONFRAMEWORKDIR=no-framework
89         PYTHONFRAMEWORKPREFIX=
90         PYTHONFRAMEWORKINSTALLDIR=
91         enable_framework=
93 AC_SUBST(PYTHONFRAMEWORK)
94 AC_SUBST(PYTHONFRAMEWORKDIR)
95 AC_SUBST(PYTHONFRAMEWORKPREFIX)
96 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
98 ##AC_ARG_WITH(dyld,
99 ##            AC_HELP_STRING(--with-dyld,
100 ##                           Use (OpenStep|Rhapsody) dynamic linker))
102 # Set name for machine-dependent library files
103 AC_SUBST(MACHDEP)
104 AC_MSG_CHECKING(MACHDEP)
105 if test -z "$MACHDEP"
106 then
107         ac_sys_system=`uname -s`
108         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
109         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
110                 ac_sys_release=`uname -v`
111         else
112                 ac_sys_release=`uname -r`
113         fi
114         ac_md_system=`echo $ac_sys_system |
115                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
116         ac_md_release=`echo $ac_sys_release |
117                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
118         MACHDEP="$ac_md_system$ac_md_release"
120         case $MACHDEP in
121         cygwin*) MACHDEP="cygwin";;
122         darwin*) MACHDEP="darwin";;
123         atheos*) MACHDEP="atheos";;
124         irix646) MACHDEP="irix6";;
125         '')     MACHDEP="unknown";;
126         esac
128         
129 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
130 # disable features if it is defined, without any means to access these
131 # features as extensions. For these systems, we skip the definition of
132 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
133 # some feature, make sure there is no alternative way to access this
134 # feature. Also, when using wildcards, make sure you have verified the
135 # need for not defining _XOPEN_SOURCE on all systems matching the
136 # wildcard, and that the wildcard does not include future systems
137 # (which may remove their limitations).
138 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
139 case $ac_sys_system/$ac_sys_release in
140   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
141   # even though select is a POSIX function. Reported by J. Ribbens.
142   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
143   OpenBSD/2.* | OpenBSD/3.@<:@0123456@:>@) 
144     define_xopen_source=no;;
145   # On Solaris 2.6, sys/wait.h is inconsistent in the usage
146   # of union __?sigval. Reported by Stuart Bishop.
147   SunOS/5.6)
148     define_xopen_source=no;;
149   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
150   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
151   # Reconfirmed for 7.1.4 by Martin v. Loewis.
152   OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
153     define_xopen_source=no;;
154   # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
155   # but used in struct sockaddr.sa_family. Reported by Tim Rice.
156   SCO_SV/3.2)
157     define_xopen_source=no;;
158   # On FreeBSD 4.8 and MacOS X 10.2, a bug in ncurses.h means that
159   # it craps out if _XOPEN_EXTENDED_SOURCE is defined. Apparently,
160   # this is fixed in 10.3, which identifies itself as Darwin/7.*
161   # This should hopefully be fixed in FreeBSD 4.9
162   FreeBSD/4.8* | Darwin/6* )
163     define_xopen_source=no;;
164   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
165   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
166   # or has another value. By not (re)defining it, the defaults come in place.
167   AIX/4)
168     define_xopen_source=no;;
169   AIX/5)
170     if test `uname -r` -eq 1; then
171       define_xopen_source=no
172     fi
173     ;;
174   # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
175   # disables platform specific features beyond repair.
176   Darwin/8.*)
177     define_xopen_source=no
178     ;;
180 esac
182 if test $define_xopen_source = yes
183 then
184   # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
185   # defined precisely as g++ defines it
186   case $ac_sys_system/$ac_sys_release in
187     SunOS/5.8|SunOS/5.9)
188       AC_DEFINE(_XOPEN_SOURCE, 500, 
189                 Define to the level of X/Open that your system supports)
190       ;;
191     *)
192       AC_DEFINE(_XOPEN_SOURCE, 600, 
193                 Define to the level of X/Open that your system supports)
194       ;;
195   esac
197   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
198   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
199   # several APIs are not declared. Since this is also needed in some
200   # cases for HP-UX, we define it globally.
201   
202   AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Define to activate Unix95-and-earlier features)
204   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
205   
209 # SGI compilers allow the specification of the both the ABI and the
210 # ISA on the command line.  Depending on the values of these switches,
211 # different and often incompatable code will be generated.
213 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
214 # thus supply support for various ABI/ISA combinations.  The MACHDEP
215 # variable is also adjusted.
217 AC_SUBST(SGI_ABI)
218 if test ! -z "$SGI_ABI"
219 then
220         CC="cc $SGI_ABI"
221         LDFLAGS="$SGI_ABI $LDFLAGS"
222         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
224 AC_MSG_RESULT($MACHDEP)
226 # And add extra plat-mac for darwin
227 AC_SUBST(EXTRAPLATDIR)
228 AC_SUBST(EXTRAMACHDEPPATH)
229 AC_MSG_CHECKING(EXTRAPLATDIR)
230 if test -z "$EXTRAPLATDIR"
231 then
232         case $MACHDEP in
233         darwin) 
234                 EXTRAPLATDIR="\$(PLATMACDIRS)"
235                 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
236                 ;;
237         *) 
238                 EXTRAPLATDIR=""
239                 EXTRAMACHDEPPATH=""
240                 ;;
241         esac
243 AC_MSG_RESULT($EXTRAPLATDIR)
245 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
246 # it may influence the way we can build extensions, so distutils
247 # needs to check it
248 AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
249 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
251 # checks for alternative programs
253 # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
254 # for debug/optimization stuff.  BASECFLAGS is for flags that are required
255 # just to get things to compile and link.  Users are free to override OPT
256 # when running configure or make.  The build should not break if they do.
257 # BASECFLAGS should generally not be messed with, however.
259 # XXX shouldn't some/most/all of this code be merged with the stuff later
260 # on that fiddles with OPT and BASECFLAGS?
261 AC_MSG_CHECKING(for --without-gcc)
262 AC_ARG_WITH(gcc,
263             AC_HELP_STRING(--without-gcc,never use gcc),
265         case $withval in
266         no)     CC=cc
267                 without_gcc=yes;;
268         yes)    CC=gcc
269                 without_gcc=no;;
270         *)      CC=$withval
271                 without_gcc=$withval;;
272         esac], [
273         case $ac_sys_system in
274         AIX*)   CC=cc_r
275                 without_gcc=;;
276         BeOS*)
277                 case $BE_HOST_CPU in
278                 ppc)
279                         CC=mwcc
280                         without_gcc=yes
281                         BASECFLAGS="$BASECFLAGS -export pragma"
282                         OPT="$OPT -O"
283                         LDFLAGS="$LDFLAGS -nodup"
284                         ;;
285                 x86)
286                         CC=gcc
287                         without_gcc=no
288                         OPT="$OPT -O"
289                         ;;
290                 *)
291                         AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
292                         ;;
293                 esac
294                 AR="\$(srcdir)/Modules/ar_beos"
295                 RANLIB=:
296                 ;;
297     Monterey*)
298         RANLIB=:
299         without_gcc=;;
300         *)      without_gcc=no;;
301         esac])
302 AC_MSG_RESULT($without_gcc)
304 AC_SUBST(CXX)
305 AC_SUBST(MAINOBJ)
306 MAINOBJ=python.o
307 AC_MSG_CHECKING(for --with-cxx=<compiler>)
308 AC_ARG_WITH(cxx,
309             AC_HELP_STRING(--with-cxx=<compiler>, enable C++ support),
311         check_cxx=no
312         case $withval in
313         no)     CXX=
314                 with_cxx=no;;
315         *)      CXX=$withval
316                 MAINOBJ=ccpython.o
317                 with_cxx=$withval;;
318         esac], [
319         with_cxx=no
320         check_cxx=yes
322 AC_MSG_RESULT($with_cxx)
324 if test "$with_cxx" = "yes"
325 then
326         AC_MSG_ERROR([must supply a compiler when using --with-cxx])
329 dnl The following fragment works similar to AC_PROG_CXX.
330 dnl It does not fail if CXX is not found, and it is not executed if 
331 dnl --without-cxx was given.
332 dnl Finally, it does not test whether CXX is g++.
334 dnl Autoconf 2.5x does not have AC_PROG_CXX_WORKS anymore
335 ifdef([AC_PROG_CXX_WORKS],[],
336       [AC_DEFUN([AC_PROG_CXX_WORKS],
337       [AC_LANG_PUSH(C++)dnl
338        _AC_COMPILER_EXEEXT
339        AC_LANG_POP()
340       ]
343 if test "$check_cxx" = "yes" 
344 then
345         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
346         if test "$CXX" = "notfound"
347         then
348                 CXX=
349         else
350                 AC_PROG_CXX_WORKS
351         fi
354 # If the user switches compilers, we can't believe the cache
355 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
356 then
357   AC_MSG_ERROR([cached CC is different -- throw away $cache_file
358 (it is also a good idea to do 'make clean' before compiling)])
361 AC_PROG_CC
363 # checks for UNIX variants that set C preprocessor variables
364 AC_AIX
366 # Check for unsupported systems
367 case $ac_sys_system/$ac_sys_release in
368 Linux*/1*)
369    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
370    echo See README for details.
371    exit 1;;
372 esac
374 AC_EXEEXT
375 AC_MSG_CHECKING(for --with-suffix)
376 AC_ARG_WITH(suffix,
377             AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
379         case $withval in
380         no)     EXEEXT=;;
381         yes)    EXEEXT=.exe;;
382         *)      EXEEXT=$withval;;
383         esac])
384 AC_MSG_RESULT($EXEEXT)
386 # Test whether we're running on a non-case-sensitive system, in which
387 # case we give a warning if no ext is given
388 AC_SUBST(BUILDEXEEXT)
389 AC_MSG_CHECKING(for case-insensitive build directory)
390 if test ! -d CaseSensitiveTestDir; then
391 mkdir CaseSensitiveTestDir
394 if test -d casesensitivetestdir
395 then
396     AC_MSG_RESULT(yes)
397     BUILDEXEEXT=.exe
398 else
399         AC_MSG_RESULT(no)
400         BUILDEXEEXT=$EXEEXT
402 rmdir CaseSensitiveTestDir
404 case $MACHDEP in
405 bsdos*)
406     case $CC in
407     gcc) CC="$CC -D_HAVE_BSDI";;
408     esac;;
409 esac
411 case $ac_sys_system in
412 hp*|HP*)
413     case $CC in
414     cc|*/cc) CC="$CC -Ae";;
415     esac;;
416 Monterey*)
417     case $CC in
418     cc) CC="$CC -Wl,-Bexport";;
419     esac;;
420 SunOS*)
421     # Some functions have a prototype only with that define, e.g. confstr
422     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
423     ;;
424 esac
427 AC_SUBST(LIBRARY)
428 AC_MSG_CHECKING(LIBRARY)
429 if test -z "$LIBRARY"
430 then
431         LIBRARY='libpython$(VERSION).a'
433 AC_MSG_RESULT($LIBRARY)
435 # LDLIBRARY is the name of the library to link against (as opposed to the
436 # name of the library into which to insert object files). BLDLIBRARY is also
437 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
438 # is blank as the main program is not linked directly against LDLIBRARY.
439 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
440 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
441 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
442 # DLLLIBRARY is the shared (i.e., DLL) library.
444 # RUNSHARED is used to run shared python without installed libraries
446 # INSTSONAME is the name of the shared library that will be use to install
447 # on the system - some systems like version suffix, others don't
448 AC_SUBST(LDLIBRARY)
449 AC_SUBST(DLLLIBRARY)
450 AC_SUBST(BLDLIBRARY)
451 AC_SUBST(LDLIBRARYDIR)
452 AC_SUBST(INSTSONAME)
453 AC_SUBST(RUNSHARED)
454 LDLIBRARY="$LIBRARY"
455 BLDLIBRARY='$(LDLIBRARY)'
456 INSTSONAME='$(LDLIBRARY)'
457 DLLLIBRARY=''
458 LDLIBRARYDIR=''
459 RUNSHARED=''
461 # LINKCC is the command that links the python executable -- default is $(CC).
462 # If CXX is set, and if it is needed to link a main function that was
463 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
464 # python might then depend on the C++ runtime
465 # This is altered for AIX in order to build the export list before 
466 # linking.
467 AC_SUBST(LINKCC)
468 AC_MSG_CHECKING(LINKCC)
469 if test -z "$LINKCC"
470 then
471         if test -z "$CXX"; then
472               LINKCC="\$(PURIFY) \$(CC)"
473         else
474               echo 'extern "C" void foo();int main(){foo();}' > conftest_a.cc
475               $CXX -c conftest_a.cc # 2>&5
476               echo 'void foo(){}' > conftest_b.$ac_ext
477               $CC -c conftest_b.$ac_ext # 2>&5
478               if $CC -o conftest$ac_exeext conftest_a.$ac_objext conftest_b.$ac_objext 2>&5 \
479                  && test -s conftest$ac_exeext && ./conftest$ac_exeext
480               then
481                  LINKCC="\$(PURIFY) \$(CC)"
482               else
483                  LINKCC="\$(PURIFY) \$(CXX)"
484               fi
485               rm -fr conftest*
486         fi
487         case $ac_sys_system in
488         AIX*)
489            exp_extra="\"\""
490            if test $ac_sys_release -ge 5 -o \
491                    $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
492                exp_extra="."
493            fi
494            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
495         Monterey64*)
496            LINKCC="$LINKCC -L/usr/lib/ia64l64";;
497         esac
499 AC_MSG_RESULT($LINKCC)
501 AC_MSG_CHECKING(for --enable-shared)
502 AC_ARG_ENABLE(shared,
503               AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
505 if test -z "$enable_shared"
506 then 
507   case $ac_sys_system in
508   CYGWIN* | atheos*)
509     enable_shared="yes";;
510   *)
511     enable_shared="no";;
512   esac
514 AC_MSG_RESULT($enable_shared)
516 AC_MSG_CHECKING(for --enable-profiling)
517 AC_ARG_ENABLE(profiling,
518               AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
519 [ac_save_cc="$CC"
520  CC="$CC -pg"
521  AC_TRY_RUN([int main() { return 0; }],
522    ac_enable_profiling="yes",
523    ac_enable_profiling="no",
524    ac_enable_profiling="no")
525  CC="$ac_save_cc"])
526 AC_MSG_RESULT($ac_enable_profiling)
528 case "$ac_enable_profiling" in
529     "yes")
530         BASECFLAGS="-pg $BASECFLAGS"
531         LDFLAGS="-pg $LDFLAGS"
532     ;;
533 esac
535 AC_MSG_CHECKING(LDLIBRARY)
537 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
538 # library that we build, but we do not want to link against it (we
539 # will find it with a -framework option). For this reason there is an
540 # extra variable BLDLIBRARY against which Python and the extension
541 # modules are linked, BLDLIBRARY. This is normally the same as
542 # LDLIBRARY, but empty for MacOSX framework builds.
543 if test "$enable_framework"
544 then
545   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
546   RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
547   BLDLIBRARY=''
548 else
549   BLDLIBRARY='$(LDLIBRARY)'
550 fi  
552 # Other platforms follow
553 if test $enable_shared = "yes"; then
554   AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
555   case $ac_sys_system in
556     BeOS*)
557           LDLIBRARY='libpython$(VERSION).so'
558           ;;
559     CYGWIN*)
560           LDLIBRARY='libpython$(VERSION).dll.a'
561           DLLLIBRARY='libpython$(VERSION).dll'
562           ;;
563     SunOS*)
564           LDLIBRARY='libpython$(VERSION).so'
565           BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
566           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
567           INSTSONAME="$LDLIBRARY".$SOVERSION
568           ;;
569     Linux*|GNU*|NetBSD*|FreeBSD*)
570           LDLIBRARY='libpython$(VERSION).so'
571           BLDLIBRARY='-L. -lpython$(VERSION)'
572           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
573           case $ac_sys_system in
574               FreeBSD*)
575                 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
576                 ;;
577           esac
578           INSTSONAME="$LDLIBRARY".$SOVERSION
579           ;;
580     hp*|HP*)
581           LDLIBRARY='libpython$(VERSION).sl'
582           BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
583           RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
584           ;;
585     OSF*)
586           LDLIBRARY='libpython$(VERSION).so'
587          BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
588           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
589           ;;
590     atheos*)
591           LDLIBRARY='libpython$(VERSION).so'
592           BLDLIBRARY='-L. -lpython$(VERSION)'
593           RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
594           ;;
595   esac
596 else # shared is disabled
597   case $ac_sys_system in
598     CYGWIN*)
599           BLDLIBRARY='$(LIBRARY)'
600           LDLIBRARY='libpython$(VERSION).dll.a'
601           ;;
602   esac
605 AC_MSG_RESULT($LDLIBRARY)
607 AC_PROG_RANLIB
608 AC_SUBST(AR)
609 AC_CHECK_PROGS(AR, ar aal, ar)
611 case $MACHDEP in
612 bsdos*|hp*|HP*)
613         # install -d does not work on BSDI or HP-UX
614         if test -z "$INSTALL"
615         then
616                 INSTALL="${srcdir}/install-sh -c"
617         fi
618 esac
619 AC_PROG_INSTALL
621 # Not every filesystem supports hard links
622 AC_SUBST(LN)
623 if test -z "$LN" ; then
624         case $ac_sys_system in
625                 BeOS*) LN="ln -s";;
626                 CYGWIN*) LN="ln -s";;
627                 atheos*) LN="ln -s";;
628                 *) LN=ln;;
629         esac
632 # Check for --with-pydebug
633 AC_MSG_CHECKING(for --with-pydebug)
634 AC_ARG_WITH(pydebug, 
635             AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
637 if test "$withval" != no
638 then 
639   AC_DEFINE(Py_DEBUG, 1, 
640   [Define if you want to build an interpreter with many run-time checks.]) 
641   AC_MSG_RESULT(yes); 
642   Py_DEBUG='true'
643 else AC_MSG_RESULT(no); Py_DEBUG='false'
644 fi],
645 [AC_MSG_RESULT(no)])
647 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
648 # merged with this chunk of code?
650 # Optimizer/debugger flags
651 # ------------------------
652 # (The following bit of code is complicated enough - please keep things
653 # indented properly.  Just pretend you're editing Python code. ;-)
655 # There are two parallel sets of case statements below, one that checks to
656 # see if OPT was set and one that does BASECFLAGS setting based upon
657 # compiler and platform.  BASECFLAGS tweaks need to be made even if the
658 # user set OPT.
660 # tweak OPT based on compiler and platform, only if the user didn't set
661 # it on the command line
662 AC_SUBST(OPT)
663 if test -z "$OPT"
664 then
665     case $GCC in
666     yes)
667         case $ac_cv_prog_cc_g in
668         yes)
669             if test "$Py_DEBUG" = 'true' ; then
670                 # Optimization messes up debuggers, so turn it off for
671                 # debug builds.
672                 OPT="-g -Wall -Wstrict-prototypes"
673             else
674                 OPT="-g -O3 -Wall -Wstrict-prototypes"
675             fi
676             ;;
677         *)
678             OPT="-O3 -Wall -Wstrict-prototypes"
679             ;;
680         esac
681         case $ac_sys_system in
682             SCO_SV*) OPT="$OPT -m486 -DSCO5"
683             ;;
684         esac
685         ;;
687     *)
688         OPT="-O"
689         ;;
690     esac
692     # The current (beta) Monterey compiler dies with optimizations
693     # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
694     case $ac_sys_system in
695         Monterey*)
696             OPT=""
697             ;;
698     esac
702 AC_SUBST(BASECFLAGS)
703 # tweak BASECFLAGS based on compiler and platform
704 case $GCC in
705 yes)
706     # Python violates C99 rules, by casting between incompatible
707     # pointer types. GCC may generate bad code as a result of that,
708     # so use -fno-strict-aliasing if supported.
709     AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
710      ac_save_cc="$CC"
711      CC="$CC -fno-strict-aliasing"
712      AC_TRY_RUN([int main() { return 0; }],
713      ac_cv_no_strict_aliasing_ok=yes,
714      ac_cv_no_strict_aliasing_ok=no,
715      ac_cv_no_strict_aliasing_ok=no)
716      CC="$ac_save_cc"
717     AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
718     if test $ac_cv_no_strict_aliasing_ok = yes
719     then
720       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
721     fi
722     case $ac_sys_system in
723         SCO_SV*)
724             BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
725             ;;
726         # is there any other compiler on Darwin besides gcc?
727         Darwin*)
728             BASECFLAGS="$BASECFLAGS -Wno-long-double -no-cpp-precomp -mno-fused-madd"
729             ;;
730     esac
731     ;;
734     case $ac_sys_system in
735     OpenUNIX*|UnixWare*)
736         BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
737         ;;
738     OSF*)
739         BASECFLAGS="$BASECFLAGS -ieee -std"
740         ;;
741     SCO_SV*)
742         BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
743         ;;
744     esac
745     ;;
746 esac
748 if test "$Py_DEBUG" = 'true'; then
749   :
750 else
751   OPT="-DNDEBUG $OPT"
754 if test "$ac_arch_flags"
755 then
756         BASECFLAGS="$BASECFLAGS $ac_arch_flags"
759 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
760 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
761 [ac_save_cc="$CC"
762 CC="$CC -OPT:Olimit=0"
763 AC_TRY_RUN([int main() { return 0; }],
764   ac_cv_opt_olimit_ok=yes,
765   ac_cv_opt_olimit_ok=no,
766   ac_cv_opt_olimit_ok=no)
767 CC="$ac_save_cc"])
768 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
769 if test $ac_cv_opt_olimit_ok = yes; then
770     case $ac_sys_system in
771         # XXX is this branch needed? On MacOSX 10.2.2 the result of the
772         # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
773         # environment?
774         Darwin*)
775             ;;
776         *)
777             BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
778             ;;
779     esac
780 else
781   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
782   AC_CACHE_VAL(ac_cv_olimit_ok,
783   [ac_save_cc="$CC"
784   CC="$CC -Olimit 1500"
785   AC_TRY_RUN([int main() { return 0; }],
786     ac_cv_olimit_ok=yes,
787     ac_cv_olimit_ok=no,
788     ac_cv_olimit_ok=no)
789   CC="$ac_save_cc"])
790   AC_MSG_RESULT($ac_cv_olimit_ok)
791   if test $ac_cv_olimit_ok = yes; then
792     BASECFLAGS="$BASECFLAGS -Olimit 1500"
793   fi
796 # On some compilers, pthreads are available without further options
797 # (e.g. MacOS X). On some of these systems, the compiler will not
798 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
799 # So we have to see first whether pthreads are available without
800 # options before we can check whether -Kpthread improves anything.
801 AC_MSG_CHECKING(whether pthreads are available without options)
802 AC_CACHE_VAL(ac_cv_pthread_is_default,
803 [AC_TRY_RUN([
804 #include <pthread.h>
806 void* routine(void* p){return NULL;}
808 int main(){
809   pthread_t p;
810   if(pthread_create(&p,NULL,routine,NULL)!=0)
811     return 1;
812   (void)pthread_detach(p);
813   return 0;
817   ac_cv_pthread_is_default=yes
818   ac_cv_kthread=no
819   ac_cv_pthread=no
821   ac_cv_pthread_is_default=no,
822   ac_cv_pthread_is_default=no)
824 AC_MSG_RESULT($ac_cv_pthread_is_default)
827 if test $ac_cv_pthread_is_default = yes 
828 then
829   ac_cv_kpthread=no
830 else
831 # -Kpthread, if available, provides the right #defines
832 # and linker options to make pthread_create available
833 # Some compilers won't report that they do not support -Kpthread,
834 # so we need to run a program to see whether it really made the
835 # function available.
836 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
837 AC_CACHE_VAL(ac_cv_kpthread,
838 [ac_save_cc="$CC"
839 CC="$CC -Kpthread"
840 AC_TRY_RUN([
841 #include <pthread.h>
843 void* routine(void* p){return NULL;}
845 int main(){
846   pthread_t p;
847   if(pthread_create(&p,NULL,routine,NULL)!=0)
848     return 1;
849   (void)pthread_detach(p);
850   return 0;
853   ac_cv_kpthread=yes,
854   ac_cv_kpthread=no,
855   ac_cv_kpthread=no)
856 CC="$ac_save_cc"])
857 AC_MSG_RESULT($ac_cv_kpthread)
860 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
861 then
862 # -Kthread, if available, provides the right #defines
863 # and linker options to make pthread_create available
864 # Some compilers won't report that they do not support -Kthread,
865 # so we need to run a program to see whether it really made the
866 # function available.
867 AC_MSG_CHECKING(whether $CC accepts -Kthread)
868 AC_CACHE_VAL(ac_cv_kthread,
869 [ac_save_cc="$CC"
870 CC="$CC -Kthread"
871 AC_TRY_RUN([
872 #include <pthread.h>
874 void* routine(void* p){return NULL;}
876 int main(){
877   pthread_t p;
878   if(pthread_create(&p,NULL,routine,NULL)!=0)
879     return 1;
880   (void)pthread_detach(p);
881   return 0;
884   ac_cv_kthread=yes,
885   ac_cv_kthread=no,
886   ac_cv_kthread=no)
887 CC="$ac_save_cc"])
888 AC_MSG_RESULT($ac_cv_kthread)
891 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
892 then
893 # -pthread, if available, provides the right #defines
894 # and linker options to make pthread_create available
895 # Some compilers won't report that they do not support -pthread,
896 # so we need to run a program to see whether it really made the
897 # function available.
898 AC_MSG_CHECKING(whether $CC accepts -pthread)
899 AC_CACHE_VAL(ac_cv_thread,
900 [ac_save_cc="$CC"
901 CC="$CC -pthread"
902 AC_TRY_RUN([
903 #include <pthread.h>
905 void* routine(void* p){return NULL;}
907 int main(){
908   pthread_t p;
909   if(pthread_create(&p,NULL,routine,NULL)!=0)
910     return 1;
911   (void)pthread_detach(p);
912   return 0;
915   ac_cv_pthread=yes,
916   ac_cv_pthread=no,
917   ac_cv_pthread=no)
918 CC="$ac_save_cc"])
919 AC_MSG_RESULT($ac_cv_pthread)
922 # If we have set a CC compiler flag for thread support then
923 # check if it works for CXX, too.
924 ac_cv_cxx_thread=no
925 if test ! -z "$CXX"
926 then
927 AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
928 ac_save_cxx="$CXX"
930 if test "$ac_cv_kpthread" = "yes"
931 then
932   CXX="$CXX -Kpthread"  
933   ac_cv_cxx_thread=yes
934 elif test "$ac_cv_kthread" = "yes"
935 then
936   CXX="$CXX -Kthread"
937   ac_cv_cxx_thread=yes
938 elif test "$ac_cv_pthread" = "yes"
939 then 
940   CXX="$CXX -pthread"
941   ac_cv_cxx_thread=yes
944 if test $ac_cv_cxx_thread = yes
945 then
946   echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
947   $CXX -c conftest.$ac_ext 2>&5
948   if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
949      && test -s conftest$ac_exeext && ./conftest$ac_exeext
950   then
951     ac_cv_cxx_thread=yes
952   else
953     ac_cv_cxx_thread=no
954   fi
955   rm -fr conftest*
957 AC_MSG_RESULT($ac_cv_cxx_thread)
959 CXX="$ac_save_cxx"
961 dnl # check for ANSI or K&R ("traditional") preprocessor
962 dnl AC_MSG_CHECKING(for C preprocessor type)
963 dnl AC_TRY_COMPILE([
964 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
965 dnl int foo;
966 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
967 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
968 dnl AC_MSG_RESULT($cpp_type)
970 # checks for header files
971 AC_HEADER_STDC
972 AC_CHECK_HEADERS(curses.h dlfcn.h fcntl.h grp.h shadow.h langinfo.h \
973 libintl.h ncurses.h poll.h pthread.h \
974 stropts.h termios.h thread.h \
975 unistd.h utime.h \
976 sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \
977 sys/modem.h \
978 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
979 sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
980 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
981 bluetooth/bluetooth.h)
982 AC_HEADER_DIRENT
983 AC_HEADER_MAJOR
985 # On Solaris, term.h requires curses.h
986 AC_CHECK_HEADERS(term.h,,,[
987 #ifdef HAVE_CURSES_H
988 #include <curses.h>
989 #endif
992 # checks for typedefs
993 was_it_defined=no
994 AC_MSG_CHECKING(for clock_t in time.h)
995 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
996     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
998 AC_MSG_RESULT($was_it_defined)
1000 # Check whether using makedev requires defining _OSF_SOURCE
1001 AC_MSG_CHECKING(for makedev)
1002 AC_TRY_LINK([#include <sys/types.h> ],
1003             [ makedev(0, 0) ],
1004             ac_cv_has_makedev=yes,
1005             ac_cv_has_makedev=no)
1006 if test "$ac_cv_has_makedev" = "no"; then
1007     # we didn't link, try if _OSF_SOURCE will allow us to link
1008     AC_TRY_LINK([
1009 #define _OSF_SOURCE 1
1010 #include <sys/types.h>
1011     ],
1012     [ makedev(0, 0) ],
1013     ac_cv_has_makedev=yes,
1014     ac_cv_has_makedev=no)
1015     if test "$ac_cv_has_makedev" = "yes"; then
1016         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1017     fi
1019 AC_MSG_RESULT($ac_cv_has_makedev)
1020 if test "$ac_cv_has_makedev" = "yes"; then
1021     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1024 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1025 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1026 # defined, but the compiler does not support pragma redefine_extname,
1027 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1028 # structures (such as rlimit64) without declaring them. As a
1029 # work-around, disable LFS on such configurations
1031 use_lfs=yes
1032 AC_MSG_CHECKING(Solaris LFS bug)
1033 AC_TRY_COMPILE([
1034 #define _LARGEFILE_SOURCE 1
1035 #define _FILE_OFFSET_BITS 64
1036 #include <sys/resource.h>
1037 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1038 AC_MSG_RESULT($sol_lfs_bug)
1039 if test "$sol_lfs_bug" = "yes"; then
1040   use_lfs=no
1043 if test "$use_lfs" = "yes"; then
1044 # Two defines needed to enable largefile support on various platforms
1045 # These may affect some typedefs
1046 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
1047 [This must be defined on some systems to enable large file support.])
1048 AC_DEFINE(_FILE_OFFSET_BITS, 64,
1049 [This must be set to 64 on some systems to enable large file support.])
1052 # Add some code to confdefs.h so that the test for off_t works on SCO
1053 cat >> confdefs.h <<\EOF
1054 #if defined(SCO_DS)
1055 #undef _OFF_T
1056 #endif
1059 # Type availability checks
1060 AC_TYPE_MODE_T
1061 AC_TYPE_OFF_T
1062 AC_TYPE_PID_T
1063 AC_TYPE_SIGNAL
1064 AC_TYPE_SIZE_T
1065 AC_TYPE_UID_T
1067 # Sizes of various common basic types
1068 # ANSI C requires sizeof(char) == 1, so no need to check it
1069 AC_CHECK_SIZEOF(int, 4)
1070 AC_CHECK_SIZEOF(long, 4)
1071 AC_CHECK_SIZEOF(void *, 4)
1072 AC_CHECK_SIZEOF(short, 2)
1073 AC_CHECK_SIZEOF(float, 4)
1074 AC_CHECK_SIZEOF(double, 8)
1075 AC_CHECK_SIZEOF(fpos_t, 4)
1077 AC_MSG_CHECKING(for long long support)
1078 have_long_long=no
1079 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1080   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
1081   have_long_long=yes
1083 AC_MSG_RESULT($have_long_long)
1084 if test "$have_long_long" = yes ; then
1085 AC_CHECK_SIZEOF(long long, 8)
1088 AC_MSG_CHECKING(for uintptr_t support)
1089 have_uintptr_t=no
1090 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], [
1091   AC_DEFINE(HAVE_UINTPTR_T, 1, [Define this if you have the type uintptr_t.]) 
1092   have_uintptr_t=yes
1094 AC_MSG_RESULT($have_uintptr_t)
1095 if test "$have_uintptr_t" = yes ; then
1096 AC_CHECK_SIZEOF(uintptr_t, 4)
1099 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1100 AC_MSG_CHECKING(size of off_t)
1101 AC_CACHE_VAL(ac_cv_sizeof_off_t,
1102 [AC_TRY_RUN([#include <stdio.h>
1103 #include <sys/types.h>
1104 main()
1106   FILE *f=fopen("conftestval", "w");
1107   if (!f) exit(1);
1108   fprintf(f, "%d\n", sizeof(off_t));
1109   exit(0);
1111 ac_cv_sizeof_off_t=`cat conftestval`,
1112 ac_cv_sizeof_off_t=0,
1113 ac_cv_sizeof_off_t=4)
1115 AC_MSG_RESULT($ac_cv_sizeof_off_t)
1116 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1117 [The number of bytes in an off_t.])
1119 AC_MSG_CHECKING(whether to enable large file support)
1120 if test "$have_long_long" = yes -a \
1121         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1122         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1123   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
1124   [Defined to enable large file support when an off_t is bigger than a long
1125    and long long is available and at least as big as an off_t. You may need
1126    to add some flags for configuration and compilation to enable this mode.
1127    (For Solaris and Linux, the necessary defines are already defined.)])
1128   AC_MSG_RESULT(yes)
1129 else
1130   AC_MSG_RESULT(no)
1133 # AC_CHECK_SIZEOF() doesn't include <time.h>.
1134 AC_MSG_CHECKING(size of time_t)
1135 AC_CACHE_VAL(ac_cv_sizeof_time_t,
1136 [AC_TRY_RUN([#include <stdio.h>
1137 #include <time.h>
1138 main()
1140   FILE *f=fopen("conftestval", "w");
1141   if (!f) exit(1);
1142   fprintf(f, "%d\n", sizeof(time_t));
1143   exit(0);
1145 ac_cv_sizeof_time_t=`cat conftestval`,
1146 ac_cv_sizeof_time_t=0,
1147 ac_cv_sizeof_time_t=4)
1149 AC_MSG_RESULT($ac_cv_sizeof_time_t)
1150 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
1151 [The number of bytes in a time_t.])
1154 # if have pthread_t then define SIZEOF_PTHREAD_T
1155 ac_save_cc="$CC"
1156 if test "$ac_cv_kpthread" = "yes"
1157 then CC="$CC -Kpthread"
1158 elif test "$ac_cv_kthread" = "yes"
1159 then CC="$CC -Kthread"
1160 elif test "$ac_cv_pthread" = "yes"
1161 then CC="$CC -pthread"
1163 AC_MSG_CHECKING(for pthread_t)
1164 have_pthread_t=no
1165 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
1166 AC_MSG_RESULT($have_pthread_t)
1167 if test "$have_pthread_t" = yes ; then
1168   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1169   AC_MSG_CHECKING(size of pthread_t)
1170   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1171   [AC_TRY_RUN([#include <stdio.h>
1172 #include <pthread.h>
1173   main()
1174   {
1175     FILE *f=fopen("conftestval", "w");
1176     if (!f) exit(1);
1177     fprintf(f, "%d\n", sizeof(pthread_t));
1178     exit(0);
1179   }],
1180   ac_cv_sizeof_pthread_t=`cat conftestval`,
1181   ac_cv_sizeof_pthread_t=0,
1182   ac_cv_sizeof_pthread_t=4)
1183   ])
1184   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
1185   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1186    [The number of bytes in a pthread_t.])
1188 CC="$ac_save_cc"
1190 AC_MSG_CHECKING(for --enable-toolbox-glue)
1191 AC_ARG_ENABLE(toolbox-glue,
1192               AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
1194 if test -z "$enable_toolbox_glue"
1195 then 
1196         case $ac_sys_system/$ac_sys_release in
1197         Darwin/*)
1198                 enable_toolbox_glue="yes";;
1199         *)
1200                 enable_toolbox_glue="no";;
1201         esac
1203 case "$enable_toolbox_glue" in
1204 yes)
1205         extra_machdep_objs="Python/mactoolboxglue.o"
1206         extra_undefs="-u _PyMac_Error"
1207         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1208          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1209         ;;
1211         extra_machdep_objs=""
1212         extra_undefs=""
1213         ;;
1214 esac
1215 AC_MSG_RESULT($enable_toolbox_glue)
1217 AC_SUBST(OTHER_LIBTOOL_OPT)
1218 case $ac_sys_system/$ac_sys_release in
1219   Darwin/@<:@01234567@:>@.*) 
1220     OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1221     ;;
1222   Darwin/*)
1223     OTHER_LIBTOOL_OPT=""
1224     ;;
1225 esac
1227 AC_SUBST(LIBTOOL_CRUFT)
1228 case $ac_sys_system/$ac_sys_release in
1229   Darwin/@<:@01234567@:>@.*) 
1230     LIBTOOL_CRUFT="-framework System -lcc_dynamic -arch_only ppc"
1231     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1232     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1233   Darwin/*)
1234     gcc_version=`gcc -v 2>&1 |  grep version | cut -d\  -f3`
1235     if test ${gcc_version} '<' 4.0
1236         then
1237             LIBTOOL_CRUFT="-lcc_dynamic"
1238         else 
1239             LIBTOOL_CRUFT=""
1240     fi
1241     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -lSystem -lSystemStubs -arch_only ppc'
1242     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1243     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1244 esac
1246 AC_MSG_CHECKING(for --enable-framework)
1247 if test "$enable_framework"
1248 then
1249         BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1250         # -F. is needed to allow linking to the framework while 
1251         # in the build location.
1252         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
1253          [Define if you want to produce an OpenStep/Rhapsody framework
1254          (shared library plus accessory files).])
1255         AC_MSG_RESULT(yes)
1256 else
1257         AC_MSG_RESULT(no)
1260 AC_MSG_CHECKING(for dyld)
1261 case $ac_sys_system/$ac_sys_release in
1262   Darwin/*)
1263         AC_DEFINE(WITH_DYLD, 1, 
1264         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1265          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1266          linker (rld). Dyld is necessary to support frameworks.])
1267         AC_MSG_RESULT(always on for Darwin)
1268         ;;
1269   *)
1270         AC_MSG_RESULT(no)
1271         ;;
1272 esac
1274 # Set info about shared libraries.
1275 AC_SUBST(SO)
1276 AC_SUBST(LDSHARED)
1277 AC_SUBST(BLDSHARED)
1278 AC_SUBST(CCSHARED)
1279 AC_SUBST(LINKFORSHARED)
1280 # SO is the extension of shared libraries `(including the dot!)
1281 # -- usually .so, .sl on HP-UX, .dll on Cygwin
1282 AC_MSG_CHECKING(SO)
1283 if test -z "$SO"
1284 then
1285         case $ac_sys_system in
1286         hp*|HP*)   SO=.sl;;
1287         CYGWIN*)   SO=.dll;;
1288         *)         SO=.so;;
1289         esac
1290 else
1291         # this might also be a termcap variable, see #610332
1292         echo
1293         echo '====================================================================='
1294         echo '+                                                                   +'
1295         echo '+ WARNING: You have set SO in your environment.                     +'
1296         echo '+ Do you really mean to change the extension for shared libraries?  +'
1297         echo '+ Continuing in 10 seconds to let you to ponder.                    +'
1298         echo '+                                                                   +'
1299         echo '====================================================================='
1300         sleep 10
1302 AC_MSG_RESULT($SO)
1303 # LDSHARED is the ld *command* used to create shared library
1304 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1305 # (Shared libraries in this instance are shared modules to be loaded into
1306 # Python, as opposed to building Python itself as a shared library.)
1307 AC_MSG_CHECKING(LDSHARED)
1308 if test -z "$LDSHARED"
1309 then
1310         case $ac_sys_system/$ac_sys_release in
1311         AIX*)
1312                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1313                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1314                 ;;
1315         BeOS*)
1316                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1317                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1318                 ;;
1319         IRIX/5*) LDSHARED="ld -shared";;
1320         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1321         SunOS/5*) 
1322                 if test "$GCC" = "yes"
1323                 then LDSHARED='$(CC) -shared'
1324                 else LDSHARED='$(CC) -G';
1325                 fi ;;
1326         hp*|HP*) LDSHARED="ld -b";;
1327         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1328         Darwin/1.3*)
1329                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1330                 if test "$enable_framework" ; then
1331                         # Link against the framework. All externals should be defined.
1332                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1333                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1334                 else
1335                         # No framework. Ignore undefined symbols, assuming they come from Python
1336                         LDSHARED="$LDSHARED -undefined suppress"
1337                 fi ;;
1338         Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1339                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1340                 if test "$enable_framework" ; then
1341                         # Link against the framework. All externals should be defined.
1342                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1343                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1344                 else
1345                         # No framework, use the Python app as bundle-loader
1346                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1347                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1348                 fi ;;
1349         Darwin/*)
1350                 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1351                 # This allows an extension to be used in any Python
1352                 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1353                 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1354                 if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2
1355                 then
1356                         LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1357                         BLDSHARED="$LDSHARED"
1358                 else
1359                         LDSHARED='$(CC) $(LDFLAGS) -bundle'
1360                         if test "$enable_framework" ; then
1361                                 # Link against the framework. All externals should be defined.
1362                                 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1363                                 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1364                         else
1365                                 # No framework, use the Python app as bundle-loader
1366                                 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1367                                 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1368                         fi
1369                 fi
1370                 ;;
1371         Linux*|GNU*) LDSHARED='$(CC) -shared';;
1372         BSD/OS*/4*) LDSHARED="gcc -shared";;
1373         OpenBSD*|FreeBSD*)
1374                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1375                 then
1376                         LDSHARED="$CC -shared ${LDFLAGS}"
1377                 else
1378                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1379                 fi;;
1380         NetBSD*) LDSHARED="cc -shared ${LDFLAGS}";;
1381         OpenUNIX*|UnixWare*)
1382                 if test "$GCC" = "yes"
1383                 then LDSHARED='$(CC) -shared'
1384                 else LDSHARED='$(CC) -G'
1385                 fi;;
1386         SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1387         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
1388         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1389         atheos*) LDSHARED="gcc -shared";;
1390         *)      LDSHARED="ld";;
1391         esac
1393 AC_MSG_RESULT($LDSHARED)
1394 BLDSHARED=${BLDSHARED-$LDSHARED}
1395 # CCSHARED are the C *flags* used to create objects to go into a shared
1396 # library (module) -- this is only needed for a few systems
1397 AC_MSG_CHECKING(CCSHARED)
1398 if test -z "$CCSHARED"
1399 then
1400         case $ac_sys_system/$ac_sys_release in
1401         SunOS*) if test "$GCC" = yes;
1402                 then CCSHARED="-fPIC";
1403                 fi;;
1404         hp*|HP*) if test "$GCC" = yes;
1405                  then CCSHARED="-fPIC";
1406                  else CCSHARED="+z";
1407                  fi;;
1408         Linux*|GNU*) CCSHARED="-fPIC";;
1409         BSD/OS*/4*) CCSHARED="-fpic";;
1410         FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
1411         OpenUNIX*|UnixWare*)
1412                 if test "$GCC" = "yes"
1413                 then CCSHARED="-fPIC"
1414                 else CCSHARED="-KPIC"
1415                 fi;;
1416         SCO_SV*)
1417                 if test "$GCC" = "yes"
1418                 then CCSHARED="-fPIC"
1419                 else CCSHARED="-Kpic -belf"
1420                 fi;;
1421         Monterey*) CCSHARED="-G";;
1422         IRIX*/6*)  case $CC in
1423                    *gcc*) CCSHARED="-shared";;
1424                    *) CCSHARED="";;
1425                    esac;;
1426         atheos*) CCSHARED="-fPIC";;
1427         esac
1429 AC_MSG_RESULT($CCSHARED)
1430 # LINKFORSHARED are the flags passed to the $(CC) command that links
1431 # the python executable -- this is only needed for a few systems
1432 AC_MSG_CHECKING(LINKFORSHARED)
1433 if test -z "$LINKFORSHARED"
1434 then
1435         case $ac_sys_system/$ac_sys_release in
1436         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1437         hp*|HP*)
1438             LINKFORSHARED="-Wl,-E -Wl,+s";;
1439 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1440         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1441         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1442         # -u libsys_s pulls in all symbols in libsys
1443         Darwin/*) 
1444                 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1445                 # which is
1446                 # not used by the core itself but which needs to be in the core so
1447                 # that dynamically loaded extension modules have access to it.
1448                 # -prebind is no longer used, because it actually seems to give a
1449                 # slowdown in stead of a speedup, maybe due to the large number of
1450                 # dynamic loads Python does.
1452                 LINKFORSHARED="$extra_undefs"
1453                 if test "$enable_framework"
1454                 then
1455                         LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1456                 fi
1457                 LINKFORSHARED="$LINKFORSHARED";;
1458         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1459         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1460         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1461         FreeBSD*|NetBSD*|OpenBSD*) 
1462                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1463                 then
1464                         LINKFORSHARED="-Wl,--export-dynamic"
1465                 fi;;
1466         SunOS/5*) case $CC in
1467                   *gcc*)
1468                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1469                     then
1470                         LINKFORSHARED="-Xlinker --export-dynamic"
1471                     fi;;
1472                   esac;;
1473         CYGWIN*)
1474                 if test $enable_shared = "no"
1475                 then
1476                         LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1477                 fi;;
1478         esac
1480 AC_MSG_RESULT($LINKFORSHARED)
1482 AC_SUBST(CFLAGSFORSHARED)
1483 AC_MSG_CHECKING(CFLAGSFORSHARED)
1484 if test ! "$LIBRARY" = "$LDLIBRARY"
1485 then
1486         case $ac_sys_system in
1487         CYGWIN*)
1488                 # Cygwin needs CCSHARED when building extension DLLs
1489                 # but not when building the interpreter DLL.
1490                 CFLAGSFORSHARED='';;
1491         *)
1492                 CFLAGSFORSHARED='$(CCSHARED)'
1493         esac
1495 AC_MSG_RESULT($CFLAGSFORSHARED)
1497 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1498 # library (with --enable-shared).
1499 # For platforms on which shared libraries are not allowed to have unresolved
1500 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1501 # if it is not required, since it creates a dependency of the shared library
1502 # to LIBS. This, in turn, means that applications linking the shared libpython
1503 # don't need to link LIBS explicitly. The default should be only changed
1504 # on systems where this approach causes problems.
1505 AC_SUBST(SHLIBS)
1506 AC_MSG_CHECKING(SHLIBS)
1507 case "$ac_sys_system" in
1508         *)
1509                 SHLIBS='$(LIBS)';;
1510 esac
1511 AC_MSG_RESULT($SHLIBS)
1514 # checks for libraries
1515 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1516 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1518 # only check for sem_ini if thread support is requested
1519 if test "$with_threads" = "yes" -o -z "$with_threads"; then
1520     AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1521                                                 # posix4 on Solaris 2.6
1522                                                 # pthread (first!) on Linux
1525 # check if we need libintl for locale functions
1526 AC_CHECK_LIB(intl, textdomain,
1527         AC_DEFINE(WITH_LIBINTL, 1,
1528         [Define to 1 if libintl is needed for locale functions.]))
1530 # checks for system dependent C++ extensions support
1531 case "$ac_sys_system" in
1532         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1533                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1534                             [loadAndInit("", 0, "")],
1535                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1536                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1537                        and you want support for AIX C++ shared extension modules.])
1538                              AC_MSG_RESULT(yes)],
1539                             [AC_MSG_RESULT(no)]);;
1540         *) ;;
1541 esac
1543 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1544 # BeOS' sockets are stashed in libnet.
1545 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1546 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1548 case "$ac_sys_system" in
1549 BeOS*)
1550 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1552 esac
1554 AC_MSG_CHECKING(for --with-libs)
1555 AC_ARG_WITH(libs,
1556             AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1558 AC_MSG_RESULT($withval)
1559 LIBS="$withval $LIBS"
1561 [AC_MSG_RESULT(no)])
1563 # Determine if signalmodule should be used.
1564 AC_SUBST(USE_SIGNAL_MODULE)
1565 AC_SUBST(SIGNAL_OBJS)
1566 AC_MSG_CHECKING(for --with-signal-module)
1567 AC_ARG_WITH(signal-module,
1568             AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1570 if test -z "$with_signal_module"
1571 then with_signal_module="yes"
1573 AC_MSG_RESULT($with_signal_module)
1575 if test "${with_signal_module}" = "yes"; then
1576         USE_SIGNAL_MODULE=""
1577         SIGNAL_OBJS=""
1578 else
1579         USE_SIGNAL_MODULE="#"
1580         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1583 # This is used to generate Setup.config
1584 AC_SUBST(USE_THREAD_MODULE)
1585 USE_THREAD_MODULE=""
1587 AC_MSG_CHECKING(for --with-dec-threads)
1588 AC_SUBST(LDLAST)
1589 AC_ARG_WITH(dec-threads,
1590             AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1592 AC_MSG_RESULT($withval)
1593 LDLAST=-threads
1594 if test "${with_thread+set}" != set; then
1595    with_thread="$withval";
1596 fi],
1597 [AC_MSG_RESULT(no)])
1599 # Templates for things AC_DEFINEd more than once.
1600 # For a single AC_DEFINE, no template is needed.
1601 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1602 AH_TEMPLATE(_REENTRANT,
1603   [Define to force use of thread-safe errno, h_errno, and other functions])
1604 AH_TEMPLATE(WITH_THREAD,
1605   [Define if you want to compile in rudimentary thread support])
1607 AC_MSG_CHECKING(for --with-threads)
1608 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1609 AC_ARG_WITH(threads,
1610             AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
1612 # --with-thread is deprecated, but check for it anyway
1613 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1614 AC_ARG_WITH(thread,
1615             AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1616             [with_threads=$with_thread])
1618 if test -z "$with_threads"
1619 then with_threads="yes"
1621 AC_MSG_RESULT($with_threads)
1623 AC_SUBST(THREADOBJ)
1624 if test "$with_threads" = "no"
1625 then
1626     USE_THREAD_MODULE="#"
1627 elif test "$ac_cv_pthread_is_default" = yes
1628 then
1629     AC_DEFINE(WITH_THREAD)
1630     # Defining _REENTRANT on system with POSIX threads should not hurt.
1631     AC_DEFINE(_REENTRANT)
1632     posix_threads=yes
1633     THREADOBJ="Python/thread.o"    
1634 elif test "$ac_cv_kpthread" = "yes"
1635 then
1636     CC="$CC -Kpthread"
1637     if test "$ac_cv_cxx_thread" = "yes"; then
1638         CXX="$CXX -Kpthread"
1639     fi
1640     AC_DEFINE(WITH_THREAD)
1641     posix_threads=yes
1642     THREADOBJ="Python/thread.o"
1643 elif test "$ac_cv_kthread" = "yes"
1644 then
1645     CC="$CC -Kthread"
1646     if test "$ac_cv_cxx_thread" = "yes"; then
1647         CXX="$CXX -Kthread"
1648     fi
1649     AC_DEFINE(WITH_THREAD)
1650     posix_threads=yes
1651     THREADOBJ="Python/thread.o"
1652 elif test "$ac_cv_pthread" = "yes"
1653 then
1654     CC="$CC -pthread"
1655     if test "$ac_cv_cxx_thread" = "yes"; then
1656         CXX="$CXX -pthread"
1657     fi
1658     AC_DEFINE(WITH_THREAD)
1659     posix_threads=yes
1660     THREADOBJ="Python/thread.o"
1661 else
1662     if test ! -z "$with_threads" -a -d "$with_threads"
1663     then LDFLAGS="$LDFLAGS -L$with_threads"
1664     fi
1665     if test ! -z "$withval" -a -d "$withval"
1666     then LDFLAGS="$LDFLAGS -L$withval"
1667     fi
1669     # According to the POSIX spec, a pthreads implementation must
1670     # define _POSIX_THREADS in unistd.h. Some apparently don't
1671     # (e.g. gnu pth with pthread emulation)
1672     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1673     AC_EGREP_CPP(yes,
1674     [
1675 #include <unistd.h>
1676 #ifdef _POSIX_THREADS
1678 #endif
1679     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1680     AC_MSG_RESULT($unistd_defines_pthreads)
1682     AC_DEFINE(_REENTRANT)
1683     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1684     AC_DEFINE(C_THREADS)
1685     AC_DEFINE(HURD_C_THREADS, 1,
1686     [Define if you are using Mach cthreads directly under /include])
1687     LIBS="$LIBS -lthreads"
1688     THREADOBJ="Python/thread.o"],[
1689     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1690     AC_DEFINE(C_THREADS)
1691     AC_DEFINE(MACH_C_THREADS, 1,
1692     [Define if you are using Mach cthreads under mach /])
1693     THREADOBJ="Python/thread.o"],[
1694     AC_MSG_CHECKING(for --with-pth)
1695     AC_ARG_WITH([pth],
1696                 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
1697                 [AC_MSG_RESULT($withval)
1698                   AC_DEFINE([WITH_THREAD])
1699                   AC_DEFINE([HAVE_PTH], 1,
1700                             [Define if you have GNU PTH threads.])
1701                   LIBS="-lpth $LIBS"
1702                   THREADOBJ="Python/thread.o"],
1703                 [AC_MSG_RESULT(no)
1705     # Just looking for pthread_create in libpthread is not enough:
1706     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1707     # So we really have to include pthread.h, and then link.
1708     _libs=$LIBS
1709     LIBS="$LIBS -lpthread"
1710     AC_MSG_CHECKING([for pthread_create in -lpthread])
1711     AC_TRY_LINK([#include <pthread.h>
1713 void * start_routine (void *arg) { exit (0); }], [
1714 pthread_create (NULL, NULL, start_routine, NULL)], [
1715     AC_MSG_RESULT(yes)
1716     AC_DEFINE(WITH_THREAD)
1717     posix_threads=yes
1718     THREADOBJ="Python/thread.o"],[
1719     LIBS=$_libs
1720     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
1721     posix_threads=yes
1722     THREADOBJ="Python/thread.o"],[
1723     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1724     AC_DEFINE(ATHEOS_THREADS, 1,
1725     [Define this if you have AtheOS threads.])
1726     THREADOBJ="Python/thread.o"],[
1727     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1728     AC_DEFINE(BEOS_THREADS, 1,
1729     [Define this if you have BeOS threads.])
1730     THREADOBJ="Python/thread.o"],[
1731     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
1732     posix_threads=yes
1733     LIBS="$LIBS -lpthreads"
1734     THREADOBJ="Python/thread.o"], [
1735     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
1736     posix_threads=yes
1737     LIBS="$LIBS -lc_r"
1738     THREADOBJ="Python/thread.o"], [
1739     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
1740     posix_threads=yes
1741     LIBS="$LIBS -lpthread"
1742     THREADOBJ="Python/thread.o"], [
1743     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
1744     posix_threads=yes
1745     LIBS="$LIBS -lcma"
1746     THREADOBJ="Python/thread.o"],[
1747     USE_THREAD_MODULE="#"])
1748     ])])])])])])])])])])
1750     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1751     LIBS="$LIBS -lmpc"
1752     THREADOBJ="Python/thread.o"
1753     USE_THREAD_MODULE=""])
1755     if test "$posix_threads" != "yes"; then     
1756       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1757       LIBS="$LIBS -lthread"
1758       THREADOBJ="Python/thread.o"
1759       USE_THREAD_MODULE=""])
1760     fi
1762     if test "$USE_THREAD_MODULE" != "#"
1763     then
1764         # If the above checks didn't disable threads, (at least) OSF1
1765         # needs this '-threads' argument during linking.
1766         case $ac_sys_system in
1767         OSF1) LDLAST=-threads;;
1768         esac
1769     fi
1772 if test "$posix_threads" = "yes"; then
1773       if test "$unistd_defines_pthreads" = "no"; then
1774          AC_DEFINE(_POSIX_THREADS, 1,
1775          [Define if you have POSIX threads, 
1776           and your system does not define that.])
1777       fi
1779       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
1780       case  $ac_sys_system/$ac_sys_release in
1781   SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
1782                        Defined for Solaris 2.6 bug in pthread header.)
1783                        ;;
1784       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
1785                        Define if the Posix semaphores do not work on your system)
1786                        ;;
1787       esac
1789       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
1790       AC_CACHE_VAL(ac_cv_pthread_system_supported,
1791       [AC_TRY_RUN([#include <pthread.h>
1792       void *foo(void *parm) {
1793         return NULL;
1794       }
1795       main() {
1796         pthread_attr_t attr;
1797         pthread_t id;
1798         if (pthread_attr_init(&attr)) exit(-1);
1799         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
1800         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
1801         exit(0);
1802       }],
1803       ac_cv_pthread_system_supported=yes,
1804       ac_cv_pthread_system_supported=no,
1805       ac_cv_pthread_system_supported=no)
1806       ])
1807       AC_MSG_RESULT($ac_cv_pthread_system_supported)
1808       if test "$ac_cv_pthread_system_supported" = "yes"; then
1809         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
1810       fi
1811       AC_CHECK_FUNCS(pthread_sigmask,
1812         [case $ac_sys_system in
1813         CYGWIN*)
1814           AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
1815             [Define if pthread_sigmask() does not work on your system.])
1816             ;;
1817         esac])
1821 # Check for enable-ipv6
1822 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
1823 AC_MSG_CHECKING([if --enable-ipv6 is specified])
1824 AC_ARG_ENABLE(ipv6,
1825 [  --enable-ipv6           Enable ipv6 (with ipv4) support
1826   --disable-ipv6          Disable ipv6 support],
1827 [ case "$enableval" in
1828   no)
1829        AC_MSG_RESULT(no)
1830        ipv6=no
1831        ;;
1832   *)   AC_MSG_RESULT(yes)
1833        AC_DEFINE(ENABLE_IPV6)
1834        ipv6=yes
1835        ;;
1836   esac ],
1839 dnl the check does not work on cross compilation case...
1840   AC_TRY_RUN([ /* AF_INET6 available check */
1841 #include <sys/types.h>
1842 #include <sys/socket.h>
1843 main()
1845  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1846    exit(1);
1847  else
1848    exit(0);
1851   AC_MSG_RESULT(yes)
1852   ipv6=yes,
1853   AC_MSG_RESULT(no)
1854   ipv6=no,
1855   AC_MSG_RESULT(no)
1856   ipv6=no
1859 if test "$ipv6" = "yes"; then
1860         AC_MSG_CHECKING(if RFC2553 API is available)
1861         AC_TRY_COMPILE([#include <sys/types.h>
1862 #include <netinet/in.h>],
1863         [struct sockaddr_in6 x;
1864 x.sin6_scope_id;],
1865                 AC_MSG_RESULT(yes)
1866                 ipv6=yes,
1867                 AC_MSG_RESULT(no, IPv6 disabled)
1868                 ipv6=no)
1871 if test "$ipv6" = "yes"; then
1872         AC_DEFINE(ENABLE_IPV6)
1876 ipv6type=unknown
1877 ipv6lib=none
1878 ipv6trylibc=no
1880 if test "$ipv6" = "yes"; then
1881         AC_MSG_CHECKING([ipv6 stack type])
1882         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1883         do
1884                 case $i in
1885                 inria)
1886                         dnl http://www.kame.net/
1887                         AC_EGREP_CPP(yes, [
1888 #include <netinet/in.h>
1889 #ifdef IPV6_INRIA_VERSION
1891 #endif],
1892                                 [ipv6type=$i])
1893                         ;;
1894                 kame)
1895                         dnl http://www.kame.net/
1896                         AC_EGREP_CPP(yes, [
1897 #include <netinet/in.h>
1898 #ifdef __KAME__
1900 #endif],
1901                                 [ipv6type=$i;
1902                                 ipv6lib=inet6
1903                                 ipv6libdir=/usr/local/v6/lib
1904                                 ipv6trylibc=yes])
1905                         ;;
1906                 linux-glibc)
1907                         dnl http://www.v6.linux.or.jp/
1908                         AC_EGREP_CPP(yes, [
1909 #include <features.h>
1910 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1912 #endif],
1913                                 [ipv6type=$i;
1914                                 ipv6trylibc=yes])
1915                         ;;
1916                 linux-inet6)
1917                         dnl http://www.v6.linux.or.jp/
1918                         if test -d /usr/inet6; then
1919                                 ipv6type=$i
1920                                 ipv6lib=inet6
1921                                 ipv6libdir=/usr/inet6/lib
1922                                 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
1923                         fi
1924                         ;;
1925                 solaris)
1926                         if test -f /etc/netconfig; then
1927                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1928                                 ipv6type=$i
1929                                 ipv6trylibc=yes
1930                           fi
1931                         fi
1932                         ;;
1933                 toshiba)
1934                         AC_EGREP_CPP(yes, [
1935 #include <sys/param.h>
1936 #ifdef _TOSHIBA_INET6
1938 #endif],
1939                                 [ipv6type=$i;
1940                                 ipv6lib=inet6;
1941                                 ipv6libdir=/usr/local/v6/lib])
1942                         ;;
1943                 v6d)
1944                         AC_EGREP_CPP(yes, [
1945 #include </usr/local/v6/include/sys/v6config.h>
1946 #ifdef __V6D__
1948 #endif],
1949                                 [ipv6type=$i;
1950                                 ipv6lib=v6;
1951                                 ipv6libdir=/usr/local/v6/lib;
1952                                 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
1953                         ;;
1954                 zeta)
1955                         AC_EGREP_CPP(yes, [
1956 #include <sys/param.h>
1957 #ifdef _ZETA_MINAMI_INET6
1959 #endif],
1960                                 [ipv6type=$i;
1961                                 ipv6lib=inet6;
1962                                 ipv6libdir=/usr/local/v6/lib])
1963                         ;;
1964                 esac
1965                 if test "$ipv6type" != "unknown"; then
1966                         break
1967                 fi
1968         done
1969         AC_MSG_RESULT($ipv6type)
1972 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1973         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1974                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1975                 echo "using lib$ipv6lib"
1976         else
1977                 if test $ipv6trylibc = "yes"; then
1978                         echo "using libc"
1979                 else
1980                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
1981                         echo "You need to fetch lib$ipv6lib.a from appropriate"
1982                         echo 'ipv6 kit and compile beforehand.'
1983                         exit 1
1984                 fi
1985         fi
1988 # Check for --with-doc-strings
1989 AC_MSG_CHECKING(for --with-doc-strings)
1990 AC_ARG_WITH(doc-strings,
1991             AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
1993 if test -z "$with_doc_strings"
1994 then with_doc_strings="yes"
1996 if test "$with_doc_strings" != "no"
1997 then
1998     AC_DEFINE(WITH_DOC_STRINGS, 1,
1999       [Define if you want documentation strings in extension modules])
2001 AC_MSG_RESULT($with_doc_strings)
2003 # Check for Python-specific malloc support
2004 AC_MSG_CHECKING(for --with-tsc)
2005 AC_ARG_WITH(tsc,
2006 [  --with(out)-tsc         enable/disable timestamp counter profile], [
2007 if test "$withval" != no
2008 then 
2009   AC_DEFINE(WITH_TSC, 1, 
2010     [Define to profile with the Pentium timestamp counter]) 
2011     AC_MSG_RESULT(yes)
2012 else AC_MSG_RESULT(no)
2013 fi],
2014 [AC_MSG_RESULT(no)])
2016 # Check for Python-specific malloc support
2017 AC_MSG_CHECKING(for --with-pymalloc)
2018 AC_ARG_WITH(pymalloc,
2019             AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
2021 if test -z "$with_pymalloc"
2022 then with_pymalloc="yes"
2024 if test "$with_pymalloc" != "no"
2025 then
2026     AC_DEFINE(WITH_PYMALLOC, 1, 
2027      [Define if you want to compile in Python-specific mallocs])
2029 AC_MSG_RESULT($with_pymalloc)
2031 # Check for --with-wctype-functions
2032 AC_MSG_CHECKING(for --with-wctype-functions)
2033 AC_ARG_WITH(wctype-functions, 
2034             AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2036 if test "$withval" != no
2037 then 
2038   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2039   [Define if you want wctype.h functions to be used instead of the
2040    one supplied by Python itself. (see Include/unicodectype.h).]) 
2041   AC_MSG_RESULT(yes)
2042 else AC_MSG_RESULT(no)
2043 fi],
2044 [AC_MSG_RESULT(no)])
2046 # -I${DLINCLDIR} is added to the compile rule for importdl.o
2047 AC_SUBST(DLINCLDIR)
2048 DLINCLDIR=.
2050 # the dlopen() function means we might want to use dynload_shlib.o. some
2051 # platforms, such as AIX, have dlopen(), but don't want to use it.
2052 AC_CHECK_FUNCS(dlopen)
2054 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2055 # loading of modules.
2056 AC_SUBST(DYNLOADFILE)
2057 AC_MSG_CHECKING(DYNLOADFILE)
2058 if test -z "$DYNLOADFILE"
2059 then
2060         case $ac_sys_system/$ac_sys_release in
2061         AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2062         if test "$ac_cv_func_dlopen" = yes
2063         then DYNLOADFILE="dynload_shlib.o"
2064         else DYNLOADFILE="dynload_aix.o"
2065         fi
2066         ;;
2067         BeOS*) DYNLOADFILE="dynload_beos.o";;
2068         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2069         Darwin/*) DYNLOADFILE="dynload_next.o";;
2070         atheos*) DYNLOADFILE="dynload_atheos.o";;
2071         *)
2072         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2073         # out any dynamic loading
2074         if test "$ac_cv_func_dlopen" = yes
2075         then DYNLOADFILE="dynload_shlib.o"
2076         else DYNLOADFILE="dynload_stub.o"
2077         fi
2078         ;;
2079         esac
2081 AC_MSG_RESULT($DYNLOADFILE)
2082 if test "$DYNLOADFILE" != "dynload_stub.o"
2083 then
2084         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2085         [Defined when any dynamic module loading is enabled.])
2088 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
2090 AC_SUBST(MACHDEP_OBJS)
2091 AC_MSG_CHECKING(MACHDEP_OBJS)
2092 if test -z "$MACHDEP_OBJS"
2093 then
2094         MACHDEP_OBJS=$extra_machdep_objs
2095 else
2096         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2098 AC_MSG_RESULT(MACHDEP_OBJS)
2100 # checks for library functions
2101 AC_CHECK_FUNCS(alarm bind_textdomain_codeset chown clock confstr ctermid \
2102  execv fork fpathconf ftime ftruncate \
2103  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2104  getpriority getpwent getspnam getspent getsid getwd \
2105  kill killpg lchown lstat mkfifo mknod mktime \
2106  mremap nice pathconf pause plock poll pthread_init \
2107  putenv readlink realpath \
2108  select setegid seteuid setgid \
2109  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2110  sigaction siginterrupt sigrelse strftime \
2111  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2112  truncate uname unsetenv utimes waitpid wcscoll _getpty)
2114 # For some functions, having a definition is not sufficient, since
2115 # we want to take their address.
2116 AC_MSG_CHECKING(for chroot)
2117 AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2118   AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2119   AC_MSG_RESULT(yes),
2120   AC_MSG_RESULT(no)
2122 AC_MSG_CHECKING(for link)
2123 AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2124   AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2125   AC_MSG_RESULT(yes),
2126   AC_MSG_RESULT(no)
2128 AC_MSG_CHECKING(for symlink)
2129 AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2130   AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2131   AC_MSG_RESULT(yes),
2132   AC_MSG_RESULT(no)
2134 AC_MSG_CHECKING(for fchdir)
2135 AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2136   AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2137   AC_MSG_RESULT(yes),
2138   AC_MSG_RESULT(no)
2140 AC_MSG_CHECKING(for fsync)
2141 AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
2142   AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2143   AC_MSG_RESULT(yes),
2144   AC_MSG_RESULT(no)
2146 AC_MSG_CHECKING(for fdatasync)
2147 AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2148   AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2149   AC_MSG_RESULT(yes),
2150   AC_MSG_RESULT(no)
2153 # On some systems (eg. FreeBSD 5), we would find a definition of the
2154 # functions ctermid_r, setgroups in the library, but no prototype
2155 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2156 # address to avoid compiler warnings and potential miscompilations
2157 # because of the missing prototypes.
2159 AC_MSG_CHECKING(for ctermid_r)
2160 AC_TRY_COMPILE([
2161 #include "confdefs.h" 
2162 #include <stdio.h>
2163 ], void* p = ctermid_r,
2164   AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2165   AC_MSG_RESULT(yes),
2166   AC_MSG_RESULT(no)
2169 AC_MSG_CHECKING(for flock)
2170 AC_TRY_COMPILE([
2171 #include "confdefs.h" 
2172 #include <sys/file.h>
2173 ], void* p = flock,
2174   AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2175   AC_MSG_RESULT(yes),
2176   AC_MSG_RESULT(no)
2179 AC_MSG_CHECKING(for getpagesize)
2180 AC_TRY_COMPILE([
2181 #include "confdefs.h" 
2182 #include <unistd.h>
2183 ], void* p = getpagesize,
2184   AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2185   AC_MSG_RESULT(yes),
2186   AC_MSG_RESULT(no)
2189 dnl check for true
2190 AC_CHECK_PROGS(TRUE, true, /bin/true)
2192 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2193 dnl On others, they are in the C library, so we to take no action
2194 AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2195   AC_CHECK_LIB(resolv, inet_aton)
2198 AC_MSG_CHECKING(for hstrerror)
2199 AC_TRY_LINK([
2200 #include "confdefs.h" 
2201 #include <netdb.h>
2202 ], void* p = hstrerror; hstrerror(0),
2203   AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2204   AC_MSG_RESULT(yes),
2205   AC_MSG_RESULT(no)
2208 AC_MSG_CHECKING(for inet_aton)
2209 AC_TRY_LINK([
2210 #include "confdefs.h" 
2211 #include <sys/socket.h>
2212 #include <netinet/in.h>
2213 #include <arpa/inet.h>
2214 ], void* p = inet_aton;inet_aton(0,0),
2215   AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2216   AC_MSG_RESULT(yes),
2217   AC_MSG_RESULT(no)
2220 AC_MSG_CHECKING(for inet_pton)
2221 AC_TRY_COMPILE([
2222 #include "confdefs.h" 
2223 #include <sys/types.h>
2224 #include <sys/socket.h>
2225 #include <netinet/in.h>
2226 #include <arpa/inet.h>
2227 ], void* p = inet_pton,
2228   AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2229   AC_MSG_RESULT(yes),
2230   AC_MSG_RESULT(no)
2233 # On some systems, setgroups is in unistd.h, on others, in grp.h
2234 AC_MSG_CHECKING(for setgroups)
2235 AC_TRY_COMPILE([
2236 #include "confdefs.h" 
2237 #include <unistd.h>
2238 #ifdef HAVE_GRP_H
2239 #include <grp.h>
2240 #endif
2241 ], 
2242 void* p = setgroups,
2243   AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2244   AC_MSG_RESULT(yes),
2245   AC_MSG_RESULT(no)
2248 # check for openpty and forkpty
2250 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"]))
2251 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"]))
2253 # check for long file support functions
2254 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2256 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
2257 AC_CHECK_FUNCS(getpgrp, 
2258   AC_TRY_COMPILE([#include <unistd.h>], 
2259    [getpgrp(0);], 
2260    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2261    [Define if getpgrp() must be called as getpgrp(0).])
2264 AC_CHECK_FUNCS(setpgrp,
2265   AC_TRY_COMPILE([#include <unistd.h>],
2266     [setpgrp(0,0);],
2267     AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2268     [Define if setpgrp() must be called as setpgrp(0, 0).])
2269   )
2271 AC_CHECK_FUNCS(gettimeofday, 
2272   AC_TRY_COMPILE([#include <sys/time.h>], 
2273     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2274     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2275     [Define if gettimeofday() does not have second (timezone) argument
2276      This is the case on Motorola V4 (R40V4.2)])
2277   )
2280 AC_MSG_CHECKING(for major, minor, and makedev)
2281 AC_TRY_LINK([
2282 #if defined(MAJOR_IN_MKDEV)
2283 #include <sys/mkdev.h>
2284 #elif defined(MAJOR_IN_SYSMACROS)
2285 #include <sys/sysmacros.h>
2286 #else
2287 #include <sys/types.h>
2288 #endif
2290   makedev(major(0),minor(0));
2292   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2293             [Define to 1 if you have the device macros.])
2294   AC_MSG_RESULT(yes)
2296   AC_MSG_RESULT(no)
2299 # On OSF/1 V5.1, getaddrinfo is available, but a define
2300 # for [no]getaddrinfo in netdb.h. 
2301 AC_MSG_CHECKING(for getaddrinfo)
2302 AC_TRY_LINK([
2303 #include <sys/types.h>
2304 #include <sys/socket.h>
2305 #include <netdb.h>
2306 #include <stdio.h>
2308 getaddrinfo(NULL, NULL, NULL, NULL);
2309 ], [
2310 AC_MSG_RESULT(yes)
2311 AC_MSG_CHECKING(getaddrinfo bug)
2312 AC_TRY_RUN([
2313 #include <sys/types.h>
2314 #include <netdb.h>
2315 #include <string.h>
2316 #include <sys/socket.h>
2317 #include <netinet/in.h>
2319 main()
2321   int passive, gaierr, inet4 = 0, inet6 = 0;
2322   struct addrinfo hints, *ai, *aitop;
2323   char straddr[INET6_ADDRSTRLEN], strport[16];
2325   for (passive = 0; passive <= 1; passive++) {
2326     memset(&hints, 0, sizeof(hints));
2327     hints.ai_family = AF_UNSPEC;
2328     hints.ai_flags = passive ? AI_PASSIVE : 0;
2329     hints.ai_socktype = SOCK_STREAM;
2330     hints.ai_protocol = IPPROTO_TCP;
2331     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2332       (void)gai_strerror(gaierr);
2333       goto bad;
2334     }
2335     for (ai = aitop; ai; ai = ai->ai_next) {
2336       if (ai->ai_addr == NULL ||
2337           ai->ai_addrlen == 0 ||
2338           getnameinfo(ai->ai_addr, ai->ai_addrlen,
2339                       straddr, sizeof(straddr), strport, sizeof(strport),
2340                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2341         goto bad;
2342       }
2343       switch (ai->ai_family) {
2344       case AF_INET:
2345         if (strcmp(strport, "54321") != 0) {
2346           goto bad;
2347         }
2348         if (passive) {
2349           if (strcmp(straddr, "0.0.0.0") != 0) {
2350             goto bad;
2351           }
2352         } else {
2353           if (strcmp(straddr, "127.0.0.1") != 0) {
2354             goto bad;
2355           }
2356         }
2357         inet4++;
2358         break;
2359       case AF_INET6:
2360         if (strcmp(strport, "54321") != 0) {
2361           goto bad;
2362         }
2363         if (passive) {
2364           if (strcmp(straddr, "::") != 0) {
2365             goto bad;
2366           }
2367         } else {
2368           if (strcmp(straddr, "::1") != 0) {
2369             goto bad;
2370           }
2371         }
2372         inet6++;
2373         break;
2374       case AF_UNSPEC:
2375         goto bad;
2376         break;
2377       default:
2378         /* another family support? */
2379         break;
2380       }
2381     }
2382   }
2384   if (!(inet4 == 0 || inet4 == 2))
2385     goto bad;
2386   if (!(inet6 == 0 || inet6 == 2))
2387     goto bad;
2389   if (aitop)
2390     freeaddrinfo(aitop);
2391   exit(0);
2393  bad:
2394   if (aitop)
2395     freeaddrinfo(aitop);
2396   exit(1);
2399 AC_MSG_RESULT(good)
2400 buggygetaddrinfo=no,
2401 AC_MSG_RESULT(buggy)
2402 buggygetaddrinfo=yes,
2403 AC_MSG_RESULT(buggy)
2404 buggygetaddrinfo=yes)], [
2405 AC_MSG_RESULT(no)
2406 buggygetaddrinfo=yes
2409 if test "$buggygetaddrinfo" = "yes"; then
2410         if test "$ipv6" = "yes"; then
2411                 echo 'Fatal: You must get working getaddrinfo() function.'
2412                 echo '       or you can specify "--disable-ipv6"'.
2413                 exit 1
2414         fi
2415 else
2416         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2418 AC_CHECK_FUNCS(getnameinfo)
2420 # checks for structures
2421 AC_HEADER_TIME
2422 AC_STRUCT_TM
2423 AC_STRUCT_TIMEZONE
2424 AC_CHECK_MEMBERS([struct stat.st_rdev])
2425 AC_CHECK_MEMBERS([struct stat.st_blksize])
2426 AC_CHECK_MEMBERS([struct stat.st_flags])
2427 AC_CHECK_MEMBERS([struct stat.st_gen])
2428 AC_CHECK_MEMBERS([struct stat.st_birthtime])
2429 AC_STRUCT_ST_BLOCKS
2431 AC_MSG_CHECKING(for time.h that defines altzone)
2432 AC_CACHE_VAL(ac_cv_header_time_altzone,
2433 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2434   ac_cv_header_time_altzone=yes,
2435   ac_cv_header_time_altzone=no)])
2436 AC_MSG_RESULT($ac_cv_header_time_altzone)
2437 if test $ac_cv_header_time_altzone = yes; then
2438   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2441 was_it_defined=no
2442 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2443 AC_TRY_COMPILE([
2444 #include <sys/types.h>
2445 #include <sys/select.h>
2446 #include <sys/time.h>
2447 ], [;], [
2448   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2449   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
2450    (which you can't on SCO ODT 3.0).]) 
2451   was_it_defined=yes
2453 AC_MSG_RESULT($was_it_defined)
2455 AC_MSG_CHECKING(for addrinfo)
2456 AC_CACHE_VAL(ac_cv_struct_addrinfo,
2457 AC_TRY_COMPILE([
2458 #               include <netdb.h>],
2459         [struct addrinfo a],
2460         ac_cv_struct_addrinfo=yes,
2461         ac_cv_struct_addrinfo=no))
2462 AC_MSG_RESULT($ac_cv_struct_addrinfo)
2463 if test $ac_cv_struct_addrinfo = yes; then
2464         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
2467 AC_MSG_CHECKING(for sockaddr_storage)
2468 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2469 AC_TRY_COMPILE([
2470 #               include <sys/types.h>
2471 #               include <sys/socket.h>],
2472         [struct sockaddr_storage s],
2473         ac_cv_struct_sockaddr_storage=yes,
2474         ac_cv_struct_sockaddr_storage=no))
2475 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2476 if test $ac_cv_struct_sockaddr_storage = yes; then
2477         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
2480 # checks for compiler characteristics
2482 AC_C_CHAR_UNSIGNED
2483 AC_C_CONST
2485 works=no
2486 AC_MSG_CHECKING(for working volatile)
2487 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
2488   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2490 AC_MSG_RESULT($works)
2492 works=no
2493 AC_MSG_CHECKING(for working signed char)
2494 AC_TRY_COMPILE([], [signed char c;], works=yes, 
2495   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2497 AC_MSG_RESULT($works)
2499 have_prototypes=no
2500 AC_MSG_CHECKING(for prototypes)
2501 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2502   AC_DEFINE(HAVE_PROTOTYPES, 1, 
2503    [Define if your compiler supports function prototype]) 
2504   have_prototypes=yes
2506 AC_MSG_RESULT($have_prototypes)
2508 works=no
2509 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
2510 AC_TRY_COMPILE([
2511 #include <stdarg.h>
2512 int foo(int x, ...) {
2513         va_list va;
2514         va_start(va, x);
2515         va_arg(va, int);
2516         va_arg(va, char *);
2517         va_arg(va, double);
2518         return 0;
2520 ], [return foo(10, "", 3.14);], [
2521   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2522    [Define if your compiler supports variable length function prototypes
2523    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
2524   works=yes
2526 AC_MSG_RESULT($works)
2528 # check for socketpair
2529 AC_MSG_CHECKING(for socketpair)
2530 AC_TRY_COMPILE([
2531 #include <sys/types.h>
2532 #include <sys/socket.h>
2533 ], void *x=socketpair,
2534   AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
2535   AC_MSG_RESULT(yes),
2536   AC_MSG_RESULT(no)
2539 # check if sockaddr has sa_len member
2540 AC_MSG_CHECKING(if sockaddr has sa_len member)
2541 AC_TRY_COMPILE([#include <sys/types.h>
2542 #include <sys/socket.h>],
2543 [struct sockaddr x;
2544 x.sa_len = 0;],
2545         AC_MSG_RESULT(yes)
2546         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
2547         AC_MSG_RESULT(no))
2549 va_list_is_array=no
2550 AC_MSG_CHECKING(whether va_list is an array)
2551 AC_TRY_COMPILE([
2552 #ifdef HAVE_STDARG_PROTOTYPES
2553 #include <stdarg.h>
2554 #else
2555 #include <varargs.h>
2556 #endif
2557 ], [va_list list1, list2; list1 = list2;], , [
2558  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
2559  va_list_is_array=yes
2561 AC_MSG_RESULT($va_list_is_array)
2563 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
2564 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2565   [Define this if you have some version of gethostbyname_r()])
2567 AC_CHECK_FUNC(gethostbyname_r, [
2568   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2569   AC_MSG_CHECKING([gethostbyname_r with 6 args])
2570   OLD_CFLAGS=$CFLAGS
2571   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2572   AC_TRY_COMPILE([
2573 #   include <netdb.h>
2574   ], [
2575     char *name;
2576     struct hostent *he, *res;
2577     char buffer[2048];
2578     int buflen = 2048;
2579     int h_errnop;
2581     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2582   ], [
2583     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2584     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2585     [Define this if you have the 6-arg version of gethostbyname_r().])
2586     AC_MSG_RESULT(yes)
2587   ], [
2588     AC_MSG_RESULT(no)
2589     AC_MSG_CHECKING([gethostbyname_r with 5 args])
2590     AC_TRY_COMPILE([
2591 #     include <netdb.h>
2592     ], [
2593       char *name;
2594       struct hostent *he;
2595       char buffer[2048];
2596       int buflen = 2048;
2597       int h_errnop;
2599       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2600     ], [
2601       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2602       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2603       [Define this if you have the 5-arg version of gethostbyname_r().])
2604       AC_MSG_RESULT(yes)
2605     ], [
2606       AC_MSG_RESULT(no)
2607       AC_MSG_CHECKING([gethostbyname_r with 3 args])
2608       AC_TRY_COMPILE([
2609 #       include <netdb.h>
2610       ], [
2611         char *name;
2612         struct hostent *he;
2613         struct hostent_data data;
2615         (void) gethostbyname_r(name, he, &data);
2616       ], [
2617         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2618         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2619         [Define this if you have the 3-arg version of gethostbyname_r().])
2620         AC_MSG_RESULT(yes)
2621       ], [
2622         AC_MSG_RESULT(no)
2623       ])
2624     ])
2625   ])
2626   CFLAGS=$OLD_CFLAGS
2627 ], [
2628   AC_CHECK_FUNCS(gethostbyname)
2630 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2631 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2632 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
2633 AC_SUBST(HAVE_GETHOSTBYNAME_R)
2634 AC_SUBST(HAVE_GETHOSTBYNAME)
2636 # checks for system services
2637 # (none yet)
2639 # Linux requires this for correct f.p. operations
2640 AC_CHECK_FUNC(__fpu_control,
2641   [],
2642   [AC_CHECK_LIB(ieee, __fpu_control)
2645 # Check for --with-fpectl
2646 AC_MSG_CHECKING(for --with-fpectl)
2647 AC_ARG_WITH(fpectl,
2648             AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
2650 if test "$withval" != no
2651 then 
2652   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2653   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
2654   AC_MSG_RESULT(yes)
2655 else AC_MSG_RESULT(no)
2656 fi],
2657 [AC_MSG_RESULT(no)])
2659 # check for --with-libm=...
2660 AC_SUBST(LIBM)
2661 case $ac_sys_system in
2662 Darwin) ;;
2663 BeOS) ;;
2664 *) LIBM=-lm
2665 esac
2666 AC_MSG_CHECKING(for --with-libm=STRING)
2667 AC_ARG_WITH(libm,
2668             AC_HELP_STRING(--with-libm=STRING, math library),
2670 if test "$withval" = no
2671 then LIBM=
2672      AC_MSG_RESULT(force LIBM empty)
2673 elif test "$withval" != yes
2674 then LIBM=$withval
2675      AC_MSG_RESULT(set LIBM="$withval")
2676 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
2677 fi],
2678 [AC_MSG_RESULT(default LIBM="$LIBM")])
2680 # check for --with-libc=...
2681 AC_SUBST(LIBC)
2682 AC_MSG_CHECKING(for --with-libc=STRING)
2683 AC_ARG_WITH(libc,
2684             AC_HELP_STRING(--with-libc=STRING, C library),
2686 if test "$withval" = no
2687 then LIBC=
2688      AC_MSG_RESULT(force LIBC empty)
2689 elif test "$withval" != yes
2690 then LIBC=$withval
2691      AC_MSG_RESULT(set LIBC="$withval")
2692 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
2693 fi],
2694 [AC_MSG_RESULT(default LIBC="$LIBC")])
2696 # check for hypot() in math library
2697 LIBS_SAVE=$LIBS
2698 LIBS="$LIBS $LIBM"
2699 AC_REPLACE_FUNCS(hypot)
2700 LIBS=$LIBS_SAVE
2702 # check for wchar.h
2703 AC_CHECK_HEADER(wchar.h, [
2704   AC_DEFINE(HAVE_WCHAR_H, 1, 
2705   [Define if the compiler provides a wchar.h header file.]) 
2706   wchar_h="yes"
2708 wchar_h="no"
2711 # determine wchar_t size
2712 if test "$wchar_h" = yes
2713 then
2714   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
2717 AC_MSG_CHECKING(for UCS-4 tcl)
2718 have_ucs4_tcl=no
2719 AC_TRY_COMPILE([
2720 #include <tcl.h>
2721 #if TCL_UTF_MAX != 6
2722 # error "NOT UCS4_TCL"
2723 #endif], [], [
2724   AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
2725   have_ucs4_tcl=yes
2727 AC_MSG_RESULT($have_ucs4_tcl)
2729 # check whether wchar_t is signed or not
2730 if test "$wchar_h" = yes
2731 then
2732   # check whether wchar_t is signed or not
2733   AC_MSG_CHECKING(whether wchar_t is signed)
2734   AC_CACHE_VAL(ac_cv_wchar_t_signed, [
2735   AC_TRY_RUN([
2736   #include <wchar.h>
2737   int main()
2738   {
2739         exit((((wchar_t) -1) < ((wchar_t) 0)) ? 1 : 0);
2740   }
2741   ],
2742   ac_cv_wchar_t_signed=yes,
2743   ac_cv_wchar_t_signed=no,
2744   ac_cv_wchar_t_signed=yes)])
2745   AC_MSG_RESULT($ac_cv_wchar_t_signed)
2747   
2748 AC_MSG_CHECKING(what type to use for unicode)
2749 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2750 AC_ARG_ENABLE(unicode, 
2751               AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
2752               [],
2753               [enable_unicode=yes])
2755 if test $enable_unicode = yes
2756 then
2757   # Without any arguments, Py_UNICODE defaults to two-byte mode
2758   case "$have_ucs4_tcl" in
2759   yes) enable_unicode="ucs4"
2760        ;;
2761   *)   enable_unicode="ucs2"
2762        ;;
2763   esac
2766 AH_TEMPLATE(Py_UNICODE_SIZE,
2767   [Define as the size of the unicode type.])
2768 case "$enable_unicode" in
2769 ucs2) unicode_size="2"
2770       AC_DEFINE(Py_UNICODE_SIZE,2)
2771       ;;
2772 ucs4) unicode_size="4"
2773       AC_DEFINE(Py_UNICODE_SIZE,4)
2774       ;;
2775 esac
2777 AH_TEMPLATE(PY_UNICODE_TYPE,
2778   [Define as the integral type used for Unicode representation.])
2780 AC_SUBST(UNICODE_OBJS)
2781 if test "$enable_unicode" = "no"
2782 then
2783   UNICODE_OBJS=""
2784   AC_MSG_RESULT(not used)
2785 else
2786   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
2787   AC_DEFINE(Py_USING_UNICODE, 1,
2788   [Define if you want to have a Unicode type.])
2790   # wchar_t is only usable if it maps to an unsigned type
2791   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
2792           -a "$ac_cv_wchar_t_signed" = "no"
2793   then
2794     PY_UNICODE_TYPE="wchar_t"
2795     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
2796     [Define if you have a useable wchar_t type defined in wchar.h; useable
2797      means wchar_t must be an unsigned type with at least 16 bits. (see
2798      Include/unicodeobject.h).])
2799     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
2800   elif test "$ac_cv_sizeof_short" = "$unicode_size"
2801   then
2802        PY_UNICODE_TYPE="unsigned short"
2803        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
2804   elif test "$ac_cv_sizeof_long" = "$unicode_size"
2805   then
2806        PY_UNICODE_TYPE="unsigned long"
2807        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
2808   else
2809        PY_UNICODE_TYPE="no type found"
2810   fi
2811   AC_MSG_RESULT($PY_UNICODE_TYPE)
2814 # check for endianness
2815 AC_C_BIGENDIAN
2817 # Check whether right shifting a negative integer extends the sign bit
2818 # or fills with zeros (like the Cray J90, according to Tim Peters).
2819 AC_MSG_CHECKING(whether right shift extends the sign bit)
2820 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
2821 AC_TRY_RUN([
2822 int main()
2824         exit(((-1)>>3 == -1) ? 0 : 1);
2827 ac_cv_rshift_extends_sign=yes,
2828 ac_cv_rshift_extends_sign=no,
2829 ac_cv_rshift_extends_sign=yes)])
2830 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
2831 if test "$ac_cv_rshift_extends_sign" = no
2832 then
2833   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
2834   [Define if i>>j for signed int i does not extend the sign bit
2835    when i < 0])
2838 # check for getc_unlocked and related locking functions
2839 AC_MSG_CHECKING(for getc_unlocked() and friends)
2840 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
2841 AC_TRY_LINK([#include <stdio.h>],[
2842         FILE *f = fopen("/dev/null", "r");
2843         flockfile(f);
2844         getc_unlocked(f);
2845         funlockfile(f);
2846 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
2847 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
2848 if test "$ac_cv_have_getc_unlocked" = yes
2849 then
2850   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
2851   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
2854 # check for readline 2.1
2855 AC_CHECK_LIB(readline, rl_callback_handler_install,
2856         AC_DEFINE(HAVE_RL_CALLBACK, 1,
2857         [Define if you have readline 2.1]), , -ltermcap)
2859 # check for readline 2.2
2860 AC_TRY_CPP([#include <readline/readline.h>],
2861 have_readline=yes, have_readline=no)
2862 if test $have_readline = yes
2863 then
2864   AC_EGREP_HEADER([extern int rl_completion_append_character;],
2865   [readline/readline.h],
2866   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
2867   [Define if you have readline 2.2]), )
2870 # check for readline 4.0
2871 AC_CHECK_LIB(readline, rl_pre_input_hook,
2872         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
2873         [Define if you have readline 4.0]), , -ltermcap)
2875 # check for readline 4.2
2876 AC_CHECK_LIB(readline, rl_completion_matches,
2877         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
2878         [Define if you have readline 4.2]), , -ltermcap)
2880 # also in readline 4.2
2881 AC_TRY_CPP([#include <readline/readline.h>],
2882 have_readline=yes, have_readline=no)
2883 if test $have_readline = yes
2884 then
2885   AC_EGREP_HEADER([extern int rl_catch_signals;],
2886   [readline/readline.h],
2887   AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
2888   [Define if you can turn off readline's signal handling.]), )
2891 AC_MSG_CHECKING(for broken nice())
2892 AC_CACHE_VAL(ac_cv_broken_nice, [
2893 AC_TRY_RUN([
2894 int main()
2896         int val1 = nice(1);
2897         if (val1 != -1 && val1 == nice(2))
2898                 exit(0);
2899         exit(1);
2902 ac_cv_broken_nice=yes,
2903 ac_cv_broken_nice=no,
2904 ac_cv_broken_nice=no)])
2905 AC_MSG_RESULT($ac_cv_broken_nice)
2906 if test "$ac_cv_broken_nice" = yes
2907 then
2908   AC_DEFINE(HAVE_BROKEN_NICE, 1,
2909   [Define if nice() returns success/failure instead of the new priority.])
2912 AC_MSG_CHECKING(for broken poll())
2913 AC_TRY_RUN([
2914 #include <poll.h>
2916 int main (void)
2917     {
2918     struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
2919     
2920     close (42);
2922     int poll_test = poll (&poll_struct, 1, 0);
2924     if (poll_test < 0)
2925         {
2926         exit(0);
2927         }
2928     else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
2929         {
2930         exit(0);
2931         }
2932     else
2933         {
2934         exit(1);
2935         }
2936     }
2938 ac_cv_broken_poll=yes,
2939 ac_cv_broken_poll=no,
2940 ac_cv_broken_poll=no)
2941 AC_MSG_RESULT($ac_cv_broken_poll)
2942 if test "$ac_cv_broken_poll" = yes
2943 then
2944   AC_DEFINE(HAVE_BROKEN_POLL, 1,
2945       [Define if poll() sets errno on invalid file descriptors.])
2948 # Before we can test tzset, we need to check if struct tm has a tm_zone 
2949 # (which is not required by ISO C or UNIX spec) and/or if we support
2950 # tzname[]
2951 AC_STRUCT_TIMEZONE
2953 # check tzset(3) exists and works like we expect it to
2954 AC_MSG_CHECKING(for working tzset())
2955 AC_CACHE_VAL(ac_cv_working_tzset, [
2956 AC_TRY_RUN([
2957 #include <stdlib.h>
2958 #include <time.h>
2959 #include <string.h>
2961 #if HAVE_TZNAME
2962 extern char *tzname[];
2963 #endif
2965 int main()
2967         /* Note that we need to ensure that not only does tzset(3)
2968            do 'something' with localtime, but it works as documented
2969            in the library reference and as expected by the test suite.
2970            This includes making sure that tzname is set properly if
2971            tm->tm_zone does not exist since it is the alternative way
2972            of getting timezone info.
2974            Red Hat 6.2 doesn't understand the southern hemisphere 
2975            after New Year's Day.
2976         */
2978         time_t groundhogday = 1044144000; /* GMT-based */
2979         time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
2981         putenv("TZ=UTC+0");
2982         tzset();
2983         if (localtime(&groundhogday)->tm_hour != 0)
2984             exit(1);
2985 #if HAVE_TZNAME
2986         /* For UTC, tzname[1] is sometimes "", sometimes "   " */
2987         if (strcmp(tzname[0], "UTC") || 
2988                 (tzname[1][0] != 0 && tzname[1][0] != ' '))
2989             exit(1);
2990 #endif
2992         putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
2993         tzset();
2994         if (localtime(&groundhogday)->tm_hour != 19)
2995             exit(1);
2996 #if HAVE_TZNAME
2997         if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
2998             exit(1);
2999 #endif
3001         putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3002         tzset();
3003         if (localtime(&groundhogday)->tm_hour != 11)
3004             exit(1);
3005 #if HAVE_TZNAME
3006         if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3007             exit(1);
3008 #endif
3010 #if HAVE_STRUCT_TM_TM_ZONE
3011         if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3012             exit(1);
3013         if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3014             exit(1);
3015 #endif
3017         exit(0);
3020 ac_cv_working_tzset=yes,
3021 ac_cv_working_tzset=no,
3022 ac_cv_working_tzset=no)])
3023 AC_MSG_RESULT($ac_cv_working_tzset)
3024 if test "$ac_cv_working_tzset" = yes
3025 then
3026   AC_DEFINE(HAVE_WORKING_TZSET, 1,
3027   [Define if tzset() actually switches the local timezone in a meaningful way.])
3030 # Look for subsecond timestamps in struct stat
3031 AC_MSG_CHECKING(for tv_nsec in struct stat)
3032 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3033 AC_TRY_COMPILE([#include <sys/stat.h>], [
3034 struct stat st;
3035 st.st_mtim.tv_nsec = 1;
3037 ac_cv_stat_tv_nsec=yes,
3038 ac_cv_stat_tv_nsec=no,
3039 ac_cv_stat_tv_nsec=no))
3040 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3041 if test "$ac_cv_stat_tv_nsec" = yes
3042 then
3043   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3044   [Define if you have struct stat.st_mtim.tv_nsec])
3047 # Look for BSD style subsecond timestamps in struct stat
3048 AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3049 AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3050 AC_TRY_COMPILE([#include <sys/stat.h>], [
3051 struct stat st;
3052 st.st_mtimespec.tv_nsec = 1;
3054 ac_cv_stat_tv_nsec2=yes,
3055 ac_cv_stat_tv_nsec2=no,
3056 ac_cv_stat_tv_nsec2=no))
3057 AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3058 if test "$ac_cv_stat_tv_nsec2" = yes
3059 then
3060   AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3061   [Define if you have struct stat.st_mtimensec])
3064 # On HP/UX 11.0, mvwdelch is a block with a return statement
3065 AC_MSG_CHECKING(whether mvwdelch is an expression)
3066 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3067 AC_TRY_COMPILE([#include <curses.h>], [
3068   int rtn;
3069   rtn = mvwdelch(0,0,0);
3070 ], ac_cv_mvwdelch_is_expression=yes,
3071    ac_cv_mvwdelch_is_expression=no,
3072    ac_cv_mvwdelch_is_expression=yes))
3073 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3075 if test "$ac_cv_mvwdelch_is_expression" = yes
3076 then
3077   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3078   [Define if mvwdelch in curses.h is an expression.])
3081 AC_MSG_CHECKING(whether WINDOW has _flags)
3082 AC_CACHE_VAL(ac_cv_window_has_flags,
3083 AC_TRY_COMPILE([#include <curses.h>], [
3084   WINDOW *w;
3085   w->_flags = 0;
3086 ], ac_cv_window_has_flags=yes,
3087    ac_cv_window_has_flags=no,
3088    ac_cv_window_has_flags=no))
3089 AC_MSG_RESULT($ac_cv_window_has_flags)
3092 if test "$ac_cv_window_has_flags" = yes
3093 then
3094   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
3095   [Define if WINDOW in curses.h offers a field _flags.])
3098 AC_MSG_CHECKING(for /dev/ptmx)
3100 if test -e /dev/ptmx
3101 then
3102   AC_MSG_RESULT(yes)
3103   AC_DEFINE(HAVE_DEV_PTMX, 1,
3104   [Define if we have /dev/ptmx.])
3105 else
3106   AC_MSG_RESULT(no)
3109 AC_MSG_CHECKING(for /dev/ptc)
3111 if test -e /dev/ptc
3112 then
3113   AC_MSG_RESULT(yes)
3114   AC_DEFINE(HAVE_DEV_PTC, 1,
3115   [Define if we have /dev/ptc.])
3116 else
3117   AC_MSG_RESULT(no)
3120 AC_CHECK_TYPE(socklen_t,,
3121   AC_DEFINE(socklen_t,int,
3122             Define to `int' if <sys/socket.h> does not define.),[
3123 #ifdef HAVE_SYS_TYPES_H
3124 #include <sys/types.h>
3125 #endif
3126 #ifdef HAVE_SYS_SOCKET_H
3127 #include <sys/socket.h>
3128 #endif
3131 AC_SUBST(THREADHEADERS)
3133 for h in `(cd $srcdir;echo Python/thread_*.h)`
3135   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3136 done
3138 AC_SUBST(SRCDIRS)
3139 SRCDIRS="Parser Grammar Objects Python Modules Mac Mac/Python"
3140 AC_MSG_CHECKING(for build directories)
3141 for dir in $SRCDIRS; do
3142     if test ! -d $dir; then
3143         mkdir $dir
3144     fi
3145 done
3146 AC_MSG_RESULT(done)
3148 # generate output files
3149 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
3150 AC_OUTPUT
3152 echo "creating Setup"
3153 if test ! -f Modules/Setup
3154 then
3155         cp $srcdir/Modules/Setup.dist Modules/Setup
3158 echo "creating Setup.local"
3159 if test ! -f Modules/Setup.local
3160 then
3161         echo "# Edit this file for local setup changes" >Modules/Setup.local
3164 echo "creating Makefile"
3165 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3166                         -s Modules Modules/Setup.config \
3167                         Modules/Setup.local Modules/Setup
3168 mv config.c Modules