Issue #7568: typo in docstring. Thanks Mike Putnam.
[python.git] / configure.in
blob59056b904fbad2d87c5ee4684aa2e658df1d992e
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_SUBST(LIPO_32BIT_FLAGS)
116 AC_MSG_CHECKING(for --with-universal-archs)
117 AC_ARG_WITH(universal-archs,
118     AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")),
120         AC_MSG_RESULT($withval)
121         UNIVERSAL_ARCHS="$withval"
122         if test "${enable_universalsdk}" ; then
123                 :
124         else
125                 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
126         fi
129         AC_MSG_RESULT(32-bit)
134 AC_ARG_WITH(framework-name,
135               AC_HELP_STRING(--with-framework-name=FRAMEWORK, 
136                              specify an alternate name of the framework built with --enable-framework),
138     if test "${enable_framework}"; then
139             :
140     else
141         AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
142     fi
143     PYTHONFRAMEWORK=${withval}
144     PYTHONFRAMEWORKDIR=${withval}.framework
145     PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
146     ],[
147     PYTHONFRAMEWORK=Python
148     PYTHONFRAMEWORKDIR=Python.framework
149     PYTHONFRAMEWORKIDENTIFIER=org.python.python
151 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
152 AC_ARG_ENABLE(framework,
153               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
155         case $enableval in
156         yes) 
157                 enableval=/Library/Frameworks
158         esac
159         case $enableval in
160         no)
161                 PYTHONFRAMEWORK=
162                 PYTHONFRAMEWORKDIR=no-framework
163                 PYTHONFRAMEWORKPREFIX=
164                 PYTHONFRAMEWORKINSTALLDIR=
165                 FRAMEWORKINSTALLFIRST=
166                 FRAMEWORKINSTALLLAST=
167                 FRAMEWORKALTINSTALLFIRST=
168                 FRAMEWORKALTINSTALLLAST=
169                 if test "x${prefix}" = "xNONE"; then
170                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
171                 else
172                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
173                 fi
174                 enable_framework=
175                 ;;
176         *)
177                 PYTHONFRAMEWORKPREFIX=$enableval
178                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
179                 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
180                 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
181                 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
182                 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
184                 if test "x${prefix}" = "xNONE" ; then
185                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
186                 else
187                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
188                 fi
189                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
191                 # Add files for Mac specific code to the list of output
192                 # files:
193                 AC_CONFIG_FILES(Mac/Makefile)
194                 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
195                 AC_CONFIG_FILES(Mac/IDLE/Makefile)
196                 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
197                 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
198         esac
199         ],[
200         PYTHONFRAMEWORK=
201         PYTHONFRAMEWORKDIR=no-framework
202         PYTHONFRAMEWORKPREFIX=
203         PYTHONFRAMEWORKINSTALLDIR=
204         FRAMEWORKINSTALLFIRST=
205         FRAMEWORKINSTALLLAST=
206         FRAMEWORKALTINSTALLFIRST=
207         FRAMEWORKALTINSTALLLAST=
208         if test "x${prefix}" = "xNONE" ; then
209                 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
210         else
211                 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
212         fi
213         enable_framework=
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_COMPILE([],[int main() { return 0; }],
912      ac_cv_no_strict_aliasing_ok=yes,
913      ac_cv_no_strict_aliasing_ok=no))
914      CC="$ac_save_cc"
915     AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
916     if test $ac_cv_no_strict_aliasing_ok = yes
917     then
918       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
919     fi
921     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
922     # support.  Without this, treatment of subnormals doesn't follow
923     # the standard.
924     case $ac_sys_machine in
925          alpha*)
926                 BASECFLAGS="$BASECFLAGS -mieee"
927                 ;;
928     esac
930     case $ac_sys_system in
931         SCO_SV*)
932             BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
933             ;;
934         # is there any other compiler on Darwin besides gcc?
935         Darwin*)
936             # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
937             # used to be here, but non-Apple gcc doesn't accept them.
940             if test "${enable_universalsdk}"; then
941                 UNIVERSAL_ARCH_FLAGS=""
942                 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
943                    UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
944                    ARCH_RUN_32BIT=""
945                    LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
947                  elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
948                    UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
949                    LIPO_32BIT_FLAGS=""
950                    ARCH_RUN_32BIT="true"
952                  elif test "$UNIVERSAL_ARCHS" = "all" ; then
953                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
954                    LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
955                    ARCH_RUN_32BIT="arch -i386 -ppc"
957                  elif test "$UNIVERSAL_ARCHS" = "intel" ; then
958                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
959                    LIPO_32BIT_FLAGS="-extract i386"
960                    ARCH_RUN_32BIT="arch -i386"
962                  elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
963                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
964                    LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
965                    ARCH_RUN_32BIT="arch -i386 -ppc7400"
967                  else
968                    AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
970                  fi
973                 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
974                 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
975                 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
976                         CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
977                 fi
978             fi
980             # Calculate the right deployment target for this build.
981             #
982             cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
983             if test ${cur_target} '>' 10.2; then
984                     cur_target=10.3
985                     if test ${enable_universalsdk}; then
986                             if test "${UNIVERSAL_ARCHS}" = "all"; then
987                                     # Ensure that the default platform for a 
988                                     # 4-way universal build is OSX 10.5, 
989                                     # that's the first OS release where 
990                                     # 4-way builds make sense.
991                                     cur_target='10.5'
993                             elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
994                                     cur_target='10.5'
996                             elif test "${UNIVERSAL_ARCHS}" = "intel"; then
997                                     cur_target='10.5'
999                             elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1000                                     cur_target='10.5'
1001                             fi
1002                     else
1003                             if test `arch` = "i386"; then
1004                                     # On Intel macs default to a deployment
1005                                     # target of 10.4, that's the first OSX
1006                                     # release with Intel support.
1007                                     cur_target="10.4"
1008                             fi
1009                     fi
1010             fi
1011             CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1012             
1013             # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
1014             # environment with a value that is the same as what we'll use
1015             # in the Makefile to ensure that we'll get the same compiler
1016             # environment during configure and build time.
1017             MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1018             export MACOSX_DEPLOYMENT_TARGET
1019             EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1021             ;;
1022         OSF*)
1023             BASECFLAGS="$BASECFLAGS -mieee"
1024             ;;
1025     esac
1026     ;;
1029     case $ac_sys_system in
1030     OpenUNIX*|UnixWare*)
1031         BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1032         ;;
1033     OSF*)
1034         BASECFLAGS="$BASECFLAGS -ieee -std"
1035         ;;
1036     SCO_SV*)
1037         BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1038         ;;
1039     esac
1040     ;;
1041 esac
1043 if test "$Py_DEBUG" = 'true'; then
1044   :
1045 else
1046   OPT="-DNDEBUG $OPT"
1049 if test "$ac_arch_flags"
1050 then
1051         BASECFLAGS="$BASECFLAGS $ac_arch_flags"
1054 # disable check for icc since it seems to pass, but generates a warning
1055 if test "$CC" = icc
1056 then
1057   ac_cv_opt_olimit_ok=no
1060 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1061 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1062 [ac_save_cc="$CC"
1063 CC="$CC -OPT:Olimit=0"
1064 AC_TRY_COMPILE([],[int main() { return 0; }],
1065   ac_cv_opt_olimit_ok=yes,
1066   ac_cv_opt_olimit_ok=no,
1067   )
1068 CC="$ac_save_cc"])
1069 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
1070 if test $ac_cv_opt_olimit_ok = yes; then
1071     case $ac_sys_system in
1072         # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1073         # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
1074         # environment?
1075         Darwin*)
1076             ;;
1077         *)
1078             BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1079             ;;
1080     esac
1081 else
1082   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1083   AC_CACHE_VAL(ac_cv_olimit_ok,
1084   [ac_save_cc="$CC"
1085   CC="$CC -Olimit 1500"
1086   AC_TRY_COMPILE([],[int main() { return 0; }],
1087     ac_cv_olimit_ok=yes,
1088     ac_cv_olimit_ok=no,
1089     )
1090   CC="$ac_save_cc"])
1091   AC_MSG_RESULT($ac_cv_olimit_ok)
1092   if test $ac_cv_olimit_ok = yes; then
1093     BASECFLAGS="$BASECFLAGS -Olimit 1500"
1094   fi
1097 # Check whether GCC supports PyArg_ParseTuple format
1098 if test "$GCC" = "yes"
1099 then
1100   AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1101   save_CFLAGS=$CFLAGS
1102   CFLAGS="$CFLAGS -Werror"
1103   AC_TRY_COMPILE([
1104     void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1105   ],,
1106   AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1107   AC_MSG_RESULT(yes),
1108   AC_MSG_RESULT(no)
1109   )
1110   CFLAGS=$save_CFLAGS
1113 # On some compilers, pthreads are available without further options
1114 # (e.g. MacOS X). On some of these systems, the compiler will not
1115 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1116 # So we have to see first whether pthreads are available without
1117 # options before we can check whether -Kpthread improves anything.
1118 AC_MSG_CHECKING(whether pthreads are available without options)
1119 AC_CACHE_VAL(ac_cv_pthread_is_default,
1120 [AC_TRY_RUN([
1121 #include <pthread.h>
1123 void* routine(void* p){return NULL;}
1125 int main(){
1126   pthread_t p;
1127   if(pthread_create(&p,NULL,routine,NULL)!=0)
1128     return 1;
1129   (void)pthread_detach(p);
1130   return 0;
1134   ac_cv_pthread_is_default=yes
1135   ac_cv_kthread=no
1136   ac_cv_pthread=no
1138   ac_cv_pthread_is_default=no,
1139   ac_cv_pthread_is_default=no)
1141 AC_MSG_RESULT($ac_cv_pthread_is_default)
1144 if test $ac_cv_pthread_is_default = yes 
1145 then
1146   ac_cv_kpthread=no
1147 else
1148 # -Kpthread, if available, provides the right #defines
1149 # and linker options to make pthread_create available
1150 # Some compilers won't report that they do not support -Kpthread,
1151 # so we need to run a program to see whether it really made the
1152 # function available.
1153 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1154 AC_CACHE_VAL(ac_cv_kpthread,
1155 [ac_save_cc="$CC"
1156 CC="$CC -Kpthread"
1157 AC_TRY_RUN([
1158 #include <pthread.h>
1160 void* routine(void* p){return NULL;}
1162 int main(){
1163   pthread_t p;
1164   if(pthread_create(&p,NULL,routine,NULL)!=0)
1165     return 1;
1166   (void)pthread_detach(p);
1167   return 0;
1170   ac_cv_kpthread=yes,
1171   ac_cv_kpthread=no,
1172   ac_cv_kpthread=no)
1173 CC="$ac_save_cc"])
1174 AC_MSG_RESULT($ac_cv_kpthread)
1177 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
1178 then
1179 # -Kthread, if available, provides the right #defines
1180 # and linker options to make pthread_create available
1181 # Some compilers won't report that they do not support -Kthread,
1182 # so we need to run a program to see whether it really made the
1183 # function available.
1184 AC_MSG_CHECKING(whether $CC accepts -Kthread)
1185 AC_CACHE_VAL(ac_cv_kthread,
1186 [ac_save_cc="$CC"
1187 CC="$CC -Kthread"
1188 AC_TRY_RUN([
1189 #include <pthread.h>
1191 void* routine(void* p){return NULL;}
1193 int main(){
1194   pthread_t p;
1195   if(pthread_create(&p,NULL,routine,NULL)!=0)
1196     return 1;
1197   (void)pthread_detach(p);
1198   return 0;
1201   ac_cv_kthread=yes,
1202   ac_cv_kthread=no,
1203   ac_cv_kthread=no)
1204 CC="$ac_save_cc"])
1205 AC_MSG_RESULT($ac_cv_kthread)
1208 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
1209 then
1210 # -pthread, if available, provides the right #defines
1211 # and linker options to make pthread_create available
1212 # Some compilers won't report that they do not support -pthread,
1213 # so we need to run a program to see whether it really made the
1214 # function available.
1215 AC_MSG_CHECKING(whether $CC accepts -pthread)
1216 AC_CACHE_VAL(ac_cv_thread,
1217 [ac_save_cc="$CC"
1218 CC="$CC -pthread"
1219 AC_TRY_RUN([
1220 #include <pthread.h>
1222 void* routine(void* p){return NULL;}
1224 int main(){
1225   pthread_t p;
1226   if(pthread_create(&p,NULL,routine,NULL)!=0)
1227     return 1;
1228   (void)pthread_detach(p);
1229   return 0;
1232   ac_cv_pthread=yes,
1233   ac_cv_pthread=no,
1234   ac_cv_pthread=no)
1235 CC="$ac_save_cc"])
1236 AC_MSG_RESULT($ac_cv_pthread)
1239 # If we have set a CC compiler flag for thread support then
1240 # check if it works for CXX, too.
1241 ac_cv_cxx_thread=no
1242 if test ! -z "$CXX"
1243 then
1244 AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1245 ac_save_cxx="$CXX"
1247 if test "$ac_cv_kpthread" = "yes"
1248 then
1249   CXX="$CXX -Kpthread"  
1250   ac_cv_cxx_thread=yes
1251 elif test "$ac_cv_kthread" = "yes"
1252 then
1253   CXX="$CXX -Kthread"
1254   ac_cv_cxx_thread=yes
1255 elif test "$ac_cv_pthread" = "yes"
1256 then 
1257   CXX="$CXX -pthread"
1258   ac_cv_cxx_thread=yes
1261 if test $ac_cv_cxx_thread = yes
1262 then
1263   echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1264   $CXX -c conftest.$ac_ext 2>&5
1265   if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1266      && test -s conftest$ac_exeext && ./conftest$ac_exeext
1267   then
1268     ac_cv_cxx_thread=yes
1269   else
1270     ac_cv_cxx_thread=no
1271   fi
1272   rm -fr conftest*
1274 AC_MSG_RESULT($ac_cv_cxx_thread)
1276 CXX="$ac_save_cxx"
1278 dnl # check for ANSI or K&R ("traditional") preprocessor
1279 dnl AC_MSG_CHECKING(for C preprocessor type)
1280 dnl AC_TRY_COMPILE([
1281 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1282 dnl int foo;
1283 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1284 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1285 dnl AC_MSG_RESULT($cpp_type)
1287 # checks for header files
1288 AC_HEADER_STDC
1289 AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1290 fcntl.h grp.h \
1291 ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
1292 shadow.h signal.h stdint.h stropts.h termios.h thread.h \
1293 unistd.h utime.h \
1294 sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1295 sys/lock.h sys/mkdev.h sys/modem.h \
1296 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
1297 sys/termio.h sys/time.h \
1298 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
1299 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
1300 bluetooth/bluetooth.h linux/tipc.h)
1301 AC_HEADER_DIRENT
1302 AC_HEADER_MAJOR
1304 # On Solaris, term.h requires curses.h
1305 AC_CHECK_HEADERS(term.h,,,[
1306 #ifdef HAVE_CURSES_H
1307 #include <curses.h>
1308 #endif
1311 # On Linux, netlink.h requires asm/types.h
1312 AC_CHECK_HEADERS(linux/netlink.h,,,[
1313 #ifdef HAVE_ASM_TYPES_H
1314 #include <asm/types.h>
1315 #endif
1316 #ifdef HAVE_SYS_SOCKET_H
1317 #include <sys/socket.h>
1318 #endif
1321 # checks for typedefs
1322 was_it_defined=no
1323 AC_MSG_CHECKING(for clock_t in time.h)
1324 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1325     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1327 AC_MSG_RESULT($was_it_defined)
1329 # Check whether using makedev requires defining _OSF_SOURCE
1330 AC_MSG_CHECKING(for makedev)
1331 AC_TRY_LINK([#include <sys/types.h> ],
1332             [ makedev(0, 0) ],
1333             ac_cv_has_makedev=yes,
1334             ac_cv_has_makedev=no)
1335 if test "$ac_cv_has_makedev" = "no"; then
1336     # we didn't link, try if _OSF_SOURCE will allow us to link
1337     AC_TRY_LINK([
1338 #define _OSF_SOURCE 1
1339 #include <sys/types.h>
1340     ],
1341     [ makedev(0, 0) ],
1342     ac_cv_has_makedev=yes,
1343     ac_cv_has_makedev=no)
1344     if test "$ac_cv_has_makedev" = "yes"; then
1345         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1346     fi
1348 AC_MSG_RESULT($ac_cv_has_makedev)
1349 if test "$ac_cv_has_makedev" = "yes"; then
1350     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1353 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1354 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1355 # defined, but the compiler does not support pragma redefine_extname,
1356 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1357 # structures (such as rlimit64) without declaring them. As a
1358 # work-around, disable LFS on such configurations
1360 use_lfs=yes
1361 AC_MSG_CHECKING(Solaris LFS bug)
1362 AC_TRY_COMPILE([
1363 #define _LARGEFILE_SOURCE 1
1364 #define _FILE_OFFSET_BITS 64
1365 #include <sys/resource.h>
1366 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1367 AC_MSG_RESULT($sol_lfs_bug)
1368 if test "$sol_lfs_bug" = "yes"; then
1369   use_lfs=no
1372 if test "$use_lfs" = "yes"; then
1373 # Two defines needed to enable largefile support on various platforms
1374 # These may affect some typedefs
1375 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
1376 [This must be defined on some systems to enable large file support.])
1377 AC_DEFINE(_FILE_OFFSET_BITS, 64,
1378 [This must be set to 64 on some systems to enable large file support.])
1381 # Add some code to confdefs.h so that the test for off_t works on SCO
1382 cat >> confdefs.h <<\EOF
1383 #if defined(SCO_DS)
1384 #undef _OFF_T
1385 #endif
1388 # Type availability checks
1389 AC_TYPE_MODE_T
1390 AC_TYPE_OFF_T
1391 AC_TYPE_PID_T
1392 AC_TYPE_SIGNAL
1393 AC_TYPE_SIZE_T
1394 AC_TYPE_UID_T
1395 AC_TYPE_UINT32_T
1396 AC_TYPE_UINT64_T
1397 AC_TYPE_INT32_T
1398 AC_TYPE_INT64_T
1399 AC_CHECK_TYPE(ssize_t,
1400   AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
1402 # Sizes of various common basic types
1403 # ANSI C requires sizeof(char) == 1, so no need to check it
1404 AC_CHECK_SIZEOF(int, 4)
1405 AC_CHECK_SIZEOF(long, 4)
1406 AC_CHECK_SIZEOF(void *, 4)
1407 AC_CHECK_SIZEOF(short, 2)
1408 AC_CHECK_SIZEOF(float, 4)
1409 AC_CHECK_SIZEOF(double, 8)
1410 AC_CHECK_SIZEOF(fpos_t, 4)
1411 AC_CHECK_SIZEOF(size_t, 4)
1412 AC_CHECK_SIZEOF(pid_t, 4)
1414 AC_MSG_CHECKING(for long long support)
1415 have_long_long=no
1416 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1417   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
1418   have_long_long=yes
1420 AC_MSG_RESULT($have_long_long)
1421 if test "$have_long_long" = yes ; then
1422 AC_CHECK_SIZEOF(long long, 8)
1425 AC_MSG_CHECKING(for long double support)
1426 have_long_double=no
1427 AC_TRY_COMPILE([], [long double x; x = (long double)0.;], [
1428   AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1429   have_long_double=yes
1431 AC_MSG_RESULT($have_long_double)
1432 if test "$have_long_double" = yes ; then
1433 AC_CHECK_SIZEOF(long double, 12)
1436 AC_MSG_CHECKING(for _Bool support)
1437 have_c99_bool=no
1438 AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1439   AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) 
1440   have_c99_bool=yes
1442 AC_MSG_RESULT($have_c99_bool)
1443 if test "$have_c99_bool" = yes ; then
1444 AC_CHECK_SIZEOF(_Bool, 1)
1447 AC_CHECK_TYPES(uintptr_t, 
1448    [AC_CHECK_SIZEOF(uintptr_t, 4)], 
1449    [], [#ifdef HAVE_STDINT_H
1450         #include <stdint.h>
1451         #endif])
1453 AC_CHECK_SIZEOF(off_t, [], [
1454 #ifdef HAVE_SYS_TYPES_H
1455 #include <sys/types.h>
1456 #endif
1459 AC_MSG_CHECKING(whether to enable large file support)
1460 if test "$have_long_long" = yes -a \
1461         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1462         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1463   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
1464   [Defined to enable large file support when an off_t is bigger than a long
1465    and long long is available and at least as big as an off_t. You may need
1466    to add some flags for configuration and compilation to enable this mode.
1467    (For Solaris and Linux, the necessary defines are already defined.)])
1468   AC_MSG_RESULT(yes)
1469 else
1470   AC_MSG_RESULT(no)
1473 AC_CHECK_SIZEOF(time_t, [], [
1474 #ifdef HAVE_SYS_TYPES_H
1475 #include <sys/types.h>
1476 #endif
1477 #ifdef HAVE_TIME_H
1478 #include <time.h>
1479 #endif
1482 # if have pthread_t then define SIZEOF_PTHREAD_T
1483 ac_save_cc="$CC"
1484 if test "$ac_cv_kpthread" = "yes"
1485 then CC="$CC -Kpthread"
1486 elif test "$ac_cv_kthread" = "yes"
1487 then CC="$CC -Kthread"
1488 elif test "$ac_cv_pthread" = "yes"
1489 then CC="$CC -pthread"
1491 AC_MSG_CHECKING(for pthread_t)
1492 have_pthread_t=no
1493 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
1494 AC_MSG_RESULT($have_pthread_t)
1495 if test "$have_pthread_t" = yes ; then
1496   AC_CHECK_SIZEOF(pthread_t, [], [
1497 #ifdef HAVE_PTHREAD_H
1498 #include <pthread.h>
1499 #endif
1500   ])
1502 CC="$ac_save_cc"
1504 AC_MSG_CHECKING(for --enable-toolbox-glue)
1505 AC_ARG_ENABLE(toolbox-glue,
1506               AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
1508 if test -z "$enable_toolbox_glue"
1509 then 
1510         case $ac_sys_system/$ac_sys_release in
1511         Darwin/*)
1512                 enable_toolbox_glue="yes";;
1513         *)
1514                 enable_toolbox_glue="no";;
1515         esac
1517 case "$enable_toolbox_glue" in
1518 yes)
1519         extra_machdep_objs="Python/mactoolboxglue.o"
1520         extra_undefs="-u _PyMac_Error"
1521         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1522          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1523         ;;
1525         extra_machdep_objs=""
1526         extra_undefs=""
1527         ;;
1528 esac
1529 AC_MSG_RESULT($enable_toolbox_glue)
1532 AC_SUBST(OTHER_LIBTOOL_OPT)
1533 case $ac_sys_system/$ac_sys_release in
1534   Darwin/@<:@01567@:>@\..*) 
1535     OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1536     ;;
1537   Darwin/*)
1538     OTHER_LIBTOOL_OPT=""
1539     ;;
1540 esac
1543 ARCH_RUN_32BIT=""
1544 AC_SUBST(LIBTOOL_CRUFT)
1545 case $ac_sys_system/$ac_sys_release in
1546   Darwin/@<:@01567@:>@\..*) 
1547     LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1548     if test "${enable_universalsdk}"; then
1549             :
1550     else
1551         LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
1552     fi
1553     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1554     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1555   Darwin/*)
1556     gcc_version=`gcc -v 2>&1 |  grep version | cut -d\  -f3`
1557     if test ${gcc_version} '<' 4.0
1558         then
1559             LIBTOOL_CRUFT="-lcc_dynamic"
1560         else 
1561             LIBTOOL_CRUFT=""
1562     fi
1563     AC_TRY_RUN([
1564     #include <unistd.h>
1565     int main(int argc, char*argv[])
1566     {
1567       if (sizeof(long) == 4) {
1568           return 0;
1569       } else {
1570           return 1;
1571       }
1572     }
1573     ], ac_osx_32bit=yes,
1574        ac_osx_32bit=no,
1575        ac_osx_32bit=yes)
1576     
1577     if test "${ac_osx_32bit}" = "yes"; then
1578         case `arch` in
1579         i386) 
1580                 MACOSX_DEFAULT_ARCH="i386" 
1581                 ;;
1582         ppc) 
1583                 MACOSX_DEFAULT_ARCH="ppc" 
1584                 ;;
1585         *)
1586                 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1587                 ;;
1588         esac
1589     else
1590         case `arch` in
1591         i386) 
1592                 MACOSX_DEFAULT_ARCH="x86_64" 
1593                 ;;
1594         ppc) 
1595                 MACOSX_DEFAULT_ARCH="ppc64" 
1596                 ;;
1597         *)
1598                 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1599                 ;;
1600         esac
1602         #ARCH_RUN_32BIT="true"
1603     fi
1605     LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
1606     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1607     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1608 esac
1610 AC_MSG_CHECKING(for --enable-framework)
1611 if test "$enable_framework"
1612 then
1613         BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1614         # -F. is needed to allow linking to the framework while 
1615         # in the build location.
1616         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
1617          [Define if you want to produce an OpenStep/Rhapsody framework
1618          (shared library plus accessory files).])
1619         AC_MSG_RESULT(yes)
1620         if test $enable_shared = "yes"
1621         then
1622                 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
1623         fi
1624 else
1625         AC_MSG_RESULT(no)
1628 AC_MSG_CHECKING(for dyld)
1629 case $ac_sys_system/$ac_sys_release in
1630   Darwin/*)
1631         AC_DEFINE(WITH_DYLD, 1, 
1632         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1633          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1634          linker (rld). Dyld is necessary to support frameworks.])
1635         AC_MSG_RESULT(always on for Darwin)
1636         ;;
1637   *)
1638         AC_MSG_RESULT(no)
1639         ;;
1640 esac
1642 # Set info about shared libraries.
1643 AC_SUBST(SO)
1644 AC_SUBST(LDSHARED)
1645 AC_SUBST(BLDSHARED)
1646 AC_SUBST(CCSHARED)
1647 AC_SUBST(LINKFORSHARED)
1648 # SO is the extension of shared libraries `(including the dot!)
1649 # -- usually .so, .sl on HP-UX, .dll on Cygwin
1650 AC_MSG_CHECKING(SO)
1651 if test -z "$SO"
1652 then
1653         case $ac_sys_system in
1654         hp*|HP*)
1655                 case `uname -m` in
1656                         ia64) SO=.so;;
1657                         *)    SO=.sl;;
1658                 esac
1659                 ;;
1660         CYGWIN*)   SO=.dll;;
1661         *)         SO=.so;;
1662         esac
1663 else
1664         # this might also be a termcap variable, see #610332
1665         echo
1666         echo '====================================================================='
1667         echo '+                                                                   +'
1668         echo '+ WARNING: You have set SO in your environment.                     +'
1669         echo '+ Do you really mean to change the extension for shared libraries?  +'
1670         echo '+ Continuing in 10 seconds to let you to ponder.                    +'
1671         echo '+                                                                   +'
1672         echo '====================================================================='
1673         sleep 10
1675 AC_MSG_RESULT($SO)
1677 AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
1678 # LDSHARED is the ld *command* used to create shared library
1679 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1680 # (Shared libraries in this instance are shared modules to be loaded into
1681 # Python, as opposed to building Python itself as a shared library.)
1682 AC_MSG_CHECKING(LDSHARED)
1683 if test -z "$LDSHARED"
1684 then
1685         case $ac_sys_system/$ac_sys_release in
1686         AIX*)
1687                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1688                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1689                 ;;
1690         BeOS*)
1691                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1692                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1693                 ;;
1694         IRIX/5*) LDSHARED="ld -shared";;
1695         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1696         SunOS/5*) 
1697                 if test "$GCC" = "yes"
1698                 then LDSHARED='$(CC) -shared'
1699                 else LDSHARED='$(CC) -G';
1700                 fi ;;
1701         hp*|HP*)
1702                 if test "$GCC" = "yes"
1703                 then LDSHARED='$(CC) -shared'
1704                 else LDSHARED='ld -b';
1705                 fi ;;
1706         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1707         Darwin/1.3*)
1708                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1709                 if test "$enable_framework" ; then
1710                         # Link against the framework. All externals should be defined.
1711                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1712                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1713                 else
1714                         # No framework. Ignore undefined symbols, assuming they come from Python
1715                         LDSHARED="$LDSHARED -undefined suppress"
1716                 fi ;;
1717         Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1718                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1719                 if test "$enable_framework" ; then
1720                         # Link against the framework. All externals should be defined.
1721                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1722                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1723                 else
1724                         # No framework, use the Python app as bundle-loader
1725                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1726                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1727                 fi ;;
1728         Darwin/*)
1729                 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1730                 # This allows an extension to be used in any Python
1732                 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
1733                 then
1734                         if test "${enable_universalsdk}"; then
1735                                 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1736                         fi
1737                         LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1738                         BLDSHARED="$LDSHARED"
1739                 else
1740                         LDSHARED='$(CC) $(LDFLAGS) -bundle'
1741                         if test "$enable_framework" ; then
1742                                 # Link against the framework. All externals should be defined.
1743                                 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1744                                 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1745                         else
1746                                 # No framework, use the Python app as bundle-loader
1747                                 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1748                                 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1749                         fi
1750                 fi
1751                 ;;
1752         Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
1753         BSD/OS*/4*) LDSHARED="gcc -shared";;
1754         FreeBSD*)
1755                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1756                 then
1757                         LDSHARED="$CC -shared ${LDFLAGS}"
1758                 else
1759                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1760                 fi;;
1761         OpenBSD*)
1762                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1763                 then
1764                                 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1765                 else
1766                                 case `uname -r` in
1767                                 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1768                                    LDSHARED="ld -Bshareable ${LDFLAGS}"
1769                                    ;;
1770                                 *)
1771                                    LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1772                                    ;;
1773                                 esac
1774                 fi;;
1775         NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
1776         OpenUNIX*|UnixWare*)
1777                 if test "$GCC" = "yes"
1778                 then LDSHARED='$(CC) -shared'
1779                 else LDSHARED='$(CC) -G'
1780                 fi;;
1781         SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1782         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1783         atheos*) LDSHARED="gcc -shared";;
1784         *)      LDSHARED="ld";;
1785         esac
1787 AC_MSG_RESULT($LDSHARED)
1788 BLDSHARED=${BLDSHARED-$LDSHARED}
1789 # CCSHARED are the C *flags* used to create objects to go into a shared
1790 # library (module) -- this is only needed for a few systems
1791 AC_MSG_CHECKING(CCSHARED)
1792 if test -z "$CCSHARED"
1793 then
1794         case $ac_sys_system/$ac_sys_release in
1795         SunOS*) if test "$GCC" = yes;
1796                 then CCSHARED="-fPIC";
1797                 elif test `uname -p` = sparc;
1798                 then CCSHARED="-xcode=pic32";
1799                 else CCSHARED="-Kpic";
1800                 fi;;
1801         hp*|HP*) if test "$GCC" = yes;
1802                  then CCSHARED="-fPIC";
1803                  else CCSHARED="+z";
1804                  fi;;
1805         Linux*|GNU*) CCSHARED="-fPIC";;
1806         BSD/OS*/4*) CCSHARED="-fpic";;
1807         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
1808         OpenUNIX*|UnixWare*)
1809                 if test "$GCC" = "yes"
1810                 then CCSHARED="-fPIC"
1811                 else CCSHARED="-KPIC"
1812                 fi;;
1813         SCO_SV*)
1814                 if test "$GCC" = "yes"
1815                 then CCSHARED="-fPIC"
1816                 else CCSHARED="-Kpic -belf"
1817                 fi;;
1818         IRIX*/6*)  case $CC in
1819                    *gcc*) CCSHARED="-shared";;
1820                    *) CCSHARED="";;
1821                    esac;;
1822         atheos*) CCSHARED="-fPIC";;
1823         esac
1825 AC_MSG_RESULT($CCSHARED)
1826 # LINKFORSHARED are the flags passed to the $(CC) command that links
1827 # the python executable -- this is only needed for a few systems
1828 AC_MSG_CHECKING(LINKFORSHARED)
1829 if test -z "$LINKFORSHARED"
1830 then
1831         case $ac_sys_system/$ac_sys_release in
1832         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1833         hp*|HP*)
1834             LINKFORSHARED="-Wl,-E -Wl,+s";;
1835 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1836         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1837         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1838         # -u libsys_s pulls in all symbols in libsys
1839         Darwin/*) 
1840                 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1841                 # which is
1842                 # not used by the core itself but which needs to be in the core so
1843                 # that dynamically loaded extension modules have access to it.
1844                 # -prebind is no longer used, because it actually seems to give a
1845                 # slowdown in stead of a speedup, maybe due to the large number of
1846                 # dynamic loads Python does.
1848                 LINKFORSHARED="$extra_undefs"
1849                 if test "$enable_framework"
1850                 then
1851                         LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1852                 fi
1853                 LINKFORSHARED="$LINKFORSHARED";;
1854         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1855         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1856         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1857         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) 
1858                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1859                 then
1860                         LINKFORSHARED="-Wl,--export-dynamic"
1861                 fi;;
1862         SunOS/5*) case $CC in
1863                   *gcc*)
1864                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1865                     then
1866                         LINKFORSHARED="-Xlinker --export-dynamic"
1867                     fi;;
1868                   esac;;
1869         CYGWIN*)
1870                 if test $enable_shared = "no"
1871                 then
1872                         LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1873                 fi;;
1874         QNX*)
1875                 # -Wl,-E causes the symbols to be added to the dynamic
1876                 # symbol table so that they can be found when a module
1877                 # is loaded.  -N 2048K causes the stack size to be set
1878                 # to 2048 kilobytes so that the stack doesn't overflow
1879                 # when running test_compile.py.
1880                 LINKFORSHARED='-Wl,-E -N 2048K';;
1881         esac
1883 AC_MSG_RESULT($LINKFORSHARED)
1886 AC_SUBST(CFLAGSFORSHARED)
1887 AC_MSG_CHECKING(CFLAGSFORSHARED)
1888 if test ! "$LIBRARY" = "$LDLIBRARY"
1889 then
1890         case $ac_sys_system in
1891         CYGWIN*)
1892                 # Cygwin needs CCSHARED when building extension DLLs
1893                 # but not when building the interpreter DLL.
1894                 CFLAGSFORSHARED='';;
1895         *)
1896                 CFLAGSFORSHARED='$(CCSHARED)'
1897         esac
1899 AC_MSG_RESULT($CFLAGSFORSHARED)
1901 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1902 # library (with --enable-shared).
1903 # For platforms on which shared libraries are not allowed to have unresolved
1904 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1905 # if it is not required, since it creates a dependency of the shared library
1906 # to LIBS. This, in turn, means that applications linking the shared libpython
1907 # don't need to link LIBS explicitly. The default should be only changed
1908 # on systems where this approach causes problems.
1909 AC_SUBST(SHLIBS)
1910 AC_MSG_CHECKING(SHLIBS)
1911 case "$ac_sys_system" in
1912         *)
1913                 SHLIBS='$(LIBS)';;
1914 esac
1915 AC_MSG_RESULT($SHLIBS)
1918 # checks for libraries
1919 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1920 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1922 # only check for sem_init if thread support is requested
1923 if test "$with_threads" = "yes" -o -z "$with_threads"; then
1924     AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1925                                                 # posix4 on Solaris 2.6
1926                                                 # pthread (first!) on Linux
1929 # check if we need libintl for locale functions
1930 AC_CHECK_LIB(intl, textdomain,
1931         AC_DEFINE(WITH_LIBINTL, 1,
1932         [Define to 1 if libintl is needed for locale functions.]))
1934 # checks for system dependent C++ extensions support
1935 case "$ac_sys_system" in
1936         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1937                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1938                             [loadAndInit("", 0, "")],
1939                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1940                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1941                        and you want support for AIX C++ shared extension modules.])
1942                              AC_MSG_RESULT(yes)],
1943                             [AC_MSG_RESULT(no)]);;
1944         *) ;;
1945 esac
1947 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1948 # BeOS' sockets are stashed in libnet.
1949 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1950 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1952 case "$ac_sys_system" in
1953 BeOS*)
1954 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1956 esac
1958 AC_MSG_CHECKING(for --with-libs)
1959 AC_ARG_WITH(libs,
1960             AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1962 AC_MSG_RESULT($withval)
1963 LIBS="$withval $LIBS"
1965 [AC_MSG_RESULT(no)])
1967 # Check for use of the system libffi library
1968 AC_MSG_CHECKING(for --with-system-ffi)
1969 AC_ARG_WITH(system_ffi,
1970             AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1972 AC_MSG_RESULT($with_system_ffi)
1974 # Check for --with-dbmliborder
1975 AC_MSG_CHECKING(for --with-dbmliborder)
1976 AC_ARG_WITH(dbmliborder,
1977             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'.]),
1979 if test x$with_dbmliborder = xyes
1980 then
1981 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1982 else
1983   for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1984     if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1985     then
1986       AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1987     fi
1988   done
1989 fi])
1990 AC_MSG_RESULT($with_dbmliborder)
1992 # Determine if signalmodule should be used.
1993 AC_SUBST(USE_SIGNAL_MODULE)
1994 AC_SUBST(SIGNAL_OBJS)
1995 AC_MSG_CHECKING(for --with-signal-module)
1996 AC_ARG_WITH(signal-module,
1997             AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1999 if test -z "$with_signal_module"
2000 then with_signal_module="yes"
2002 AC_MSG_RESULT($with_signal_module)
2004 if test "${with_signal_module}" = "yes"; then
2005         USE_SIGNAL_MODULE=""
2006         SIGNAL_OBJS=""
2007 else
2008         USE_SIGNAL_MODULE="#"
2009         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2012 # This is used to generate Setup.config
2013 AC_SUBST(USE_THREAD_MODULE)
2014 USE_THREAD_MODULE=""
2016 AC_MSG_CHECKING(for --with-dec-threads)
2017 AC_SUBST(LDLAST)
2018 AC_ARG_WITH(dec-threads,
2019             AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
2021 AC_MSG_RESULT($withval)
2022 LDLAST=-threads
2023 if test "${with_thread+set}" != set; then
2024    with_thread="$withval";
2025 fi],
2026 [AC_MSG_RESULT(no)])
2028 # Templates for things AC_DEFINEd more than once.
2029 # For a single AC_DEFINE, no template is needed.
2030 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2031 AH_TEMPLATE(_REENTRANT,
2032   [Define to force use of thread-safe errno, h_errno, and other functions])
2033 AH_TEMPLATE(WITH_THREAD,
2034   [Define if you want to compile in rudimentary thread support])
2036 AC_MSG_CHECKING(for --with-threads)
2037 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2038 AC_ARG_WITH(threads,
2039             AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
2041 # --with-thread is deprecated, but check for it anyway
2042 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2043 AC_ARG_WITH(thread,
2044             AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2045             [with_threads=$with_thread])
2047 if test -z "$with_threads"
2048 then with_threads="yes"
2050 AC_MSG_RESULT($with_threads)
2052 AC_SUBST(THREADOBJ)
2053 if test "$with_threads" = "no"
2054 then
2055     USE_THREAD_MODULE="#"
2056 elif test "$ac_cv_pthread_is_default" = yes
2057 then
2058     AC_DEFINE(WITH_THREAD)
2059     # Defining _REENTRANT on system with POSIX threads should not hurt.
2060     AC_DEFINE(_REENTRANT)
2061     posix_threads=yes
2062     THREADOBJ="Python/thread.o"    
2063 elif test "$ac_cv_kpthread" = "yes"
2064 then
2065     CC="$CC -Kpthread"
2066     if test "$ac_cv_cxx_thread" = "yes"; then
2067         CXX="$CXX -Kpthread"
2068     fi
2069     AC_DEFINE(WITH_THREAD)
2070     posix_threads=yes
2071     THREADOBJ="Python/thread.o"
2072 elif test "$ac_cv_kthread" = "yes"
2073 then
2074     CC="$CC -Kthread"
2075     if test "$ac_cv_cxx_thread" = "yes"; then
2076         CXX="$CXX -Kthread"
2077     fi
2078     AC_DEFINE(WITH_THREAD)
2079     posix_threads=yes
2080     THREADOBJ="Python/thread.o"
2081 elif test "$ac_cv_pthread" = "yes"
2082 then
2083     CC="$CC -pthread"
2084     if test "$ac_cv_cxx_thread" = "yes"; then
2085         CXX="$CXX -pthread"
2086     fi
2087     AC_DEFINE(WITH_THREAD)
2088     posix_threads=yes
2089     THREADOBJ="Python/thread.o"
2090 else
2091     if test ! -z "$with_threads" -a -d "$with_threads"
2092     then LDFLAGS="$LDFLAGS -L$with_threads"
2093     fi
2094     if test ! -z "$withval" -a -d "$withval"
2095     then LDFLAGS="$LDFLAGS -L$withval"
2096     fi
2098     # According to the POSIX spec, a pthreads implementation must
2099     # define _POSIX_THREADS in unistd.h. Some apparently don't
2100     # (e.g. gnu pth with pthread emulation)
2101     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2102     AC_EGREP_CPP(yes,
2103     [
2104 #include <unistd.h>
2105 #ifdef _POSIX_THREADS
2107 #endif
2108     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2109     AC_MSG_RESULT($unistd_defines_pthreads)
2111     AC_DEFINE(_REENTRANT)
2112     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2113     AC_DEFINE(C_THREADS)
2114     AC_DEFINE(HURD_C_THREADS, 1,
2115     [Define if you are using Mach cthreads directly under /include])
2116     LIBS="$LIBS -lthreads"
2117     THREADOBJ="Python/thread.o"],[
2118     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2119     AC_DEFINE(C_THREADS)
2120     AC_DEFINE(MACH_C_THREADS, 1,
2121     [Define if you are using Mach cthreads under mach /])
2122     THREADOBJ="Python/thread.o"],[
2123     AC_MSG_CHECKING(for --with-pth)
2124     AC_ARG_WITH([pth],
2125                 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2126                 [AC_MSG_RESULT($withval)
2127                   AC_DEFINE([WITH_THREAD])
2128                   AC_DEFINE([HAVE_PTH], 1,
2129                             [Define if you have GNU PTH threads.])
2130                   LIBS="-lpth $LIBS"
2131                   THREADOBJ="Python/thread.o"],
2132                 [AC_MSG_RESULT(no)
2134     # Just looking for pthread_create in libpthread is not enough:
2135     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2136     # So we really have to include pthread.h, and then link.
2137     _libs=$LIBS
2138     LIBS="$LIBS -lpthread"
2139     AC_MSG_CHECKING([for pthread_create in -lpthread])
2140     AC_TRY_LINK([#include <pthread.h>
2142 void * start_routine (void *arg) { exit (0); }], [
2143 pthread_create (NULL, NULL, start_routine, NULL)], [
2144     AC_MSG_RESULT(yes)
2145     AC_DEFINE(WITH_THREAD)
2146     posix_threads=yes
2147     THREADOBJ="Python/thread.o"],[
2148     LIBS=$_libs
2149     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
2150     posix_threads=yes
2151     THREADOBJ="Python/thread.o"],[
2152     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2153     AC_DEFINE(ATHEOS_THREADS, 1,
2154     [Define this if you have AtheOS threads.])
2155     THREADOBJ="Python/thread.o"],[
2156     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
2157     AC_DEFINE(BEOS_THREADS, 1,
2158     [Define this if you have BeOS threads.])
2159     THREADOBJ="Python/thread.o"],[
2160     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
2161     posix_threads=yes
2162     LIBS="$LIBS -lpthreads"
2163     THREADOBJ="Python/thread.o"], [
2164     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
2165     posix_threads=yes
2166     LIBS="$LIBS -lc_r"
2167     THREADOBJ="Python/thread.o"], [
2168     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
2169     posix_threads=yes
2170     LIBS="$LIBS -lpthread"
2171     THREADOBJ="Python/thread.o"], [
2172     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
2173     posix_threads=yes
2174     LIBS="$LIBS -lcma"
2175     THREADOBJ="Python/thread.o"],[
2176     USE_THREAD_MODULE="#"])
2177     ])])])])])])])])])])
2179     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2180     LIBS="$LIBS -lmpc"
2181     THREADOBJ="Python/thread.o"
2182     USE_THREAD_MODULE=""])
2184     if test "$posix_threads" != "yes"; then     
2185       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2186       LIBS="$LIBS -lthread"
2187       THREADOBJ="Python/thread.o"
2188       USE_THREAD_MODULE=""])
2189     fi
2191     if test "$USE_THREAD_MODULE" != "#"
2192     then
2193         # If the above checks didn't disable threads, (at least) OSF1
2194         # needs this '-threads' argument during linking.
2195         case $ac_sys_system in
2196         OSF1) LDLAST=-threads;;
2197         esac
2198     fi
2201 if test "$posix_threads" = "yes"; then
2202       if test "$unistd_defines_pthreads" = "no"; then
2203          AC_DEFINE(_POSIX_THREADS, 1,
2204          [Define if you have POSIX threads, 
2205           and your system does not define that.])
2206       fi
2208       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2209       case  $ac_sys_system/$ac_sys_release in
2210   SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2211                        Defined for Solaris 2.6 bug in pthread header.)
2212                        ;;
2213       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2214                        Define if the Posix semaphores do not work on your system)
2215                        ;;
2216       AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2217                        Define if the Posix semaphores do not work on your system)
2218                        ;;
2219       esac
2221       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2222       AC_CACHE_VAL(ac_cv_pthread_system_supported,
2223       [AC_TRY_RUN([#include <pthread.h>
2224       void *foo(void *parm) {
2225         return NULL;
2226       }
2227       main() {
2228         pthread_attr_t attr;
2229         pthread_t id;
2230         if (pthread_attr_init(&attr)) exit(-1);
2231         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
2232         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
2233         exit(0);
2234       }],
2235       ac_cv_pthread_system_supported=yes,
2236       ac_cv_pthread_system_supported=no,
2237       ac_cv_pthread_system_supported=no)
2238       ])
2239       AC_MSG_RESULT($ac_cv_pthread_system_supported)
2240       if test "$ac_cv_pthread_system_supported" = "yes"; then
2241         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
2242       fi
2243       AC_CHECK_FUNCS(pthread_sigmask,
2244         [case $ac_sys_system in
2245         CYGWIN*)
2246           AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2247             [Define if pthread_sigmask() does not work on your system.])
2248             ;;
2249         esac])
2253 # Check for enable-ipv6
2254 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
2255 AC_MSG_CHECKING([if --enable-ipv6 is specified])
2256 AC_ARG_ENABLE(ipv6,
2257 [  --enable-ipv6           Enable ipv6 (with ipv4) support
2258   --disable-ipv6          Disable ipv6 support],
2259 [ case "$enableval" in
2260   no)
2261        AC_MSG_RESULT(no)
2262        ipv6=no
2263        ;;
2264   *)   AC_MSG_RESULT(yes)
2265        AC_DEFINE(ENABLE_IPV6)
2266        ipv6=yes
2267        ;;
2268   esac ],
2271 dnl the check does not work on cross compilation case...
2272   AC_TRY_RUN([ /* AF_INET6 available check */
2273 #include <sys/types.h>
2274 #include <sys/socket.h>
2275 main()
2277  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2278    exit(1);
2279  else
2280    exit(0);
2283   AC_MSG_RESULT(yes)
2284   ipv6=yes,
2285   AC_MSG_RESULT(no)
2286   ipv6=no,
2287   AC_MSG_RESULT(no)
2288   ipv6=no
2291 if test "$ipv6" = "yes"; then
2292         AC_MSG_CHECKING(if RFC2553 API is available)
2293         AC_TRY_COMPILE([#include <sys/types.h>
2294 #include <netinet/in.h>],
2295         [struct sockaddr_in6 x;
2296 x.sin6_scope_id;],
2297                 AC_MSG_RESULT(yes)
2298                 ipv6=yes,
2299                 AC_MSG_RESULT(no, IPv6 disabled)
2300                 ipv6=no)
2303 if test "$ipv6" = "yes"; then
2304         AC_DEFINE(ENABLE_IPV6)
2308 ipv6type=unknown
2309 ipv6lib=none
2310 ipv6trylibc=no
2312 if test "$ipv6" = "yes"; then
2313         AC_MSG_CHECKING([ipv6 stack type])
2314         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2315         do
2316                 case $i in
2317                 inria)
2318                         dnl http://www.kame.net/
2319                         AC_EGREP_CPP(yes, [
2320 #include <netinet/in.h>
2321 #ifdef IPV6_INRIA_VERSION
2323 #endif],
2324                                 [ipv6type=$i])
2325                         ;;
2326                 kame)
2327                         dnl http://www.kame.net/
2328                         AC_EGREP_CPP(yes, [
2329 #include <netinet/in.h>
2330 #ifdef __KAME__
2332 #endif],
2333                                 [ipv6type=$i;
2334                                 ipv6lib=inet6
2335                                 ipv6libdir=/usr/local/v6/lib
2336                                 ipv6trylibc=yes])
2337                         ;;
2338                 linux-glibc)
2339                         dnl http://www.v6.linux.or.jp/
2340                         AC_EGREP_CPP(yes, [
2341 #include <features.h>
2342 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2344 #endif],
2345                                 [ipv6type=$i;
2346                                 ipv6trylibc=yes])
2347                         ;;
2348                 linux-inet6)
2349                         dnl http://www.v6.linux.or.jp/
2350                         if test -d /usr/inet6; then
2351                                 ipv6type=$i
2352                                 ipv6lib=inet6
2353                                 ipv6libdir=/usr/inet6/lib
2354                                 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
2355                         fi
2356                         ;;
2357                 solaris)
2358                         if test -f /etc/netconfig; then
2359                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2360                                 ipv6type=$i
2361                                 ipv6trylibc=yes
2362                           fi
2363                         fi
2364                         ;;
2365                 toshiba)
2366                         AC_EGREP_CPP(yes, [
2367 #include <sys/param.h>
2368 #ifdef _TOSHIBA_INET6
2370 #endif],
2371                                 [ipv6type=$i;
2372                                 ipv6lib=inet6;
2373                                 ipv6libdir=/usr/local/v6/lib])
2374                         ;;
2375                 v6d)
2376                         AC_EGREP_CPP(yes, [
2377 #include </usr/local/v6/include/sys/v6config.h>
2378 #ifdef __V6D__
2380 #endif],
2381                                 [ipv6type=$i;
2382                                 ipv6lib=v6;
2383                                 ipv6libdir=/usr/local/v6/lib;
2384                                 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
2385                         ;;
2386                 zeta)
2387                         AC_EGREP_CPP(yes, [
2388 #include <sys/param.h>
2389 #ifdef _ZETA_MINAMI_INET6
2391 #endif],
2392                                 [ipv6type=$i;
2393                                 ipv6lib=inet6;
2394                                 ipv6libdir=/usr/local/v6/lib])
2395                         ;;
2396                 esac
2397                 if test "$ipv6type" != "unknown"; then
2398                         break
2399                 fi
2400         done
2401         AC_MSG_RESULT($ipv6type)
2404 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2405         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2406                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2407                 echo "using lib$ipv6lib"
2408         else
2409                 if test $ipv6trylibc = "yes"; then
2410                         echo "using libc"
2411                 else
2412                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
2413                         echo "You need to fetch lib$ipv6lib.a from appropriate"
2414                         echo 'ipv6 kit and compile beforehand.'
2415                         exit 1
2416                 fi
2417         fi
2420 AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2421 AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2422   AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2423   AC_MSG_RESULT(yes),
2424   AC_MSG_RESULT(no)
2427 # Check for --with-doc-strings
2428 AC_MSG_CHECKING(for --with-doc-strings)
2429 AC_ARG_WITH(doc-strings,
2430             AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
2432 if test -z "$with_doc_strings"
2433 then with_doc_strings="yes"
2435 if test "$with_doc_strings" != "no"
2436 then
2437     AC_DEFINE(WITH_DOC_STRINGS, 1,
2438       [Define if you want documentation strings in extension modules])
2440 AC_MSG_RESULT($with_doc_strings)
2442 # Check for Python-specific malloc support
2443 AC_MSG_CHECKING(for --with-tsc)
2444 AC_ARG_WITH(tsc,
2445 [  --with(out)-tsc         enable/disable timestamp counter profile], [
2446 if test "$withval" != no
2447 then 
2448   AC_DEFINE(WITH_TSC, 1, 
2449     [Define to profile with the Pentium timestamp counter]) 
2450     AC_MSG_RESULT(yes)
2451 else AC_MSG_RESULT(no)
2452 fi],
2453 [AC_MSG_RESULT(no)])
2455 # Check for Python-specific malloc support
2456 AC_MSG_CHECKING(for --with-pymalloc)
2457 AC_ARG_WITH(pymalloc,
2458             AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
2460 if test -z "$with_pymalloc"
2461 then with_pymalloc="yes"
2463 if test "$with_pymalloc" != "no"
2464 then
2465     AC_DEFINE(WITH_PYMALLOC, 1, 
2466      [Define if you want to compile in Python-specific mallocs])
2468 AC_MSG_RESULT($with_pymalloc)
2470 # Check for Valgrind support
2471 AC_MSG_CHECKING([for --with-valgrind])
2472 AC_ARG_WITH([valgrind],
2473   AC_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2474   with_valgrind=no)
2475 AC_MSG_RESULT([$with_valgrind])
2476 if test "$with_valgrind" != no; then
2477     AC_CHECK_HEADER([valgrind/valgrind.h],
2478       [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2479       [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2480     )
2483 # Check for --with-wctype-functions
2484 AC_MSG_CHECKING(for --with-wctype-functions)
2485 AC_ARG_WITH(wctype-functions, 
2486             AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2488 if test "$withval" != no
2489 then 
2490   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2491   [Define if you want wctype.h functions to be used instead of the
2492    one supplied by Python itself. (see Include/unicodectype.h).]) 
2493   AC_MSG_RESULT(yes)
2494 else AC_MSG_RESULT(no)
2495 fi],
2496 [AC_MSG_RESULT(no)])
2498 # -I${DLINCLDIR} is added to the compile rule for importdl.o
2499 AC_SUBST(DLINCLDIR)
2500 DLINCLDIR=.
2502 # the dlopen() function means we might want to use dynload_shlib.o. some
2503 # platforms, such as AIX, have dlopen(), but don't want to use it.
2504 AC_CHECK_FUNCS(dlopen)
2506 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2507 # loading of modules.
2508 AC_SUBST(DYNLOADFILE)
2509 AC_MSG_CHECKING(DYNLOADFILE)
2510 if test -z "$DYNLOADFILE"
2511 then
2512         case $ac_sys_system/$ac_sys_release in
2513         AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2514         if test "$ac_cv_func_dlopen" = yes
2515         then DYNLOADFILE="dynload_shlib.o"
2516         else DYNLOADFILE="dynload_aix.o"
2517         fi
2518         ;;
2519         BeOS*) DYNLOADFILE="dynload_beos.o";;
2520         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2521         # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2522         Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
2523         atheos*) DYNLOADFILE="dynload_atheos.o";;
2524         *)
2525         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2526         # out any dynamic loading
2527         if test "$ac_cv_func_dlopen" = yes
2528         then DYNLOADFILE="dynload_shlib.o"
2529         else DYNLOADFILE="dynload_stub.o"
2530         fi
2531         ;;
2532         esac
2534 AC_MSG_RESULT($DYNLOADFILE)
2535 if test "$DYNLOADFILE" != "dynload_stub.o"
2536 then
2537         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2538         [Defined when any dynamic module loading is enabled.])
2541 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
2543 AC_SUBST(MACHDEP_OBJS)
2544 AC_MSG_CHECKING(MACHDEP_OBJS)
2545 if test -z "$MACHDEP_OBJS"
2546 then
2547         MACHDEP_OBJS=$extra_machdep_objs
2548 else
2549         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2551 AC_MSG_RESULT(MACHDEP_OBJS)
2553 # checks for library functions
2554 AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2555  clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
2556  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2557  getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
2558  initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
2559  mremap nice pathconf pause plock poll pthread_init \
2560  putenv readlink realpath \
2561  select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2562  setgid \
2563  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2564  setlocale setregid setreuid setresuid setresgid \
2565  setsid setpgid setpgrp setuid setvbuf snprintf \
2566  sigaction siginterrupt sigrelse strftime \
2567  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2568  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
2570 # For some functions, having a definition is not sufficient, since
2571 # we want to take their address.
2572 AC_MSG_CHECKING(for chroot)
2573 AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2574   AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2575   AC_MSG_RESULT(yes),
2576   AC_MSG_RESULT(no)
2578 AC_MSG_CHECKING(for link)
2579 AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2580   AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2581   AC_MSG_RESULT(yes),
2582   AC_MSG_RESULT(no)
2584 AC_MSG_CHECKING(for symlink)
2585 AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2586   AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2587   AC_MSG_RESULT(yes),
2588   AC_MSG_RESULT(no)
2590 AC_MSG_CHECKING(for fchdir)
2591 AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2592   AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2593   AC_MSG_RESULT(yes),
2594   AC_MSG_RESULT(no)
2596 AC_MSG_CHECKING(for fsync)
2597 AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
2598   AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2599   AC_MSG_RESULT(yes),
2600   AC_MSG_RESULT(no)
2602 AC_MSG_CHECKING(for fdatasync)
2603 AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2604   AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2605   AC_MSG_RESULT(yes),
2606   AC_MSG_RESULT(no)
2608 AC_MSG_CHECKING(for epoll)
2609 AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2610   AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2611   AC_MSG_RESULT(yes),
2612   AC_MSG_RESULT(no)
2614 AC_MSG_CHECKING(for kqueue)
2615 AC_TRY_COMPILE([
2616 #include <sys/types.h>
2617 #include <sys/event.h>
2618     ], int x=kqueue(),
2619   AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2620   AC_MSG_RESULT(yes),
2621   AC_MSG_RESULT(no)
2623 # On some systems (eg. FreeBSD 5), we would find a definition of the
2624 # functions ctermid_r, setgroups in the library, but no prototype
2625 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2626 # address to avoid compiler warnings and potential miscompilations
2627 # because of the missing prototypes.
2629 AC_MSG_CHECKING(for ctermid_r)
2630 AC_TRY_COMPILE([
2631 #include "confdefs.h" 
2632 #include <stdio.h>
2633 ], void* p = ctermid_r,
2634   AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2635   AC_MSG_RESULT(yes),
2636   AC_MSG_RESULT(no)
2639 AC_MSG_CHECKING(for flock)
2640 AC_TRY_COMPILE([
2641 #include "confdefs.h" 
2642 #include <sys/file.h>
2643 ], void* p = flock,
2644   AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2645   AC_MSG_RESULT(yes),
2646   AC_MSG_RESULT(no)
2649 AC_MSG_CHECKING(for getpagesize)
2650 AC_TRY_COMPILE([
2651 #include "confdefs.h" 
2652 #include <unistd.h>
2653 ], void* p = getpagesize,
2654   AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2655   AC_MSG_RESULT(yes),
2656   AC_MSG_RESULT(no)
2659 dnl check for true
2660 AC_CHECK_PROGS(TRUE, true, /bin/true)
2662 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2663 dnl On others, they are in the C library, so we to take no action
2664 AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2665   AC_CHECK_LIB(resolv, inet_aton)
2668 # On Tru64, chflags seems to be present, but calling it will
2669 # exit Python
2670 AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
2671 AC_TRY_RUN([[
2672 #include <sys/stat.h>
2673 #include <unistd.h>
2674 int main(int argc, char*argv[])
2676   if(chflags(argv[0], 0) != 0)
2677     return 1;
2678   return 0;
2680 ]], ac_cv_have_chflags=yes,
2681    ac_cv_have_chflags=no,
2682    ac_cv_have_chflags=cross)
2684 if test "$ac_cv_have_chflags" = cross ; then
2685   AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2687 if test "$ac_cv_have_chflags" = yes ; then
2688   AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2691 AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
2692 AC_TRY_RUN([[
2693 #include <sys/stat.h>
2694 #include <unistd.h>
2695 int main(int argc, char*argv[])
2697   if(lchflags(argv[0], 0) != 0)
2698     return 1;
2699   return 0;
2701 ]], ac_cv_have_lchflags=yes,
2702    ac_cv_have_lchflags=no,
2703    ac_cv_have_lchflags=cross)
2705 if test "$ac_cv_have_lchflags" = cross ; then
2706   AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2708 if test "$ac_cv_have_lchflags" = yes ; then
2709   AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2712 dnl Check if system zlib has *Copy() functions
2714 dnl On MacOSX the linker will search for dylibs on the entire linker path
2715 dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2716 dnl to revert to a more traditional unix behaviour and make it possible to
2717 dnl override the system libz with a local static library of libz. Temporarily
2718 dnl add that flag to our CFLAGS as well to ensure that we check the version
2719 dnl of libz that will be used by setup.py. 
2720 dnl The -L/usr/local/lib is needed as wel to get the same compilation 
2721 dnl environment as setup.py (and leaving it out can cause configure to use the
2722 dnl wrong version of the library)
2723 case $ac_sys_system/$ac_sys_release in
2724 Darwin/*) 
2725         _CUR_CFLAGS="${CFLAGS}"
2726         _CUR_LDFLAGS="${LDFLAGS}"
2727         CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2728         LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2729         ;;
2730 esac
2732 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2734 case $ac_sys_system/$ac_sys_release in
2735 Darwin/*) 
2736         CFLAGS="${_CUR_CFLAGS}"
2737         LDFLAGS="${_CUR_LDFLAGS}"
2738         ;;
2739 esac
2741 AC_MSG_CHECKING(for hstrerror)
2742 AC_TRY_LINK([
2743 #include "confdefs.h" 
2744 #include <netdb.h>
2745 ], void* p = hstrerror; hstrerror(0),
2746   AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2747   AC_MSG_RESULT(yes),
2748   AC_MSG_RESULT(no)
2751 AC_MSG_CHECKING(for inet_aton)
2752 AC_TRY_LINK([
2753 #include "confdefs.h" 
2754 #include <sys/types.h>
2755 #include <sys/socket.h>
2756 #include <netinet/in.h>
2757 #include <arpa/inet.h>
2758 ], void* p = inet_aton;inet_aton(0,0),
2759   AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2760   AC_MSG_RESULT(yes),
2761   AC_MSG_RESULT(no)
2764 AC_MSG_CHECKING(for inet_pton)
2765 AC_TRY_COMPILE([
2766 #include "confdefs.h" 
2767 #include <sys/types.h>
2768 #include <sys/socket.h>
2769 #include <netinet/in.h>
2770 #include <arpa/inet.h>
2771 ], void* p = inet_pton,
2772   AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2773   AC_MSG_RESULT(yes),
2774   AC_MSG_RESULT(no)
2777 # On some systems, setgroups is in unistd.h, on others, in grp.h
2778 AC_MSG_CHECKING(for setgroups)
2779 AC_TRY_COMPILE([
2780 #include "confdefs.h" 
2781 #include <unistd.h>
2782 #ifdef HAVE_GRP_H
2783 #include <grp.h>
2784 #endif
2785 ], 
2786 void* p = setgroups,
2787   AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2788   AC_MSG_RESULT(yes),
2789   AC_MSG_RESULT(no)
2792 # check for openpty and forkpty
2794 AC_CHECK_FUNCS(openpty,, 
2795    AC_CHECK_LIB(util,openpty,
2796      [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2797      AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2798    )
2800 AC_CHECK_FUNCS(forkpty,, 
2801    AC_CHECK_LIB(util,forkpty, 
2802      [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2803      AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2804    )
2807 # Stuff for expat.
2808 AC_CHECK_FUNCS(memmove)
2810 # check for long file support functions
2811 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2813 AC_REPLACE_FUNCS(dup2 getcwd strdup)
2814 AC_CHECK_FUNCS(getpgrp, 
2815   AC_TRY_COMPILE([#include <unistd.h>], 
2816    [getpgrp(0);], 
2817    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2818    [Define if getpgrp() must be called as getpgrp(0).])
2821 AC_CHECK_FUNCS(setpgrp,
2822   AC_TRY_COMPILE([#include <unistd.h>],
2823     [setpgrp(0,0);],
2824     AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2825     [Define if setpgrp() must be called as setpgrp(0, 0).])
2826   )
2828 AC_CHECK_FUNCS(gettimeofday, 
2829   AC_TRY_COMPILE([#include <sys/time.h>], 
2830     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2831     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2832     [Define if gettimeofday() does not have second (timezone) argument
2833      This is the case on Motorola V4 (R40V4.2)])
2834   )
2837 AC_MSG_CHECKING(for major, minor, and makedev)
2838 AC_TRY_LINK([
2839 #if defined(MAJOR_IN_MKDEV)
2840 #include <sys/mkdev.h>
2841 #elif defined(MAJOR_IN_SYSMACROS)
2842 #include <sys/sysmacros.h>
2843 #else
2844 #include <sys/types.h>
2845 #endif
2847   makedev(major(0),minor(0));
2849   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2850             [Define to 1 if you have the device macros.])
2851   AC_MSG_RESULT(yes)
2853   AC_MSG_RESULT(no)
2856 # On OSF/1 V5.1, getaddrinfo is available, but a define
2857 # for [no]getaddrinfo in netdb.h. 
2858 AC_MSG_CHECKING(for getaddrinfo)
2859 AC_TRY_LINK([
2860 #include <sys/types.h>
2861 #include <sys/socket.h>
2862 #include <netdb.h>
2863 #include <stdio.h>
2864 ], [getaddrinfo(NULL, NULL, NULL, NULL);],
2865 have_getaddrinfo=yes,
2866 have_getaddrinfo=no)
2867 AC_MSG_RESULT($have_getaddrinfo)
2868 if test $have_getaddrinfo = yes
2869 then
2870   AC_MSG_CHECKING(getaddrinfo bug)
2871   AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2872   AC_TRY_RUN([[
2873 #include <sys/types.h>
2874 #include <netdb.h>
2875 #include <string.h>
2876 #include <sys/socket.h>
2877 #include <netinet/in.h>
2879 int main()
2881   int passive, gaierr, inet4 = 0, inet6 = 0;
2882   struct addrinfo hints, *ai, *aitop;
2883   char straddr[INET6_ADDRSTRLEN], strport[16];
2885   for (passive = 0; passive <= 1; passive++) {
2886     memset(&hints, 0, sizeof(hints));
2887     hints.ai_family = AF_UNSPEC;
2888     hints.ai_flags = passive ? AI_PASSIVE : 0;
2889     hints.ai_socktype = SOCK_STREAM;
2890     hints.ai_protocol = IPPROTO_TCP;
2891     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2892       (void)gai_strerror(gaierr);
2893       goto bad;
2894     }
2895     for (ai = aitop; ai; ai = ai->ai_next) {
2896       if (ai->ai_addr == NULL ||
2897           ai->ai_addrlen == 0 ||
2898           getnameinfo(ai->ai_addr, ai->ai_addrlen,
2899                       straddr, sizeof(straddr), strport, sizeof(strport),
2900                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2901         goto bad;
2902       }
2903       switch (ai->ai_family) {
2904       case AF_INET:
2905         if (strcmp(strport, "54321") != 0) {
2906           goto bad;
2907         }
2908         if (passive) {
2909           if (strcmp(straddr, "0.0.0.0") != 0) {
2910             goto bad;
2911           }
2912         } else {
2913           if (strcmp(straddr, "127.0.0.1") != 0) {
2914             goto bad;
2915           }
2916         }
2917         inet4++;
2918         break;
2919       case AF_INET6:
2920         if (strcmp(strport, "54321") != 0) {
2921           goto bad;
2922         }
2923         if (passive) {
2924           if (strcmp(straddr, "::") != 0) {
2925             goto bad;
2926           }
2927         } else {
2928           if (strcmp(straddr, "::1") != 0) {
2929             goto bad;
2930           }
2931         }
2932         inet6++;
2933         break;
2934       case AF_UNSPEC:
2935         goto bad;
2936         break;
2937       default:
2938         /* another family support? */
2939         break;
2940       }
2941     }
2942   }
2944   if (!(inet4 == 0 || inet4 == 2))
2945     goto bad;
2946   if (!(inet6 == 0 || inet6 == 2))
2947     goto bad;
2949   if (aitop)
2950     freeaddrinfo(aitop);
2951   return 0;
2953  bad:
2954   if (aitop)
2955     freeaddrinfo(aitop);
2956   return 1;
2958 ]], ac_cv_buggy_getaddrinfo=no,
2959     ac_cv_buggy_getaddrinfo=yes,
2960     ac_cv_buggy_getaddrinfo=yes))
2963 if test $have_getaddrinfo = no -o $ac_cv_buggy_getaddrinfo = yes
2964 then
2965         if test $ipv6 = yes
2966         then
2967                 echo 'Fatal: You must get working getaddrinfo() function.'
2968                 echo '       or you can specify "--disable-ipv6"'.
2969                 exit 1
2970         fi
2971 else
2972         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2974 AC_CHECK_FUNCS(getnameinfo)
2976 # checks for structures
2977 AC_HEADER_TIME
2978 AC_STRUCT_TM
2979 AC_STRUCT_TIMEZONE
2980 AC_CHECK_MEMBERS([struct stat.st_rdev])
2981 AC_CHECK_MEMBERS([struct stat.st_blksize])
2982 AC_CHECK_MEMBERS([struct stat.st_flags])
2983 AC_CHECK_MEMBERS([struct stat.st_gen])
2984 AC_CHECK_MEMBERS([struct stat.st_birthtime])
2985 AC_STRUCT_ST_BLOCKS
2987 AC_MSG_CHECKING(for time.h that defines altzone)
2988 AC_CACHE_VAL(ac_cv_header_time_altzone,
2989 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2990   ac_cv_header_time_altzone=yes,
2991   ac_cv_header_time_altzone=no)])
2992 AC_MSG_RESULT($ac_cv_header_time_altzone)
2993 if test $ac_cv_header_time_altzone = yes; then
2994   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2997 was_it_defined=no
2998 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2999 AC_TRY_COMPILE([
3000 #include <sys/types.h>
3001 #include <sys/select.h>
3002 #include <sys/time.h>
3003 ], [;], [
3004   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3005   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
3006    (which you can't on SCO ODT 3.0).]) 
3007   was_it_defined=yes
3009 AC_MSG_RESULT($was_it_defined)
3011 AC_MSG_CHECKING(for addrinfo)
3012 AC_CACHE_VAL(ac_cv_struct_addrinfo,
3013 AC_TRY_COMPILE([
3014 #               include <netdb.h>],
3015         [struct addrinfo a],
3016         ac_cv_struct_addrinfo=yes,
3017         ac_cv_struct_addrinfo=no))
3018 AC_MSG_RESULT($ac_cv_struct_addrinfo)
3019 if test $ac_cv_struct_addrinfo = yes; then
3020         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
3023 AC_MSG_CHECKING(for sockaddr_storage)
3024 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
3025 AC_TRY_COMPILE([
3026 #               include <sys/types.h>
3027 #               include <sys/socket.h>],
3028         [struct sockaddr_storage s],
3029         ac_cv_struct_sockaddr_storage=yes,
3030         ac_cv_struct_sockaddr_storage=no))
3031 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3032 if test $ac_cv_struct_sockaddr_storage = yes; then
3033         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
3036 # checks for compiler characteristics
3038 AC_C_CHAR_UNSIGNED
3039 AC_C_CONST
3041 works=no
3042 AC_MSG_CHECKING(for working volatile)
3043 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
3044   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
3046 AC_MSG_RESULT($works)
3048 works=no
3049 AC_MSG_CHECKING(for working signed char)
3050 AC_TRY_COMPILE([], [signed char c;], works=yes, 
3051   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3053 AC_MSG_RESULT($works)
3055 have_prototypes=no
3056 AC_MSG_CHECKING(for prototypes)
3057 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3058   AC_DEFINE(HAVE_PROTOTYPES, 1, 
3059    [Define if your compiler supports function prototype]) 
3060   have_prototypes=yes
3062 AC_MSG_RESULT($have_prototypes)
3064 works=no
3065 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
3066 AC_TRY_COMPILE([
3067 #include <stdarg.h>
3068 int foo(int x, ...) {
3069         va_list va;
3070         va_start(va, x);
3071         va_arg(va, int);
3072         va_arg(va, char *);
3073         va_arg(va, double);
3074         return 0;
3076 ], [return foo(10, "", 3.14);], [
3077   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3078    [Define if your compiler supports variable length function prototypes
3079    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
3080   works=yes
3082 AC_MSG_RESULT($works)
3084 # check for socketpair
3085 AC_MSG_CHECKING(for socketpair)
3086 AC_TRY_COMPILE([
3087 #include <sys/types.h>
3088 #include <sys/socket.h>
3089 ], void *x=socketpair,
3090   AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3091   AC_MSG_RESULT(yes),
3092   AC_MSG_RESULT(no)
3095 # check if sockaddr has sa_len member
3096 AC_MSG_CHECKING(if sockaddr has sa_len member)
3097 AC_TRY_COMPILE([#include <sys/types.h>
3098 #include <sys/socket.h>],
3099 [struct sockaddr x;
3100 x.sa_len = 0;],
3101         AC_MSG_RESULT(yes)
3102         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
3103         AC_MSG_RESULT(no))
3105 va_list_is_array=no
3106 AC_MSG_CHECKING(whether va_list is an array)
3107 AC_TRY_COMPILE([
3108 #ifdef HAVE_STDARG_PROTOTYPES
3109 #include <stdarg.h>
3110 #else
3111 #include <varargs.h>
3112 #endif
3113 ], [va_list list1, list2; list1 = list2;], , [
3114  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
3115  va_list_is_array=yes
3117 AC_MSG_RESULT($va_list_is_array)
3119 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
3120 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3121   [Define this if you have some version of gethostbyname_r()])
3123 AC_CHECK_FUNC(gethostbyname_r, [
3124   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3125   AC_MSG_CHECKING([gethostbyname_r with 6 args])
3126   OLD_CFLAGS=$CFLAGS
3127   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3128   AC_TRY_COMPILE([
3129 #   include <netdb.h>
3130   ], [
3131     char *name;
3132     struct hostent *he, *res;
3133     char buffer[2048];
3134     int buflen = 2048;
3135     int h_errnop;
3137     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3138   ], [
3139     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3140     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3141     [Define this if you have the 6-arg version of gethostbyname_r().])
3142     AC_MSG_RESULT(yes)
3143   ], [
3144     AC_MSG_RESULT(no)
3145     AC_MSG_CHECKING([gethostbyname_r with 5 args])
3146     AC_TRY_COMPILE([
3147 #     include <netdb.h>
3148     ], [
3149       char *name;
3150       struct hostent *he;
3151       char buffer[2048];
3152       int buflen = 2048;
3153       int h_errnop;
3155       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3156     ], [
3157       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3158       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3159       [Define this if you have the 5-arg version of gethostbyname_r().])
3160       AC_MSG_RESULT(yes)
3161     ], [
3162       AC_MSG_RESULT(no)
3163       AC_MSG_CHECKING([gethostbyname_r with 3 args])
3164       AC_TRY_COMPILE([
3165 #       include <netdb.h>
3166       ], [
3167         char *name;
3168         struct hostent *he;
3169         struct hostent_data data;
3171         (void) gethostbyname_r(name, he, &data);
3172       ], [
3173         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3174         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3175         [Define this if you have the 3-arg version of gethostbyname_r().])
3176         AC_MSG_RESULT(yes)
3177       ], [
3178         AC_MSG_RESULT(no)
3179       ])
3180     ])
3181   ])
3182   CFLAGS=$OLD_CFLAGS
3183 ], [
3184   AC_CHECK_FUNCS(gethostbyname)
3186 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3187 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3188 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
3189 AC_SUBST(HAVE_GETHOSTBYNAME_R)
3190 AC_SUBST(HAVE_GETHOSTBYNAME)
3192 # checks for system services
3193 # (none yet)
3195 # Linux requires this for correct f.p. operations
3196 AC_CHECK_FUNC(__fpu_control,
3197   [],
3198   [AC_CHECK_LIB(ieee, __fpu_control)
3201 # Check for --with-fpectl
3202 AC_MSG_CHECKING(for --with-fpectl)
3203 AC_ARG_WITH(fpectl,
3204             AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3206 if test "$withval" != no
3207 then 
3208   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3209   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
3210   AC_MSG_RESULT(yes)
3211 else AC_MSG_RESULT(no)
3212 fi],
3213 [AC_MSG_RESULT(no)])
3215 # check for --with-libm=...
3216 AC_SUBST(LIBM)
3217 case $ac_sys_system in
3218 Darwin) ;;
3219 BeOS) ;;
3220 *) LIBM=-lm
3221 esac
3222 AC_MSG_CHECKING(for --with-libm=STRING)
3223 AC_ARG_WITH(libm,
3224             AC_HELP_STRING(--with-libm=STRING, math library),
3226 if test "$withval" = no
3227 then LIBM=
3228      AC_MSG_RESULT(force LIBM empty)
3229 elif test "$withval" != yes
3230 then LIBM=$withval
3231      AC_MSG_RESULT(set LIBM="$withval")
3232 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
3233 fi],
3234 [AC_MSG_RESULT(default LIBM="$LIBM")])
3236 # check for --with-libc=...
3237 AC_SUBST(LIBC)
3238 AC_MSG_CHECKING(for --with-libc=STRING)
3239 AC_ARG_WITH(libc,
3240             AC_HELP_STRING(--with-libc=STRING, C library),
3242 if test "$withval" = no
3243 then LIBC=
3244      AC_MSG_RESULT(force LIBC empty)
3245 elif test "$withval" != yes
3246 then LIBC=$withval
3247      AC_MSG_RESULT(set LIBC="$withval")
3248 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
3249 fi],
3250 [AC_MSG_RESULT(default LIBC="$LIBC")])
3252 # **************************************************
3253 # * Check for various properties of floating point *
3254 # **************************************************
3256 AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3257 AC_CACHE_VAL(ac_cv_little_endian_double, [
3258 AC_TRY_RUN([
3259 #include <string.h>
3260 int main() {
3261     double x = 9006104071832581.0;
3262     if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3263         return 0;
3264     else
3265         return 1;
3268 ac_cv_little_endian_double=yes,
3269 ac_cv_little_endian_double=no,
3270 ac_cv_little_endian_double=no)])
3271 AC_MSG_RESULT($ac_cv_little_endian_double)
3272 if test "$ac_cv_little_endian_double" = yes
3273 then
3274   AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3275   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3276    with the least significant byte first])
3279 AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3280 AC_CACHE_VAL(ac_cv_big_endian_double, [
3281 AC_TRY_RUN([
3282 #include <string.h>
3283 int main() {
3284     double x = 9006104071832581.0;
3285     if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3286         return 0;
3287     else
3288         return 1;
3291 ac_cv_big_endian_double=yes,
3292 ac_cv_big_endian_double=no,
3293 ac_cv_big_endian_double=no)])
3294 AC_MSG_RESULT($ac_cv_big_endian_double)
3295 if test "$ac_cv_big_endian_double" = yes
3296 then
3297   AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3298   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3299    with the most significant byte first])
3302 # Some ARM platforms use a mixed-endian representation for doubles.
3303 # While Python doesn't currently have full support for these platforms
3304 # (see e.g., issue 1762561), we can at least make sure that float <-> string
3305 # conversions work.
3306 AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3307 AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3308 AC_TRY_RUN([
3309 #include <string.h>
3310 int main() {
3311     double x = 9006104071832581.0;
3312     if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3313         return 0;
3314     else
3315         return 1;
3318 ac_cv_mixed_endian_double=yes,
3319 ac_cv_mixed_endian_double=no,
3320 ac_cv_mixed_endian_double=no)])
3321 AC_MSG_RESULT($ac_cv_mixed_endian_double)
3322 if test "$ac_cv_mixed_endian_double" = yes
3323 then
3324   AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3325   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3326    in ARM mixed-endian order (byte order 45670123)])
3329 # The short float repr introduced in Python 3.1 requires the
3330 # correctly-rounded string <-> double conversion functions from
3331 # Python/dtoa.c, which in turn require that the FPU uses 53-bit
3332 # rounding; this is a problem on x86, where the x87 FPU has a default
3333 # rounding precision of 64 bits.  For gcc/x86, we can fix this by
3334 # using inline assembler to get and set the x87 FPU control word.
3336 # This inline assembler syntax may also work for suncc and icc,
3337 # so we try it on all platforms.
3339 AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3340 AC_TRY_COMPILE([], [
3341   unsigned short cw;
3342   __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3343   __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3345 [have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3346 AC_MSG_RESULT($have_gcc_asm_for_x87)
3347 if test "$have_gcc_asm_for_x87" = yes
3348 then
3349     AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3350     [Define if we can use gcc inline assembler to get and set x87 control word])
3353 # Detect whether system arithmetic is subject to x87-style double
3354 # rounding issues.  The result of this test has little meaning on non
3355 # IEEE 754 platforms.  On IEEE 754, test should return 1 if rounding
3356 # mode is round-to-nearest and double rounding issues are present, and
3357 # 0 otherwise.  See http://bugs.python.org/issue2937 for more info.
3358 AC_MSG_CHECKING(for x87-style double rounding)
3359 # $BASECFLAGS may affect the result
3360 ac_save_cc="$CC"
3361 CC="$CC $BASECFLAGS"
3362 AC_TRY_RUN([
3363 #include <stdlib.h>
3364 #include <math.h>
3365 int main() {
3366     volatile double x, y, z;
3367     /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3368     x = 0.99999999999999989; /* 1-2**-53 */
3369     y = 1./x;
3370     if (y != 1.)
3371         exit(0);
3372     /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3373     x = 1e16;
3374     y = 2.99999;
3375     z = x + y;
3376     if (z != 1e16+4.)
3377         exit(0);
3378     /* both tests show evidence of double rounding */
3379     exit(1);
3382 ac_cv_x87_double_rounding=no,
3383 ac_cv_x87_double_rounding=yes,
3384 ac_cv_x87_double_rounding=no)
3385 CC="$ac_save_cc"
3386 AC_MSG_RESULT($ac_cv_x87_double_rounding)
3387 if test "$ac_cv_x87_double_rounding" = yes
3388 then
3389   AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3390   [Define if arithmetic is subject to x87-style double rounding issue])
3393 # ************************************
3394 # * Check for mathematical functions *
3395 # ************************************
3397 LIBS_SAVE=$LIBS
3398 LIBS="$LIBS $LIBM"
3400 # On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3401 # -0. on some architectures.
3402 AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3403 AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3404 AC_TRY_RUN([
3405 #include <math.h>
3406 #include <stdlib.h>
3407 int main() {
3408     /* return 0 if either negative zeros don't exist
3409        on this platform or if negative zeros exist
3410        and tanh(-0.) == -0. */
3411   if (atan2(0., -1.) == atan2(-0., -1.) ||
3412       atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3413   else exit(1);
3416 ac_cv_tanh_preserves_zero_sign=yes,
3417 ac_cv_tanh_preserves_zero_sign=no,
3418 ac_cv_tanh_preserves_zero_sign=no)])
3419 AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3420 if test "$ac_cv_tanh_preserves_zero_sign" = yes
3421 then
3422   AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3423   [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3426 AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3427 AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3428 AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3430 LIBS=$LIBS_SAVE
3432 # For multiprocessing module, check that sem_open
3433 # actually works.  For FreeBSD versions <= 7.2,
3434 # the kernel module that provides POSIX semaphores
3435 # isn't loaded by default, so an attempt to call
3436 # sem_open results in a 'Signal 12' error.
3437 AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3438 AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3439 AC_TRY_RUN([
3440 #include <unistd.h>
3441 #include <fcntl.h>
3442 #include <stdio.h>
3443 #include <semaphore.h>
3444 #include <sys/stat.h>
3446 int main(void) {
3447   sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3448   if (a == SEM_FAILED) {
3449     perror("sem_open");
3450     return 1;
3451   }
3452   sem_close(a);
3453   sem_unlink("/autoconf");
3454   return 0;
3456 ], ac_cv_posix_semaphores_enabled=yes,
3457    ac_cv_posix_semaphores_enabled=no,
3458    ac_cv_posix_semaphores_enabled=yes)
3460 AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3461 if test $ac_cv_posix_semaphores_enabled = no
3462 then
3463   AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3464             [Define if POSIX semaphores aren't enabled on your system])
3467 # Multiprocessing check for broken sem_getvalue
3468 AC_MSG_CHECKING(for broken sem_getvalue)
3469 AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
3470 AC_TRY_RUN([
3471 #include <unistd.h>
3472 #include <fcntl.h>
3473 #include <stdio.h>
3474 #include <semaphore.h>
3475 #include <sys/stat.h>
3477 int main(void){
3478   sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
3479   int count;
3480   int res;
3481   if(a==SEM_FAILED){
3482     perror("sem_open");
3483     return 1;
3485   }
3486   res = sem_getvalue(a, &count);
3487   sem_close(a);
3488   sem_unlink("/autocftw");
3489   return res==-1 ? 1 : 0;
3491 ], ac_cv_broken_sem_getvalue=no,
3492    ac_cv_broken_sem_getvalue=yes,
3493    ac_cv_broken_sem_getvalue=yes)
3495 AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3496 if test $ac_cv_broken_sem_getvalue = yes
3497 then
3498   AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3499   [define to 1 if your sem_getvalue is broken.])
3502 # determine what size digit to use for Python's longs
3503 AC_MSG_CHECKING([digit size for Python's longs])
3504 AC_ARG_ENABLE(big-digits,
3505 AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3506 [case $enable_big_digits in
3507 yes)
3508   enable_big_digits=30 ;;
3510   enable_big_digits=15 ;;
3511 [15|30])
3512   ;;
3514   AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3515 esac
3516 AC_MSG_RESULT($enable_big_digits)
3517 AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3519 [AC_MSG_RESULT(no value specified)])
3521 # check for wchar.h
3522 AC_CHECK_HEADER(wchar.h, [
3523   AC_DEFINE(HAVE_WCHAR_H, 1, 
3524   [Define if the compiler provides a wchar.h header file.]) 
3525   wchar_h="yes"
3527 wchar_h="no"
3530 # determine wchar_t size
3531 if test "$wchar_h" = yes
3532 then
3533   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
3536 AC_MSG_CHECKING(for UCS-4 tcl)
3537 have_ucs4_tcl=no
3538 AC_TRY_COMPILE([
3539 #include <tcl.h>
3540 #if TCL_UTF_MAX != 6
3541 # error "NOT UCS4_TCL"
3542 #endif], [], [
3543   AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3544   have_ucs4_tcl=yes
3546 AC_MSG_RESULT($have_ucs4_tcl)
3548 # check whether wchar_t is signed or not
3549 if test "$wchar_h" = yes
3550 then
3551   # check whether wchar_t is signed or not
3552   AC_MSG_CHECKING(whether wchar_t is signed)
3553   AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3554   AC_TRY_RUN([
3555   #include <wchar.h>
3556   int main()
3557   {
3558         /* Success: exit code 0 */
3559         exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
3560   }
3561   ],
3562   ac_cv_wchar_t_signed=yes,
3563   ac_cv_wchar_t_signed=no,
3564   ac_cv_wchar_t_signed=yes)])
3565   AC_MSG_RESULT($ac_cv_wchar_t_signed)
3567   
3568 AC_MSG_CHECKING(what type to use for unicode)
3569 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3570 AC_ARG_ENABLE(unicode, 
3571               AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
3572               [],
3573               [enable_unicode=yes])
3575 if test $enable_unicode = yes
3576 then
3577   # Without any arguments, Py_UNICODE defaults to two-byte mode
3578   case "$have_ucs4_tcl" in
3579   yes) enable_unicode="ucs4"
3580        ;;
3581   *)   enable_unicode="ucs2"
3582        ;;
3583   esac
3586 AH_TEMPLATE(Py_UNICODE_SIZE,
3587   [Define as the size of the unicode type.])
3588 case "$enable_unicode" in
3589 ucs2) unicode_size="2"
3590       AC_DEFINE(Py_UNICODE_SIZE,2)
3591       ;;
3592 ucs4) unicode_size="4"
3593       AC_DEFINE(Py_UNICODE_SIZE,4)
3594       ;;
3595 esac
3597 AH_TEMPLATE(PY_UNICODE_TYPE,
3598   [Define as the integral type used for Unicode representation.])
3600 AC_SUBST(UNICODE_OBJS)
3601 if test "$enable_unicode" = "no"
3602 then
3603   UNICODE_OBJS=""
3604   AC_MSG_RESULT(not used)
3605 else
3606   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
3607   AC_DEFINE(Py_USING_UNICODE, 1,
3608   [Define if you want to have a Unicode type.])
3610   # wchar_t is only usable if it maps to an unsigned type
3611   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
3612           -a "$ac_cv_wchar_t_signed" = "no"
3613   then
3614     PY_UNICODE_TYPE="wchar_t"
3615     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3616     [Define if you have a useable wchar_t type defined in wchar.h; useable
3617      means wchar_t must be an unsigned type with at least 16 bits. (see
3618      Include/unicodeobject.h).])
3619     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3620   elif test "$ac_cv_sizeof_short" = "$unicode_size"
3621   then
3622        PY_UNICODE_TYPE="unsigned short"
3623        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3624   elif test "$ac_cv_sizeof_long" = "$unicode_size"
3625   then
3626        PY_UNICODE_TYPE="unsigned long"
3627        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3628   else
3629        PY_UNICODE_TYPE="no type found"
3630   fi
3631   AC_MSG_RESULT($PY_UNICODE_TYPE)
3634 # check for endianness
3635 AC_C_BIGENDIAN
3637 # Check whether right shifting a negative integer extends the sign bit
3638 # or fills with zeros (like the Cray J90, according to Tim Peters).
3639 AC_MSG_CHECKING(whether right shift extends the sign bit)
3640 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
3641 AC_TRY_RUN([
3642 int main()
3644         exit(((-1)>>3 == -1) ? 0 : 1);
3647 ac_cv_rshift_extends_sign=yes,
3648 ac_cv_rshift_extends_sign=no,
3649 ac_cv_rshift_extends_sign=yes)])
3650 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3651 if test "$ac_cv_rshift_extends_sign" = no
3652 then
3653   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3654   [Define if i>>j for signed int i does not extend the sign bit
3655    when i < 0])
3658 # check for getc_unlocked and related locking functions
3659 AC_MSG_CHECKING(for getc_unlocked() and friends)
3660 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3661 AC_TRY_LINK([#include <stdio.h>],[
3662         FILE *f = fopen("/dev/null", "r");
3663         flockfile(f);
3664         getc_unlocked(f);
3665         funlockfile(f);
3666 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3667 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3668 if test "$ac_cv_have_getc_unlocked" = yes
3669 then
3670   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3671   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
3674 # check where readline lives
3675 # save the value of LIBS so we don't actually link Python with readline
3676 LIBS_no_readline=$LIBS
3678 # On some systems we need to link readline to a termcap compatible
3679 # library.  NOTE: Keep the precedence of listed libraries synchronised
3680 # with setup.py.
3681 py_cv_lib_readline=no
3682 AC_MSG_CHECKING([how to link readline libs])
3683 for py_libtermcap in "" ncursesw ncurses curses termcap; do
3684   if test -z "$py_libtermcap"; then
3685     READLINE_LIBS="-lreadline"
3686   else
3687     READLINE_LIBS="-lreadline -l$py_libtermcap"
3688   fi
3689   LIBS="$READLINE_LIBS $LIBS_no_readline"
3690   AC_LINK_IFELSE(
3691     [AC_LANG_CALL([],[readline])],
3692     [py_cv_lib_readline=yes])
3693   if test $py_cv_lib_readline = yes; then
3694     break
3695   fi
3696 done
3697 # Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3698 #AC_SUBST([READLINE_LIBS])
3699 if test $py_cv_lib_readline = no; then
3700   AC_MSG_RESULT([none])
3701 else
3702   AC_MSG_RESULT([$READLINE_LIBS])
3703   AC_DEFINE(HAVE_LIBREADLINE, 1,
3704     [Define if you have the readline library (-lreadline).])
3707 # check for readline 2.1
3708 AC_CHECK_LIB(readline, rl_callback_handler_install,
3709         AC_DEFINE(HAVE_RL_CALLBACK, 1,
3710         [Define if you have readline 2.1]), ,$READLINE_LIBS)
3712 # check for readline 2.2
3713 AC_TRY_CPP([#include <readline/readline.h>],
3714 have_readline=yes, have_readline=no)
3715 if test $have_readline = yes
3716 then
3717   AC_EGREP_HEADER([extern int rl_completion_append_character;],
3718   [readline/readline.h],
3719   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3720   [Define if you have readline 2.2]), )
3721   AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3722   [readline/readline.h],
3723   AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3724   [Define if you have rl_completion_suppress_append]), )
3727 # check for readline 4.0
3728 AC_CHECK_LIB(readline, rl_pre_input_hook,
3729         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
3730         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3732 # also in 4.0
3733 AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3734         AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
3735         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3737 # check for readline 4.2
3738 AC_CHECK_LIB(readline, rl_completion_matches,
3739         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
3740         [Define if you have readline 4.2]), ,$READLINE_LIBS)
3742 # also in readline 4.2
3743 AC_TRY_CPP([#include <readline/readline.h>],
3744 have_readline=yes, have_readline=no)
3745 if test $have_readline = yes
3746 then
3747   AC_EGREP_HEADER([extern int rl_catch_signals;],
3748   [readline/readline.h],
3749   AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3750   [Define if you can turn off readline's signal handling.]), )
3753 # End of readline checks: restore LIBS
3754 LIBS=$LIBS_no_readline
3756 AC_MSG_CHECKING(for broken nice())
3757 AC_CACHE_VAL(ac_cv_broken_nice, [
3758 AC_TRY_RUN([
3759 int main()
3761         int val1 = nice(1);
3762         if (val1 != -1 && val1 == nice(2))
3763                 exit(0);
3764         exit(1);
3767 ac_cv_broken_nice=yes,
3768 ac_cv_broken_nice=no,
3769 ac_cv_broken_nice=no)])
3770 AC_MSG_RESULT($ac_cv_broken_nice)
3771 if test "$ac_cv_broken_nice" = yes
3772 then
3773   AC_DEFINE(HAVE_BROKEN_NICE, 1,
3774   [Define if nice() returns success/failure instead of the new priority.])
3777 AC_MSG_CHECKING(for broken poll())
3778 AC_CACHE_VAL(ac_cv_broken_poll,
3779 AC_TRY_RUN([
3780 #include <poll.h>
3782 int main()
3784     struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3785     int poll_test;
3787     close (42);
3789     poll_test = poll(&poll_struct, 1, 0);
3790     if (poll_test < 0)
3791         return 0;
3792     else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3793         return 0;
3794     else
3795         return 1;
3798 ac_cv_broken_poll=yes,
3799 ac_cv_broken_poll=no,
3800 ac_cv_broken_poll=no))
3801 AC_MSG_RESULT($ac_cv_broken_poll)
3802 if test "$ac_cv_broken_poll" = yes
3803 then
3804   AC_DEFINE(HAVE_BROKEN_POLL, 1,
3805       [Define if poll() sets errno on invalid file descriptors.])
3808 # Before we can test tzset, we need to check if struct tm has a tm_zone 
3809 # (which is not required by ISO C or UNIX spec) and/or if we support
3810 # tzname[]
3811 AC_STRUCT_TIMEZONE
3813 # check tzset(3) exists and works like we expect it to
3814 AC_MSG_CHECKING(for working tzset())
3815 AC_CACHE_VAL(ac_cv_working_tzset, [
3816 AC_TRY_RUN([
3817 #include <stdlib.h>
3818 #include <time.h>
3819 #include <string.h>
3821 #if HAVE_TZNAME
3822 extern char *tzname[];
3823 #endif
3825 int main()
3827         /* Note that we need to ensure that not only does tzset(3)
3828            do 'something' with localtime, but it works as documented
3829            in the library reference and as expected by the test suite.
3830            This includes making sure that tzname is set properly if
3831            tm->tm_zone does not exist since it is the alternative way
3832            of getting timezone info.
3834            Red Hat 6.2 doesn't understand the southern hemisphere 
3835            after New Year's Day.
3836         */
3838         time_t groundhogday = 1044144000; /* GMT-based */
3839         time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3841         putenv("TZ=UTC+0");
3842         tzset();
3843         if (localtime(&groundhogday)->tm_hour != 0)
3844             exit(1);
3845 #if HAVE_TZNAME
3846         /* For UTC, tzname[1] is sometimes "", sometimes "   " */
3847         if (strcmp(tzname[0], "UTC") || 
3848                 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3849             exit(1);
3850 #endif
3852         putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
3853         tzset();
3854         if (localtime(&groundhogday)->tm_hour != 19)
3855             exit(1);
3856 #if HAVE_TZNAME
3857         if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3858             exit(1);
3859 #endif
3861         putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3862         tzset();
3863         if (localtime(&groundhogday)->tm_hour != 11)
3864             exit(1);
3865 #if HAVE_TZNAME
3866         if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3867             exit(1);
3868 #endif
3870 #if HAVE_STRUCT_TM_TM_ZONE
3871         if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3872             exit(1);
3873         if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3874             exit(1);
3875 #endif
3877         exit(0);
3880 ac_cv_working_tzset=yes,
3881 ac_cv_working_tzset=no,
3882 ac_cv_working_tzset=no)])
3883 AC_MSG_RESULT($ac_cv_working_tzset)
3884 if test "$ac_cv_working_tzset" = yes
3885 then
3886   AC_DEFINE(HAVE_WORKING_TZSET, 1,
3887   [Define if tzset() actually switches the local timezone in a meaningful way.])
3890 # Look for subsecond timestamps in struct stat
3891 AC_MSG_CHECKING(for tv_nsec in struct stat)
3892 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3893 AC_TRY_COMPILE([#include <sys/stat.h>], [
3894 struct stat st;
3895 st.st_mtim.tv_nsec = 1;
3897 ac_cv_stat_tv_nsec=yes,
3898 ac_cv_stat_tv_nsec=no,
3899 ac_cv_stat_tv_nsec=no))
3900 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3901 if test "$ac_cv_stat_tv_nsec" = yes
3902 then
3903   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3904   [Define if you have struct stat.st_mtim.tv_nsec])
3907 # Look for BSD style subsecond timestamps in struct stat
3908 AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3909 AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3910 AC_TRY_COMPILE([#include <sys/stat.h>], [
3911 struct stat st;
3912 st.st_mtimespec.tv_nsec = 1;
3914 ac_cv_stat_tv_nsec2=yes,
3915 ac_cv_stat_tv_nsec2=no,
3916 ac_cv_stat_tv_nsec2=no))
3917 AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3918 if test "$ac_cv_stat_tv_nsec2" = yes
3919 then
3920   AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3921   [Define if you have struct stat.st_mtimensec])
3924 # On HP/UX 11.0, mvwdelch is a block with a return statement
3925 AC_MSG_CHECKING(whether mvwdelch is an expression)
3926 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3927 AC_TRY_COMPILE([#include <curses.h>], [
3928   int rtn;
3929   rtn = mvwdelch(0,0,0);
3930 ], ac_cv_mvwdelch_is_expression=yes,
3931    ac_cv_mvwdelch_is_expression=no,
3932    ac_cv_mvwdelch_is_expression=yes))
3933 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3935 if test "$ac_cv_mvwdelch_is_expression" = yes
3936 then
3937   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3938   [Define if mvwdelch in curses.h is an expression.])
3941 AC_MSG_CHECKING(whether WINDOW has _flags)
3942 AC_CACHE_VAL(ac_cv_window_has_flags,
3943 AC_TRY_COMPILE([#include <curses.h>], [
3944   WINDOW *w;
3945   w->_flags = 0;
3946 ], ac_cv_window_has_flags=yes,
3947    ac_cv_window_has_flags=no,
3948    ac_cv_window_has_flags=no))
3949 AC_MSG_RESULT($ac_cv_window_has_flags)
3952 if test "$ac_cv_window_has_flags" = yes
3953 then
3954   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
3955   [Define if WINDOW in curses.h offers a field _flags.])
3958 AC_MSG_CHECKING(for is_term_resized)
3959 AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3960   AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3961   AC_MSG_RESULT(yes),
3962   AC_MSG_RESULT(no)
3965 AC_MSG_CHECKING(for resize_term)
3966 AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3967   AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3968   AC_MSG_RESULT(yes),
3969   AC_MSG_RESULT(no)
3972 AC_MSG_CHECKING(for resizeterm)
3973 AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3974   AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3975   AC_MSG_RESULT(yes),
3976   AC_MSG_RESULT(no)
3979 AC_MSG_CHECKING(for /dev/ptmx)
3981 if test -r /dev/ptmx
3982 then
3983   AC_MSG_RESULT(yes)
3984   AC_DEFINE(HAVE_DEV_PTMX, 1,
3985   [Define if we have /dev/ptmx.])
3986 else
3987   AC_MSG_RESULT(no)
3990 AC_MSG_CHECKING(for /dev/ptc)
3992 if test -r /dev/ptc
3993 then
3994   AC_MSG_RESULT(yes)
3995   AC_DEFINE(HAVE_DEV_PTC, 1,
3996   [Define if we have /dev/ptc.])
3997 else
3998   AC_MSG_RESULT(no)
4001 if test "$have_long_long" = yes
4002 then
4003   AC_MSG_CHECKING(for %lld and %llu printf() format support)
4004   AC_CACHE_VAL(ac_cv_have_long_long_format,
4005   AC_TRY_RUN([[
4006   #include <stdio.h>
4007   #include <stddef.h>
4008   #include <string.h>
4010   #ifdef HAVE_SYS_TYPES_H
4011   #include <sys/types.h>
4012   #endif
4014   int main()
4015   {
4016       char buffer[256];
4018       if (sprintf(buffer, "%lld", (long long)123) < 0)
4019           return 1;
4020       if (strcmp(buffer, "123"))
4021           return 1;
4023       if (sprintf(buffer, "%lld", (long long)-123) < 0)
4024           return 1;
4025       if (strcmp(buffer, "-123"))
4026           return 1;
4028       if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4029           return 1;
4030       if (strcmp(buffer, "123"))
4031           return 1;
4033       return 0;
4034   }
4035   ]], ac_cv_have_long_long_format=yes,
4036       ac_cv_have_long_long_format=no,
4037       ac_cv_have_long_long_format=no)
4038   )
4039   AC_MSG_RESULT($ac_cv_have_long_long_format)
4042 if test $ac_cv_have_long_long_format = yes
4043 then
4044   AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4045   [Define to printf format modifier for long long type])
4048 if test $ac_sys_system = Darwin
4049 then
4050         LIBS="$LIBS -framework CoreFoundation"
4054 AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4055 AC_TRY_RUN([
4056 #include <stdio.h>
4057 #include <stddef.h>
4058 #include <string.h>
4060 #ifdef HAVE_SYS_TYPES_H
4061 #include <sys/types.h>
4062 #endif
4064 #ifdef HAVE_SSIZE_T
4065 typedef ssize_t Py_ssize_t;
4066 #elif SIZEOF_VOID_P == SIZEOF_LONG
4067 typedef long Py_ssize_t;
4068 #else
4069 typedef int Py_ssize_t;
4070 #endif
4072 int main()
4074     char buffer[256];
4076     if(sprintf(buffer, "%zd", (size_t)123) < 0)
4077         return 1;
4079     if (strcmp(buffer, "123"))
4080         return 1;
4082     if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4083         return 1;
4085     if (strcmp(buffer, "-123"))
4086         return 1;
4088     return 0;
4090 ], ac_cv_have_size_t_format=yes,
4091     ac_cv_have_size_t_format=no,
4092     [ac_cv_have_size_t_format="cross -- assuming yes"]
4094 if test "$ac_cv_have_size_t_format" != no ; then
4095   AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4096   [Define to printf format modifier for Py_ssize_t])
4099 AC_CHECK_TYPE(socklen_t,,
4100   AC_DEFINE(socklen_t,int,
4101             Define to `int' if <sys/socket.h> does not define.),[
4102 #ifdef HAVE_SYS_TYPES_H
4103 #include <sys/types.h>
4104 #endif
4105 #ifdef HAVE_SYS_SOCKET_H
4106 #include <sys/socket.h>
4107 #endif
4110 AC_SUBST(THREADHEADERS)
4112 for h in `(cd $srcdir;echo Python/thread_*.h)`
4114   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4115 done
4117 AC_SUBST(SRCDIRS)
4118 SRCDIRS="Parser Grammar Objects Python Modules Mac"
4119 AC_MSG_CHECKING(for build directories)
4120 for dir in $SRCDIRS; do
4121     if test ! -d $dir; then
4122         mkdir $dir
4123     fi
4124 done
4125 AC_MSG_RESULT(done)
4127 # generate output files
4128 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
4129 AC_OUTPUT
4131 echo "creating Modules/Setup"
4132 if test ! -f Modules/Setup
4133 then
4134         cp $srcdir/Modules/Setup.dist Modules/Setup
4137 echo "creating Modules/Setup.local"
4138 if test ! -f Modules/Setup.local
4139 then
4140         echo "# Edit this file for local setup changes" >Modules/Setup.local
4143 echo "creating Makefile"
4144 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4145                         -s Modules Modules/Setup.config \
4146                         Modules/Setup.local Modules/Setup
4148 case $ac_sys_system in
4149 BeOS)
4150         AC_MSG_WARN([
4152   Support for BeOS is deprecated as of Python 2.6.
4153   See PEP 11 for the gory details.
4154   ])
4155   ;;
4156 *) ;;
4157 esac
4159 mv config.c Modules