This commit was manufactured by cvs2svn to create tag 'r234c1'.
[python/dscho.git] / configure.in
bloba9ea12635e71488adae993b56aab7aeeeaed984b
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.3)
6 AC_REVISION($Revision$)
7 AC_PREREQ(2.53)
8 AC_INIT(python, PYTHON_VERSION)
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 define_xopen_source=yes
55 # Arguments passed to configure.
56 AC_SUBST(CONFIG_ARGS)
57 CONFIG_ARGS="$ac_configure_args"
59 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
60 AC_ARG_ENABLE(framework,
61               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
63         case $enableval in
64         yes) 
65                 enableval=/Library/Frameworks
66         esac
67         case $enableval in
68         no)
69                 PYTHONFRAMEWORK=
70                 PYTHONFRAMEWORKDIR=no-framework
71                 PYTHONFRAMEWORKPREFIX=
72                 PYTHONFRAMEWORKINSTALLDIR=
73                 enable_framework=
74                 ;;
75         *)
76                 PYTHONFRAMEWORK=Python
77                 PYTHONFRAMEWORKDIR=Python.framework
78                 PYTHONFRAMEWORKPREFIX=$enableval
79                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
80                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
81         esac
82         ],[
83         PYTHONFRAMEWORK=
84         PYTHONFRAMEWORKDIR=no-framework
85         PYTHONFRAMEWORKPREFIX=
86         PYTHONFRAMEWORKINSTALLDIR=
87         enable_framework=
89 AC_SUBST(PYTHONFRAMEWORK)
90 AC_SUBST(PYTHONFRAMEWORKDIR)
91 AC_SUBST(PYTHONFRAMEWORKPREFIX)
92 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
94 ##AC_ARG_WITH(dyld,
95 ##            AC_HELP_STRING(--with-dyld,
96 ##                           Use (OpenStep|Rhapsody) dynamic linker))
98 # Set name for machine-dependent library files
99 AC_SUBST(MACHDEP)
100 AC_MSG_CHECKING(MACHDEP)
101 if test -z "$MACHDEP"
102 then
103         ac_sys_system=`uname -s`
104         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
105         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
106                 ac_sys_release=`uname -v`
107         else
108                 ac_sys_release=`uname -r`
109         fi
110         ac_md_system=`echo $ac_sys_system |
111                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
112         ac_md_release=`echo $ac_sys_release |
113                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
114         MACHDEP="$ac_md_system$ac_md_release"
116         case $MACHDEP in
117         cygwin*) MACHDEP="cygwin";;
118         darwin*) MACHDEP="darwin";;
119         atheos*) MACHDEP="atheos";;
120         irix646) MACHDEP="irix6";;
121         '')     MACHDEP="unknown";;
122         esac
124         
125 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
126 # disable features if it is defined, without any means to access these
127 # features as extensions. For these systems, we skip the definition of
128 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
129 # some feature, make sure there is no alternative way to access this
130 # feature. Also, when using wildcards, make sure you have verified the
131 # need for not defining _XOPEN_SOURCE on all systems matching the
132 # wildcard, and that the wildcard does not include future systems
133 # (which may remove their limitations).
134 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
135 case $ac_sys_system/$ac_sys_release in
136   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
137   # even though select is a POSIX function. Reported by J. Ribbens.
138   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
139   OpenBSD/2.* | OpenBSD/3.@<:@01234@:>@) 
140     define_xopen_source=no;;
141   # On Solaris 2.6, sys/wait.h is inconsistent in the usage
142   # of union __?sigval. Reported by Stuart Bishop.
143   SunOS/5.6)
144     define_xopen_source=no;;
145   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
146   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
147   # Reconfirmed for 7.1.4 by Martin v. Loewis.
148   OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
149     define_xopen_source=no;;
150   # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
151   # but used in struct sockaddr.sa_family. Reported by Tim Rice.
152   SCO_SV/3.2)
153     define_xopen_source=no;;
154   # On FreeBSD 4.8 and MacOS X 10.2, a bug in ncurses.h means that
155   # it craps out if _XOPEN_EXTENDED_SOURCE is defined. Apparently,
156   # this is fixed in 10.3, which identifies itself as Darwin/7.*
157   # This should hopefully be fixed in FreeBSD 4.9
158   FreeBSD/4.8* | Darwin/6* )
159     define_xopen_source=no;;
160   # On AIX 4, mbstate_t is defined only when _XOPEN_SOURCE == 500 but used in
161   # wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined or
162   # has another value. By not (re)defining it, the defaults come in place.
163   AIX/4)
164     define_xopen_source=no;;
165 esac
167 if test $define_xopen_source = yes
168 then
169   AC_DEFINE(_XOPEN_SOURCE, 600, 
170             Define to the level of X/Open that your system supports)
172   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
173   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
174   # several APIs are not declared. Since this is also needed in some
175   # cases for HP-UX, we define it globally.
176   
177   AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Define to activate Unix95-and-earlier features)
178   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
183 # SGI compilers allow the specification of the both the ABI and the
184 # ISA on the command line.  Depending on the values of these switches,
185 # different and often incompatable code will be generated.
187 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
188 # thus supply support for various ABI/ISA combinations.  The MACHDEP
189 # variable is also adjusted.
191 AC_SUBST(SGI_ABI)
192 if test ! -z "$SGI_ABI"
193 then
194         CC="cc $SGI_ABI"
195         LDFLAGS="$SGI_ABI $LDFLAGS"
196         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
198 AC_MSG_RESULT($MACHDEP)
200 # And add extra plat-mac for darwin
201 AC_SUBST(EXTRAPLATDIR)
202 AC_SUBST(EXTRAMACHDEPPATH)
203 AC_MSG_CHECKING(EXTRAPLATDIR)
204 if test -z "$EXTRAPLATDIR"
205 then
206         case $MACHDEP in
207         darwin) 
208                 EXTRAPLATDIR="\$(PLATMACDIRS)"
209                 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
210                 ;;
211         *) 
212                 EXTRAPLATDIR=""
213                 EXTRAMACHDEPPATH=""
214                 ;;
215         esac
217 AC_MSG_RESULT($EXTRAPLATDIR)
219 # checks for alternative programs
221 # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
222 # for debug/optimization stuff.  BASECFLAGS is for flags that are required
223 # just to get things to compile and link.  Users are free to override OPT
224 # when running configure or make.  The build should not break if they do.
225 # BASECFLAGS should generally not be messed with, however.
227 # XXX shouldn't some/most/all of this code be merged with the stuff later
228 # on that fiddles with OPT and BASECFLAGS?
229 AC_MSG_CHECKING(for --without-gcc)
230 AC_ARG_WITH(gcc,
231             AC_HELP_STRING(--without-gcc,never use gcc),
233         case $withval in
234         no)     CC=cc
235                 without_gcc=yes;;
236         yes)    CC=gcc
237                 without_gcc=no;;
238         *)      CC=$withval
239                 without_gcc=$withval;;
240         esac], [
241         case $ac_sys_system in
242         AIX*)   CC=cc_r
243                 without_gcc=;;
244         BeOS*)
245                 case $BE_HOST_CPU in
246                 ppc)
247                         CC=mwcc
248                         without_gcc=yes
249                         BASECFLAGS="$BASECFLAGS -export pragma"
250                         OPT="$OPT -O"
251                         LDFLAGS="$LDFLAGS -nodup"
252                         ;;
253                 x86)
254                         CC=gcc
255                         without_gcc=no
256                         OPT="$OPT -O"
257                         ;;
258                 *)
259                         AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
260                         ;;
261                 esac
262                 AR="\$(srcdir)/Modules/ar_beos"
263                 RANLIB=:
264                 ;;
265     Monterey*)
266         RANLIB=:
267         without_gcc=;;
268         *)      without_gcc=no;;
269         esac])
270 AC_MSG_RESULT($without_gcc)
272 AC_SUBST(CXX)
273 AC_SUBST(MAINOBJ)
274 MAINOBJ=python.o
275 AC_MSG_CHECKING(for --with-cxx=<compiler>)
276 AC_ARG_WITH(cxx,
277             AC_HELP_STRING(--with-cxx=<compiler>, enable C++ support),
279         check_cxx=no
280         case $withval in
281         no)     CXX=
282                 with_cxx=no;;
283         *)      CXX=$withval
284                 MAINOBJ=ccpython.o
285                 with_cxx=$withval;;
286         esac], [
287         with_cxx=no
288         check_cxx=yes
290 AC_MSG_RESULT($with_cxx)
292 if test "$with_cxx" = "yes"
293 then
294         AC_MSG_ERROR([must supply a compiler when using --with-cxx])
297 dnl The following fragment works similar to AC_PROG_CXX.
298 dnl It does not fail if CXX is not found, and it is not executed if 
299 dnl --without-cxx was given.
300 dnl Finally, it does not test whether CXX is g++.
302 dnl Autoconf 2.5x does not have AC_PROG_CXX_WORKS anymore
303 ifdef([AC_PROG_CXX_WORKS],[],
304       [AC_DEFUN([AC_PROG_CXX_WORKS],
305       [AC_LANG_PUSH(C++)dnl
306        _AC_COMPILER_EXEEXT
307        AC_LANG_POP()
308       ]
311 if test "$check_cxx" = "yes" 
312 then
313         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
314         if test "$CXX" = "notfound"
315         then
316                 CXX=
317         else
318                 AC_PROG_CXX_WORKS
319         fi
322 # If the user switches compilers, we can't believe the cache
323 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
324 then
325   AC_MSG_ERROR([cached CC is different -- throw away $cache_file
326 (it is also a good idea to do 'make clean' before compiling)])
329 AC_PROG_CC
331 # checks for UNIX variants that set C preprocessor variables
332 AC_AIX
333 AC_MINIX
335 # Check for unsupported systems
336 case $ac_sys_system/$ac_sys_release in
337 SunOS/4*|DYNIX/*|dgux*/*|IRIX/4*|Linux*/1*)
338    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
339    echo See README for details.
340    exit 1;;
341 esac
343 if test "$MINIX" = yes; then
344    echo This system \(MINIX\) is no longer supported.
345    echo Read README for details.
346    exit 1
349 AC_EXEEXT
350 AC_MSG_CHECKING(for --with-suffix)
351 AC_ARG_WITH(suffix,
352             AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
354         case $withval in
355         no)     EXEEXT=;;
356         yes)    EXEEXT=.exe;;
357         *)      EXEEXT=$withval;;
358         esac])
359 AC_MSG_RESULT($EXEEXT)
361 # Test whether we're running on a non-case-sensitive system, in which
362 # case we give a warning if no ext is given
363 AC_SUBST(BUILDEXEEXT)
364 AC_MSG_CHECKING(for case-insensitive build directory)
365 if test ! -d CaseSensitiveTestDir; then
366 mkdir CaseSensitiveTestDir
369 if test -d casesensitivetestdir
370 then
371     AC_MSG_RESULT(yes)
372     BUILDEXEEXT=.exe
373 else
374         AC_MSG_RESULT(no)
375         BUILDEXEEXT=$EXEEXT
377 rmdir CaseSensitiveTestDir
379 case $MACHDEP in
380 bsdos*)
381     case $CC in
382     gcc) CC="$CC -D_HAVE_BSDI";;
383     esac;;
384 esac
386 case $ac_sys_system in
387 hp*|HP*)
388     case $CC in
389     cc|*/cc) CC="$CC -Ae";;
390     esac;;
391 Monterey*)
392     case $CC in
393     cc) CC="$CC -Wl,-Bexport";;
394     esac;;
395 SunOS*)
396     # Some functions have a prototype only with that define, e.g. confstr
397     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
398     ;;
399 esac
402 AC_SUBST(LIBRARY)
403 AC_MSG_CHECKING(LIBRARY)
404 if test -z "$LIBRARY"
405 then
406         LIBRARY='libpython$(VERSION).a'
408 AC_MSG_RESULT($LIBRARY)
410 # LDLIBRARY is the name of the library to link against (as opposed to the
411 # name of the library into which to insert object files). BLDLIBRARY is also
412 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
413 # is blank as the main program is not linked directly against LDLIBRARY.
414 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
415 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
416 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
417 # DLLLIBRARY is the shared (i.e., DLL) library.
419 # RUNSHARED is used to run shared python without installed libraries
421 # INSTSONAME is the name of the shared library that will be use to install
422 # on the system - some systems like version suffix, others don't
423 AC_SUBST(LDLIBRARY)
424 AC_SUBST(DLLLIBRARY)
425 AC_SUBST(BLDLIBRARY)
426 AC_SUBST(LDLIBRARYDIR)
427 AC_SUBST(INSTSONAME)
428 AC_SUBST(RUNSHARED)
429 LDLIBRARY="$LIBRARY"
430 BLDLIBRARY='$(LDLIBRARY)'
431 INSTSONAME='$(LDLIBRARY)'
432 DLLLIBRARY=''
433 LDLIBRARYDIR=''
434 RUNSHARED=''
436 # LINKCC is the command that links the python executable -- default is $(CC).
437 # If CXX is set, and if it is needed to link a main function that was
438 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
439 # python might then depend on the C++ runtime
440 # This is altered for AIX in order to build the export list before 
441 # linking.
442 AC_SUBST(LINKCC)
443 AC_MSG_CHECKING(LINKCC)
444 if test -z "$LINKCC"
445 then
446         if test -z "$CXX"; then
447               LINKCC="\$(PURIFY) \$(CC)"
448         else
449               echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
450               $CXX -c conftest.$ac_ext 2>&5
451               if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
452                  && test -s conftest$ac_exeext && ./conftest$ac_exeext
453               then
454                  LINKCC="\$(PURIFY) \$(CC)"
455               else
456                  LINKCC="\$(PURIFY) \$(CXX)"
457               fi
458               rm -fr conftest*
459         fi
460         case $ac_sys_system in
461         AIX*)
462            exp_extra="\"\""
463            if test $ac_sys_release -ge 5 -o \
464                    $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
465                exp_extra="."
466            fi
467            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
468         dgux*)
469            LINKCC="LD_RUN_PATH=$libdir $LINKCC";;
470         Monterey64*)
471            LINKCC="$LINKCC -L/usr/lib/ia64l64";;
472         esac
474 AC_MSG_RESULT($LINKCC)
476 AC_MSG_CHECKING(for --enable-shared)
477 AC_ARG_ENABLE(shared,
478               AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
480 if test -z "$enable_shared"
481 then 
482   case $ac_sys_system in
483   CYGWIN* | atheos*)
484     enable_shared="yes";;
485   *)
486     enable_shared="no";;
487   esac
489 AC_MSG_RESULT($enable_shared)
492 AC_MSG_CHECKING(LDLIBRARY)
494 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
495 # library that we build, but we do not want to link against it (we
496 # will find it with a -framework option). For this reason there is an
497 # extra variable BLDLIBRARY against which Python and the extension
498 # modules are linked, BLDLIBRARY. This is normally the same as
499 # LDLIBRARY, but empty for MacOSX framework builds.
500 if test "$enable_framework"
501 then
502   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
503   RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
504   BLDLIBRARY=''
505 else
506   BLDLIBRARY='$(LDLIBRARY)'
507 fi  
509 # Other platforms follow
510 if test $enable_shared = "yes"; then
511   AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
512   case $ac_sys_system in
513     BeOS*)
514           LDLIBRARY='libpython$(VERSION).so'
515           ;;
516     CYGWIN*)
517           LDLIBRARY='libpython$(VERSION).dll.a'
518           DLLLIBRARY='libpython$(VERSION).dll'
519           ;;
520     SunOS*)
521           LDLIBRARY='libpython$(VERSION).so'
522           BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
523           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
524           INSTSONAME="$LDLIBRARY".$SOVERSION
525           ;;
526     Linux*|GNU*|NetBSD*)
527           LDLIBRARY='libpython$(VERSION).so'
528           BLDLIBRARY='-L. -lpython$(VERSION)'
529           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
530           INSTSONAME="$LDLIBRARY".$SOVERSION
531           ;;
532     hp*|HP*)
533           LDLIBRARY='libpython$(VERSION).sl'
534           BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
535           RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
536           ;;
537     OSF*)
538           LDLIBRARY='libpython$(VERSION).so'
539          BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
540           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
541           ;;
542     atheos*)
543           LDLIBRARY='libpython$(VERSION).so'
544           BLDLIBRARY='-L. -lpython$(VERSION)'
545           RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
546           ;;
547   esac
548   # DG/UX requires some fancy ld contortions to produce a .so from an .a
549   case $MACHDEP in
550   dguxR4)
551         LDLIBRARY='libpython$(VERSION).so'
552         BASECFLAGS="$BASECFLAGS -pic"
553         ;;
554   esac
557 AC_MSG_RESULT($LDLIBRARY)
559 AC_PROG_RANLIB
560 AC_SUBST(AR)
561 AC_CHECK_PROGS(AR, ar aal, ar)
563 case $MACHDEP in
564 bsdos*|hp*|HP*)
565         # install -d does not work on BSDI or HP-UX
566         if test -z "$INSTALL"
567         then
568                 INSTALL="${srcdir}/install-sh -c"
569         fi
570 esac
571 AC_PROG_INSTALL
573 # Not every filesystem supports hard links
574 AC_SUBST(LN)
575 if test -z "$LN" ; then
576         case $ac_sys_system in
577                 BeOS*) LN="ln -s";;
578                 CYGWIN*) LN="ln -s";;
579                 atheos*) LN="ln -s";;
580                 *) LN=ln;;
581         esac
584 # Check for --with-pydebug
585 AC_MSG_CHECKING(for --with-pydebug)
586 AC_ARG_WITH(pydebug, 
587             AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
589 if test "$withval" != no
590 then 
591   AC_DEFINE(Py_DEBUG, 1, 
592   [Define if you want to build an interpreter with many run-time checks.]) 
593   AC_MSG_RESULT(yes); 
594   Py_DEBUG='true'
595 else AC_MSG_RESULT(no); Py_DEBUG='false'
596 fi],
597 [AC_MSG_RESULT(no)])
599 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
600 # merged with this chunk of code?
602 # Optimizer/debugger flags
603 # ------------------------
604 # (The following bit of code is complicated enough - please keep things
605 # indented properly.  Just pretend you're editing Python code. ;-)
607 # There are two parallel sets of case statements below, one that checks to
608 # see if OPT was set and one that does BASECFLAGS setting based upon
609 # compiler and platform.  BASECFLAGS tweaks need to be made even if the
610 # user set OPT.
612 # tweak OPT based on compiler and platform, only if the user didn't set
613 # it on the command line
614 AC_SUBST(OPT)
615 if test -z "$OPT"
616 then
617     case $GCC in
618     yes)
619         case $ac_cv_prog_cc_g in
620         yes)
621             if test "$Py_DEBUG" = 'true' ; then
622                 # Optimization messes up debuggers, so turn it off for
623                 # debug builds.
624                 OPT="-g -Wall -Wstrict-prototypes"
625             else
626                 OPT="-g -O3 -Wall -Wstrict-prototypes"
627             fi
628             ;;
629         *)
630             OPT="-O3 -Wall -Wstrict-prototypes"
631             ;;
632         esac
633         case $ac_sys_system in
634             SCO_SV*) OPT="$OPT -m486 -DSCO5"
635             ;;
636         esac
637         ;;
639     *)
640         OPT="-O"
641         ;;
642     esac
644     # The current (beta) Monterey compiler dies with optimizations
645     # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
646     case $ac_sys_system in
647         Monterey*)
648             OPT=""
649             ;;
650     esac
654 AC_SUBST(BASECFLAGS)
655 # tweak BASECFLAGS based on compiler and platform
656 case $GCC in
657 yes)
658     # Python violates C99 rules, by casting between incompatible
659     # pointer types. GCC may generate bad code as a result of that,
660     # so use -fno-strict-aliasing if supported.
661     AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
662      ac_save_cc="$CC"
663      CC="$CC -fno-strict-aliasing"
664      AC_TRY_RUN([int main() { return 0; }],
665      ac_cv_no_strict_aliasing_ok=yes,
666      ac_cv_no_strict_aliasing_ok=no,
667      ac_cv_no_strict_aliasing_ok=no)
668      CC="$ac_save_cc"
669     AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
670     if test $ac_cv_no_strict_aliasing_ok = yes
671     then
672       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
673     fi
674     case $ac_sys_system in
675         SCO_SV*)
676             BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
677             ;;
678         # is there any other compiler on Darwin besides gcc?
679         Darwin*)
680             BASECFLAGS="$BASECFLAGS -Wno-long-double -no-cpp-precomp -mno-fused-madd"
681             ;;
682     esac
683     ;;
686     case $ac_sys_system in
687     OpenUNIX*|UnixWare*)
688         BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
689         ;;
690     OSF*)
691         BASECFLAGS="$BASECFLAGS -ieee -std"
692         ;;
693     SCO_SV*)
694         BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
695         ;;
696     esac
697     ;;
698 esac
700 if test "$Py_DEBUG" = 'true'; then
701   :
702 else
703   OPT="-DNDEBUG $OPT"
706 if test "$ac_arch_flags"
707 then
708         BASECFLAGS="$BASECFLAGS $ac_arch_flags"
711 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
712 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
713 [ac_save_cc="$CC"
714 CC="$CC -OPT:Olimit=0"
715 AC_TRY_RUN([int main() { return 0; }],
716   ac_cv_opt_olimit_ok=yes,
717   ac_cv_opt_olimit_ok=no,
718   ac_cv_opt_olimit_ok=no)
719 CC="$ac_save_cc"])
720 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
721 if test $ac_cv_opt_olimit_ok = yes; then
722     case $ac_sys_system in
723         # XXX is this branch needed? On MacOSX 10.2.2 the result of the
724         # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
725         # environment?
726         Darwin*)
727             ;;
728         *)
729             BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
730             ;;
731     esac
732 else
733   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
734   AC_CACHE_VAL(ac_cv_olimit_ok,
735   [ac_save_cc="$CC"
736   CC="$CC -Olimit 1500"
737   AC_TRY_RUN([int main() { return 0; }],
738     ac_cv_olimit_ok=yes,
739     ac_cv_olimit_ok=no,
740     ac_cv_olimit_ok=no)
741   CC="$ac_save_cc"])
742   AC_MSG_RESULT($ac_cv_olimit_ok)
743   if test $ac_cv_olimit_ok = yes; then
744     BASECFLAGS="$BASECFLAGS -Olimit 1500"
745   fi
748 # On some compilers, pthreads are available without further options
749 # (e.g. MacOS X). On some of these systems, the compiler will not
750 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
751 # So we have to see first whether pthreads are available without
752 # options before we can check whether -Kpthread improves anything.
753 AC_MSG_CHECKING(whether pthreads are available without options)
754 AC_CACHE_VAL(ac_cv_pthread_is_default,
755 [AC_TRY_RUN([
756 #include <pthread.h>
758 void* routine(void* p){return NULL;}
760 int main(){
761   pthread_t p;
762   if(pthread_create(&p,NULL,routine,NULL)!=0)
763     return 1;
764   (void)pthread_detach(p);
765   return 0;
769   ac_cv_pthread_is_default=yes
770   ac_cv_kthread=no
771   ac_cv_pthread=no
773   ac_cv_pthread_is_default=no,
774   ac_cv_pthread_is_default=no)
776 AC_MSG_RESULT($ac_cv_pthread_is_default)
779 if test $ac_cv_pthread_is_default = yes 
780 then
781   ac_cv_kpthread=no
782 else
783 # -Kpthread, if available, provides the right #defines
784 # and linker options to make pthread_create available
785 # Some compilers won't report that they do not support -Kpthread,
786 # so we need to run a program to see whether it really made the
787 # function available.
788 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
789 AC_CACHE_VAL(ac_cv_kpthread,
790 [ac_save_cc="$CC"
791 CC="$CC -Kpthread"
792 AC_TRY_RUN([
793 #include <pthread.h>
795 void* routine(void* p){return NULL;}
797 int main(){
798   pthread_t p;
799   if(pthread_create(&p,NULL,routine,NULL)!=0)
800     return 1;
801   (void)pthread_detach(p);
802   return 0;
805   ac_cv_kpthread=yes,
806   ac_cv_kpthread=no,
807   ac_cv_kpthread=no)
808 CC="$ac_save_cc"])
809 AC_MSG_RESULT($ac_cv_kpthread)
812 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
813 then
814 # -Kthread, if available, provides the right #defines
815 # and linker options to make pthread_create available
816 # Some compilers won't report that they do not support -Kthread,
817 # so we need to run a program to see whether it really made the
818 # function available.
819 AC_MSG_CHECKING(whether $CC accepts -Kthread)
820 AC_CACHE_VAL(ac_cv_kthread,
821 [ac_save_cc="$CC"
822 CC="$CC -Kthread"
823 AC_TRY_RUN([
824 #include <pthread.h>
826 void* routine(void* p){return NULL;}
828 int main(){
829   pthread_t p;
830   if(pthread_create(&p,NULL,routine,NULL)!=0)
831     return 1;
832   (void)pthread_detach(p);
833   return 0;
836   ac_cv_kthread=yes,
837   ac_cv_kthread=no,
838   ac_cv_kthread=no)
839 CC="$ac_save_cc"])
840 AC_MSG_RESULT($ac_cv_kthread)
843 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
844 then
845 # -pthread, if available, provides the right #defines
846 # and linker options to make pthread_create available
847 # Some compilers won't report that they do not support -pthread,
848 # so we need to run a program to see whether it really made the
849 # function available.
850 AC_MSG_CHECKING(whether $CC accepts -pthread)
851 AC_CACHE_VAL(ac_cv_thread,
852 [ac_save_cc="$CC"
853 CC="$CC -pthread"
854 AC_TRY_RUN([
855 #include <pthread.h>
857 void* routine(void* p){return NULL;}
859 int main(){
860   pthread_t p;
861   if(pthread_create(&p,NULL,routine,NULL)!=0)
862     return 1;
863   (void)pthread_detach(p);
864   return 0;
867   ac_cv_pthread=yes,
868   ac_cv_pthread=no,
869   ac_cv_pthread=no)
870 CC="$ac_save_cc"])
871 AC_MSG_RESULT($ac_cv_pthread)
874 # If we have set a CC compiler flag for thread support then
875 # check if it works for CXX, too.
876 ac_cv_cxx_thread=no
877 if test ! -z "$CXX"
878 then
879 AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
880 ac_save_cxx="$CXX"
882 if test "$ac_cv_kpthread" = "yes"
883 then
884   CXX="$CXX -Kpthread"  
885   ac_cv_cxx_thread=yes
886 elif test "$ac_cv_kthread" = "yes"
887 then
888   CXX="$CXX -Kthread"
889   ac_cv_cxx_thread=yes
890 elif test "$ac_cv_pthread" = "yes"
891 then 
892   CXX="$CXX -pthread"
893   ac_cv_cxx_thread=yes
896 if test $ac_cv_cxx_thread = yes
897 then
898   echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
899   $CXX -c conftest.$ac_ext 2>&5
900   if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
901      && test -s conftest$ac_exeext && ./conftest$ac_exeext
902   then
903     ac_cv_cxx_thread=yes
904   else
905     ac_cv_cxx_thread=no
906   fi
907   rm -fr conftest*
910 CXX="$ac_save_cxx"
911 AC_MSG_RESULT($ac_cv_cxx_thread)
913 dnl # check for ANSI or K&R ("traditional") preprocessor
914 dnl AC_MSG_CHECKING(for C preprocessor type)
915 dnl AC_TRY_COMPILE([
916 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
917 dnl int foo;
918 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
919 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
920 dnl AC_MSG_RESULT($cpp_type)
922 # checks for header files
923 AC_HEADER_STDC
924 AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h \
925 libintl.h locale.h ncurses.h poll.h pthread.h \
926 signal.h stdarg.h stddef.h stdlib.h stropts.h termios.h thread.h \
927 unistd.h utime.h \
928 sys/audioio.h sys/bsdtty.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
929 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
930 sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
931 sys/resource.h netpacket/packet.h sysexits.h)
932 AC_HEADER_DIRENT
933 AC_HEADER_MAJOR
935 # checks for typedefs
936 was_it_defined=no
937 AC_MSG_CHECKING(for clock_t in time.h)
938 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
939     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
941 AC_MSG_RESULT($was_it_defined)
943 # Check whether using makedev requires defining _OSF_SOURCE
944 AC_MSG_CHECKING(for makedev)
945 AC_TRY_LINK([#include <sys/types.h> ],
946             [ makedev(0, 0) ],
947             ac_cv_has_makedev=yes,
948             ac_cv_has_makedev=no)
949 if test "$ac_cv_has_makedev" = "no"; then
950     # we didn't link, try if _OSF_SOURCE will allow us to link
951     AC_TRY_LINK([
952 #define _OSF_SOURCE 1
953 #include <sys/types.h>
954     ],
955     [ makedev(0, 0) ],
956     ac_cv_has_makedev=yes,
957     ac_cv_has_makedev=no)
958     if test "$ac_cv_has_makedev" = "yes"; then
959         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
960     fi
962 AC_MSG_RESULT($ac_cv_has_makedev)
963 if test "$ac_cv_has_makedev" = "yes"; then
964     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
967 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
968 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
969 # defined, but the compiler does not support pragma redefine_extname,
970 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
971 # structures (such as rlimit64) without declaring them. As a
972 # work-around, disable LFS on such configurations
974 use_lfs=yes
975 AC_MSG_CHECKING(Solaris LFS bug)
976 AC_TRY_COMPILE([
977 #define _LARGEFILE_SOURCE 1
978 #define _FILE_OFFSET_BITS 64
979 #include <sys/resource.h>
980 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
981 AC_MSG_RESULT($sol_lfs_bug)
982 if test "$sol_lfs_bug" = "yes"; then
983   use_lfs=no
986 if test "$use_lfs" = "yes"; then
987 # Two defines needed to enable largefile support on various platforms
988 # These may affect some typedefs
989 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
990 [This must be defined on some systems to enable large file support.])
991 AC_DEFINE(_FILE_OFFSET_BITS, 64,
992 [This must be set to 64 on some systems to enable large file support.])
995 # Add some code to confdefs.h so that the test for off_t works on SCO
996 cat >> confdefs.h <<\EOF
997 #if defined(SCO_DS)
998 #undef _OFF_T
999 #endif
1002 # Type availability checks
1003 AC_TYPE_MODE_T
1004 AC_TYPE_OFF_T
1005 AC_TYPE_PID_T
1006 AC_TYPE_SIGNAL
1007 AC_TYPE_SIZE_T
1008 AC_TYPE_UID_T
1010 # Sizes of various common basic types
1011 AC_CHECK_SIZEOF(int, 4)
1012 AC_CHECK_SIZEOF(long, 4)
1013 AC_CHECK_SIZEOF(void *, 4)
1014 AC_CHECK_SIZEOF(char, 1)
1015 AC_CHECK_SIZEOF(short, 2)
1016 AC_CHECK_SIZEOF(float, 4)
1017 AC_CHECK_SIZEOF(double, 8)
1018 AC_CHECK_SIZEOF(fpos_t, 4)
1020 AC_MSG_CHECKING(for long long support)
1021 have_long_long=no
1022 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1023   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
1024   have_long_long=yes
1026 AC_MSG_RESULT($have_long_long)
1027 if test "$have_long_long" = yes ; then
1028 AC_CHECK_SIZEOF(long long, 8)
1031 AC_MSG_CHECKING(for uintptr_t support)
1032 have_uintptr_t=no
1033 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], [
1034   AC_DEFINE(HAVE_UINTPTR_T, 1, [Define this if you have the type uintptr_t.]) 
1035   have_uintptr_t=yes
1037 AC_MSG_RESULT($have_uintptr_t)
1038 if test "$have_uintptr_t" = yes ; then
1039 AC_CHECK_SIZEOF(uintptr_t, 4)
1042 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1043 AC_MSG_CHECKING(size of off_t)
1044 AC_CACHE_VAL(ac_cv_sizeof_off_t,
1045 [AC_TRY_RUN([#include <stdio.h>
1046 #include <sys/types.h>
1047 main()
1049   FILE *f=fopen("conftestval", "w");
1050   if (!f) exit(1);
1051   fprintf(f, "%d\n", sizeof(off_t));
1052   exit(0);
1054 ac_cv_sizeof_off_t=`cat conftestval`,
1055 ac_cv_sizeof_off_t=0,
1056 ac_cv_sizeof_off_t=4)
1058 AC_MSG_RESULT($ac_cv_sizeof_off_t)
1059 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1060 [The number of bytes in an off_t.])
1062 AC_MSG_CHECKING(whether to enable large file support)
1063 if test "$have_long_long" = yes -a \
1064         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1065         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1066   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
1067   [Defined to enable large file support when an off_t is bigger than a long
1068    and long long is available and at least as big as an off_t. You may need
1069    to add some flags for configuration and compilation to enable this mode.
1070    (For Solaris and Linux, the necessary defines are already defined.)])
1071   AC_MSG_RESULT(yes)
1072 else
1073   AC_MSG_RESULT(no)
1076 # AC_CHECK_SIZEOF() doesn't include <time.h>.
1077 AC_MSG_CHECKING(size of time_t)
1078 AC_CACHE_VAL(ac_cv_sizeof_time_t,
1079 [AC_TRY_RUN([#include <stdio.h>
1080 #include <time.h>
1081 main()
1083   FILE *f=fopen("conftestval", "w");
1084   if (!f) exit(1);
1085   fprintf(f, "%d\n", sizeof(time_t));
1086   exit(0);
1088 ac_cv_sizeof_time_t=`cat conftestval`,
1089 ac_cv_sizeof_time_t=0,
1090 ac_cv_sizeof_time_t=4)
1092 AC_MSG_RESULT($ac_cv_sizeof_time_t)
1093 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
1094 [The number of bytes in a time_t.])
1097 # if have pthread_t then define SIZEOF_PTHREAD_T
1098 ac_save_cc="$CC"
1099 if test "$ac_cv_kpthread" = "yes"
1100 then CC="$CC -Kpthread"
1101 elif test "$ac_cv_kthread" = "yes"
1102 then CC="$CC -Kthread"
1103 elif test "$ac_cv_pthread" = "yes"
1104 then CC="$CC -pthread"
1106 AC_MSG_CHECKING(for pthread_t)
1107 have_pthread_t=no
1108 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
1109 AC_MSG_RESULT($have_pthread_t)
1110 if test "$have_pthread_t" = yes ; then
1111   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1112   AC_MSG_CHECKING(size of pthread_t)
1113   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1114   [AC_TRY_RUN([#include <stdio.h>
1115 #include <pthread.h>
1116   main()
1117   {
1118     FILE *f=fopen("conftestval", "w");
1119     if (!f) exit(1);
1120     fprintf(f, "%d\n", sizeof(pthread_t));
1121     exit(0);
1122   }],
1123   ac_cv_sizeof_pthread_t=`cat conftestval`,
1124   ac_cv_sizeof_pthread_t=0,
1125   ac_cv_sizeof_pthread_t=4)
1126   ])
1127   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
1128   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1129    [The number of bytes in a pthread_t.])
1131 CC="$ac_save_cc"
1133 AC_MSG_CHECKING(for --enable-toolbox-glue)
1134 AC_ARG_ENABLE(toolbox-glue,
1135               AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
1137 if test -z "$enable_toolbox_glue"
1138 then 
1139         case $ac_sys_system/$ac_sys_release in
1140         Darwin/*)
1141                 enable_toolbox_glue="yes";;
1142         *)
1143                 enable_toolbox_glue="no";;
1144         esac
1146 case "$enable_toolbox_glue" in
1147 yes)
1148         extra_frameworks="-framework CoreServices -framework Foundation"
1149         extra_machdep_objs="Python/mactoolboxglue.o"
1150         extra_undefs="-u __dummy -u _PyMac_Error"
1151         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1152          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1153         ;;
1155         extra_frameworks=""
1156         extra_machdep_objs=""
1157         extra_undefs=""
1158         ;;
1159 esac
1160 AC_MSG_RESULT($enable_toolbox_glue)
1162 AC_SUBST(LIBTOOL_CRUFT)
1163 case $ac_sys_system/$ac_sys_release in
1164   Darwin/1.3*)
1165     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
1166         LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
1167     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python'
1168     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1169   Darwin/*)
1170     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
1171       LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
1172     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/Python'
1173     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1174 esac
1176 AC_MSG_CHECKING(for --enable-framework)
1177 if test "$enable_framework"
1178 then
1179         BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1180         # -F. is needed to allow linking to the framework while 
1181         # in the build location.
1182         LDFLAGS="$LDFLAGS -Wl,-F."
1183         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
1184          [Define if you want to produce an OpenStep/Rhapsody framework
1185          (shared library plus accessory files).])
1186         AC_MSG_RESULT(yes)
1187 else
1188         AC_MSG_RESULT(no)
1191 AC_MSG_CHECKING(for dyld)
1192 case $ac_sys_system/$ac_sys_release in
1193   Darwin/*)
1194         AC_DEFINE(WITH_DYLD, 1, 
1195         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1196          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1197          linker (rld). Dyld is necessary to support frameworks.])
1198         AC_MSG_RESULT(always on for Darwin)
1199         ;;
1200   *)
1201         AC_MSG_RESULT(no)
1202         ;;
1203 esac
1205 # Set info about shared libraries.
1206 AC_SUBST(SO)
1207 AC_SUBST(LDSHARED)
1208 AC_SUBST(BLDSHARED)
1209 AC_SUBST(CCSHARED)
1210 AC_SUBST(LINKFORSHARED)
1211 # SO is the extension of shared libraries `(including the dot!)
1212 # -- usually .so, .sl on HP-UX, .dll on Cygwin
1213 AC_MSG_CHECKING(SO)
1214 if test -z "$SO"
1215 then
1216         case $ac_sys_system in
1217         hp*|HP*)   SO=.sl;;
1218         CYGWIN*)   SO=.dll;;
1219         *)         SO=.so;;
1220         esac
1221 else
1222         # this might also be a termcap variable, see #610332
1223         echo
1224         echo '====================================================================='
1225         echo '+                                                                   +'
1226         echo '+ WARNING: You have set SO in your environment.                     +'
1227         echo '+ Do you really mean to change the extension for shared libraries?  +'
1228         echo '+ Continuing in 10 seconds to let you to ponder.                    +'
1229         echo '+                                                                   +'
1230         echo '====================================================================='
1231         sleep 10
1233 AC_MSG_RESULT($SO)
1234 # LDSHARED is the ld *command* used to create shared library
1235 # -- "ld" on SunOS 4.x.x, "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1236 # (Shared libraries in this instance are shared modules to be loaded into
1237 # Python, as opposed to building Python itself as a shared library.)
1238 AC_MSG_CHECKING(LDSHARED)
1239 if test -z "$LDSHARED"
1240 then
1241         case $ac_sys_system/$ac_sys_release in
1242         AIX*)
1243                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1244                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1245                 ;;
1246         BeOS*)
1247                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1248                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1249                 ;;
1250         IRIX/5*) LDSHARED="ld -shared";;
1251         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1252         SunOS/4*) LDSHARED="ld";;
1253         SunOS/5*) 
1254                 if test "$GCC" = "yes"
1255                 then LDSHARED='$(CC) -shared'
1256                 else LDSHARED='$(CC) -G';
1257                 fi ;;
1258         hp*|HP*) LDSHARED="ld -b";;
1259         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1260         DYNIX/ptx*) LDSHARED="ld -G";;
1261         Darwin/1.3*)
1262                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1263                 if test "$enable_framework" ; then
1264                         # Link against the framework. All externals should be defined.
1265                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
1266                 else
1267                         # No framework. Ignore undefined symbols, assuming they come from Python
1268                         LDSHARED="$LDSHARED -undefined suppress"
1269                 fi ;;
1270         Darwin/*)
1271                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1272                 if test "$enable_framework" ; then
1273                         # Link against the framework. All externals should be defined.
1274                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
1275                 else
1276                         # No framework, use the Python app as bundle-loader
1277                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1278                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1279                 fi ;;
1280         Linux*|GNU*) LDSHARED='$(CC) -shared';;
1281         dgux*) LDSHARED="ld -G";;
1282         BSD/OS*/4*) LDSHARED="gcc -shared";;
1283         OpenBSD*|FreeBSD*)
1284                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1285                 then
1286                         LDSHARED="cc -shared ${LDFLAGS}"
1287                 else
1288                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1289                 fi;;
1290         NetBSD*) LDSHARED="cc -shared ${LDFLAGS}";;
1291         OpenUNIX*|UnixWare*)
1292                 if test "$GCC" = "yes"
1293                 then LDSHARED='$(CC) -shared'
1294                 else LDSHARED='$(CC) -G'
1295                 fi;;
1296         SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1297         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
1298         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1299         atheos*) LDSHARED="gcc -shared";;
1300         *)      LDSHARED="ld";;
1301         esac
1303 AC_MSG_RESULT($LDSHARED)
1304 BLDSHARED=${BLDSHARED-$LDSHARED}
1305 # CCSHARED are the C *flags* used to create objects to go into a shared
1306 # library (module) -- this is only needed for a few systems
1307 AC_MSG_CHECKING(CCSHARED)
1308 if test -z "$CCSHARED"
1309 then
1310         case $ac_sys_system/$ac_sys_release in
1311         SunOS*) if test "$GCC" = yes;
1312                 then CCSHARED="-fPIC";
1313                 fi;;
1314         hp*|HP*) if test "$GCC" = yes;
1315                  then CCSHARED="-fPIC";
1316                  else CCSHARED="+z";
1317                  fi;;
1318         Linux*|GNU*) CCSHARED="-fPIC";;
1319         BSD/OS*/4*) CCSHARED="-fpic";;
1320         FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
1321         OpenUNIX*|UnixWare*)
1322                 if test "$GCC" = "yes"
1323                 then CCSHARED="-fPIC"
1324                 else CCSHARED="-KPIC"
1325                 fi;;
1326         SCO_SV*)
1327                 if test "$GCC" = "yes"
1328                 then CCSHARED="-fPIC"
1329                 else CCSHARED="-Kpic -belf"
1330                 fi;;
1331         Monterey*) CCSHARED="-G";;
1332         IRIX*/6*)  case $CC in
1333                    *gcc*) CCSHARED="-shared";;
1334                    *) CCSHARED="";;
1335                    esac;;
1336         atheos*) CCSHARED="-fPIC";;
1337         esac
1339 AC_MSG_RESULT($CCSHARED)
1340 # LINKFORSHARED are the flags passed to the $(CC) command that links
1341 # the python executable -- this is only needed for a few systems
1342 AC_MSG_CHECKING(LINKFORSHARED)
1343 if test -z "$LINKFORSHARED"
1344 then
1345         case $ac_sys_system/$ac_sys_release in
1346         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1347         hp*|HP*)
1348             LINKFORSHARED="-Wl,-E -Wl,+s";;
1349 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1350         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1351         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1352         # -u libsys_s pulls in all symbols in libsys
1353         Darwin/*) 
1354                 # -u __dummy makes the linker aware of the objc runtime
1355                 # in System.framework; otherwise, __objcInit (referenced in
1356                 # crt1.o) gets erroneously defined as common, which breaks dynamic
1357                 # loading of any modules which reference it in System.framework.
1358                 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
1359                 # not used by the core itself but which needs to be in the core so
1360                 # that dynamically loaded extension modules have access to it.
1361                 # -prebind is no longer used, because it actually seems to give a
1362                 # slowdown in stead of a speedup, maybe due to the large number of
1363                 # dynamic loads Python does.
1364                 LINKFORSHARED="$extra_undefs -framework System"
1365                 if test "$enable_framework"
1366                 then
1367                         LINKFORSHARED="$LINKFORSHARED -framework Python"
1368                 fi
1369                 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
1370         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1371         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1372         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1373         FreeBSD*|NetBSD*|OpenBSD*) 
1374                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1375                 then
1376                         LINKFORSHARED="-Wl,--export-dynamic"
1377                 fi;;
1378         SunOS/5*) case $CC in
1379                   *gcc*)
1380                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1381                     then
1382                         LINKFORSHARED="-Xlinker --export-dynamic"
1383                     fi;;
1384                   esac;;
1385         esac
1387 AC_MSG_RESULT($LINKFORSHARED)
1389 AC_SUBST(CFLAGSFORSHARED)
1390 AC_MSG_CHECKING(CFLAGSFORSHARED)
1391 if test ! "$LIBRARY" = "$LDLIBRARY"
1392 then
1393         case $ac_sys_system in
1394         CYGWIN*)
1395                 # Cygwin needs CCSHARED when building extension DLLs
1396                 # but not when building the interpreter DLL.
1397                 CFLAGSFORSHARED='';;
1398         *)
1399                 CFLAGSFORSHARED='$(CCSHARED)'
1400         esac
1402 AC_MSG_RESULT($CFLAGSFORSHARED)
1404 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1405 # library (with --enable-shared).
1406 # For platforms on which shared libraries are not allowed to have unresolved
1407 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1408 # if it is not required, since it creates a dependency of the shared library
1409 # to LIBS. This, in turn, means that applications linking the shared libpython
1410 # don't need to link LIBS explicitly. The default should be only changed
1411 # on systems where this approach causes problems.
1412 AC_SUBST(SHLIBS)
1413 AC_MSG_CHECKING(SHLIBS)
1414 case "$ac_sys_system" in
1415         *)
1416                 SHLIBS='$(LIBS)';;
1417 esac
1418 AC_MSG_RESULT($SHLIBS)
1421 # checks for libraries
1422 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1423 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1425 # only check for sem_ini if thread support is requested
1426 if test "$with_threads" = "yes" -o -z "$with_threads"; then
1427     AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1428                                                 # posix4 on Solaris 2.6
1429                                                 # pthread (first!) on Linux
1432 # check if we need libintl for locale functions
1433 AC_CHECK_LIB(intl, textdomain,
1434         AC_DEFINE(WITH_LIBINTL, 1,
1435         [Define to 1 if libintl is needed for locale functions.]))
1437 # checks for system dependent C++ extensions support
1438 case "$ac_sys_system" in
1439         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1440                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1441                             [loadAndInit("", 0, "")],
1442                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1443                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1444                        and you want support for AIX C++ shared extension modules.])
1445                              AC_MSG_RESULT(yes)],
1446                             [AC_MSG_RESULT(no)]);;
1447         *) ;;
1448 esac
1450 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1451 # However on SGI IRIX 4, these exist but are broken.
1452 # BeOS' sockets are stashed in libnet.
1453 case "$ac_sys_system" in
1454 IRIX*) ;;
1456 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1457 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1459 esac
1460 case "$ac_sys_system" in
1461 BeOS*)
1462 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1464 esac
1466 AC_MSG_CHECKING(for --with-libs)
1467 AC_ARG_WITH(libs,
1468             AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1470 AC_MSG_RESULT($withval)
1471 LIBS="$withval $LIBS"
1473 [AC_MSG_RESULT(no)])
1475 # Determine if signalmodule should be used.
1476 AC_SUBST(USE_SIGNAL_MODULE)
1477 AC_SUBST(SIGNAL_OBJS)
1478 AC_MSG_CHECKING(for --with-signal-module)
1479 AC_ARG_WITH(signal-module,
1480             AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1482 if test -z "$with_signal_module"
1483 then with_signal_module="yes"
1485 AC_MSG_RESULT($with_signal_module)
1487 if test "${with_signal_module}" = "yes"; then
1488         USE_SIGNAL_MODULE=""
1489         SIGNAL_OBJS=""
1490 else
1491         USE_SIGNAL_MODULE="#"
1492         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1495 # This is used to generate Setup.config
1496 AC_SUBST(USE_THREAD_MODULE)
1497 USE_THREAD_MODULE=""
1499 AC_MSG_CHECKING(for --with-dec-threads)
1500 AC_SUBST(LDLAST)
1501 AC_ARG_WITH(dec-threads,
1502             AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1504 AC_MSG_RESULT($withval)
1505 LDLAST=-threads
1506 if test "${with_thread+set}" != set; then
1507    with_thread="$withval";
1508 fi],
1509 [AC_MSG_RESULT(no)])
1511 # Templates for things AC_DEFINEd more than once.
1512 # For a single AC_DEFINE, no template is needed.
1513 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1514 AH_TEMPLATE(_REENTRANT,
1515   [Define to force use of thread-safe errno, h_errno, and other functions])
1516 AH_TEMPLATE(WITH_THREAD,
1517   [Define if you want to compile in rudimentary thread support])
1519 AC_MSG_CHECKING(for --with-threads)
1520 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1521 AC_ARG_WITH(threads,
1522             AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
1524 # --with-thread is deprecated, but check for it anyway
1525 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1526 AC_ARG_WITH(thread,
1527             AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1528             [with_threads=$with_thread])
1530 if test -z "$with_threads"
1531 then with_threads="yes"
1533 AC_MSG_RESULT($with_threads)
1535 AC_SUBST(THREADOBJ)
1536 if test "$with_threads" = "no"
1537 then
1538     USE_THREAD_MODULE="#"
1539 elif test "$ac_cv_pthread_is_default" = yes
1540 then
1541     AC_DEFINE(WITH_THREAD)
1542     # Defining _REENTRANT on system with POSIX threads should not hurt.
1543     AC_DEFINE(_REENTRANT)
1544     posix_threads=yes
1545     THREADOBJ="Python/thread.o"    
1546 elif test "$ac_cv_kpthread" = "yes"
1547 then
1548     CC="$CC -Kpthread"
1549     if test "$ac_cv_cxx_thread" = "yes"; then
1550         CXX="$CXX -Kpthread"
1551     fi
1552     AC_DEFINE(WITH_THREAD)
1553     posix_threads=yes
1554     THREADOBJ="Python/thread.o"
1555 elif test "$ac_cv_kthread" = "yes"
1556 then
1557     CC="$CC -Kthread"
1558     if test "$ac_cv_cxx_thread" = "yes"; then
1559         CXX="$CXX -Kthread"
1560     fi
1561     AC_DEFINE(WITH_THREAD)
1562     posix_threads=yes
1563     THREADOBJ="Python/thread.o"
1564 elif test "$ac_cv_pthread" = "yes"
1565 then
1566     CC="$CC -pthread"
1567     if test "$ac_cv_cxx_thread" = "yes"; then
1568         CXX="$CXX -pthread"
1569     fi
1570     AC_DEFINE(WITH_THREAD)
1571     posix_threads=yes
1572     THREADOBJ="Python/thread.o"
1573 else
1574     if test ! -z "$with_threads" -a -d "$with_threads"
1575     then LDFLAGS="$LDFLAGS -L$with_threads"
1576     fi
1577     if test ! -z "$withval" -a -d "$withval"
1578     then LDFLAGS="$LDFLAGS -L$withval"
1579     fi
1581     # According to the POSIX spec, a pthreads implementation must
1582     # define _POSIX_THREADS in unistd.h. Some apparently don't (which ones?)
1583     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1584     AC_EGREP_CPP(yes,
1585     [
1586 #include <unistd.h>
1587 #ifdef _POSIX_THREADS
1589 #endif
1590     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1591     AC_MSG_RESULT($unistd_defines_pthreads)
1593     AC_DEFINE(_REENTRANT)
1594     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1595     AC_DEFINE(C_THREADS)
1596     AC_DEFINE(HURD_C_THREADS, 1,
1597     [Define if you are using Mach cthreads directly under /include])
1598     LIBS="$LIBS -lthreads"
1599     THREADOBJ="Python/thread.o"],[
1600     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1601     AC_DEFINE(C_THREADS)
1602     AC_DEFINE(MACH_C_THREADS, 1,
1603     [Define if you are using Mach cthreads under mach /])
1604     THREADOBJ="Python/thread.o"],[
1605     AC_MSG_CHECKING(for --with-pth)
1606     AC_ARG_WITH([pth],
1607                 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
1608                 [AC_MSG_RESULT($withval)
1609                   AC_DEFINE([WITH_THREAD])
1610                   AC_DEFINE([HAVE_PTH], 1,
1611                             [Define if you have GNU PTH threads.])
1612                   LIBS="-lpth $LIBS"
1613                   THREADOBJ="Python/thread.o"],
1614                 [AC_MSG_RESULT(no)
1616     # Just looking for pthread_create in libpthread is not enough:
1617     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1618     # So we really have to include pthread.h, and then link.
1619     _libs=$LIBS
1620     LIBS="$LIBS -lpthread"
1621     AC_MSG_CHECKING([for pthread_create in -lpthread])
1622     AC_TRY_LINK([#include <pthread.h>
1624 void * start_routine (void *arg) { exit (0); }], [
1625 pthread_create (NULL, NULL, start_routine, NULL)], [
1626     AC_MSG_RESULT(yes)
1627     AC_DEFINE(WITH_THREAD)
1628     posix_threads=yes
1629     THREADOBJ="Python/thread.o"],[
1630     LIBS=$_libs
1631     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
1632     posix_threads=yes
1633     THREADOBJ="Python/thread.o"],[
1634     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1635     AC_DEFINE(ATHEOS_THREADS, 1,
1636     [Define this if you have AtheOS threads.])
1637     THREADOBJ="Python/thread.o"],[
1638     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1639     AC_DEFINE(BEOS_THREADS, 1,
1640     [Define this if you have BeOS threads.])
1641     THREADOBJ="Python/thread.o"],[
1642     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
1643     posix_threads=yes
1644     LIBS="$LIBS -lpthreads"
1645     THREADOBJ="Python/thread.o"], [
1646     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
1647     posix_threads=yes
1648     LIBS="$LIBS -lc_r"
1649     THREADOBJ="Python/thread.o"], [
1650     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
1651     echo Systems with __d6_pthread_create are not supported anymore.
1652     echo See README
1653     exit 1
1654     posix_threads=yes
1655     LIBS="$LIBS -lthread"
1656     THREADOBJ="Python/thread.o"], [
1657     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
1658     posix_threads=yes
1659     LIBS="$LIBS -lpthread"
1660     THREADOBJ="Python/thread.o"], [
1661     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
1662     posix_threads=yes
1663     LIBS="$LIBS -lcma"
1664     THREADOBJ="Python/thread.o"],[
1665     USE_THREAD_MODULE="#"])
1666     ])])])])])])])])])])])
1668     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1669     LIBS="$LIBS -lmpc"
1670     THREADOBJ="Python/thread.o"
1671     USE_THREAD_MODULE=""])
1673     if test "$posix_threads" != "yes"; then     
1674       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1675       LIBS="$LIBS -lthread"
1676       THREADOBJ="Python/thread.o"
1677       USE_THREAD_MODULE=""])
1678     fi
1680     if test "$USE_THREAD_MODULE" != "#"
1681     then
1682         # If the above checks didn't disable threads, (at least) OSF1
1683         # needs this '-threads' argument during linking.
1684         case $ac_sys_system in
1685         OSF1) LDLAST=-threads;;
1686         esac
1687     fi
1690 if test "$posix_threads" = "yes"; then
1691       if test "$unistd_defines_pthreads" = "no"; then
1692          AC_DEFINE(_POSIX_THREADS, 1,
1693          [Define if you have POSIX threads, 
1694           and your system does not define that.])
1695       fi
1697       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
1698       case  $ac_sys_system/$ac_sys_release in
1699   SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
1700                        Defined for Solaris 2.6 bug in pthread header.)
1701                        ;;
1702       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
1703                        Define if the Posix semaphores do not work on your system)
1704                        ;;
1705       esac
1707       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
1708       AC_CACHE_VAL(ac_cv_pthread_system_supported,
1709       [AC_TRY_RUN([#include <pthread.h>
1710       void *foo(void *parm) {
1711         return NULL;
1712       }
1713       main() {
1714         pthread_attr_t attr;
1715         pthread_t id;
1716         if (pthread_attr_init(&attr)) exit(-1);
1717         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
1718         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
1719         exit(0);
1720       }],
1721       ac_cv_pthread_system_supported=yes,
1722       ac_cv_pthread_system_supported=no,
1723       ac_cv_pthread_system_supported=no)
1724       ])
1725       AC_MSG_RESULT($ac_cv_pthread_system_supported)
1726       if test "$ac_cv_pthread_system_supported" = "yes"; then
1727         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
1728       fi
1729       AC_CHECK_FUNCS(pthread_sigmask,
1730         [case $ac_sys_system in
1731         CYGWIN*)
1732           AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
1733             [Define if pthread_sigmask() does not work on your system.])
1734             ;;
1735         esac])
1739 # Check for enable-ipv6
1740 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
1741 AC_MSG_CHECKING([if --enable-ipv6 is specified])
1742 AC_ARG_ENABLE(ipv6,
1743 [  --enable-ipv6           Enable ipv6 (with ipv4) support
1744   --disable-ipv6          Disable ipv6 support],
1745 [ case "$enableval" in
1746   no)
1747        AC_MSG_RESULT(no)
1748        ipv6=no
1749        ;;
1750   *)   AC_MSG_RESULT(yes)
1751        AC_DEFINE(ENABLE_IPV6)
1752        ipv6=yes
1753        ;;
1754   esac ],
1757 dnl the check does not work on cross compilation case...
1758   AC_TRY_RUN([ /* AF_INET6 available check */
1759 #include <sys/types.h>
1760 #include <sys/socket.h>
1761 main()
1763  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1764    exit(1);
1765  else
1766    exit(0);
1769   AC_MSG_RESULT(yes)
1770   ipv6=yes,
1771   AC_MSG_RESULT(no)
1772   ipv6=no,
1773   AC_MSG_RESULT(no)
1774   ipv6=no
1777 if test "$ipv6" = "yes"; then
1778         AC_MSG_CHECKING(if RFC2553 API is available)
1779         AC_TRY_COMPILE([#include <sys/types.h>
1780 #include <netinet/in.h>],
1781         [struct sockaddr_in6 x;
1782 x.sin6_scope_id;],
1783                 AC_MSG_RESULT(yes)
1784                 ipv6=yes,
1785                 AC_MSG_RESULT(no, IPv6 disabled)
1786                 ipv6=no)
1789 if test "$ipv6" = "yes"; then
1790         AC_DEFINE(ENABLE_IPV6)
1794 ipv6type=unknown
1795 ipv6lib=none
1796 ipv6trylibc=no
1798 if test "$ipv6" = "yes"; then
1799         AC_MSG_CHECKING([ipv6 stack type])
1800         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1801         do
1802                 case $i in
1803                 inria)
1804                         dnl http://www.kame.net/
1805                         AC_EGREP_CPP(yes, [
1806 #include <netinet/in.h>
1807 #ifdef IPV6_INRIA_VERSION
1809 #endif],
1810                                 [ipv6type=$i])
1811                         ;;
1812                 kame)
1813                         dnl http://www.kame.net/
1814                         AC_EGREP_CPP(yes, [
1815 #include <netinet/in.h>
1816 #ifdef __KAME__
1818 #endif],
1819                                 [ipv6type=$i;
1820                                 ipv6lib=inet6
1821                                 ipv6libdir=/usr/local/v6/lib
1822                                 ipv6trylibc=yes])
1823                         ;;
1824                 linux-glibc)
1825                         dnl http://www.v6.linux.or.jp/
1826                         AC_EGREP_CPP(yes, [
1827 #include <features.h>
1828 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1830 #endif],
1831                                 [ipv6type=$i;
1832                                 ipv6trylibc=yes])
1833                         ;;
1834                 linux-inet6)
1835                         dnl http://www.v6.linux.or.jp/
1836                         if test -d /usr/inet6; then
1837                                 ipv6type=$i
1838                                 ipv6lib=inet6
1839                                 ipv6libdir=/usr/inet6/lib
1840                                 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
1841                         fi
1842                         ;;
1843                 solaris)
1844                         if test -f /etc/netconfig; then
1845                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1846                                 ipv6type=$i
1847                                 ipv6trylibc=yes
1848                           fi
1849                         fi
1850                         ;;
1851                 toshiba)
1852                         AC_EGREP_CPP(yes, [
1853 #include <sys/param.h>
1854 #ifdef _TOSHIBA_INET6
1856 #endif],
1857                                 [ipv6type=$i;
1858                                 ipv6lib=inet6;
1859                                 ipv6libdir=/usr/local/v6/lib])
1860                         ;;
1861                 v6d)
1862                         AC_EGREP_CPP(yes, [
1863 #include </usr/local/v6/include/sys/v6config.h>
1864 #ifdef __V6D__
1866 #endif],
1867                                 [ipv6type=$i;
1868                                 ipv6lib=v6;
1869                                 ipv6libdir=/usr/local/v6/lib;
1870                                 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
1871                         ;;
1872                 zeta)
1873                         AC_EGREP_CPP(yes, [
1874 #include <sys/param.h>
1875 #ifdef _ZETA_MINAMI_INET6
1877 #endif],
1878                                 [ipv6type=$i;
1879                                 ipv6lib=inet6;
1880                                 ipv6libdir=/usr/local/v6/lib])
1881                         ;;
1882                 esac
1883                 if test "$ipv6type" != "unknown"; then
1884                         break
1885                 fi
1886         done
1887         AC_MSG_RESULT($ipv6type)
1890 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1891         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1892                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1893                 echo "using lib$ipv6lib"
1894         else
1895                 if test $ipv6trylibc = "yes"; then
1896                         echo "using libc"
1897                 else
1898                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
1899                         echo "You need to fetch lib$ipv6lib.a from appropriate"
1900                         echo 'ipv6 kit and compile beforehand.'
1901                         exit 1
1902                 fi
1903         fi
1906 # Check for universal newline support
1907 AC_MSG_CHECKING(for --with-universal-newlines)
1908 AC_ARG_WITH(universal-newlines,
1909             AC_HELP_STRING(--with(out)-universal-newlines, disable/enable foreign newlines))
1911 if test -z "$with_universal_newlines"
1912 then with_universal_newlines="yes"
1914 if test "$with_universal_newlines" = "no"
1915 then
1916     echo --without-universal-newlines is unsupported, see README
1917     exit 1
1918 else
1919     AC_DEFINE(WITH_UNIVERSAL_NEWLINES, 1,
1920       [Define if you want to read files with foreign newlines.])
1922 AC_MSG_RESULT($with_universal_newlines)
1924 # Check for --with-doc-strings
1925 AC_MSG_CHECKING(for --with-doc-strings)
1926 AC_ARG_WITH(doc-strings,
1927             AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
1929 if test -z "$with_doc_strings"
1930 then with_doc_strings="yes"
1932 if test "$with_doc_strings" != "no"
1933 then
1934     AC_DEFINE(WITH_DOC_STRINGS, 1,
1935       [Define if you want documentation strings in extension modules])
1937 AC_MSG_RESULT($with_doc_strings)
1939 # Check for Python-specific malloc support
1940 AC_MSG_CHECKING(for --with-pymalloc)
1941 AC_ARG_WITH(pymalloc,
1942             AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
1944 if test -z "$with_pymalloc"
1945 then with_pymalloc="yes"
1947 if test "$with_pymalloc" != "no"
1948 then
1949     AC_DEFINE(WITH_PYMALLOC, 1, 
1950      [Define if you want to compile in Python-specific mallocs])
1952 AC_MSG_RESULT($with_pymalloc)
1954 # Check for --with-wctype-functions
1955 AC_MSG_CHECKING(for --with-wctype-functions)
1956 AC_ARG_WITH(wctype-functions, 
1957             AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
1959 if test "$withval" != no
1960 then 
1961   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
1962   [Define if you want wctype.h functions to be used instead of the
1963    one supplied by Python itself. (see Include/unicodectype.h).]) 
1964   AC_MSG_RESULT(yes)
1965 else AC_MSG_RESULT(no)
1966 fi],
1967 [AC_MSG_RESULT(no)])
1969 # -I${DLINCLDIR} is added to the compile rule for importdl.o
1970 AC_SUBST(DLINCLDIR)
1971 DLINCLDIR=.
1973 AC_MSG_CHECKING(for --with-sgi-dl)
1974 AC_ARG_WITH(sgi-dl,
1975             AC_HELP_STRING(--with-sgi-dl=DIRECTORY, IRIX 4 dynamic linking),
1977 AC_MSG_RESULT($withval)
1978 echo --with-sgi-dl is unsupported, see README
1979 exit 1
1980 AC_DEFINE(WITH_SGI_DL, 1,
1981   [Define if you want to use SGI (IRIX 4) dynamic linking.
1982    This requires the "dl" library by Jack Jansen,
1983    ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z.
1984    Do not bother on IRIX 5, it already has dynamic linking using SunOS
1985    style shared libraries])
1986 DYNLOADFILE="dynload_dl.o"
1987 dldir=$withval
1988 if test ! -z "$dldir" -a -d "$dldir"
1989 then LDFLAGS="$LDFLAGS -L$dldir"
1990 else AC_MSG_ERROR([proper usage is --with-sgi-dl=DIRECTORY])
1992 DLINCLDIR=${dldir}
1993 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
1995 AC_MSG_CHECKING(for --with-dl-dld)
1996 AC_ARG_WITH(dl-dld,
1997             AC_HELP_STRING(--with-dl-dld=DL_DIR, GNU dynamic linking),
1999 AC_MSG_RESULT($withval)
2000 echo --with-dl-dld is unsupported, see README
2001 exit 1
2002 AC_DEFINE(WITH_DL_DLD, 1, 
2003   [Define if you want to emulate SGI (IRIX 4) dynamic linking.
2004    This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4),
2005    Sequent Symmetry (Dynix), and Atari ST.
2006    This requires the 'dl-dld' library,
2007    ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z,
2008    as well as the 'GNU dld' library,
2009    ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z.
2010    Do not bother on SunOS 4 or 5, they already have dynamic linking using
2011    shared libraries.])
2012 DYNLOADFILE="dynload_dl.o"
2013 dldir=`echo "$withval" | sed 's/,.*//'`
2014 dlddir=`echo "$withval" | sed 's/.*,//'`
2015 if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
2016 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
2017 else AC_MSG_ERROR([proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY])
2019 DLINCLDIR=${dldir}
2020 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
2022 # the dlopen() function means we might want to use dynload_shlib.o. some
2023 # platforms, such as AIX, have dlopen(), but don't want to use it.
2024 AC_CHECK_FUNCS(dlopen)
2026 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2027 # loading of modules.
2028 AC_SUBST(DYNLOADFILE)
2029 AC_MSG_CHECKING(DYNLOADFILE)
2030 if test -z "$DYNLOADFILE"
2031 then
2032         case $ac_sys_system/$ac_sys_release in
2033         AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2034         if test "$ac_cv_func_dlopen" = yes
2035         then DYNLOADFILE="dynload_shlib.o"
2036         else DYNLOADFILE="dynload_aix.o"
2037         fi
2038         ;;
2039         BeOS*) DYNLOADFILE="dynload_beos.o";;
2040         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2041         Darwin/*) DYNLOADFILE="dynload_next.o";;
2042         atheos*) DYNLOADFILE="dynload_atheos.o";;
2043         *)
2044         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2045         # out any dynamic loading
2046         if test "$ac_cv_func_dlopen" = yes
2047         then DYNLOADFILE="dynload_shlib.o"
2048         else DYNLOADFILE="dynload_stub.o"
2049         fi
2050         ;;
2051         esac
2053 AC_MSG_RESULT($DYNLOADFILE)
2054 if test "$DYNLOADFILE" != "dynload_stub.o"
2055 then
2056         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2057         [Defined when any dynamic module loading is enabled.])
2060 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
2062 AC_SUBST(MACHDEP_OBJS)
2063 AC_MSG_CHECKING(MACHDEP_OBJS)
2064 if test -z "$MACHDEP_OBJS"
2065 then
2066         MACHDEP_OBJS=$extra_machdep_objs
2067 else
2068         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2070 AC_MSG_RESULT(MACHDEP_OBJS)
2072 # checks for library functions
2073 AC_CHECK_FUNCS(alarm chown clock confstr ctermid execv \
2074  fork fpathconf ftime ftruncate \
2075  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2076  getpriority getpwent getwd \
2077  kill killpg lchown lstat mkfifo mknod mktime \
2078  mremap nice pathconf pause plock poll pthread_init \
2079  putenv readlink realpath \
2080  select setegid seteuid setgid \
2081  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2082  sigaction siginterrupt sigrelse strftime strptime \
2083  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2084  truncate uname unsetenv utimes waitpid wcscoll _getpty)
2086 # For some functions, having a definition is not sufficient, since
2087 # we want to take their address.
2088 AC_MSG_CHECKING(for chroot)
2089 AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2090   AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2091   AC_MSG_RESULT(yes),
2092   AC_MSG_RESULT(no)
2094 AC_MSG_CHECKING(for link)
2095 AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2096   AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2097   AC_MSG_RESULT(yes),
2098   AC_MSG_RESULT(no)
2100 AC_MSG_CHECKING(for symlink)
2101 AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2102   AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2103   AC_MSG_RESULT(yes),
2104   AC_MSG_RESULT(no)
2106 AC_MSG_CHECKING(for fchdir)
2107 AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2108   AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2109   AC_MSG_RESULT(yes),
2110   AC_MSG_RESULT(no)
2112 AC_MSG_CHECKING(for fsync)
2113 AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
2114   AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2115   AC_MSG_RESULT(yes),
2116   AC_MSG_RESULT(no)
2118 AC_MSG_CHECKING(for fdatasync)
2119 AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2120   AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2121   AC_MSG_RESULT(yes),
2122   AC_MSG_RESULT(no)
2125 # On some systems (eg. FreeBSD 5), we would find a definition of the
2126 # functions ctermid_r, setgroups in the library, but no prototype
2127 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2128 # address to avoid compiler warnings and potential miscompilations
2129 # because of the missing prototypes.
2131 AC_MSG_CHECKING(for ctermid_r)
2132 AC_TRY_COMPILE([
2133 #include "confdefs.h" 
2134 #include <stdio.h>
2135 ], void* p = ctermid_r,
2136   AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2137   AC_MSG_RESULT(yes),
2138   AC_MSG_RESULT(no)
2141 AC_MSG_CHECKING(for flock)
2142 AC_TRY_COMPILE([
2143 #include "confdefs.h" 
2144 #include <sys/file.h>
2145 ], void* p = flock,
2146   AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2147   AC_MSG_RESULT(yes),
2148   AC_MSG_RESULT(no)
2151 AC_MSG_CHECKING(for getpagesize)
2152 AC_TRY_COMPILE([
2153 #include "confdefs.h" 
2154 #include <unistd.h>
2155 ], void* p = getpagesize,
2156   AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2157   AC_MSG_RESULT(yes),
2158   AC_MSG_RESULT(no)
2161 dnl check for true
2162 AC_CHECK_PROGS(TRUE, true, /bin/true)
2164 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2165 dnl On others, they are in the C library, so we to take no action
2166 AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2167   AC_CHECK_LIB(resolv, inet_aton)
2170 AC_MSG_CHECKING(for hstrerror)
2171 AC_TRY_LINK([
2172 #include "confdefs.h" 
2173 #include <netdb.h>
2174 ], void* p = hstrerror; hstrerror(0),
2175   AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2176   AC_MSG_RESULT(yes),
2177   AC_MSG_RESULT(no)
2180 AC_MSG_CHECKING(for inet_aton)
2181 AC_TRY_LINK([
2182 #include "confdefs.h" 
2183 #include <sys/socket.h>
2184 #include <netinet/in.h>
2185 #include <arpa/inet.h>
2186 ], void* p = inet_aton;inet_aton(0,0),
2187   AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2188   AC_MSG_RESULT(yes),
2189   AC_MSG_RESULT(no)
2192 AC_MSG_CHECKING(for inet_pton)
2193 AC_TRY_COMPILE([
2194 #include "confdefs.h" 
2195 #include <sys/types.h>
2196 #include <sys/socket.h>
2197 #include <netinet/in.h>
2198 #include <arpa/inet.h>
2199 ], void* p = inet_pton,
2200   AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2201   AC_MSG_RESULT(yes),
2202   AC_MSG_RESULT(no)
2205 # On some systems, setgroups is in unistd.h, on others, in grp.h
2206 AC_MSG_CHECKING(for setgroups)
2207 AC_TRY_COMPILE([
2208 #include "confdefs.h" 
2209 #include <unistd.h>
2210 #ifdef HAVE_GRP_H
2211 #include <grp.h>
2212 #endif
2213 ], 
2214 void* p = setgroups,
2215   AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2216   AC_MSG_RESULT(yes),
2217   AC_MSG_RESULT(no)
2220 # check for openpty and forkpty
2222 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"]))
2223 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"]))
2225 # check for long file support functions
2226 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2228 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
2229 AC_CHECK_FUNCS(getpgrp, 
2230   AC_TRY_COMPILE([#include <unistd.h>], 
2231    [getpgrp(0);], 
2232    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2233    [Define if getpgrp() must be called as getpgrp(0).])
2236 AC_CHECK_FUNCS(setpgrp,
2237   AC_TRY_COMPILE([#include <unistd.h>],
2238     [setpgrp(0,0);],
2239     AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2240     [Define if setpgrp() must be called as setpgrp(0, 0).])
2241   )
2243 AC_CHECK_FUNCS(gettimeofday, 
2244   AC_TRY_COMPILE([#include <sys/time.h>], 
2245     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2246     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2247     [Define if gettimeofday() does not have second (timezone) argument
2248      This is the case on Motorola V4 (R40V4.2)])
2249   )
2252 AC_MSG_CHECKING(for major, minor, and makedev)
2253 AC_TRY_LINK([
2254 #if defined(MAJOR_IN_MKDEV)
2255 #include <sys/mkdev.h>
2256 #elif defined(MAJOR_IN_SYSMACROS)
2257 #include <sys/sysmacros.h>
2258 #else
2259 #include <sys/types.h>
2260 #endif
2262   makedev(major(0),minor(0));
2264   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2265             [Define to 1 if you have the device macros.])
2266   AC_MSG_RESULT(yes)
2268   AC_MSG_RESULT(no)
2271 # On OSF/1 V5.1, getaddrinfo is available, but a define
2272 # for [no]getaddrinfo in netdb.h. 
2273 AC_MSG_CHECKING(for getaddrinfo)
2274 AC_TRY_LINK([
2275 #include <sys/types.h>
2276 #include <sys/socket.h>
2277 #include <netdb.h>
2278 #include <stdio.h>
2280 getaddrinfo(NULL, NULL, NULL, NULL);
2281 ], [
2282 AC_MSG_RESULT(yes)
2283 AC_MSG_CHECKING(getaddrinfo bug)
2284 AC_TRY_RUN([
2285 #include <sys/types.h>
2286 #include <netdb.h>
2287 #include <string.h>
2288 #include <sys/socket.h>
2289 #include <netinet/in.h>
2291 main()
2293   int passive, gaierr, inet4 = 0, inet6 = 0;
2294   struct addrinfo hints, *ai, *aitop;
2295   char straddr[INET6_ADDRSTRLEN], strport[16];
2297   for (passive = 0; passive <= 1; passive++) {
2298     memset(&hints, 0, sizeof(hints));
2299     hints.ai_family = AF_UNSPEC;
2300     hints.ai_flags = passive ? AI_PASSIVE : 0;
2301     hints.ai_socktype = SOCK_STREAM;
2302     hints.ai_protocol = IPPROTO_TCP;
2303     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2304       (void)gai_strerror(gaierr);
2305       goto bad;
2306     }
2307     for (ai = aitop; ai; ai = ai->ai_next) {
2308       if (ai->ai_addr == NULL ||
2309           ai->ai_addrlen == 0 ||
2310           getnameinfo(ai->ai_addr, ai->ai_addrlen,
2311                       straddr, sizeof(straddr), strport, sizeof(strport),
2312                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2313         goto bad;
2314       }
2315       switch (ai->ai_family) {
2316       case AF_INET:
2317         if (strcmp(strport, "54321") != 0) {
2318           goto bad;
2319         }
2320         if (passive) {
2321           if (strcmp(straddr, "0.0.0.0") != 0) {
2322             goto bad;
2323           }
2324         } else {
2325           if (strcmp(straddr, "127.0.0.1") != 0) {
2326             goto bad;
2327           }
2328         }
2329         inet4++;
2330         break;
2331       case AF_INET6:
2332         if (strcmp(strport, "54321") != 0) {
2333           goto bad;
2334         }
2335         if (passive) {
2336           if (strcmp(straddr, "::") != 0) {
2337             goto bad;
2338           }
2339         } else {
2340           if (strcmp(straddr, "::1") != 0) {
2341             goto bad;
2342           }
2343         }
2344         inet6++;
2345         break;
2346       case AF_UNSPEC:
2347         goto bad;
2348         break;
2349       default:
2350         /* another family support? */
2351         break;
2352       }
2353     }
2354   }
2356   if (!(inet4 == 0 || inet4 == 2))
2357     goto bad;
2358   if (!(inet6 == 0 || inet6 == 2))
2359     goto bad;
2361   if (aitop)
2362     freeaddrinfo(aitop);
2363   exit(0);
2365  bad:
2366   if (aitop)
2367     freeaddrinfo(aitop);
2368   exit(1);
2371 AC_MSG_RESULT(good)
2372 buggygetaddrinfo=no,
2373 AC_MSG_RESULT(buggy)
2374 buggygetaddrinfo=yes,
2375 AC_MSG_RESULT(buggy)
2376 buggygetaddrinfo=yes)], [
2377 AC_MSG_RESULT(no)
2378 buggygetaddrinfo=yes
2381 if test "$buggygetaddrinfo" = "yes"; then
2382         if test "$ipv6" = "yes"; then
2383                 echo 'Fatal: You must get working getaddrinfo() function.'
2384                 echo '       or you can specify "--disable-ipv6"'.
2385                 exit 1
2386         fi
2387 else
2388         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2390 AC_CHECK_FUNCS(getnameinfo)
2392 # checks for structures
2393 AC_HEADER_TIME
2394 AC_STRUCT_TM
2395 AC_STRUCT_TIMEZONE
2396 AC_CHECK_MEMBERS([struct stat.st_rdev])
2397 AC_CHECK_MEMBERS([struct stat.st_blksize])
2398 AC_STRUCT_ST_BLOCKS
2400 AC_MSG_CHECKING(for time.h that defines altzone)
2401 AC_CACHE_VAL(ac_cv_header_time_altzone,
2402 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2403   ac_cv_header_time_altzone=yes,
2404   ac_cv_header_time_altzone=no)])
2405 AC_MSG_RESULT($ac_cv_header_time_altzone)
2406 if test $ac_cv_header_time_altzone = yes; then
2407   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2410 was_it_defined=no
2411 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2412 AC_TRY_COMPILE([
2413 #include <sys/types.h>
2414 #include <sys/select.h>
2415 #include <sys/time.h>
2416 ], [;], [
2417   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2418   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
2419    (which you can't on SCO ODT 3.0).]) 
2420   was_it_defined=yes
2422 AC_MSG_RESULT($was_it_defined)
2424 AC_MSG_CHECKING(for addrinfo)
2425 AC_CACHE_VAL(ac_cv_struct_addrinfo,
2426 AC_TRY_COMPILE([
2427 #               include <netdb.h>],
2428         [struct addrinfo a],
2429         ac_cv_struct_addrinfo=yes,
2430         ac_cv_struct_addrinfo=no))
2431 AC_MSG_RESULT($ac_cv_struct_addrinfo)
2432 if test $ac_cv_struct_addrinfo = yes; then
2433         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
2436 AC_MSG_CHECKING(for sockaddr_storage)
2437 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2438 AC_TRY_COMPILE([
2439 #               include <sys/types.h>
2440 #               include <sys/socket.h>],
2441         [struct sockaddr_storage s],
2442         ac_cv_struct_sockaddr_storage=yes,
2443         ac_cv_struct_sockaddr_storage=no))
2444 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2445 if test $ac_cv_struct_sockaddr_storage = yes; then
2446         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
2449 # checks for compiler characteristics
2451 AC_C_CHAR_UNSIGNED
2452 AC_C_CONST
2454 works=no
2455 AC_MSG_CHECKING(for working volatile)
2456 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
2457   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2459 AC_MSG_RESULT($works)
2461 works=no
2462 AC_MSG_CHECKING(for working signed char)
2463 AC_TRY_COMPILE([], [signed char c;], works=yes, 
2464   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2466 AC_MSG_RESULT($works)
2468 have_prototypes=no
2469 AC_MSG_CHECKING(for prototypes)
2470 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2471   AC_DEFINE(HAVE_PROTOTYPES, 1, 
2472    [Define if your compiler supports function prototype]) 
2473   have_prototypes=yes
2475 AC_MSG_RESULT($have_prototypes)
2477 works=no
2478 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
2479 AC_TRY_COMPILE([
2480 #include <stdarg.h>
2481 int foo(int x, ...) {
2482         va_list va;
2483         va_start(va, x);
2484         va_arg(va, int);
2485         va_arg(va, char *);
2486         va_arg(va, double);
2487         return 0;
2489 ], [return foo(10, "", 3.14);], [
2490   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2491    [Define if your compiler supports variable length function prototypes
2492    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
2493   works=yes
2495 AC_MSG_RESULT($works)
2497 if test "$have_prototypes" = yes; then
2498 bad_prototypes=no
2499 AC_MSG_CHECKING(for bad exec* prototypes)
2500 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
2501     AC_DEFINE(BAD_EXEC_PROTOTYPES, 1,
2502     [Define if your <unistd.h> contains bad prototypes for exec*()
2503     (as it does on SGI IRIX 4.x)]) 
2504     bad_prototypes=yes
2506 AC_MSG_RESULT($bad_prototypes)
2509 # check if sockaddr has sa_len member
2510 AC_MSG_CHECKING(if sockaddr has sa_len member)
2511 AC_TRY_COMPILE([#include <sys/types.h>
2512 #include <sys/socket.h>],
2513 [struct sockaddr x;
2514 x.sa_len = 0;],
2515         AC_MSG_RESULT(yes)
2516         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
2517         AC_MSG_RESULT(no))
2519 va_list_is_array=no
2520 AC_MSG_CHECKING(whether va_list is an array)
2521 AC_TRY_COMPILE([
2522 #ifdef HAVE_STDARG_PROTOTYPES
2523 #include <stdarg.h>
2524 #else
2525 #include <varargs.h>
2526 #endif
2527 ], [va_list list1, list2; list1 = list2;], , [
2528  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
2529  va_list_is_array=yes
2531 AC_MSG_RESULT($va_list_is_array)
2533 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
2534 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2535   [Define this if you have some version of gethostbyname_r()])
2537 AC_CHECK_FUNC(gethostbyname_r, [
2538   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2539   AC_MSG_CHECKING([gethostbyname_r with 6 args])
2540   OLD_CFLAGS=$CFLAGS
2541   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2542   AC_TRY_COMPILE([
2543 #   include <netdb.h>
2544   ], [
2545     char *name;
2546     struct hostent *he, *res;
2547     char buffer[2048];
2548     int buflen = 2048;
2549     int h_errnop;
2551     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2552   ], [
2553     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2554     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2555     [Define this if you have the 6-arg version of gethostbyname_r().])
2556     AC_MSG_RESULT(yes)
2557   ], [
2558     AC_MSG_RESULT(no)
2559     AC_MSG_CHECKING([gethostbyname_r with 5 args])
2560     AC_TRY_COMPILE([
2561 #     include <netdb.h>
2562     ], [
2563       char *name;
2564       struct hostent *he;
2565       char buffer[2048];
2566       int buflen = 2048;
2567       int h_errnop;
2569       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2570     ], [
2571       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2572       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2573       [Define this if you have the 5-arg version of gethostbyname_r().])
2574       AC_MSG_RESULT(yes)
2575     ], [
2576       AC_MSG_RESULT(no)
2577       AC_MSG_CHECKING([gethostbyname_r with 3 args])
2578       AC_TRY_COMPILE([
2579 #       include <netdb.h>
2580       ], [
2581         char *name;
2582         struct hostent *he;
2583         struct hostent_data data;
2585         (void) gethostbyname_r(name, he, &data);
2586       ], [
2587         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2588         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2589         [Define this if you have the 3-arg version of gethostbyname_r().])
2590         AC_MSG_RESULT(yes)
2591       ], [
2592         AC_MSG_RESULT(no)
2593       ])
2594     ])
2595   ])
2596   CFLAGS=$OLD_CFLAGS
2597 ], [
2598   AC_CHECK_FUNCS(gethostbyname)
2600 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2601 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2602 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
2603 AC_SUBST(HAVE_GETHOSTBYNAME_R)
2604 AC_SUBST(HAVE_GETHOSTBYNAME)
2606 # checks for system services
2607 # (none yet)
2609 # Linux requires this for correct f.p. operations
2610 AC_CHECK_FUNC(__fpu_control,
2611   [],
2612   [AC_CHECK_LIB(ieee, __fpu_control)
2615 # Check for --with-fpectl
2616 AC_MSG_CHECKING(for --with-fpectl)
2617 AC_ARG_WITH(fpectl,
2618             AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
2620 if test "$withval" != no
2621 then 
2622   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2623   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
2624   AC_MSG_RESULT(yes)
2625 else AC_MSG_RESULT(no)
2626 fi],
2627 [AC_MSG_RESULT(no)])
2629 # check for --with-libm=...
2630 AC_SUBST(LIBM)
2631 case $ac_sys_system in
2632 Darwin) ;;
2633 BeOS) ;;
2634 *) LIBM=-lm
2635 esac
2636 AC_MSG_CHECKING(for --with-libm=STRING)
2637 AC_ARG_WITH(libm,
2638             AC_HELP_STRING(--with-libm=STRING, math library),
2640 if test "$withval" = no
2641 then LIBM=
2642      AC_MSG_RESULT(force LIBM empty)
2643 elif test "$withval" != yes
2644 then LIBM=$withval
2645      AC_MSG_RESULT(set LIBM="$withval")
2646 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
2647 fi],
2648 [AC_MSG_RESULT(default LIBM="$LIBM")])
2650 # check for --with-libc=...
2651 AC_SUBST(LIBC)
2652 AC_MSG_CHECKING(for --with-libc=STRING)
2653 AC_ARG_WITH(libc,
2654             AC_HELP_STRING(--with-libc=STRING, C library),
2656 if test "$withval" = no
2657 then LIBC=
2658      AC_MSG_RESULT(force LIBC empty)
2659 elif test "$withval" != yes
2660 then LIBC=$withval
2661      AC_MSG_RESULT(set LIBC="$withval")
2662 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
2663 fi],
2664 [AC_MSG_RESULT(default LIBC="$LIBC")])
2666 # check for hypot() in math library
2667 LIBS_SAVE=$LIBS
2668 LIBS="$LIBS $LIBM"
2669 AC_REPLACE_FUNCS(hypot)
2670 LIBS=$LIBS_SAVE
2672 # check for wchar.h
2673 AC_CHECK_HEADER(wchar.h, [
2674   AC_DEFINE(HAVE_WCHAR_H, 1, 
2675   [Define if the compiler provides a wchar.h header file.]) 
2676   wchar_h="yes"
2678 wchar_h="no"
2681 # determine wchar_t size
2682 if test "$wchar_h" = yes
2683 then
2684   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
2687 AC_MSG_CHECKING(for UCS-4 tcl)
2688 have_ucs4_tcl=no
2689 AC_TRY_COMPILE([
2690 #include <tcl.h>
2691 #if TCL_UTF_MAX != 6
2692 # error "NOT UCS4_TCL"
2693 #endif], [], [
2694   AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
2695   have_ucs4_tcl=yes
2697 AC_MSG_RESULT($have_ucs4_tcl)
2699 AC_MSG_CHECKING(what type to use for unicode)
2700 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2701 AC_ARG_ENABLE(unicode, 
2702               AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
2703               [],
2704               [enable_unicode=yes])
2706 if test $enable_unicode = yes
2707 then
2708   # Without any arguments, Py_UNICODE defaults to two-byte mode
2709   case "$have_ucs4_tcl" in
2710   yes) enable_unicode="ucs4"
2711        ;;
2712   *)   enable_unicode="ucs2"
2713        ;;
2714   esac
2717 AH_TEMPLATE(Py_UNICODE_SIZE,
2718   [Define as the size of the unicode type.])
2719 case "$enable_unicode" in
2720 ucs2) unicode_size="2"
2721       AC_DEFINE(Py_UNICODE_SIZE,2)
2722       ;;
2723 ucs4) unicode_size="4"
2724       AC_DEFINE(Py_UNICODE_SIZE,4)
2725       ;;
2726 esac
2728 AH_TEMPLATE(PY_UNICODE_TYPE,
2729   [Define as the integral type used for Unicode representation.])
2731 AC_SUBST(UNICODE_OBJS)
2732 if test "$enable_unicode" = "no"
2733 then
2734   UNICODE_OBJS=""
2735   AC_MSG_RESULT(not used)
2736 else
2737   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
2738   AC_DEFINE(Py_USING_UNICODE, 1,
2739   [Define if you want to have a Unicode type.])
2740   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
2741   then
2742     PY_UNICODE_TYPE="wchar_t"
2743     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
2744     [Define if you have a useable wchar_t type defined in wchar.h; useable
2745      means wchar_t must be 16-bit unsigned type. (see
2746      Include/unicodeobject.h).])
2747     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
2748   elif test "$ac_cv_sizeof_short" = "$unicode_size"
2749   then
2750        PY_UNICODE_TYPE="unsigned short"
2751        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
2752   elif test "$ac_cv_sizeof_long" = "$unicode_size"
2753   then
2754        PY_UNICODE_TYPE="unsigned long"
2755        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
2756   else
2757        PY_UNICODE_TYPE="no type found"
2758   fi
2759   AC_MSG_RESULT($PY_UNICODE_TYPE)
2762 # check for endianness
2763 AC_C_BIGENDIAN
2765 # Check whether right shifting a negative integer extends the sign bit
2766 # or fills with zeros (like the Cray J90, according to Tim Peters).
2767 AC_MSG_CHECKING(whether right shift extends the sign bit)
2768 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
2769 AC_TRY_RUN([
2770 int main()
2772         exit(((-1)>>3 == -1) ? 0 : 1);
2775 ac_cv_rshift_extends_sign=yes,
2776 ac_cv_rshift_extends_sign=no,
2777 ac_cv_rshift_extends_sign=yes)])
2778 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
2779 if test "$ac_cv_rshift_extends_sign" = no
2780 then
2781   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
2782   [Define if i>>j for signed int i does not extend the sign bit
2783    when i < 0])
2786 # check for getc_unlocked and related locking functions
2787 AC_MSG_CHECKING(for getc_unlocked() and friends)
2788 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
2789 AC_TRY_LINK([#include <stdio.h>],[
2790         FILE *f = fopen("/dev/null", "r");
2791         flockfile(f);
2792         getc_unlocked(f);
2793         funlockfile(f);
2794 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
2795 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
2796 if test "$ac_cv_have_getc_unlocked" = yes
2797 then
2798   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
2799   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
2802 # check for readline 2.2
2803 AC_TRY_CPP([#include <readline/readline.h>],
2804 have_readline=yes, have_readline=no)
2805 if test $have_readline = yes
2806 then
2807   AC_EGREP_HEADER([extern int rl_completion_append_character;],
2808   [readline/readline.h],
2809   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
2810   [Define if you have readline 2.2]), )
2813 # check for readline 4.0
2814 AC_CHECK_LIB(readline, rl_pre_input_hook,
2815         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
2816         [Define if you have readline 4.0]), , -ltermcap)
2818 # check for readline 4.2
2819 AC_CHECK_LIB(readline, rl_completion_matches,
2820         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
2821         [Define if you have readline 4.2]), , -ltermcap)
2823 AC_MSG_CHECKING(for broken nice())
2824 AC_CACHE_VAL(ac_cv_broken_nice, [
2825 AC_TRY_RUN([
2826 int main()
2828         int val1 = nice(1);
2829         if (val1 != -1 && val1 == nice(2))
2830                 exit(0);
2831         exit(1);
2834 ac_cv_broken_nice=yes,
2835 ac_cv_broken_nice=no,
2836 ac_cv_broken_nice=no)])
2837 AC_MSG_RESULT($ac_cv_broken_nice)
2838 if test "$ac_cv_broken_nice" = yes
2839 then
2840   AC_DEFINE(HAVE_BROKEN_NICE, 1,
2841   [Define if nice() returns success/failure instead of the new priority.])
2844 AC_MSG_CHECKING(for broken poll())
2845 AC_TRY_RUN([
2846 #include <poll.h>
2848 int main (void)
2849     {
2850     struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
2851     
2852     close (42);
2854     int poll_test = poll (&poll_struct, 1, 0);
2856     if (poll_test < 0)
2857         {
2858         exit(0);
2859         }
2860     else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
2861         {
2862         exit(0);
2863         }
2864     else
2865         {
2866         exit(1);
2867         }
2868     }
2870 ac_cv_broken_poll=yes,
2871 ac_cv_broken_poll=no,
2872 ac_cv_broken_poll=no)
2873 AC_MSG_RESULT($ac_cv_broken_poll)
2874 if test "$ac_cv_broken_poll" = yes
2875 then
2876   AC_DEFINE(HAVE_BROKEN_POLL, 1,
2877       [Define if poll() sets errno on invalid file descriptors.])
2881 # tzset(3) exists and works like we expect it to
2882 AC_MSG_CHECKING(for working tzset())
2883 AC_CACHE_VAL(ac_cv_working_tzset, [
2884 AC_TRY_RUN([
2885 #include <stdlib.h>
2886 #include <time.h>
2887 #include <string.h>
2888 int main()
2890         /* Note that we need to ensure that not only does tzset(3)
2891            do 'something' with localtime, but it works as documented
2892            in the library reference and as expected by the test suite.
2894            Linux 6.2 doesn't understand the southern hemisphere 
2895            after New Year's Day.
2896         */
2898         time_t groundhogday = 1044144000; /* GMT-based, well, it's a colony */
2899         time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
2901         putenv("TZ=UTC+0");
2902         tzset();
2903         if (localtime(&groundhogday)->tm_hour != 0)
2904             exit(1);
2906         putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
2907         tzset();
2908         if (localtime(&groundhogday)->tm_hour != 19)
2909             exit(1);
2911         putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
2912         tzset();
2913         if (localtime(&groundhogday)->tm_hour != 11)
2914             exit(1);
2915         if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
2916             exit(1);
2917         if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
2918             exit(1);
2920         exit(0);
2923 ac_cv_working_tzset=yes,
2924 ac_cv_working_tzset=no,
2925 ac_cv_working_tzset=no)])
2926 AC_MSG_RESULT($ac_cv_working_tzset)
2927 if test "$ac_cv_working_tzset" = yes
2928 then
2929   AC_DEFINE(HAVE_WORKING_TZSET, 1,
2930   [Define if tzset() actually switches the local timezone in a meaningful way.])
2933 # Look for subsecond timestamps in struct stat
2934 AC_MSG_CHECKING(for tv_nsec in struct stat)
2935 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
2936 AC_TRY_COMPILE([#include <sys/stat.h>], [
2937 struct stat st;
2938 st.st_mtim.tv_nsec = 1;
2940 ac_cv_stat_tv_nsec=yes,
2941 ac_cv_stat_tv_nsec=no,
2942 ac_cv_stat_tv_nsec=no))
2943 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
2944 if test "$ac_cv_stat_tv_nsec" = yes
2945 then
2946   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
2947   [Define if you have struct stat.st_mtim.tv_nsec])
2950 # On HP/UX 11.0, mvwdelch is a block with a return statement
2951 AC_MSG_CHECKING(whether mvwdelch is an expression)
2952 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
2953 AC_TRY_COMPILE([#include <curses.h>], [
2954   int rtn;
2955   rtn = mvwdelch(0,0,0);
2956 ], ac_cv_mvwdelch_is_expression=yes,
2957    ac_cv_mvwdelch_is_expression=no,
2958    ac_cv_mvwdelch_is_expression=yes))
2959 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
2961 if test "$ac_cv_mvwdelch_is_expression" = yes
2962 then
2963   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
2964   [Define if mvwdelch in curses.h is an expression.])
2967 AC_MSG_CHECKING(whether WINDOW has _flags)
2968 AC_CACHE_VAL(ac_cv_window_has_flags,
2969 AC_TRY_COMPILE([#include <curses.h>], [
2970   WINDOW *w;
2971   w->_flags = 0;
2972 ], ac_cv_window_has_flags=yes,
2973    ac_cv_window_has_flags=no,
2974    ac_cv_window_has_flags=no))
2975 AC_MSG_RESULT($ac_cv_window_has_flags)
2978 if test "$ac_cv_window_has_flags" = yes
2979 then
2980   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
2981   [Define if WINDOW in curses.h offers a field _flags.])
2984 AC_MSG_CHECKING(for /dev/ptmx)
2986 if test -e /dev/ptmx
2987 then
2988   AC_MSG_RESULT(yes)
2989   AC_DEFINE(HAVE_DEV_PTMX, 1,
2990   [Define if we have /dev/ptmx.])
2991 else
2992   AC_MSG_RESULT(no)
2995 AC_MSG_CHECKING(for /dev/ptc)
2997 if test -e /dev/ptc
2998 then
2999   AC_MSG_RESULT(yes)
3000   AC_DEFINE(HAVE_DEV_PTC, 1,
3001   [Define if we have /dev/ptc.])
3002 else
3003   AC_MSG_RESULT(no)
3006 AC_CHECK_TYPE(socklen_t,,
3007   AC_DEFINE(socklen_t,int,
3008             Define to `int' if <sys/socket.h> does not define.),[
3009 #ifdef HAVE_SYS_TYPES_H
3010 #include <sys/types.h>
3011 #endif
3012 #ifdef HAVE_SYS_SOCKET_H
3013 #include <sys/socket.h>
3014 #endif
3017 AC_SUBST(THREADHEADERS)
3019 for h in `(cd $srcdir;echo Python/thread_*.h)`
3021   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3022 done
3024 AC_SUBST(SRCDIRS)
3025 SRCDIRS="Parser Grammar Objects Python Modules Mac Mac/Python"
3026 AC_MSG_CHECKING(for build directories)
3027 for dir in $SRCDIRS; do
3028     if test ! -d $dir; then
3029         mkdir $dir
3030     fi
3031 done
3032 AC_MSG_RESULT(done)
3034 # generate output files
3035 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
3036 AC_OUTPUT
3038 echo "creating Setup"
3039 if test ! -f Modules/Setup
3040 then
3041         cp $srcdir/Modules/Setup.dist Modules/Setup
3044 echo "creating Setup.local"
3045 if test ! -f Modules/Setup.local
3046 then
3047         echo "# Edit this file for local setup changes" >Modules/Setup.local
3050 echo "creating Makefile"
3051 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3052                         -s Modules Modules/Setup.config \
3053                         Modules/Setup.local Modules/Setup
3054 mv config.c Modules