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