Merged revisions 78818 via svnmerge from
[python/dscho.git] / configure.in
blob9c8bde224db19509748fc6781d6dc3879b09c394
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, 3.1)
9 AC_REVISION($Revision$)
10 AC_PREREQ(2.61)
11 AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
12 AC_CONFIG_SRCDIR([Include/object.h])
13 AC_CONFIG_HEADER(pyconfig.h)
15 dnl Ensure that if prefix is specified, it does not end in a slash. If
16 dnl it does, we get path names containing '//' which is both ugly and
17 dnl can cause trouble.
19 dnl Last slash shouldn't be stripped if prefix=/
20 if test "$prefix" != "/"; then
21     prefix=`echo "$prefix" | sed -e 's/\/$//g'`
22 fi    
24 dnl This is for stuff that absolutely must end up in pyconfig.h.
25 dnl Please use pyport.h instead, if possible.
26 AH_TOP([
27 #ifndef Py_PYCONFIG_H
28 #define Py_PYCONFIG_H
30 AH_BOTTOM([
31 /* Define the macros needed if on a UnixWare 7.x system. */
32 #if defined(__USLC__) && defined(__SCO_VERSION__)
33 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
34 #endif
36 #endif /*Py_PYCONFIG_H*/
39 # We don't use PACKAGE_ variables, and they cause conflicts
40 # with other autoconf-based packages that include Python.h
41 grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
42 rm confdefs.h
43 mv confdefs.h.new confdefs.h
45 AC_SUBST(VERSION)
46 VERSION=PYTHON_VERSION
48 AC_SUBST(SOVERSION)
49 SOVERSION=1.0
51 # The later defininition of _XOPEN_SOURCE disables certain features
52 # on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
53 AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
55 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
56 # certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
57 # them.
58 AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
60 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
61 # certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
62 # them.
63 AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
65 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
66 # u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
67 AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
69 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
70 # certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
71 # them.
72 AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
75 define_xopen_source=yes
77 # Arguments passed to configure.
78 AC_SUBST(CONFIG_ARGS)
79 CONFIG_ARGS="$ac_configure_args"
81 AC_MSG_CHECKING([for --enable-universalsdk])
82 AC_ARG_ENABLE(universalsdk,
83         AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
85         case $enableval in
86         yes)
87                 enableval=/Developer/SDKs/MacOSX10.4u.sdk
88                 if test ! -d "${enableval}"
89                 then
90                         enableval=/
91                 fi
92                 ;;
93         esac
94         case $enableval in
95         no)
96                 UNIVERSALSDK=
97                 enable_universalsdk=
98                 ;;
99         *)
100                 UNIVERSALSDK=$enableval
101                 if test ! -d "${UNIVERSALSDK}"
102                 then
103                         AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
104                 fi
105                 ;;
106         esac
107         
109         UNIVERSALSDK=
110         enable_universalsdk=
112 if test -n "${UNIVERSALSDK}"
113 then
114         AC_MSG_RESULT(${UNIVERSALSDK})
115 else
116         AC_MSG_RESULT(no)
118 AC_SUBST(UNIVERSALSDK)
120 AC_SUBST(ARCH_RUN_32BIT)
122 UNIVERSAL_ARCHS="32-bit"
123 AC_MSG_CHECKING(for --with-universal-archs)
124 AC_ARG_WITH(universal-archs,
125     AC_HELP_STRING(--with-universal-archs=ARCH, select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")),
127         AC_MSG_RESULT($withval)
128         UNIVERSAL_ARCHS="$withval"
131         AC_MSG_RESULT(32-bit)
136 AC_ARG_WITH(framework-name,
137               AC_HELP_STRING(--with-framework-name=FRAMEWORK, 
138                              specify an alternate name of the framework built with --enable-framework),
140     PYTHONFRAMEWORK=${withval}
141     PYTHONFRAMEWORKDIR=${withval}.framework
142     PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
143     ],[
144     PYTHONFRAMEWORK=Python
145     PYTHONFRAMEWORKDIR=Python.framework
146     PYTHONFRAMEWORKIDENTIFIER=org.python.python
148 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
149 AC_ARG_ENABLE(framework,
150               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
152         case $enableval in
153         yes) 
154                 enableval=/Library/Frameworks
155         esac
156         case $enableval in
157         no)
158                 PYTHONFRAMEWORK=
159                 PYTHONFRAMEWORKDIR=no-framework
160                 PYTHONFRAMEWORKPREFIX=
161                 PYTHONFRAMEWORKINSTALLDIR=
162                 FRAMEWORKINSTALLFIRST=
163                 FRAMEWORKINSTALLLAST=
164                 FRAMEWORKALTINSTALLFIRST=
165                 FRAMEWORKALTINSTALLLAST=
166                 if test "x${prefix}" = "xNONE"; then
167                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
168                 else
169                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
170                 fi
171                 enable_framework=
172                 ;;
173         *)
174                 PYTHONFRAMEWORKPREFIX=$enableval
175                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
176                 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
177                 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure "
178                 if test "$UNIVERSAL_ARCHS" = "all"
179                 then
180                         FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkinstallunixtools4way"
181                         FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps4way frameworkaltinstallunixtools4way"
182                 else
183                         FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
184                         FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
185                 fi
187                 if test "x${prefix}" = "xNONE" ; then
188                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
189                 else
190                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
191                 fi
192                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
194                 # Add files for Mac specific code to the list of output
195                 # files:
196                 AC_CONFIG_FILES(Mac/Makefile)
197                 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
198                 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
199                 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
200         esac
201         ],[
202         PYTHONFRAMEWORK=
203         PYTHONFRAMEWORKDIR=no-framework
204         PYTHONFRAMEWORKPREFIX=
205         PYTHONFRAMEWORKINSTALLDIR=
206         FRAMEWORKINSTALLFIRST=
207         FRAMEWORKINSTALLLAST=
208         FRAMEWORKALTINSTALLFIRST=
209         FRAMEWORKALTINSTALLLAST=
210         if test "x${prefix}" = "xNONE" ; then
211                 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
212         else
213                 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
214         fi
215         enable_framework=
217         if test "$UNIVERSAL_ARCHS" = "all" 
218         then
219                 FRAMEWORKINSTALLLAST=update4wayuniversal
220                 FRAMEWORKALTINSTALLLAST=update4wayuniversal
221         fi
223 AC_SUBST(PYTHONFRAMEWORK)
224 AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
225 AC_SUBST(PYTHONFRAMEWORKDIR)
226 AC_SUBST(PYTHONFRAMEWORKPREFIX)
227 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
228 AC_SUBST(FRAMEWORKINSTALLFIRST)
229 AC_SUBST(FRAMEWORKINSTALLLAST)
230 AC_SUBST(FRAMEWORKALTINSTALLFIRST)
231 AC_SUBST(FRAMEWORKALTINSTALLLAST)
232 AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
234 ##AC_ARG_WITH(dyld,
235 ##            AC_HELP_STRING(--with-dyld,
236 ##                           Use (OpenStep|Rhapsody) dynamic linker))
238 # Set name for machine-dependent library files
239 AC_SUBST(MACHDEP)
240 AC_MSG_CHECKING(MACHDEP)
241 if test -z "$MACHDEP"
242 then
243         ac_sys_system=`uname -s`
244         if test "$ac_sys_system" = "AIX" \
245         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
246                 ac_sys_release=`uname -v`
247         else
248                 ac_sys_release=`uname -r`
249         fi
250         ac_md_system=`echo $ac_sys_system |
251                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
252         ac_md_release=`echo $ac_sys_release |
253                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
254         MACHDEP="$ac_md_system$ac_md_release"
256         case $MACHDEP in
257         cygwin*) MACHDEP="cygwin";;
258         darwin*) MACHDEP="darwin";;
259         atheos*) MACHDEP="atheos";;
260         irix646) MACHDEP="irix6";;
261         '')     MACHDEP="unknown";;
262         esac
264         
265 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
266 # disable features if it is defined, without any means to access these
267 # features as extensions. For these systems, we skip the definition of
268 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
269 # some feature, make sure there is no alternative way to access this
270 # feature. Also, when using wildcards, make sure you have verified the
271 # need for not defining _XOPEN_SOURCE on all systems matching the
272 # wildcard, and that the wildcard does not include future systems
273 # (which may remove their limitations).
274 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
275 case $ac_sys_system/$ac_sys_release in
276   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
277   # even though select is a POSIX function. Reported by J. Ribbens.
278   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
279   # In addition, Stefan Krah confirms that issue #1244610 exists through
280   # OpenBSD 4.6, but is fixed in 4.7.
281   OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@) 
282     define_xopen_source=no
283     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
284     # also defined. This can be overridden by defining _BSD_SOURCE
285     # As this has a different meaning on Linux, only define it on OpenBSD
286     AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
287     ;;
288   OpenBSD/4.@<:@789@:>@)
289     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
290     # also defined. This can be overridden by defining _BSD_SOURCE
291     # As this has a different meaning on Linux, only define it on OpenBSD
292     AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
293     ;;
294   # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
295   # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
296   # Marc Recht
297   NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
298     define_xopen_source=no;;
299   # On Solaris 2.6, sys/wait.h is inconsistent in the usage
300   # of union __?sigval. Reported by Stuart Bishop.
301   SunOS/5.6)
302     define_xopen_source=no;;
303   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
304   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
305   # Reconfirmed for 7.1.4 by Martin v. Loewis.
306   OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
307     define_xopen_source=no;;
308   # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
309   # but used in struct sockaddr.sa_family. Reported by Tim Rice.
310   SCO_SV/3.2)
311     define_xopen_source=no;;
312   # On FreeBSD 4, the math functions C89 does not cover are never defined
313   # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
314   FreeBSD/4.*)
315     define_xopen_source=no;;
316   # On MacOS X 10.2, a bug in ncurses.h means that it craps out if 
317   # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
318   # identifies itself as Darwin/7.*
319   # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
320   # disables platform specific features beyond repair.
321   # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE 
322   # has no effect, don't bother defining them
323   Darwin/@<:@6789@:>@.*)
324     define_xopen_source=no;;
325   Darwin/1@<:@0-9@:>@.*)
326     define_xopen_source=no;;
327   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
328   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
329   # or has another value. By not (re)defining it, the defaults come in place.
330   AIX/4)
331     define_xopen_source=no;;
332   AIX/5)
333     if test `uname -r` -eq 1; then
334       define_xopen_source=no
335     fi
336     ;;
337   # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
338   # defining NI_NUMERICHOST.
339   QNX/6.3.2)
340     define_xopen_source=no
341     ;;
343 esac
345 if test $define_xopen_source = yes
346 then
347   # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
348   # defined precisely as g++ defines it
349   # Furthermore, on Solaris 10, XPG6 requires the use of a C99
350   # compiler
351   case $ac_sys_system/$ac_sys_release in
352     SunOS/5.8|SunOS/5.9|SunOS/5.10)
353       AC_DEFINE(_XOPEN_SOURCE, 500, 
354                 Define to the level of X/Open that your system supports)
355       ;;
356     *)
357       AC_DEFINE(_XOPEN_SOURCE, 600, 
358                 Define to the level of X/Open that your system supports)
359       ;;
360   esac
362   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
363   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
364   # several APIs are not declared. Since this is also needed in some
365   # cases for HP-UX, we define it globally.
366   # except for Solaris 10, where it must not be defined, 
367   # as it implies XPG4.2
368   case $ac_sys_system/$ac_sys_release in
369     SunOS/5.10)
370       ;;
371     *)
372       AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
373                 Define to activate Unix95-and-earlier features)
374       ;;
375   esac
377   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
378   
382 # SGI compilers allow the specification of the both the ABI and the
383 # ISA on the command line.  Depending on the values of these switches,
384 # different and often incompatable code will be generated.
386 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
387 # thus supply support for various ABI/ISA combinations.  The MACHDEP
388 # variable is also adjusted.
390 AC_SUBST(SGI_ABI)
391 if test ! -z "$SGI_ABI"
392 then
393         CC="cc $SGI_ABI"
394         LDFLAGS="$SGI_ABI $LDFLAGS"
395         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
397 AC_MSG_RESULT($MACHDEP)
399 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
400 # it may influence the way we can build extensions, so distutils
401 # needs to check it
402 AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
403 AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
404 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
405 EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
407 AC_MSG_CHECKING(machine type as reported by uname -m)
408 ac_sys_machine=`uname -m`
409 AC_MSG_RESULT($ac_sys_machine)
411 # checks for alternative programs
413 # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
414 # for debug/optimization stuff.  BASECFLAGS is for flags that are required
415 # just to get things to compile and link.  Users are free to override OPT
416 # when running configure or make.  The build should not break if they do.
417 # BASECFLAGS should generally not be messed with, however.
419 # XXX shouldn't some/most/all of this code be merged with the stuff later
420 # on that fiddles with OPT and BASECFLAGS?
421 AC_MSG_CHECKING(for --without-gcc)
422 AC_ARG_WITH(gcc,
423             AC_HELP_STRING(--without-gcc,never use gcc),
425         case $withval in
426         no)     CC=${CC:-cc}
427                 without_gcc=yes;;
428         yes)    CC=gcc
429                 without_gcc=no;;
430         *)      CC=$withval
431                 without_gcc=$withval;;
432         esac], [
433         case $ac_sys_system in
434         AIX*)   CC=cc_r
435                 without_gcc=;;
436         *)      without_gcc=no;;
437         esac])
438 AC_MSG_RESULT($without_gcc)
440 # If the user switches compilers, we can't believe the cache
441 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
442 then
443   AC_MSG_ERROR([cached CC is different -- throw away $cache_file
444 (it is also a good idea to do 'make clean' before compiling)])
447 AC_PROG_CC
449 AC_SUBST(CXX)
450 AC_SUBST(MAINCC)
451 AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
452 AC_ARG_WITH(cxx_main,
453             AC_HELP_STRING([--with-cxx-main=<compiler>],
454                            [compile main() and link python executable with C++ compiler]),
456         
457         case $withval in
458         no)     with_cxx_main=no
459                 MAINCC='$(CC)';;
460         yes)    with_cxx_main=yes
461                 MAINCC='$(CXX)';;
462         *)      with_cxx_main=yes
463                 MAINCC=$withval
464                 if test -z "$CXX"
465                 then
466                         CXX=$withval
467                 fi;;
468         esac], [
469         with_cxx_main=no
470         MAINCC='$(CC)'
472 AC_MSG_RESULT($with_cxx_main)
474 preset_cxx="$CXX"
475 if test -z "$CXX"
476 then
477         case "$CC" in
478         gcc)    AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
479         cc)     AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
480         esac
481         if test "$CXX" = "notfound"
482         then
483                 CXX=""
484         fi
486 if test -z "$CXX"
487 then
488         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
489         if test "$CXX" = "notfound"
490         then
491                 CXX=""
492         fi
494 if test "$preset_cxx" != "$CXX"
495 then
496         AC_MSG_WARN([
498   By default, distutils will build C++ extension modules with "$CXX".
499   If this is not intended, then set CXX on the configure command line.
500   ])
504 # checks for UNIX variants that set C preprocessor variables
505 AC_AIX
507 # Check for unsupported systems
508 case $ac_sys_system/$ac_sys_release in
509 atheos*|Linux*/1*)
510    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
511    echo See README for details.
512    exit 1;;
513 esac
515 AC_EXEEXT
516 AC_MSG_CHECKING(for --with-suffix)
517 AC_ARG_WITH(suffix,
518             AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
520         case $withval in
521         no)     EXEEXT=;;
522         yes)    EXEEXT=.exe;;
523         *)      EXEEXT=$withval;;
524         esac])
525 AC_MSG_RESULT($EXEEXT)
527 # Test whether we're running on a non-case-sensitive system, in which
528 # case we give a warning if no ext is given
529 AC_SUBST(BUILDEXEEXT)
530 AC_MSG_CHECKING(for case-insensitive build directory)
531 if test ! -d CaseSensitiveTestDir; then
532 mkdir CaseSensitiveTestDir
535 if test -d casesensitivetestdir
536 then
537     AC_MSG_RESULT(yes)
538     BUILDEXEEXT=.exe
539 else
540         AC_MSG_RESULT(no)
541         BUILDEXEEXT=$EXEEXT
543 rmdir CaseSensitiveTestDir
545 case $MACHDEP in
546 bsdos*)
547     case $CC in
548     gcc) CC="$CC -D_HAVE_BSDI";;
549     esac;;
550 esac
552 case $ac_sys_system in
553 hp*|HP*)
554     case $CC in
555     cc|*/cc) CC="$CC -Ae";;
556     esac;;
557 SunOS*)
558     # Some functions have a prototype only with that define, e.g. confstr
559     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
560     ;;
561 esac
564 AC_SUBST(LIBRARY)
565 AC_MSG_CHECKING(LIBRARY)
566 if test -z "$LIBRARY"
567 then
568         LIBRARY='libpython$(VERSION).a'
570 AC_MSG_RESULT($LIBRARY)
572 # LDLIBRARY is the name of the library to link against (as opposed to the
573 # name of the library into which to insert object files). BLDLIBRARY is also
574 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
575 # is blank as the main program is not linked directly against LDLIBRARY.
576 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
577 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
578 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
579 # DLLLIBRARY is the shared (i.e., DLL) library.
581 # RUNSHARED is used to run shared python without installed libraries
583 # INSTSONAME is the name of the shared library that will be use to install
584 # on the system - some systems like version suffix, others don't
585 AC_SUBST(LDLIBRARY)
586 AC_SUBST(DLLLIBRARY)
587 AC_SUBST(BLDLIBRARY)
588 AC_SUBST(LDLIBRARYDIR)
589 AC_SUBST(INSTSONAME)
590 AC_SUBST(RUNSHARED)
591 LDLIBRARY="$LIBRARY"
592 BLDLIBRARY='$(LDLIBRARY)'
593 INSTSONAME='$(LDLIBRARY)'
594 DLLLIBRARY=''
595 LDLIBRARYDIR=''
596 RUNSHARED=''
598 # LINKCC is the command that links the python executable -- default is $(CC).
599 # If CXX is set, and if it is needed to link a main function that was
600 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
601 # python might then depend on the C++ runtime
602 # This is altered for AIX in order to build the export list before 
603 # linking.
604 AC_SUBST(LINKCC)
605 AC_MSG_CHECKING(LINKCC)
606 if test -z "$LINKCC"
607 then
608         LINKCC='$(PURIFY) $(MAINCC)'
609         case $ac_sys_system in
610         AIX*)
611            exp_extra="\"\""
612            if test $ac_sys_release -ge 5 -o \
613                    $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
614                exp_extra="."
615            fi
616            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
617         QNX*)
618            # qcc must be used because the other compilers do not
619            # support -N.
620            LINKCC=qcc;;
621         esac
623 AC_MSG_RESULT($LINKCC)
625 # GNULD is set to "yes" if the GNU linker is used.  If this goes wrong
626 # make sure we default having it set to "no": this is used by
627 # distutils.unixccompiler to know if it should add --enable-new-dtags
628 # to linker command lines, and failing to detect GNU ld simply results
629 # in the same bahaviour as before.
630 AC_SUBST(GNULD)
631 AC_MSG_CHECKING(for GNU ld)
632 ac_prog=ld
633 if test "$GCC" = yes; then
634        ac_prog=`$CC -print-prog-name=ld`
636 case `"$ac_prog" -V 2>&1 < /dev/null` in
637       *GNU*)
638           GNULD=yes;;
639       *)
640           GNULD=no;;
641 esac
642 AC_MSG_RESULT($GNULD)
644 AC_MSG_CHECKING(for --enable-shared)
645 AC_ARG_ENABLE(shared,
646               AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
648 if test -z "$enable_shared"
649 then 
650   case $ac_sys_system in
651   CYGWIN* | atheos*)
652     enable_shared="yes";;
653   *)
654     enable_shared="no";;
655   esac
657 AC_MSG_RESULT($enable_shared)
659 AC_MSG_CHECKING(for --enable-profiling)
660 AC_ARG_ENABLE(profiling,
661               AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
662 [ac_save_cc="$CC"
663  CC="$CC -pg"
664  AC_TRY_RUN([int main() { return 0; }],
665    ac_enable_profiling="yes",
666    ac_enable_profiling="no",
667    ac_enable_profiling="no")
668  CC="$ac_save_cc"])
669 AC_MSG_RESULT($ac_enable_profiling)
671 case "$ac_enable_profiling" in
672     "yes")
673         BASECFLAGS="-pg $BASECFLAGS"
674         LDFLAGS="-pg $LDFLAGS"
675     ;;
676 esac
678 AC_MSG_CHECKING(LDLIBRARY)
680 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
681 # library that we build, but we do not want to link against it (we
682 # will find it with a -framework option). For this reason there is an
683 # extra variable BLDLIBRARY against which Python and the extension
684 # modules are linked, BLDLIBRARY. This is normally the same as
685 # LDLIBRARY, but empty for MacOSX framework builds.
686 if test "$enable_framework"
687 then
688   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
689   RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
690   BLDLIBRARY=''
691 else
692   BLDLIBRARY='$(LDLIBRARY)'
693 fi  
695 # Other platforms follow
696 if test $enable_shared = "yes"; then
697   AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
698   case $ac_sys_system in
699     CYGWIN*)
700           LDLIBRARY='libpython$(VERSION).dll.a'
701           DLLLIBRARY='libpython$(VERSION).dll'
702           ;;
703     SunOS*)
704           LDLIBRARY='libpython$(VERSION).so'
705           BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
706           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
707           INSTSONAME="$LDLIBRARY".$SOVERSION
708           ;;
709     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
710           LDLIBRARY='libpython$(VERSION).so'
711           BLDLIBRARY='-L. -lpython$(VERSION)'
712           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
713           case $ac_sys_system in
714               FreeBSD*)
715                 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
716                 ;;
717           esac
718           INSTSONAME="$LDLIBRARY".$SOVERSION
719           ;;
720     hp*|HP*)
721           case `uname -m` in
722                 ia64)
723                         LDLIBRARY='libpython$(VERSION).so'
724                         ;;
725                 *)
726                         LDLIBRARY='libpython$(VERSION).sl'
727                         ;;
728           esac
729           BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
730           RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
731           ;;
732     OSF*)
733           LDLIBRARY='libpython$(VERSION).so'
734           BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
735           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
736           ;;
737     atheos*)
738           LDLIBRARY='libpython$(VERSION).so'
739           BLDLIBRARY='-L. -lpython$(VERSION)'
740           RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
741           ;;
742     Darwin*)
743         LDLIBRARY='libpython$(VERSION).dylib'
744         BLDLIBRARY='-L. -lpython$(VERSION)'
745         RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
746         ;;
748   esac
749 else # shared is disabled
750   case $ac_sys_system in
751     CYGWIN*)
752           BLDLIBRARY='$(LIBRARY)'
753           LDLIBRARY='libpython$(VERSION).dll.a'
754           ;;
755   esac
758 AC_MSG_RESULT($LDLIBRARY)
760 AC_PROG_RANLIB
761 AC_SUBST(AR)
762 AC_CHECK_PROGS(AR, ar aal, ar)
764 # tweak ARFLAGS only if the user didn't set it on the command line
765 AC_SUBST(ARFLAGS)
766 if test -z "$ARFLAGS"
767 then
768         ARFLAGS="rc"
771 AC_SUBST(SVNVERSION)
772 AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
773 if test $SVNVERSION = found
774 then
775         SVNVERSION="svnversion \$(srcdir)"
776 else
777         SVNVERSION="echo Unversioned directory"
780 case $MACHDEP in
781 bsdos*|hp*|HP*)
782         # install -d does not work on BSDI or HP-UX
783         if test -z "$INSTALL"
784         then
785                 INSTALL="${srcdir}/install-sh -c"
786         fi
787 esac
788 AC_PROG_INSTALL
790 # Not every filesystem supports hard links
791 AC_SUBST(LN)
792 if test -z "$LN" ; then
793         case $ac_sys_system in
794                 CYGWIN*) LN="ln -s";;
795                 atheos*) LN="ln -s";;
796                 *) LN=ln;;
797         esac
800 # Check for --with-pydebug
801 AC_MSG_CHECKING(for --with-pydebug)
802 AC_ARG_WITH(pydebug, 
803             AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
805 if test "$withval" != no
806 then 
807   AC_DEFINE(Py_DEBUG, 1, 
808   [Define if you want to build an interpreter with many run-time checks.]) 
809   AC_MSG_RESULT(yes); 
810   Py_DEBUG='true'
811 else AC_MSG_RESULT(no); Py_DEBUG='false'
812 fi],
813 [AC_MSG_RESULT(no)])
815 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
816 # merged with this chunk of code?
818 # Optimizer/debugger flags
819 # ------------------------
820 # (The following bit of code is complicated enough - please keep things
821 # indented properly.  Just pretend you're editing Python code. ;-)
823 # There are two parallel sets of case statements below, one that checks to
824 # see if OPT was set and one that does BASECFLAGS setting based upon
825 # compiler and platform.  BASECFLAGS tweaks need to be made even if the
826 # user set OPT.
828 # tweak OPT based on compiler and platform, only if the user didn't set
829 # it on the command line
830 AC_SUBST(OPT)
831 if test "${OPT-unset}" == "unset"
832 then
833     case $GCC in
834     yes)
835         if test "$CC" != 'g++' ; then
836             STRICT_PROTO="-Wstrict-prototypes"
837         fi
838         # For gcc 4.x we need to use -fwrapv so lets check if its supported
839         if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
840            WRAP="-fwrapv"
841         fi
842         case $ac_cv_prog_cc_g in
843         yes)
844             if test "$Py_DEBUG" = 'true' ; then
845                 # Optimization messes up debuggers, so turn it off for
846                 # debug builds.
847                 OPT="-g -Wall $STRICT_PROTO"
848             else
849                 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
850             fi
851             ;;
852         *)
853             OPT="-O3 -Wall $STRICT_PROTO"
854             ;;
855         esac
856         case $ac_sys_system in
857             SCO_SV*) OPT="$OPT -m486 -DSCO5"
858             ;;
859         esac
860         ;;
862     *)
863         OPT="-O"
864         ;;
865     esac
868 AC_SUBST(BASECFLAGS)
870 # The -arch flags for universal builds on OSX
871 UNIVERSAL_ARCH_FLAGS=
872 AC_SUBST(UNIVERSAL_ARCH_FLAGS)
874 # tweak BASECFLAGS based on compiler and platform
875 case $GCC in
876 yes)
877     # Python violates C99 rules, by casting between incompatible
878     # pointer types. GCC may generate bad code as a result of that,
879     # so use -fno-strict-aliasing if supported.
880     AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
881      ac_save_cc="$CC"
882      CC="$CC -fno-strict-aliasing"
883      AC_TRY_RUN([int main() { return 0; }],
884      ac_cv_no_strict_aliasing_ok=yes,
885      ac_cv_no_strict_aliasing_ok=no,
886      ac_cv_no_strict_aliasing_ok=no)
887      CC="$ac_save_cc"
888     AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
889     if test $ac_cv_no_strict_aliasing_ok = yes
890     then
891       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
892     fi
894     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
895     # support.  Without this, treatment of subnormals doesn't follow
896     # the standard.
897     case $ac_sys_machine in
898          alpha*)
899                 BASECFLAGS="$BASECFLAGS -mieee"
900                 ;;
901     esac
903     case $ac_sys_system in
904         SCO_SV*)
905             BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
906             ;;
907         # is there any other compiler on Darwin besides gcc?
908         Darwin*)
909             # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
910             # used to be here, but non-Apple gcc doesn't accept them.
913             if test "${enable_universalsdk}"; then
914                 UNIVERSAL_ARCH_FLAGS=""
915                 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
916                    UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
917                    ARCH_RUN_32BIT=""
919                  elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
920                    UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
921                    ARCH_RUN_32BIT="true"
923                  elif test "$UNIVERSAL_ARCHS" = "all" ; then
924                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
925                    ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
927                  elif test "$UNIVERSAL_ARCHS" = "intel" ; then
928                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
929                    ARCH_RUN_32BIT="/usr/bin/arch -i386"
931                  elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
932                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
933                    ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
935                  else
936                    AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
938                  fi
941                 BASECFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
942                 tgt=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
943                 if test "${UNIVERSALSDK}" != "/" -a "${tgt}" '>' '10.4' ; then
944                         CFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${CFLAGS}"
945                 fi
946             fi
948             # Calculate the right deployment target for this build.
949             #
950             cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
951             if test ${cur_target} '>' 10.2; then
952                     cur_target=10.3
953                     if test ${enable_universalsdk}; then
954                             if test "${UNIVERSAL_ARCHS}" = "all"; then
955                                     # Ensure that the default platform for a 
956                                     # 4-way universal build is OSX 10.5, 
957                                     # that's the first OS release where 
958                                     # 4-way builds make sense.
959                                     cur_target='10.5'
961                             elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
962                                     cur_target='10.5'
964                             elif test "${UNIVERSAL_ARCHS}" = "intel"; then
965                                     cur_target='10.5'
967                             elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
968                                     cur_target='10.5'
969                             fi
970                     else
971                             if test `/usr/bin/arch` = "i386"; then
972                                     # On Intel macs default to a deployment
973                                     # target of 10.4, that's the first OSX
974                                     # release with Intel support.
975                                     cur_target="10.4"
976                             fi
977                     fi
978             fi
979             CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
980             
981             # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
982             # environment with a value that is the same as what we'll use
983             # in the Makefile to ensure that we'll get the same compiler
984             # environment during configure and build time.
985             MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
986             export MACOSX_DEPLOYMENT_TARGET
987             EXPORT_MACOSX_DEPLOYMENT_TARGET=''
989             ;;
990         OSF*)
991             BASECFLAGS="$BASECFLAGS -mieee"
992             ;;
993     esac
994     ;;
997     case $ac_sys_system in
998     OpenUNIX*|UnixWare*)
999         BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1000         ;;
1001     OSF*)
1002         BASECFLAGS="$BASECFLAGS -ieee -std"
1003         ;;
1004     SCO_SV*)
1005         BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1006         ;;
1007     esac
1008     ;;
1009 esac
1011 if test "$Py_DEBUG" = 'true'; then
1012   :
1013 else
1014   OPT="-DNDEBUG $OPT"
1017 if test "$ac_arch_flags"
1018 then
1019         BASECFLAGS="$BASECFLAGS $ac_arch_flags"
1022 # disable check for icc since it seems to pass, but generates a warning
1023 if test "$CC" = icc
1024 then
1025   ac_cv_opt_olimit_ok=no
1028 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1029 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1030 [ac_save_cc="$CC"
1031 CC="$CC -OPT:Olimit=0"
1032 AC_TRY_RUN([int main() { return 0; }],
1033   ac_cv_opt_olimit_ok=yes,
1034   ac_cv_opt_olimit_ok=no,
1035   ac_cv_opt_olimit_ok=no)
1036 CC="$ac_save_cc"])
1037 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
1038 if test $ac_cv_opt_olimit_ok = yes; then
1039     case $ac_sys_system in
1040         # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1041         # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
1042         # environment?
1043         Darwin*)
1044             ;;
1045         *)
1046             BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1047             ;;
1048     esac
1049 else
1050   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1051   AC_CACHE_VAL(ac_cv_olimit_ok,
1052   [ac_save_cc="$CC"
1053   CC="$CC -Olimit 1500"
1054   AC_TRY_RUN([int main() { return 0; }],
1055     ac_cv_olimit_ok=yes,
1056     ac_cv_olimit_ok=no,
1057     ac_cv_olimit_ok=no)
1058   CC="$ac_save_cc"])
1059   AC_MSG_RESULT($ac_cv_olimit_ok)
1060   if test $ac_cv_olimit_ok = yes; then
1061     BASECFLAGS="$BASECFLAGS -Olimit 1500"
1062   fi
1065 # Check whether GCC supports PyArg_ParseTuple format
1066 if test "$GCC" = "yes"
1067 then
1068   AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1069   save_CFLAGS=$CFLAGS
1070   CFLAGS="$CFLAGS -Werror"
1071   AC_TRY_COMPILE([
1072     void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
1073   ],,
1074   AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1075   AC_MSG_RESULT(yes),
1076   AC_MSG_RESULT(no)
1077   )
1078   CFLAGS=$save_CFLAGS
1081 # On some compilers, pthreads are available without further options
1082 # (e.g. MacOS X). On some of these systems, the compiler will not
1083 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1084 # So we have to see first whether pthreads are available without
1085 # options before we can check whether -Kpthread improves anything.
1086 AC_MSG_CHECKING(whether pthreads are available without options)
1087 AC_CACHE_VAL(ac_cv_pthread_is_default,
1088 [AC_TRY_RUN([
1089 #include <pthread.h>
1091 void* routine(void* p){return NULL;}
1093 int main(){
1094   pthread_t p;
1095   if(pthread_create(&p,NULL,routine,NULL)!=0)
1096     return 1;
1097   (void)pthread_detach(p);
1098   return 0;
1102   ac_cv_pthread_is_default=yes
1103   ac_cv_kthread=no
1104   ac_cv_pthread=no
1106   ac_cv_pthread_is_default=no,
1107   ac_cv_pthread_is_default=no)
1109 AC_MSG_RESULT($ac_cv_pthread_is_default)
1112 if test $ac_cv_pthread_is_default = yes 
1113 then
1114   ac_cv_kpthread=no
1115 else
1116 # -Kpthread, if available, provides the right #defines
1117 # and linker options to make pthread_create available
1118 # Some compilers won't report that they do not support -Kpthread,
1119 # so we need to run a program to see whether it really made the
1120 # function available.
1121 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1122 AC_CACHE_VAL(ac_cv_kpthread,
1123 [ac_save_cc="$CC"
1124 CC="$CC -Kpthread"
1125 AC_TRY_RUN([
1126 #include <pthread.h>
1128 void* routine(void* p){return NULL;}
1130 int main(){
1131   pthread_t p;
1132   if(pthread_create(&p,NULL,routine,NULL)!=0)
1133     return 1;
1134   (void)pthread_detach(p);
1135   return 0;
1138   ac_cv_kpthread=yes,
1139   ac_cv_kpthread=no,
1140   ac_cv_kpthread=no)
1141 CC="$ac_save_cc"])
1142 AC_MSG_RESULT($ac_cv_kpthread)
1145 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
1146 then
1147 # -Kthread, if available, provides the right #defines
1148 # and linker options to make pthread_create available
1149 # Some compilers won't report that they do not support -Kthread,
1150 # so we need to run a program to see whether it really made the
1151 # function available.
1152 AC_MSG_CHECKING(whether $CC accepts -Kthread)
1153 AC_CACHE_VAL(ac_cv_kthread,
1154 [ac_save_cc="$CC"
1155 CC="$CC -Kthread"
1156 AC_TRY_RUN([
1157 #include <pthread.h>
1159 void* routine(void* p){return NULL;}
1161 int main(){
1162   pthread_t p;
1163   if(pthread_create(&p,NULL,routine,NULL)!=0)
1164     return 1;
1165   (void)pthread_detach(p);
1166   return 0;
1169   ac_cv_kthread=yes,
1170   ac_cv_kthread=no,
1171   ac_cv_kthread=no)
1172 CC="$ac_save_cc"])
1173 AC_MSG_RESULT($ac_cv_kthread)
1176 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
1177 then
1178 # -pthread, if available, provides the right #defines
1179 # and linker options to make pthread_create available
1180 # Some compilers won't report that they do not support -pthread,
1181 # so we need to run a program to see whether it really made the
1182 # function available.
1183 AC_MSG_CHECKING(whether $CC accepts -pthread)
1184 AC_CACHE_VAL(ac_cv_thread,
1185 [ac_save_cc="$CC"
1186 CC="$CC -pthread"
1187 AC_TRY_RUN([
1188 #include <pthread.h>
1190 void* routine(void* p){return NULL;}
1192 int main(){
1193   pthread_t p;
1194   if(pthread_create(&p,NULL,routine,NULL)!=0)
1195     return 1;
1196   (void)pthread_detach(p);
1197   return 0;
1200   ac_cv_pthread=yes,
1201   ac_cv_pthread=no,
1202   ac_cv_pthread=no)
1203 CC="$ac_save_cc"])
1204 AC_MSG_RESULT($ac_cv_pthread)
1207 # If we have set a CC compiler flag for thread support then
1208 # check if it works for CXX, too.
1209 ac_cv_cxx_thread=no
1210 if test ! -z "$CXX"
1211 then
1212 AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1213 ac_save_cxx="$CXX"
1215 if test "$ac_cv_kpthread" = "yes"
1216 then
1217   CXX="$CXX -Kpthread"  
1218   ac_cv_cxx_thread=yes
1219 elif test "$ac_cv_kthread" = "yes"
1220 then
1221   CXX="$CXX -Kthread"
1222   ac_cv_cxx_thread=yes
1223 elif test "$ac_cv_pthread" = "yes"
1224 then 
1225   CXX="$CXX -pthread"
1226   ac_cv_cxx_thread=yes
1229 if test $ac_cv_cxx_thread = yes
1230 then
1231   echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1232   $CXX -c conftest.$ac_ext 2>&5
1233   if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1234      && test -s conftest$ac_exeext && ./conftest$ac_exeext
1235   then
1236     ac_cv_cxx_thread=yes
1237   else
1238     ac_cv_cxx_thread=no
1239   fi
1240   rm -fr conftest*
1242 AC_MSG_RESULT($ac_cv_cxx_thread)
1244 CXX="$ac_save_cxx"
1246 dnl # check for ANSI or K&R ("traditional") preprocessor
1247 dnl AC_MSG_CHECKING(for C preprocessor type)
1248 dnl AC_TRY_COMPILE([
1249 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1250 dnl int foo;
1251 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1252 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1253 dnl AC_MSG_RESULT($cpp_type)
1255 # checks for header files
1256 AC_HEADER_STDC
1257 AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1258 fcntl.h grp.h \
1259 ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
1260 shadow.h signal.h stdint.h stropts.h termios.h thread.h \
1261 unistd.h utime.h \
1262 sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1263 sys/lock.h sys/mkdev.h sys/modem.h \
1264 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
1265 sys/termio.h sys/time.h \
1266 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
1267 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
1268 bluetooth/bluetooth.h linux/tipc.h)
1269 AC_HEADER_DIRENT
1270 AC_HEADER_MAJOR
1272 # On Solaris, term.h requires curses.h
1273 AC_CHECK_HEADERS(term.h,,,[
1274 #ifdef HAVE_CURSES_H
1275 #include <curses.h>
1276 #endif
1279 # On Linux, netlink.h requires asm/types.h
1280 AC_CHECK_HEADERS(linux/netlink.h,,,[
1281 #ifdef HAVE_ASM_TYPES_H
1282 #include <asm/types.h>
1283 #endif
1284 #ifdef HAVE_SYS_SOCKET_H
1285 #include <sys/socket.h>
1286 #endif
1289 # checks for typedefs
1290 was_it_defined=no
1291 AC_MSG_CHECKING(for clock_t in time.h)
1292 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1293     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1295 AC_MSG_RESULT($was_it_defined)
1297 # Check whether using makedev requires defining _OSF_SOURCE
1298 AC_MSG_CHECKING(for makedev)
1299 AC_TRY_LINK([#include <sys/types.h> ],
1300             [ makedev(0, 0) ],
1301             ac_cv_has_makedev=yes,
1302             ac_cv_has_makedev=no)
1303 if test "$ac_cv_has_makedev" = "no"; then
1304     # we didn't link, try if _OSF_SOURCE will allow us to link
1305     AC_TRY_LINK([
1306 #define _OSF_SOURCE 1
1307 #include <sys/types.h>
1308     ],
1309     [ makedev(0, 0) ],
1310     ac_cv_has_makedev=yes,
1311     ac_cv_has_makedev=no)
1312     if test "$ac_cv_has_makedev" = "yes"; then
1313         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1314     fi
1316 AC_MSG_RESULT($ac_cv_has_makedev)
1317 if test "$ac_cv_has_makedev" = "yes"; then
1318     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1321 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1322 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1323 # defined, but the compiler does not support pragma redefine_extname,
1324 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1325 # structures (such as rlimit64) without declaring them. As a
1326 # work-around, disable LFS on such configurations
1328 use_lfs=yes
1329 AC_MSG_CHECKING(Solaris LFS bug)
1330 AC_TRY_COMPILE([
1331 #define _LARGEFILE_SOURCE 1
1332 #define _FILE_OFFSET_BITS 64
1333 #include <sys/resource.h>
1334 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1335 AC_MSG_RESULT($sol_lfs_bug)
1336 if test "$sol_lfs_bug" = "yes"; then
1337   use_lfs=no
1340 if test "$use_lfs" = "yes"; then
1341 # Two defines needed to enable largefile support on various platforms
1342 # These may affect some typedefs
1343 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
1344 [This must be defined on some systems to enable large file support.])
1345 AC_DEFINE(_FILE_OFFSET_BITS, 64,
1346 [This must be set to 64 on some systems to enable large file support.])
1349 # Add some code to confdefs.h so that the test for off_t works on SCO
1350 cat >> confdefs.h <<\EOF
1351 #if defined(SCO_DS)
1352 #undef _OFF_T
1353 #endif
1356 # Type availability checks
1357 AC_TYPE_MODE_T
1358 AC_TYPE_OFF_T
1359 AC_TYPE_PID_T
1360 AC_TYPE_SIGNAL
1361 AC_TYPE_SIZE_T
1362 AC_TYPE_UID_T
1363 AC_TYPE_UINT32_T
1364 AC_TYPE_UINT64_T
1365 AC_TYPE_INT32_T
1366 AC_TYPE_INT64_T
1367 AC_CHECK_TYPE(ssize_t,
1368   AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
1370 # Sizes of various common basic types
1371 # ANSI C requires sizeof(char) == 1, so no need to check it
1372 AC_CHECK_SIZEOF(int, 4)
1373 AC_CHECK_SIZEOF(long, 4)
1374 AC_CHECK_SIZEOF(void *, 4)
1375 AC_CHECK_SIZEOF(short, 2)
1376 AC_CHECK_SIZEOF(float, 4)
1377 AC_CHECK_SIZEOF(double, 8)
1378 AC_CHECK_SIZEOF(fpos_t, 4)
1379 AC_CHECK_SIZEOF(size_t, 4)
1380 AC_CHECK_SIZEOF(pid_t, 4)
1382 AC_MSG_CHECKING(for long long support)
1383 have_long_long=no
1384 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1385   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
1386   have_long_long=yes
1388 AC_MSG_RESULT($have_long_long)
1389 if test "$have_long_long" = yes ; then
1390 AC_CHECK_SIZEOF(long long, 8)
1393 AC_MSG_CHECKING(for long double support)
1394 have_long_double=no
1395 AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
1396   AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.]) 
1397   have_long_double=yes
1399 AC_MSG_RESULT($have_long_double)
1400 if test "$have_long_double" = yes ; then
1401 AC_CHECK_SIZEOF(long double, 16)
1405 AC_MSG_CHECKING(for _Bool support)
1406 have_c99_bool=no
1407 AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1408   AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) 
1409   have_c99_bool=yes
1411 AC_MSG_RESULT($have_c99_bool)
1412 if test "$have_c99_bool" = yes ; then
1413 AC_CHECK_SIZEOF(_Bool, 1)
1416 AC_CHECK_TYPES(uintptr_t, 
1417    [AC_CHECK_SIZEOF(uintptr_t, 4)], 
1418    [], [#ifdef HAVE_STDINT_H
1419         #include <stdint.h>
1420         #endif])
1423 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1424 AC_MSG_CHECKING(size of off_t)
1425 AC_CACHE_VAL(ac_cv_sizeof_off_t,
1426 [AC_TRY_RUN([#include <stdio.h>
1427 #include <sys/types.h>
1428 main()
1430   FILE *f=fopen("conftestval", "w");
1431   if (!f) exit(1);
1432   fprintf(f, "%d\n", sizeof(off_t));
1433   exit(0);
1435 ac_cv_sizeof_off_t=`cat conftestval`,
1436 ac_cv_sizeof_off_t=0,
1437 ac_cv_sizeof_off_t=4)
1439 AC_MSG_RESULT($ac_cv_sizeof_off_t)
1440 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1441 [The number of bytes in an off_t.])
1443 AC_MSG_CHECKING(whether to enable large file support)
1444 if test "$have_long_long" = yes
1445 then
1446 if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1447         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1448   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
1449   [Defined to enable large file support when an off_t is bigger than a long
1450    and long long is available and at least as big as an off_t. You may need
1451    to add some flags for configuration and compilation to enable this mode.
1452    (For Solaris and Linux, the necessary defines are already defined.)])
1453   AC_MSG_RESULT(yes)
1454 else
1455   AC_MSG_RESULT(no)
1457 else
1458   AC_MSG_RESULT(no)
1461 # AC_CHECK_SIZEOF() doesn't include <time.h>.
1462 AC_MSG_CHECKING(size of time_t)
1463 AC_CACHE_VAL(ac_cv_sizeof_time_t,
1464 [AC_TRY_RUN([#include <stdio.h>
1465 #include <time.h>
1466 main()
1468   FILE *f=fopen("conftestval", "w");
1469   if (!f) exit(1);
1470   fprintf(f, "%d\n", sizeof(time_t));
1471   exit(0);
1473 ac_cv_sizeof_time_t=`cat conftestval`,
1474 ac_cv_sizeof_time_t=0,
1475 ac_cv_sizeof_time_t=4)
1477 AC_MSG_RESULT($ac_cv_sizeof_time_t)
1478 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
1479 [The number of bytes in a time_t.])
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() doesn't include <pthread.h>.
1497   AC_MSG_CHECKING(size of pthread_t)
1498   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1499   [AC_TRY_RUN([#include <stdio.h>
1500 #include <pthread.h>
1501   main()
1502   {
1503     FILE *f=fopen("conftestval", "w");
1504     if (!f) exit(1);
1505     fprintf(f, "%d\n", sizeof(pthread_t));
1506     exit(0);
1507   }],
1508   ac_cv_sizeof_pthread_t=`cat conftestval`,
1509   ac_cv_sizeof_pthread_t=0,
1510   ac_cv_sizeof_pthread_t=4)
1511   ])
1512   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
1513   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1514    [The number of bytes in a pthread_t.])
1516 CC="$ac_save_cc"
1520 AC_SUBST(OTHER_LIBTOOL_OPT)
1521 case $ac_sys_system/$ac_sys_release in
1522   Darwin/@<:@01567@:>@\..*) 
1523     OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1524     ;;
1525   Darwin/*)
1526     OTHER_LIBTOOL_OPT=""
1527     ;;
1528 esac
1531 ARCH_RUN_32BIT=""
1532 AC_SUBST(LIBTOOL_CRUFT)
1533 case $ac_sys_system/$ac_sys_release in
1534   Darwin/@<:@01567@:>@\..*) 
1535     LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1536     if test "${enable_universalsdk}"; then
1537             :
1538     else
1539         LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
1540     fi
1541     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1542     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1543   Darwin/*)
1544     gcc_version=`gcc -dumpversion`
1545     if test ${gcc_version} '<' 4.0
1546         then
1547             LIBTOOL_CRUFT="-lcc_dynamic"
1548         else 
1549             LIBTOOL_CRUFT=""
1550     fi
1551     AC_TRY_RUN([
1552     #include <unistd.h>
1553     int main(int argc, char*argv[])
1554     {
1555       if (sizeof(long) == 4) {
1556           return 0;
1557       } else {
1558           return 1;
1559       }
1560     }
1561     ], ac_osx_32bit=yes,
1562        ac_osx_32bit=no,
1563        ac_osx_32bit=yes)
1564     
1565     if test "${ac_osx_32bit}" = "yes"; then
1566         case `/usr/bin/arch` in
1567         i386) 
1568                 MACOSX_DEFAULT_ARCH="i386" 
1569                 ;;
1570         ppc) 
1571                 MACOSX_DEFAULT_ARCH="ppc" 
1572                 ;;
1573         *)
1574                 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1575                 ;;
1576         esac
1577     else
1578         case `/usr/bin/arch` in
1579         i386) 
1580                 MACOSX_DEFAULT_ARCH="x86_64" 
1581                 ;;
1582         ppc) 
1583                 MACOSX_DEFAULT_ARCH="ppc64" 
1584                 ;;
1585         *)
1586                 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1587                 ;;
1588         esac
1590         #ARCH_RUN_32BIT="true"
1591     fi
1593     LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
1594     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1595     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1596 esac
1598 AC_MSG_CHECKING(for --enable-framework)
1599 if test "$enable_framework"
1600 then
1601         BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1602         # -F. is needed to allow linking to the framework while 
1603         # in the build location.
1604         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
1605          [Define if you want to produce an OpenStep/Rhapsody framework
1606          (shared library plus accessory files).])
1607         AC_MSG_RESULT(yes)
1608         if test $enable_shared = "yes"
1609         then
1610                 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead])
1611         fi
1612 else
1613         AC_MSG_RESULT(no)
1616 AC_MSG_CHECKING(for dyld)
1617 case $ac_sys_system/$ac_sys_release in
1618   Darwin/*)
1619         AC_DEFINE(WITH_DYLD, 1, 
1620         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1621          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1622          linker (rld). Dyld is necessary to support frameworks.])
1623         AC_MSG_RESULT(always on for Darwin)
1624         ;;
1625   *)
1626         AC_MSG_RESULT(no)
1627         ;;
1628 esac
1630 # Set info about shared libraries.
1631 AC_SUBST(SO)
1632 AC_SUBST(LDSHARED)
1633 AC_SUBST(BLDSHARED)
1634 AC_SUBST(CCSHARED)
1635 AC_SUBST(LINKFORSHARED)
1636 # SO is the extension of shared libraries `(including the dot!)
1637 # -- usually .so, .sl on HP-UX, .dll on Cygwin
1638 AC_MSG_CHECKING(SO)
1639 if test -z "$SO"
1640 then
1641         case $ac_sys_system in
1642         hp*|HP*)
1643                 case `uname -m` in
1644                         ia64) SO=.so;;
1645                         *)    SO=.sl;;
1646                 esac
1647                 ;;
1648         CYGWIN*)   SO=.dll;;
1649         *)         SO=.so;;
1650         esac
1651 else
1652         # this might also be a termcap variable, see #610332
1653         echo
1654         echo '====================================================================='
1655         echo '+                                                                   +'
1656         echo '+ WARNING: You have set SO in your environment.                     +'
1657         echo '+ Do you really mean to change the extension for shared libraries?  +'
1658         echo '+ Continuing in 10 seconds to let you to ponder.                    +'
1659         echo '+                                                                   +'
1660         echo '====================================================================='
1661         sleep 10
1663 AC_MSG_RESULT($SO)
1665 AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
1666 # LDSHARED is the ld *command* used to create shared library
1667 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1668 # (Shared libraries in this instance are shared modules to be loaded into
1669 # Python, as opposed to building Python itself as a shared library.)
1670 AC_MSG_CHECKING(LDSHARED)
1671 if test -z "$LDSHARED"
1672 then
1673         case $ac_sys_system/$ac_sys_release in
1674         AIX*)
1675                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1676                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1677                 ;;
1678         IRIX/5*) LDSHARED="ld -shared";;
1679         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1680         SunOS/5*) 
1681                 if test "$GCC" = "yes"
1682                 then LDSHARED='$(CC) -shared'
1683                 else LDSHARED='$(CC) -G';
1684                 fi ;;
1685         hp*|HP*)
1686                 if test "$GCC" = "yes"
1687                 then LDSHARED='$(CC) -shared'
1688                 else LDSHARED='ld -b';
1689                 fi ;;
1690         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1691         Darwin/1.3*)
1692                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1693                 if test "$enable_framework" ; then
1694                         # Link against the framework. All externals should be defined.
1695                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1696                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1697                 else
1698                         # No framework. Ignore undefined symbols, assuming they come from Python
1699                         LDSHARED="$LDSHARED -undefined suppress"
1700                 fi ;;
1701         Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1702                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1703                 if test "$enable_framework" ; then
1704                         # Link against the framework. All externals should be defined.
1705                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1706                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1707                 else
1708                         # No framework, use the Python app as bundle-loader
1709                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1710                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1711                 fi ;;
1712         Darwin/*)
1713                 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1714                 # This allows an extension to be used in any Python
1716                 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
1717                 then
1718                         if test "${enable_universalsdk}"; then
1719                                 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1720                         fi
1721                         LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1722                         BLDSHARED="$LDSHARED"
1723                 else
1724                         LDSHARED='$(CC) $(LDFLAGS) -bundle'
1725                         if test "$enable_framework" ; then
1726                                 # Link against the framework. All externals should be defined.
1727                                 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1728                                 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1729                         else
1730                                 # No framework, use the Python app as bundle-loader
1731                                 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1732                                 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1733                         fi
1734                 fi
1735                 ;;
1736         Linux*|GNU*|QNX*) LDSHARED='$(CC) -shared';;
1737         BSD/OS*/4*) LDSHARED="gcc -shared";;
1738         FreeBSD*)
1739                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1740                 then
1741                         LDSHARED="$CC -shared ${LDFLAGS}"
1742                 else
1743                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1744                 fi;;
1745         OpenBSD*)
1746                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1747                 then
1748                                 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1749                 else
1750                                 case `uname -r` in
1751                                 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1752                                    LDSHARED="ld -Bshareable ${LDFLAGS}"
1753                                    ;;
1754                                 *)
1755                                    LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1756                                    ;;
1757                                 esac
1758                 fi;;
1759         NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
1760         OpenUNIX*|UnixWare*)
1761                 if test "$GCC" = "yes"
1762                 then LDSHARED='$(CC) -shared'
1763                 else LDSHARED='$(CC) -G'
1764                 fi;;
1765         SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1766         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1767         atheos*) LDSHARED="gcc -shared";;
1768         *)      LDSHARED="ld";;
1769         esac
1771 AC_MSG_RESULT($LDSHARED)
1772 BLDSHARED=${BLDSHARED-$LDSHARED}
1773 # CCSHARED are the C *flags* used to create objects to go into a shared
1774 # library (module) -- this is only needed for a few systems
1775 AC_MSG_CHECKING(CCSHARED)
1776 if test -z "$CCSHARED"
1777 then
1778         case $ac_sys_system/$ac_sys_release in
1779         SunOS*) if test "$GCC" = yes;
1780                 then CCSHARED="-fPIC";
1781                 elif test `uname -p` = sparc;
1782                 then CCSHARED="-xcode=pic32";
1783                 else CCSHARED="-Kpic";
1784                 fi;;
1785         hp*|HP*) if test "$GCC" = yes;
1786                  then CCSHARED="-fPIC";
1787                  else CCSHARED="+z";
1788                  fi;;
1789         Linux*|GNU*) CCSHARED="-fPIC";;
1790         BSD/OS*/4*) CCSHARED="-fpic";;
1791         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
1792         OpenUNIX*|UnixWare*)
1793                 if test "$GCC" = "yes"
1794                 then CCSHARED="-fPIC"
1795                 else CCSHARED="-KPIC"
1796                 fi;;
1797         SCO_SV*)
1798                 if test "$GCC" = "yes"
1799                 then CCSHARED="-fPIC"
1800                 else CCSHARED="-Kpic -belf"
1801                 fi;;
1802         IRIX*/6*)  case $CC in
1803                    *gcc*) CCSHARED="-shared";;
1804                    *) CCSHARED="";;
1805                    esac;;
1806         atheos*) CCSHARED="-fPIC";;
1807         esac
1809 AC_MSG_RESULT($CCSHARED)
1810 # LINKFORSHARED are the flags passed to the $(CC) command that links
1811 # the python executable -- this is only needed for a few systems
1812 AC_MSG_CHECKING(LINKFORSHARED)
1813 if test -z "$LINKFORSHARED"
1814 then
1815         case $ac_sys_system/$ac_sys_release in
1816         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1817         hp*|HP*)
1818             LINKFORSHARED="-Wl,-E -Wl,+s";;
1819 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1820         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1821         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1822         # -u libsys_s pulls in all symbols in libsys
1823         Darwin/*) 
1824                 LINKFORSHARED="$extra_undefs -framework CoreFoundation"
1825                 if test "$enable_framework"
1826                 then
1827                         LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1828                 fi
1829                 LINKFORSHARED="$LINKFORSHARED";;
1830         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1831         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1832         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1833         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) 
1834                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1835                 then
1836                         LINKFORSHARED="-Wl,--export-dynamic"
1837                 fi;;
1838         SunOS/5*) case $CC in
1839                   *gcc*)
1840                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1841                     then
1842                         LINKFORSHARED="-Xlinker --export-dynamic"
1843                     fi;;
1844                   esac;;
1845         CYGWIN*)
1846                 if test $enable_shared = "no"
1847                 then
1848                         LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1849                 fi;;
1850         QNX*)
1851                 # -Wl,-E causes the symbols to be added to the dynamic
1852                 # symbol table so that they can be found when a module
1853                 # is loaded.  -N 2048K causes the stack size to be set
1854                 # to 2048 kilobytes so that the stack doesn't overflow
1855                 # when running test_compile.py.
1856                 LINKFORSHARED='-Wl,-E -N 2048K';;
1857         esac
1859 AC_MSG_RESULT($LINKFORSHARED)
1862 AC_SUBST(CFLAGSFORSHARED)
1863 AC_MSG_CHECKING(CFLAGSFORSHARED)
1864 if test ! "$LIBRARY" = "$LDLIBRARY"
1865 then
1866         case $ac_sys_system in
1867         CYGWIN*)
1868                 # Cygwin needs CCSHARED when building extension DLLs
1869                 # but not when building the interpreter DLL.
1870                 CFLAGSFORSHARED='';;
1871         *)
1872                 CFLAGSFORSHARED='$(CCSHARED)'
1873         esac
1875 AC_MSG_RESULT($CFLAGSFORSHARED)
1877 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1878 # library (with --enable-shared).
1879 # For platforms on which shared libraries are not allowed to have unresolved
1880 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1881 # if it is not required, since it creates a dependency of the shared library
1882 # to LIBS. This, in turn, means that applications linking the shared libpython
1883 # don't need to link LIBS explicitly. The default should be only changed
1884 # on systems where this approach causes problems.
1885 AC_SUBST(SHLIBS)
1886 AC_MSG_CHECKING(SHLIBS)
1887 case "$ac_sys_system" in
1888         *)
1889                 SHLIBS='$(LIBS)';;
1890 esac
1891 AC_MSG_RESULT($SHLIBS)
1894 # checks for libraries
1895 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1896 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1898 # only check for sem_init if thread support is requested
1899 if test "$with_threads" = "yes" -o -z "$with_threads"; then
1900     AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1901                                                 # posix4 on Solaris 2.6
1902                                                 # pthread (first!) on Linux
1905 # check if we need libintl for locale functions
1906 AC_CHECK_LIB(intl, textdomain,
1907         [AC_DEFINE(WITH_LIBINTL, 1,
1908         [Define to 1 if libintl is needed for locale functions.])
1909         LIBS="-lintl $LIBS"])
1911 # checks for system dependent C++ extensions support
1912 case "$ac_sys_system" in
1913         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1914                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1915                             [loadAndInit("", 0, "")],
1916                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1917                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1918                        and you want support for AIX C++ shared extension modules.])
1919                              AC_MSG_RESULT(yes)],
1920                             [AC_MSG_RESULT(no)]);;
1921         *) ;;
1922 esac
1924 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1925 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1926 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1928 AC_MSG_CHECKING(for --with-libs)
1929 AC_ARG_WITH(libs,
1930             AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1932 AC_MSG_RESULT($withval)
1933 LIBS="$withval $LIBS"
1935 [AC_MSG_RESULT(no)])
1937 # Check for use of the system libffi library
1938 AC_MSG_CHECKING(for --with-system-ffi)
1939 AC_ARG_WITH(system_ffi,
1940             AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1942 AC_MSG_RESULT($with_system_ffi)
1944 # Check for --with-dbmliborder
1945 AC_MSG_CHECKING(for --with-dbmliborder)
1946 AC_ARG_WITH(dbmliborder,
1947             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'.]),
1949 if test x$with_dbmliborder = xyes
1950 then
1951 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1952 else
1953   for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
1954     if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
1955     then
1956       AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
1957     fi
1958   done
1959 fi])
1960 AC_MSG_RESULT($with_dbmliborder)
1962 # Determine if signalmodule should be used.
1963 AC_SUBST(USE_SIGNAL_MODULE)
1964 AC_SUBST(SIGNAL_OBJS)
1965 AC_MSG_CHECKING(for --with-signal-module)
1966 AC_ARG_WITH(signal-module,
1967             AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1969 if test -z "$with_signal_module"
1970 then with_signal_module="yes"
1972 AC_MSG_RESULT($with_signal_module)
1974 if test "${with_signal_module}" = "yes"; then
1975         USE_SIGNAL_MODULE=""
1976         SIGNAL_OBJS=""
1977 else
1978         USE_SIGNAL_MODULE="#"
1979         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1982 # This is used to generate Setup.config
1983 AC_SUBST(USE_THREAD_MODULE)
1984 USE_THREAD_MODULE=""
1986 AC_MSG_CHECKING(for --with-dec-threads)
1987 AC_SUBST(LDLAST)
1988 AC_ARG_WITH(dec-threads,
1989             AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1991 AC_MSG_RESULT($withval)
1992 LDLAST=-threads
1993 if test "${with_thread+set}" != set; then
1994    with_thread="$withval";
1995 fi],
1996 [AC_MSG_RESULT(no)])
1998 # Templates for things AC_DEFINEd more than once.
1999 # For a single AC_DEFINE, no template is needed.
2000 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2001 AH_TEMPLATE(_REENTRANT,
2002   [Define to force use of thread-safe errno, h_errno, and other functions])
2003 AH_TEMPLATE(WITH_THREAD,
2004   [Define if you want to compile in rudimentary thread support])
2006 AC_MSG_CHECKING(for --with-threads)
2007 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2008 AC_ARG_WITH(threads,
2009             AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
2011 # --with-thread is deprecated, but check for it anyway
2012 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2013 AC_ARG_WITH(thread,
2014             AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
2015             [with_threads=$with_thread])
2017 if test -z "$with_threads"
2018 then with_threads="yes"
2020 AC_MSG_RESULT($with_threads)
2022 AC_SUBST(THREADOBJ)
2023 if test "$with_threads" = "no"
2024 then
2025     USE_THREAD_MODULE="#"
2026 elif test "$ac_cv_pthread_is_default" = yes
2027 then
2028     AC_DEFINE(WITH_THREAD)
2029     # Defining _REENTRANT on system with POSIX threads should not hurt.
2030     AC_DEFINE(_REENTRANT)
2031     posix_threads=yes
2032     THREADOBJ="Python/thread.o"    
2033 elif test "$ac_cv_kpthread" = "yes"
2034 then
2035     CC="$CC -Kpthread"
2036     if test "$ac_cv_cxx_thread" = "yes"; then
2037         CXX="$CXX -Kpthread"
2038     fi
2039     AC_DEFINE(WITH_THREAD)
2040     posix_threads=yes
2041     THREADOBJ="Python/thread.o"
2042 elif test "$ac_cv_kthread" = "yes"
2043 then
2044     CC="$CC -Kthread"
2045     if test "$ac_cv_cxx_thread" = "yes"; then
2046         CXX="$CXX -Kthread"
2047     fi
2048     AC_DEFINE(WITH_THREAD)
2049     posix_threads=yes
2050     THREADOBJ="Python/thread.o"
2051 elif test "$ac_cv_pthread" = "yes"
2052 then
2053     CC="$CC -pthread"
2054     if test "$ac_cv_cxx_thread" = "yes"; then
2055         CXX="$CXX -pthread"
2056     fi
2057     AC_DEFINE(WITH_THREAD)
2058     posix_threads=yes
2059     THREADOBJ="Python/thread.o"
2060 else
2061     if test ! -z "$with_threads" -a -d "$with_threads"
2062     then LDFLAGS="$LDFLAGS -L$with_threads"
2063     fi
2064     if test ! -z "$withval" -a -d "$withval"
2065     then LDFLAGS="$LDFLAGS -L$withval"
2066     fi
2068     # According to the POSIX spec, a pthreads implementation must
2069     # define _POSIX_THREADS in unistd.h. Some apparently don't
2070     # (e.g. gnu pth with pthread emulation)
2071     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2072     AC_EGREP_CPP(yes,
2073     [
2074 #include <unistd.h>
2075 #ifdef _POSIX_THREADS
2077 #endif
2078     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2079     AC_MSG_RESULT($unistd_defines_pthreads)
2081     AC_DEFINE(_REENTRANT)
2082     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2083     AC_DEFINE(C_THREADS)
2084     AC_DEFINE(HURD_C_THREADS, 1,
2085     [Define if you are using Mach cthreads directly under /include])
2086     LIBS="$LIBS -lthreads"
2087     THREADOBJ="Python/thread.o"],[
2088     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2089     AC_DEFINE(C_THREADS)
2090     AC_DEFINE(MACH_C_THREADS, 1,
2091     [Define if you are using Mach cthreads under mach /])
2092     THREADOBJ="Python/thread.o"],[
2093     AC_MSG_CHECKING(for --with-pth)
2094     AC_ARG_WITH([pth],
2095                 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
2096                 [AC_MSG_RESULT($withval)
2097                   AC_DEFINE([WITH_THREAD])
2098                   AC_DEFINE([HAVE_PTH], 1,
2099                             [Define if you have GNU PTH threads.])
2100                   LIBS="-lpth $LIBS"
2101                   THREADOBJ="Python/thread.o"],
2102                 [AC_MSG_RESULT(no)
2104     # Just looking for pthread_create in libpthread is not enough:
2105     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2106     # So we really have to include pthread.h, and then link.
2107     _libs=$LIBS
2108     LIBS="$LIBS -lpthread"
2109     AC_MSG_CHECKING([for pthread_create in -lpthread])
2110     AC_TRY_LINK([#include <pthread.h>
2112 void * start_routine (void *arg) { exit (0); }], [
2113 pthread_create (NULL, NULL, start_routine, NULL)], [
2114     AC_MSG_RESULT(yes)
2115     AC_DEFINE(WITH_THREAD)
2116     posix_threads=yes
2117     THREADOBJ="Python/thread.o"],[
2118     LIBS=$_libs
2119     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
2120     posix_threads=yes
2121     THREADOBJ="Python/thread.o"],[
2122     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2123     AC_DEFINE(ATHEOS_THREADS, 1,
2124     [Define this if you have AtheOS threads.])
2125     THREADOBJ="Python/thread.o"],[
2126     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
2127     posix_threads=yes
2128     LIBS="$LIBS -lpthreads"
2129     THREADOBJ="Python/thread.o"], [
2130     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
2131     posix_threads=yes
2132     LIBS="$LIBS -lc_r"
2133     THREADOBJ="Python/thread.o"], [
2134     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
2135     posix_threads=yes
2136     LIBS="$LIBS -lpthread"
2137     THREADOBJ="Python/thread.o"], [
2138     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
2139     posix_threads=yes
2140     LIBS="$LIBS -lcma"
2141     THREADOBJ="Python/thread.o"],[
2142     USE_THREAD_MODULE="#"])
2143     ])])])])])])])])])
2145     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2146     LIBS="$LIBS -lmpc"
2147     THREADOBJ="Python/thread.o"
2148     USE_THREAD_MODULE=""])
2150     if test "$posix_threads" != "yes"; then     
2151       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2152       LIBS="$LIBS -lthread"
2153       THREADOBJ="Python/thread.o"
2154       USE_THREAD_MODULE=""])
2155     fi
2157     if test "$USE_THREAD_MODULE" != "#"
2158     then
2159         # If the above checks didn't disable threads, (at least) OSF1
2160         # needs this '-threads' argument during linking.
2161         case $ac_sys_system in
2162         OSF1) LDLAST=-threads;;
2163         esac
2164     fi
2167 if test "$posix_threads" = "yes"; then
2168       if test "$unistd_defines_pthreads" = "no"; then
2169          AC_DEFINE(_POSIX_THREADS, 1,
2170          [Define if you have POSIX threads, 
2171           and your system does not define that.])
2172       fi
2174       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2175       case  $ac_sys_system/$ac_sys_release in
2176   SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2177                        Defined for Solaris 2.6 bug in pthread header.)
2178                        ;;
2179       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2180                        Define if the Posix semaphores do not work on your system)
2181                        ;;
2182       AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2183                        Define if the Posix semaphores do not work on your system)
2184                        ;;
2185       esac
2187       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2188       AC_CACHE_VAL(ac_cv_pthread_system_supported,
2189       [AC_TRY_RUN([#include <pthread.h>
2190       void *foo(void *parm) {
2191         return NULL;
2192       }
2193       main() {
2194         pthread_attr_t attr;
2195         pthread_t id;
2196         if (pthread_attr_init(&attr)) exit(-1);
2197         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
2198         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
2199         exit(0);
2200       }],
2201       ac_cv_pthread_system_supported=yes,
2202       ac_cv_pthread_system_supported=no,
2203       ac_cv_pthread_system_supported=no)
2204       ])
2205       AC_MSG_RESULT($ac_cv_pthread_system_supported)
2206       if test "$ac_cv_pthread_system_supported" = "yes"; then
2207         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
2208       fi
2209       AC_CHECK_FUNCS(pthread_sigmask,
2210         [case $ac_sys_system in
2211         CYGWIN*)
2212           AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2213             [Define if pthread_sigmask() does not work on your system.])
2214             ;;
2215         esac])
2219 # Check for enable-ipv6
2220 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
2221 AC_MSG_CHECKING([if --enable-ipv6 is specified])
2222 AC_ARG_ENABLE(ipv6,
2223 [  --enable-ipv6           Enable ipv6 (with ipv4) support
2224   --disable-ipv6          Disable ipv6 support],
2225 [ case "$enableval" in
2226   no)
2227        AC_MSG_RESULT(no)
2228        ipv6=no
2229        ;;
2230   *)   AC_MSG_RESULT(yes)
2231        AC_DEFINE(ENABLE_IPV6)
2232        ipv6=yes
2233        ;;
2234   esac ],
2237 dnl the check does not work on cross compilation case...
2238   AC_TRY_RUN([ /* AF_INET6 available check */
2239 #include <sys/types.h>
2240 #include <sys/socket.h>
2241 main()
2243  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2244    exit(1);
2245  else
2246    exit(0);
2249   AC_MSG_RESULT(yes)
2250   ipv6=yes,
2251   AC_MSG_RESULT(no)
2252   ipv6=no,
2253   AC_MSG_RESULT(no)
2254   ipv6=no
2257 if test "$ipv6" = "yes"; then
2258         AC_MSG_CHECKING(if RFC2553 API is available)
2259         AC_TRY_COMPILE([#include <sys/types.h>
2260 #include <netinet/in.h>],
2261         [struct sockaddr_in6 x;
2262 x.sin6_scope_id;],
2263                 AC_MSG_RESULT(yes)
2264                 ipv6=yes,
2265                 AC_MSG_RESULT(no, IPv6 disabled)
2266                 ipv6=no)
2269 if test "$ipv6" = "yes"; then
2270         AC_DEFINE(ENABLE_IPV6)
2274 ipv6type=unknown
2275 ipv6lib=none
2276 ipv6trylibc=no
2278 if test "$ipv6" = "yes"; then
2279         AC_MSG_CHECKING([ipv6 stack type])
2280         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2281         do
2282                 case $i in
2283                 inria)
2284                         dnl http://www.kame.net/
2285                         AC_EGREP_CPP(yes, [
2286 #include <netinet/in.h>
2287 #ifdef IPV6_INRIA_VERSION
2289 #endif],
2290                                 [ipv6type=$i])
2291                         ;;
2292                 kame)
2293                         dnl http://www.kame.net/
2294                         AC_EGREP_CPP(yes, [
2295 #include <netinet/in.h>
2296 #ifdef __KAME__
2298 #endif],
2299                                 [ipv6type=$i;
2300                                 ipv6lib=inet6
2301                                 ipv6libdir=/usr/local/v6/lib
2302                                 ipv6trylibc=yes])
2303                         ;;
2304                 linux-glibc)
2305                         dnl http://www.v6.linux.or.jp/
2306                         AC_EGREP_CPP(yes, [
2307 #include <features.h>
2308 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2310 #endif],
2311                                 [ipv6type=$i;
2312                                 ipv6trylibc=yes])
2313                         ;;
2314                 linux-inet6)
2315                         dnl http://www.v6.linux.or.jp/
2316                         if test -d /usr/inet6; then
2317                                 ipv6type=$i
2318                                 ipv6lib=inet6
2319                                 ipv6libdir=/usr/inet6/lib
2320                                 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
2321                         fi
2322                         ;;
2323                 solaris)
2324                         if test -f /etc/netconfig; then
2325                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2326                                 ipv6type=$i
2327                                 ipv6trylibc=yes
2328                           fi
2329                         fi
2330                         ;;
2331                 toshiba)
2332                         AC_EGREP_CPP(yes, [
2333 #include <sys/param.h>
2334 #ifdef _TOSHIBA_INET6
2336 #endif],
2337                                 [ipv6type=$i;
2338                                 ipv6lib=inet6;
2339                                 ipv6libdir=/usr/local/v6/lib])
2340                         ;;
2341                 v6d)
2342                         AC_EGREP_CPP(yes, [
2343 #include </usr/local/v6/include/sys/v6config.h>
2344 #ifdef __V6D__
2346 #endif],
2347                                 [ipv6type=$i;
2348                                 ipv6lib=v6;
2349                                 ipv6libdir=/usr/local/v6/lib;
2350                                 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
2351                         ;;
2352                 zeta)
2353                         AC_EGREP_CPP(yes, [
2354 #include <sys/param.h>
2355 #ifdef _ZETA_MINAMI_INET6
2357 #endif],
2358                                 [ipv6type=$i;
2359                                 ipv6lib=inet6;
2360                                 ipv6libdir=/usr/local/v6/lib])
2361                         ;;
2362                 esac
2363                 if test "$ipv6type" != "unknown"; then
2364                         break
2365                 fi
2366         done
2367         AC_MSG_RESULT($ipv6type)
2370 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2371         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2372                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2373                 echo "using lib$ipv6lib"
2374         else
2375                 if test $ipv6trylibc = "yes"; then
2376                         echo "using libc"
2377                 else
2378                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
2379                         echo "You need to fetch lib$ipv6lib.a from appropriate"
2380                         echo 'ipv6 kit and compile beforehand.'
2381                         exit 1
2382                 fi
2383         fi
2386 AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2387 AC_TRY_COMPILE([#include <Carbon/Carbon.h>], FSIORefNum fRef = 0,
2388   AC_DEFINE(HAVE_OSX105_SDK, 1, Define if compiling using MacOS X 10.5 SDK or later.)
2389   AC_MSG_RESULT(yes),
2390   AC_MSG_RESULT(no)
2393 # Check for --with-doc-strings
2394 AC_MSG_CHECKING(for --with-doc-strings)
2395 AC_ARG_WITH(doc-strings,
2396             AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
2398 if test -z "$with_doc_strings"
2399 then with_doc_strings="yes"
2401 if test "$with_doc_strings" != "no"
2402 then
2403     AC_DEFINE(WITH_DOC_STRINGS, 1,
2404       [Define if you want documentation strings in extension modules])
2406 AC_MSG_RESULT($with_doc_strings)
2408 # Check for Python-specific malloc support
2409 AC_MSG_CHECKING(for --with-tsc)
2410 AC_ARG_WITH(tsc,
2411 [  --with(out)-tsc         enable/disable timestamp counter profile], [
2412 if test "$withval" != no
2413 then 
2414   AC_DEFINE(WITH_TSC, 1, 
2415     [Define to profile with the Pentium timestamp counter]) 
2416     AC_MSG_RESULT(yes)
2417 else AC_MSG_RESULT(no)
2418 fi],
2419 [AC_MSG_RESULT(no)])
2421 # Check for Python-specific malloc support
2422 AC_MSG_CHECKING(for --with-pymalloc)
2423 AC_ARG_WITH(pymalloc,
2424             AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
2426 if test -z "$with_pymalloc"
2427 then with_pymalloc="yes"
2429 if test "$with_pymalloc" != "no"
2430 then
2431     AC_DEFINE(WITH_PYMALLOC, 1, 
2432      [Define if you want to compile in Python-specific mallocs])
2434 AC_MSG_RESULT($with_pymalloc)
2436 # Check for --with-wctype-functions
2437 AC_MSG_CHECKING(for --with-wctype-functions)
2438 AC_ARG_WITH(wctype-functions, 
2439             AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2441 if test "$withval" != no
2442 then 
2443   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2444   [Define if you want wctype.h functions to be used instead of the
2445    one supplied by Python itself. (see Include/unicodectype.h).]) 
2446   AC_MSG_RESULT(yes)
2447 else AC_MSG_RESULT(no)
2448 fi],
2449 [AC_MSG_RESULT(no)])
2451 # -I${DLINCLDIR} is added to the compile rule for importdl.o
2452 AC_SUBST(DLINCLDIR)
2453 DLINCLDIR=.
2455 # the dlopen() function means we might want to use dynload_shlib.o. some
2456 # platforms, such as AIX, have dlopen(), but don't want to use it.
2457 AC_CHECK_FUNCS(dlopen)
2459 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2460 # loading of modules.
2461 AC_SUBST(DYNLOADFILE)
2462 AC_MSG_CHECKING(DYNLOADFILE)
2463 if test -z "$DYNLOADFILE"
2464 then
2465         case $ac_sys_system/$ac_sys_release in
2466         AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2467         if test "$ac_cv_func_dlopen" = yes
2468         then DYNLOADFILE="dynload_shlib.o"
2469         else DYNLOADFILE="dynload_aix.o"
2470         fi
2471         ;;
2472         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2473         # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2474         Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
2475         atheos*) DYNLOADFILE="dynload_atheos.o";;
2476         *)
2477         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2478         # out any dynamic loading
2479         if test "$ac_cv_func_dlopen" = yes
2480         then DYNLOADFILE="dynload_shlib.o"
2481         else DYNLOADFILE="dynload_stub.o"
2482         fi
2483         ;;
2484         esac
2486 AC_MSG_RESULT($DYNLOADFILE)
2487 if test "$DYNLOADFILE" != "dynload_stub.o"
2488 then
2489         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2490         [Defined when any dynamic module loading is enabled.])
2493 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
2495 AC_SUBST(MACHDEP_OBJS)
2496 AC_MSG_CHECKING(MACHDEP_OBJS)
2497 if test -z "$MACHDEP_OBJS"
2498 then
2499         MACHDEP_OBJS=$extra_machdep_objs
2500 else
2501         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2503 AC_MSG_RESULT(MACHDEP_OBJS)
2505 # checks for library functions
2506 AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2507  clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
2508  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2509  getpriority getpwent getspnam getspent getsid getwd \
2510  kill killpg lchmod lchown lstat mbrtowc mkfifo mknod mktime \
2511  mremap nice pathconf pause plock poll pthread_init \
2512  putenv readlink realpath \
2513  select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2514  setgid \
2515  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2516  sigaction siginterrupt sigrelse strftime strlcpy \
2517  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2518  truncate uname unsetenv utimes waitpid wait3 wait4 \
2519  wcscoll wcsftime wcsxfrm _getpty)
2521 # For some functions, having a definition is not sufficient, since
2522 # we want to take their address.
2523 AC_MSG_CHECKING(for chroot)
2524 AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2525   AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2526   AC_MSG_RESULT(yes),
2527   AC_MSG_RESULT(no)
2529 AC_MSG_CHECKING(for link)
2530 AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2531   AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2532   AC_MSG_RESULT(yes),
2533   AC_MSG_RESULT(no)
2535 AC_MSG_CHECKING(for symlink)
2536 AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2537   AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2538   AC_MSG_RESULT(yes),
2539   AC_MSG_RESULT(no)
2541 AC_MSG_CHECKING(for fchdir)
2542 AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2543   AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2544   AC_MSG_RESULT(yes),
2545   AC_MSG_RESULT(no)
2547 AC_MSG_CHECKING(for fsync)
2548 AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
2549   AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2550   AC_MSG_RESULT(yes),
2551   AC_MSG_RESULT(no)
2553 AC_MSG_CHECKING(for fdatasync)
2554 AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2555   AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2556   AC_MSG_RESULT(yes),
2557   AC_MSG_RESULT(no)
2559 AC_MSG_CHECKING(for epoll)
2560 AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2561   AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2562   AC_MSG_RESULT(yes),
2563   AC_MSG_RESULT(no)
2565 AC_MSG_CHECKING(for kqueue)
2566 AC_TRY_COMPILE([
2567 #include <sys/types.h>
2568 #include <sys/event.h>
2569     ], int x=kqueue(),
2570   AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2571   AC_MSG_RESULT(yes),
2572   AC_MSG_RESULT(no)
2574 # On some systems (eg. FreeBSD 5), we would find a definition of the
2575 # functions ctermid_r, setgroups in the library, but no prototype
2576 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2577 # address to avoid compiler warnings and potential miscompilations
2578 # because of the missing prototypes.
2580 AC_MSG_CHECKING(for ctermid_r)
2581 AC_TRY_COMPILE([
2582 #include "confdefs.h" 
2583 #include <stdio.h>
2584 ], void* p = ctermid_r,
2585   AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2586   AC_MSG_RESULT(yes),
2587   AC_MSG_RESULT(no)
2590 AC_MSG_CHECKING(for flock)
2591 AC_TRY_COMPILE([
2592 #include "confdefs.h" 
2593 #include <sys/file.h>
2594 ], void* p = flock,
2595   AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2596   AC_MSG_RESULT(yes),
2597   AC_MSG_RESULT(no)
2600 AC_MSG_CHECKING(for getpagesize)
2601 AC_TRY_COMPILE([
2602 #include "confdefs.h" 
2603 #include <unistd.h>
2604 ], void* p = getpagesize,
2605   AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2606   AC_MSG_RESULT(yes),
2607   AC_MSG_RESULT(no)
2610 dnl check for true
2611 AC_CHECK_PROGS(TRUE, true, /bin/true)
2613 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2614 dnl On others, they are in the C library, so we to take no action
2615 AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2616   AC_CHECK_LIB(resolv, inet_aton)
2619 # On Tru64, chflags seems to be present, but calling it will
2620 # exit Python
2621 AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
2622 AC_TRY_RUN([[
2623 #include <sys/stat.h>
2624 #include <unistd.h>
2625 int main(int argc, char*argv[])
2627   if(chflags(argv[0], 0) != 0)
2628     return 1;
2629   return 0;
2631 ]], ac_cv_have_chflags=yes,
2632    ac_cv_have_chflags=no,
2633    ac_cv_have_chflags=cross)
2635 if test "$ac_cv_have_chflags" = cross ; then
2636   AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2638 if test "$ac_cv_have_chflags" = yes ; then
2639   AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2642 AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
2643 AC_TRY_RUN([[
2644 #include <sys/stat.h>
2645 #include <unistd.h>
2646 int main(int argc, char*argv[])
2648   if(lchflags(argv[0], 0) != 0)
2649     return 1;
2650   return 0;
2652 ]], ac_cv_have_lchflags=yes,
2653    ac_cv_have_lchflags=no,
2654    ac_cv_have_lchflags=cross)
2656 if test "$ac_cv_have_lchflags" = cross ; then
2657   AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2659 if test "$ac_cv_have_lchflags" = yes ; then
2660   AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2663 dnl Check if system zlib has *Copy() functions
2665 dnl On MacOSX the linker will search for dylibs on the entire linker path
2666 dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2667 dnl to revert to a more traditional unix behaviour and make it possible to
2668 dnl override the system libz with a local static library of libz. Temporarily
2669 dnl add that flag to our CFLAGS as well to ensure that we check the version
2670 dnl of libz that will be used by setup.py. 
2671 dnl The -L/usr/local/lib is needed as wel to get the same compilation 
2672 dnl environment as setup.py (and leaving it out can cause configure to use the
2673 dnl wrong version of the library)
2674 case $ac_sys_system/$ac_sys_release in
2675 Darwin/*) 
2676         _CUR_CFLAGS="${CFLAGS}"
2677         _CUR_LDFLAGS="${LDFLAGS}"
2678         CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2679         LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2680         ;;
2681 esac
2683 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2685 case $ac_sys_system/$ac_sys_release in
2686 Darwin/*) 
2687         CFLAGS="${_CUR_CFLAGS}"
2688         LDFLAGS="${_CUR_LDFLAGS}"
2689         ;;
2690 esac
2692 AC_MSG_CHECKING(for hstrerror)
2693 AC_TRY_LINK([
2694 #include "confdefs.h" 
2695 #include <netdb.h>
2696 ], void* p = hstrerror; hstrerror(0),
2697   AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2698   AC_MSG_RESULT(yes),
2699   AC_MSG_RESULT(no)
2702 AC_MSG_CHECKING(for inet_aton)
2703 AC_TRY_LINK([
2704 #include "confdefs.h" 
2705 #include <sys/types.h>
2706 #include <sys/socket.h>
2707 #include <netinet/in.h>
2708 #include <arpa/inet.h>
2709 ], void* p = inet_aton;inet_aton(0,0),
2710   AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2711   AC_MSG_RESULT(yes),
2712   AC_MSG_RESULT(no)
2715 AC_MSG_CHECKING(for inet_pton)
2716 AC_TRY_COMPILE([
2717 #include "confdefs.h" 
2718 #include <sys/types.h>
2719 #include <sys/socket.h>
2720 #include <netinet/in.h>
2721 #include <arpa/inet.h>
2722 ], void* p = inet_pton,
2723   AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2724   AC_MSG_RESULT(yes),
2725   AC_MSG_RESULT(no)
2728 # On some systems, setgroups is in unistd.h, on others, in grp.h
2729 AC_MSG_CHECKING(for setgroups)
2730 AC_TRY_COMPILE([
2731 #include "confdefs.h" 
2732 #include <unistd.h>
2733 #ifdef HAVE_GRP_H
2734 #include <grp.h>
2735 #endif
2736 ], 
2737 void* p = setgroups,
2738   AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2739   AC_MSG_RESULT(yes),
2740   AC_MSG_RESULT(no)
2743 # check for openpty and forkpty
2745 AC_CHECK_FUNCS(openpty,, 
2746    AC_CHECK_LIB(util,openpty,
2747      [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2748      AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2749    )
2751 AC_CHECK_FUNCS(forkpty,, 
2752    AC_CHECK_LIB(util,forkpty, 
2753      [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2754      AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2755    )
2758 # Stuff for expat.
2759 AC_CHECK_FUNCS(memmove)
2761 # check for long file support functions
2762 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2764 AC_REPLACE_FUNCS(dup2 getcwd strdup)
2765 AC_CHECK_FUNCS(getpgrp, 
2766   AC_TRY_COMPILE([#include <unistd.h>], 
2767    [getpgrp(0);], 
2768    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2769    [Define if getpgrp() must be called as getpgrp(0).])
2772 AC_CHECK_FUNCS(setpgrp,
2773   AC_TRY_COMPILE([#include <unistd.h>],
2774     [setpgrp(0,0);],
2775     AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2776     [Define if setpgrp() must be called as setpgrp(0, 0).])
2777   )
2779 AC_CHECK_FUNCS(gettimeofday, 
2780   AC_TRY_COMPILE([#include <sys/time.h>], 
2781     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2782     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2783     [Define if gettimeofday() does not have second (timezone) argument
2784      This is the case on Motorola V4 (R40V4.2)])
2785   )
2788 AC_MSG_CHECKING(for major, minor, and makedev)
2789 AC_TRY_LINK([
2790 #if defined(MAJOR_IN_MKDEV)
2791 #include <sys/mkdev.h>
2792 #elif defined(MAJOR_IN_SYSMACROS)
2793 #include <sys/sysmacros.h>
2794 #else
2795 #include <sys/types.h>
2796 #endif
2798   makedev(major(0),minor(0));
2800   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2801             [Define to 1 if you have the device macros.])
2802   AC_MSG_RESULT(yes)
2804   AC_MSG_RESULT(no)
2807 # On OSF/1 V5.1, getaddrinfo is available, but a define
2808 # for [no]getaddrinfo in netdb.h. 
2809 AC_MSG_CHECKING(for getaddrinfo)
2810 AC_TRY_LINK([
2811 #include <sys/types.h>
2812 #include <sys/socket.h>
2813 #include <netdb.h>
2814 #include <stdio.h>
2816 getaddrinfo(NULL, NULL, NULL, NULL);
2817 ], [
2818 AC_MSG_RESULT(yes)
2819 AC_MSG_CHECKING(getaddrinfo bug)
2820 AC_TRY_RUN([
2821 #include <sys/types.h>
2822 #include <netdb.h>
2823 #include <string.h>
2824 #include <sys/socket.h>
2825 #include <netinet/in.h>
2827 main()
2829   int passive, gaierr, inet4 = 0, inet6 = 0;
2830   struct addrinfo hints, *ai, *aitop;
2831   char straddr[INET6_ADDRSTRLEN], strport[16];
2833   for (passive = 0; passive <= 1; passive++) {
2834     memset(&hints, 0, sizeof(hints));
2835     hints.ai_family = AF_UNSPEC;
2836     hints.ai_flags = passive ? AI_PASSIVE : 0;
2837     hints.ai_socktype = SOCK_STREAM;
2838     hints.ai_protocol = IPPROTO_TCP;
2839     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2840       (void)gai_strerror(gaierr);
2841       goto bad;
2842     }
2843     for (ai = aitop; ai; ai = ai->ai_next) {
2844       if (ai->ai_addr == NULL ||
2845           ai->ai_addrlen == 0 ||
2846           getnameinfo(ai->ai_addr, ai->ai_addrlen,
2847                       straddr, sizeof(straddr), strport, sizeof(strport),
2848                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2849         goto bad;
2850       }
2851       switch (ai->ai_family) {
2852       case AF_INET:
2853         if (strcmp(strport, "54321") != 0) {
2854           goto bad;
2855         }
2856         if (passive) {
2857           if (strcmp(straddr, "0.0.0.0") != 0) {
2858             goto bad;
2859           }
2860         } else {
2861           if (strcmp(straddr, "127.0.0.1") != 0) {
2862             goto bad;
2863           }
2864         }
2865         inet4++;
2866         break;
2867       case AF_INET6:
2868         if (strcmp(strport, "54321") != 0) {
2869           goto bad;
2870         }
2871         if (passive) {
2872           if (strcmp(straddr, "::") != 0) {
2873             goto bad;
2874           }
2875         } else {
2876           if (strcmp(straddr, "::1") != 0) {
2877             goto bad;
2878           }
2879         }
2880         inet6++;
2881         break;
2882       case AF_UNSPEC:
2883         goto bad;
2884         break;
2885       default:
2886         /* another family support? */
2887         break;
2888       }
2889     }
2890   }
2892   if (!(inet4 == 0 || inet4 == 2))
2893     goto bad;
2894   if (!(inet6 == 0 || inet6 == 2))
2895     goto bad;
2897   if (aitop)
2898     freeaddrinfo(aitop);
2899   exit(0);
2901  bad:
2902   if (aitop)
2903     freeaddrinfo(aitop);
2904   exit(1);
2907 AC_MSG_RESULT(good)
2908 buggygetaddrinfo=no,
2909 AC_MSG_RESULT(buggy)
2910 buggygetaddrinfo=yes,
2911 AC_MSG_RESULT(buggy)
2912 buggygetaddrinfo=yes)], [
2913 AC_MSG_RESULT(no)
2914 buggygetaddrinfo=yes
2917 if test "$buggygetaddrinfo" = "yes"; then
2918         if test "$ipv6" = "yes"; then
2919                 echo 'Fatal: You must get working getaddrinfo() function.'
2920                 echo '       or you can specify "--disable-ipv6"'.
2921                 exit 1
2922         fi
2923 else
2924         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2926 AC_CHECK_FUNCS(getnameinfo)
2928 # checks for structures
2929 AC_HEADER_TIME
2930 AC_STRUCT_TM
2931 AC_STRUCT_TIMEZONE
2932 AC_CHECK_MEMBERS([struct stat.st_rdev])
2933 AC_CHECK_MEMBERS([struct stat.st_blksize])
2934 AC_CHECK_MEMBERS([struct stat.st_flags])
2935 AC_CHECK_MEMBERS([struct stat.st_gen])
2936 AC_CHECK_MEMBERS([struct stat.st_birthtime])
2937 AC_STRUCT_ST_BLOCKS
2939 AC_MSG_CHECKING(for time.h that defines altzone)
2940 AC_CACHE_VAL(ac_cv_header_time_altzone,
2941 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2942   ac_cv_header_time_altzone=yes,
2943   ac_cv_header_time_altzone=no)])
2944 AC_MSG_RESULT($ac_cv_header_time_altzone)
2945 if test $ac_cv_header_time_altzone = yes; then
2946   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2949 was_it_defined=no
2950 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2951 AC_TRY_COMPILE([
2952 #include <sys/types.h>
2953 #include <sys/select.h>
2954 #include <sys/time.h>
2955 ], [;], [
2956   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2957   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
2958    (which you can't on SCO ODT 3.0).]) 
2959   was_it_defined=yes
2961 AC_MSG_RESULT($was_it_defined)
2963 AC_MSG_CHECKING(for addrinfo)
2964 AC_CACHE_VAL(ac_cv_struct_addrinfo,
2965 AC_TRY_COMPILE([
2966 #               include <netdb.h>],
2967         [struct addrinfo a],
2968         ac_cv_struct_addrinfo=yes,
2969         ac_cv_struct_addrinfo=no))
2970 AC_MSG_RESULT($ac_cv_struct_addrinfo)
2971 if test $ac_cv_struct_addrinfo = yes; then
2972         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
2975 AC_MSG_CHECKING(for sockaddr_storage)
2976 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2977 AC_TRY_COMPILE([
2978 #               include <sys/types.h>
2979 #               include <sys/socket.h>],
2980         [struct sockaddr_storage s],
2981         ac_cv_struct_sockaddr_storage=yes,
2982         ac_cv_struct_sockaddr_storage=no))
2983 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2984 if test $ac_cv_struct_sockaddr_storage = yes; then
2985         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
2988 # checks for compiler characteristics
2990 AC_C_CHAR_UNSIGNED
2991 AC_C_CONST
2993 works=no
2994 AC_MSG_CHECKING(for working volatile)
2995 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
2996   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2998 AC_MSG_RESULT($works)
3000 works=no
3001 AC_MSG_CHECKING(for working signed char)
3002 AC_TRY_COMPILE([], [signed char c;], works=yes, 
3003   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
3005 AC_MSG_RESULT($works)
3007 have_prototypes=no
3008 AC_MSG_CHECKING(for prototypes)
3009 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
3010   AC_DEFINE(HAVE_PROTOTYPES, 1, 
3011    [Define if your compiler supports function prototype]) 
3012   have_prototypes=yes
3014 AC_MSG_RESULT($have_prototypes)
3016 works=no
3017 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
3018 AC_TRY_COMPILE([
3019 #include <stdarg.h>
3020 int foo(int x, ...) {
3021         va_list va;
3022         va_start(va, x);
3023         va_arg(va, int);
3024         va_arg(va, char *);
3025         va_arg(va, double);
3026         return 0;
3028 ], [return foo(10, "", 3.14);], [
3029   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3030    [Define if your compiler supports variable length function prototypes
3031    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
3032   works=yes
3034 AC_MSG_RESULT($works)
3036 # check for socketpair
3037 AC_MSG_CHECKING(for socketpair)
3038 AC_TRY_COMPILE([
3039 #include <sys/types.h>
3040 #include <sys/socket.h>
3041 ], void *x=socketpair,
3042   AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
3043   AC_MSG_RESULT(yes),
3044   AC_MSG_RESULT(no)
3047 # check if sockaddr has sa_len member
3048 AC_MSG_CHECKING(if sockaddr has sa_len member)
3049 AC_TRY_COMPILE([#include <sys/types.h>
3050 #include <sys/socket.h>],
3051 [struct sockaddr x;
3052 x.sa_len = 0;],
3053         AC_MSG_RESULT(yes)
3054         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
3055         AC_MSG_RESULT(no))
3057 va_list_is_array=no
3058 AC_MSG_CHECKING(whether va_list is an array)
3059 AC_TRY_COMPILE([
3060 #ifdef HAVE_STDARG_PROTOTYPES
3061 #include <stdarg.h>
3062 #else
3063 #include <varargs.h>
3064 #endif
3065 ], [va_list list1, list2; list1 = list2;], , [
3066  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
3067  va_list_is_array=yes
3069 AC_MSG_RESULT($va_list_is_array)
3071 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
3072 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3073   [Define this if you have some version of gethostbyname_r()])
3075 AC_CHECK_FUNC(gethostbyname_r, [
3076   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3077   AC_MSG_CHECKING([gethostbyname_r with 6 args])
3078   OLD_CFLAGS=$CFLAGS
3079   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3080   AC_TRY_COMPILE([
3081 #   include <netdb.h>
3082   ], [
3083     char *name;
3084     struct hostent *he, *res;
3085     char buffer[2048];
3086     int buflen = 2048;
3087     int h_errnop;
3089     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3090   ], [
3091     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3092     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3093     [Define this if you have the 6-arg version of gethostbyname_r().])
3094     AC_MSG_RESULT(yes)
3095   ], [
3096     AC_MSG_RESULT(no)
3097     AC_MSG_CHECKING([gethostbyname_r with 5 args])
3098     AC_TRY_COMPILE([
3099 #     include <netdb.h>
3100     ], [
3101       char *name;
3102       struct hostent *he;
3103       char buffer[2048];
3104       int buflen = 2048;
3105       int h_errnop;
3107       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3108     ], [
3109       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3110       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3111       [Define this if you have the 5-arg version of gethostbyname_r().])
3112       AC_MSG_RESULT(yes)
3113     ], [
3114       AC_MSG_RESULT(no)
3115       AC_MSG_CHECKING([gethostbyname_r with 3 args])
3116       AC_TRY_COMPILE([
3117 #       include <netdb.h>
3118       ], [
3119         char *name;
3120         struct hostent *he;
3121         struct hostent_data data;
3123         (void) gethostbyname_r(name, he, &data);
3124       ], [
3125         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3126         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3127         [Define this if you have the 3-arg version of gethostbyname_r().])
3128         AC_MSG_RESULT(yes)
3129       ], [
3130         AC_MSG_RESULT(no)
3131       ])
3132     ])
3133   ])
3134   CFLAGS=$OLD_CFLAGS
3135 ], [
3136   AC_CHECK_FUNCS(gethostbyname)
3138 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3139 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3140 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
3141 AC_SUBST(HAVE_GETHOSTBYNAME_R)
3142 AC_SUBST(HAVE_GETHOSTBYNAME)
3144 # checks for system services
3145 # (none yet)
3147 # Linux requires this for correct f.p. operations
3148 AC_CHECK_FUNC(__fpu_control,
3149   [],
3150   [AC_CHECK_LIB(ieee, __fpu_control)
3153 # Check for --with-fpectl
3154 AC_MSG_CHECKING(for --with-fpectl)
3155 AC_ARG_WITH(fpectl,
3156             AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
3158 if test "$withval" != no
3159 then 
3160   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3161   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
3162   AC_MSG_RESULT(yes)
3163 else AC_MSG_RESULT(no)
3164 fi],
3165 [AC_MSG_RESULT(no)])
3167 # check for --with-libm=...
3168 AC_SUBST(LIBM)
3169 case $ac_sys_system in
3170 Darwin) ;;
3171 *) LIBM=-lm
3172 esac
3173 AC_MSG_CHECKING(for --with-libm=STRING)
3174 AC_ARG_WITH(libm,
3175             AC_HELP_STRING(--with-libm=STRING, math library),
3177 if test "$withval" = no
3178 then LIBM=
3179      AC_MSG_RESULT(force LIBM empty)
3180 elif test "$withval" != yes
3181 then LIBM=$withval
3182      AC_MSG_RESULT(set LIBM="$withval")
3183 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
3184 fi],
3185 [AC_MSG_RESULT(default LIBM="$LIBM")])
3187 # check for --with-libc=...
3188 AC_SUBST(LIBC)
3189 AC_MSG_CHECKING(for --with-libc=STRING)
3190 AC_ARG_WITH(libc,
3191             AC_HELP_STRING(--with-libc=STRING, C library),
3193 if test "$withval" = no
3194 then LIBC=
3195      AC_MSG_RESULT(force LIBC empty)
3196 elif test "$withval" != yes
3197 then LIBC=$withval
3198      AC_MSG_RESULT(set LIBC="$withval")
3199 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
3200 fi],
3201 [AC_MSG_RESULT(default LIBC="$LIBC")])
3203 # **************************************************
3204 # * Check for various properties of floating point *
3205 # **************************************************
3207 AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3208 AC_CACHE_VAL(ac_cv_little_endian_double, [
3209 AC_TRY_RUN([
3210 #include <string.h>
3211 int main() {
3212     double x = 9006104071832581.0;
3213     if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3214         return 0;
3215     else
3216         return 1;
3219 ac_cv_little_endian_double=yes,
3220 ac_cv_little_endian_double=no,
3221 ac_cv_little_endian_double=no)])
3222 AC_MSG_RESULT($ac_cv_little_endian_double)
3223 if test "$ac_cv_little_endian_double" = yes
3224 then
3225   AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3226   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3227    with the least significant byte first])
3230 AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3231 AC_CACHE_VAL(ac_cv_big_endian_double, [
3232 AC_TRY_RUN([
3233 #include <string.h>
3234 int main() {
3235     double x = 9006104071832581.0;
3236     if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3237         return 0;
3238     else
3239         return 1;
3242 ac_cv_big_endian_double=yes,
3243 ac_cv_big_endian_double=no,
3244 ac_cv_big_endian_double=no)])
3245 AC_MSG_RESULT($ac_cv_big_endian_double)
3246 if test "$ac_cv_big_endian_double" = yes
3247 then
3248   AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3249   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3250    with the most significant byte first])
3253 # Some ARM platforms use a mixed-endian representation for doubles.
3254 # While Python doesn't currently have full support for these platforms
3255 # (see e.g., issue 1762561), we can at least make sure that float <-> string
3256 # conversions work.
3257 AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3258 AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3259 AC_TRY_RUN([
3260 #include <string.h>
3261 int main() {
3262     double x = 9006104071832581.0;
3263     if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3264         return 0;
3265     else
3266         return 1;
3269 ac_cv_mixed_endian_double=yes,
3270 ac_cv_mixed_endian_double=no,
3271 ac_cv_mixed_endian_double=no)])
3272 AC_MSG_RESULT($ac_cv_mixed_endian_double)
3273 if test "$ac_cv_mixed_endian_double" = yes
3274 then
3275   AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3276   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3277    in ARM mixed-endian order (byte order 45670123)])
3280 # The short float repr introduced in Python 3.1 requires the
3281 # correctly-rounded string <-> double conversion functions from
3282 # Python/dtoa.c, which in turn require that the FPU uses 53-bit
3283 # rounding; this is a problem on x86, where the x87 FPU has a default
3284 # rounding precision of 64 bits.  For gcc/x86, we try to fix this by
3285 # using inline assembler to get and set the x87 FPU control word.
3286 if test "$GCC" = yes && test -n "`$CC -dM -E - </dev/null | grep i386`"
3287 then
3288     # Check that it's okay to use gcc inline assembler to get and set
3289     # x87 control word.  It should be, but you never know...
3290     AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3291     AC_TRY_COMPILE([], [
3292       unsigned short cw;
3293       __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3294       __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3295     ],
3296     [have_gcc_asm_for_x87=yes], [have_gcc_asm_for_x87=no])
3297     AC_MSG_RESULT($have_gcc_asm_for_x87)
3298     if test "$have_gcc_asm_for_x87" = yes
3299     then
3300         AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3301         [Define if we can use gcc inline assembler to get and set x87 control word])
3302     fi
3305 # Detect whether system arithmetic is subject to x87-style double
3306 # rounding issues.  The result of this test has little meaning on non
3307 # IEEE 754 platforms.  On IEEE 754, test should return 1 if rounding
3308 # mode is round-to-nearest and double rounding issues are present, and
3309 # 0 otherwise.  See http://bugs.python.org/issue2937 for more info.
3310 AC_MSG_CHECKING(for x87-style double rounding)
3311 # $BASECFLAGS may affect the result
3312 ac_save_cc="$CC"
3313 CC="$CC $BASECFLAGS"
3314 AC_TRY_RUN([
3315 #include <stdlib.h>
3316 #include <math.h>
3317 int main() {
3318     volatile double x, y, z;
3319     /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3320     x = 0.99999999999999989; /* 1-2**-53 */
3321     y = 1./x;
3322     if (y != 1.)
3323         exit(0);
3324     /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3325     x = 1e16;
3326     y = 2.99999;
3327     z = x + y;
3328     if (z != 1e16+4.)
3329         exit(0);
3330     /* both tests show evidence of double rounding */
3331     exit(1);
3334 ac_cv_x87_double_rounding=no,
3335 ac_cv_x87_double_rounding=yes,
3336 ac_cv_x87_double_rounding=no)
3337 CC="$ac_save_cc"
3338 AC_MSG_RESULT($ac_cv_x87_double_rounding)
3339 if test "$ac_cv_x87_double_rounding" = yes
3340 then
3341   AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3342   [Define if arithmetic is subject to x87-style double rounding issue])
3345 # ************************************
3346 # * Check for mathematical functions *
3347 # ************************************
3349 LIBS_SAVE=$LIBS
3350 LIBS="$LIBS $LIBM"
3352 # On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3353 # -0. on some architectures.
3354 AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3355 AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3356 AC_TRY_RUN([
3357 #include <math.h>
3358 #include <stdlib.h>
3359 int main() {
3360     /* return 0 if either negative zeros don't exist
3361        on this platform or if negative zeros exist
3362        and tanh(-0.) == -0. */
3363   if (atan2(0., -1.) == atan2(-0., -1.) ||
3364       atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3365   else exit(1);
3368 ac_cv_tanh_preserves_zero_sign=yes,
3369 ac_cv_tanh_preserves_zero_sign=no,
3370 ac_cv_tanh_preserves_zero_sign=no)])
3371 AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3372 if test "$ac_cv_tanh_preserves_zero_sign" = yes
3373 then
3374   AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3375   [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3378 AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p round])
3379 AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3381 LIBS=$LIBS_SAVE
3383 # For multiprocessing module, check that sem_open
3384 # actually works.  For FreeBSD versions <= 7.2,
3385 # the kernel module that provides POSIX semaphores
3386 # isn't loaded by default, so an attempt to call
3387 # sem_open results in a 'Signal 12' error.
3388 AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3389 AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3390 AC_TRY_RUN([
3391 #include <unistd.h>
3392 #include <fcntl.h>
3393 #include <stdio.h>
3394 #include <semaphore.h>
3395 #include <sys/stat.h>
3397 int main(void) {
3398   sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3399   if (a == SEM_FAILED) {
3400     perror("sem_open");
3401     return 1;
3402   }
3403   sem_close(a);
3404   sem_unlink("/autoconf");
3405   return 0;
3407 ], ac_cv_posix_semaphores_enabled=yes,
3408    ac_cv_posix_semaphores_enabled=no,
3409    ac_cv_posix_semaphores_enabled=yes)
3411 AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3412 if test $ac_cv_posix_semaphores_enabled = no
3413 then
3414   AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3415             [Define if POSIX semaphores aren't enabled on your system])
3418 # Multiprocessing check for broken sem_getvalue
3419 AC_MSG_CHECKING(for broken sem_getvalue)
3420 AC_TRY_RUN([
3421 #include <unistd.h>
3422 #include <fcntl.h>
3423 #include <stdio.h>
3424 #include <semaphore.h>
3425 #include <sys/stat.h>
3427 int main(void){
3428   sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
3429   int count;
3430   int res;
3431   if(a==SEM_FAILED){
3432     perror("sem_open");
3433     return 1;
3435   }
3436   res = sem_getvalue(a, &count);
3437   sem_close(a);
3438   sem_unlink("/autocftw");
3439   return res==-1 ? 1 : 0;
3442 ,AC_MSG_RESULT(no),
3443  AC_MSG_RESULT(yes)
3444   AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1, define to 1 if your sem_getvalue is broken.)
3447 # determine what size digit to use for Python's longs
3448 AC_MSG_CHECKING([digit size for Python's longs])
3449 AC_ARG_ENABLE(big-digits,
3450 AC_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3451 [case $enable_big_digits in
3452 yes)
3453   enable_big_digits=30 ;;
3455   enable_big_digits=15 ;;
3456 [15|30])
3457   ;;
3459   AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3460 esac
3461 AC_MSG_RESULT($enable_big_digits)
3462 AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3464 [AC_MSG_RESULT(no value specified)])
3466 # check for wchar.h
3467 AC_CHECK_HEADER(wchar.h, [
3468   AC_DEFINE(HAVE_WCHAR_H, 1, 
3469   [Define if the compiler provides a wchar.h header file.]) 
3470   wchar_h="yes"
3472 wchar_h="no"
3475 # determine wchar_t size
3476 if test "$wchar_h" = yes
3477 then
3478   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
3481 AC_MSG_CHECKING(for UCS-4 tcl)
3482 have_ucs4_tcl=no
3483 AC_TRY_COMPILE([
3484 #include <tcl.h>
3485 #if TCL_UTF_MAX != 6
3486 # error "NOT UCS4_TCL"
3487 #endif], [], [
3488   AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3489   have_ucs4_tcl=yes
3491 AC_MSG_RESULT($have_ucs4_tcl)
3493 # check whether wchar_t is signed or not
3494 if test "$wchar_h" = yes
3495 then
3496   # check whether wchar_t is signed or not
3497   AC_MSG_CHECKING(whether wchar_t is signed)
3498   AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3499   AC_TRY_RUN([
3500   #include <wchar.h>
3501   int main()
3502   {
3503         /* Success: exit code 0 */
3504         exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
3505   }
3506   ],
3507   ac_cv_wchar_t_signed=yes,
3508   ac_cv_wchar_t_signed=no,
3509   ac_cv_wchar_t_signed=yes)])
3510   AC_MSG_RESULT($ac_cv_wchar_t_signed)
3513 AC_MSG_CHECKING(what type to use for str)
3514 AC_ARG_WITH(wide-unicode, 
3515             AC_HELP_STRING(--with-wide-unicode, Use 4-byte Unicode characters (default is 2 bytes)),
3517 if test "$withval" != no
3518 then unicode_size="4"
3519 else unicode_size="2"
3523 case "$have_ucs4_tcl" in
3524   yes) unicode_size="4" ;;
3525   *)   unicode_size="2" ;;
3526 esac
3529 AH_TEMPLATE(Py_UNICODE_SIZE,
3530   [Define as the size of the unicode type.])
3531 case "$unicode_size" in
3532   4) AC_DEFINE(Py_UNICODE_SIZE, 4) ;;
3533   *) AC_DEFINE(Py_UNICODE_SIZE, 2) ;;
3534 esac
3536 AH_TEMPLATE(PY_UNICODE_TYPE,
3537   [Define as the integral type used for Unicode representation.])
3539 # wchar_t is only usable if it maps to an unsigned type
3540 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
3541           -a "$ac_cv_wchar_t_signed" = "no"
3542 then
3543   PY_UNICODE_TYPE="wchar_t"
3544   AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3545   [Define if you have a useable wchar_t type defined in wchar.h; useable
3546    means wchar_t must be an unsigned type with at least 16 bits. (see
3547    Include/unicodeobject.h).])
3548   AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3549 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3550 then
3551      PY_UNICODE_TYPE="unsigned short"
3552      AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3553 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3554 then
3555      PY_UNICODE_TYPE="unsigned long"
3556      AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3557 else
3558      PY_UNICODE_TYPE="no type found"
3560 AC_MSG_RESULT($PY_UNICODE_TYPE)
3562 # check for endianness
3563 AC_C_BIGENDIAN
3565 # Check whether right shifting a negative integer extends the sign bit
3566 # or fills with zeros (like the Cray J90, according to Tim Peters).
3567 AC_MSG_CHECKING(whether right shift extends the sign bit)
3568 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
3569 AC_TRY_RUN([
3570 int main()
3572         exit(((-1)>>3 == -1) ? 0 : 1);
3575 ac_cv_rshift_extends_sign=yes,
3576 ac_cv_rshift_extends_sign=no,
3577 ac_cv_rshift_extends_sign=yes)])
3578 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3579 if test "$ac_cv_rshift_extends_sign" = no
3580 then
3581   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3582   [Define if i>>j for signed int i does not extend the sign bit
3583    when i < 0])
3586 # check for getc_unlocked and related locking functions
3587 AC_MSG_CHECKING(for getc_unlocked() and friends)
3588 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3589 AC_TRY_LINK([#include <stdio.h>],[
3590         FILE *f = fopen("/dev/null", "r");
3591         flockfile(f);
3592         getc_unlocked(f);
3593         funlockfile(f);
3594 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3595 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3596 if test "$ac_cv_have_getc_unlocked" = yes
3597 then
3598   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3599   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
3602 # check where readline lives
3603 # save the value of LIBS so we don't actually link Python with readline
3604 LIBS_no_readline=$LIBS
3606 # On some systems we need to link readline to a termcap compatible
3607 # library.  NOTE: Keep the precedence of listed libraries synchronised
3608 # with setup.py.
3609 py_cv_lib_readline=no
3610 AC_MSG_CHECKING([how to link readline libs])
3611 for py_libtermcap in "" ncursesw ncurses curses termcap; do
3612   if test -z "$py_libtermcap"; then
3613     READLINE_LIBS="-lreadline"
3614   else
3615     READLINE_LIBS="-lreadline -l$py_libtermcap"
3616   fi
3617   LIBS="$READLINE_LIBS $LIBS_no_readline"
3618   AC_LINK_IFELSE(
3619     [AC_LANG_CALL([],[readline])],
3620     [py_cv_lib_readline=yes])
3621   if test $py_cv_lib_readline = yes; then
3622     break
3623   fi
3624 done
3625 # Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3626 #AC_SUBST([READLINE_LIBS])
3627 if test $py_cv_lib_readline = no; then
3628   AC_MSG_RESULT([none])
3629 else
3630   AC_MSG_RESULT([$READLINE_LIBS])
3631   AC_DEFINE(HAVE_LIBREADLINE, 1,
3632     [Define if you have the readline library (-lreadline).])
3635 # check for readline 2.1
3636 AC_CHECK_LIB(readline, rl_callback_handler_install,
3637         AC_DEFINE(HAVE_RL_CALLBACK, 1,
3638         [Define if you have readline 2.1]), ,$READLINE_LIBS)
3640 # check for readline 2.2
3641 AC_TRY_CPP([#include <readline/readline.h>],
3642 have_readline=yes, have_readline=no)
3643 if test $have_readline = yes
3644 then
3645   AC_EGREP_HEADER([extern int rl_completion_append_character;],
3646   [readline/readline.h],
3647   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3648   [Define if you have readline 2.2]), )
3649   AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3650   [readline/readline.h],
3651   AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3652   [Define if you have rl_completion_suppress_append]), )
3655 # check for readline 4.0
3656 AC_CHECK_LIB(readline, rl_pre_input_hook,
3657         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
3658         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3660 # also in 4.0
3661 AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3662         AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
3663         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3665 # check for readline 4.2
3666 AC_CHECK_LIB(readline, rl_completion_matches,
3667         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
3668         [Define if you have readline 4.2]), ,$READLINE_LIBS)
3670 # also in readline 4.2
3671 AC_TRY_CPP([#include <readline/readline.h>],
3672 have_readline=yes, have_readline=no)
3673 if test $have_readline = yes
3674 then
3675   AC_EGREP_HEADER([extern int rl_catch_signals;],
3676   [readline/readline.h],
3677   AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3678   [Define if you can turn off readline's signal handling.]), )
3681 # End of readline checks: restore LIBS
3682 LIBS=$LIBS_no_readline
3684 AC_MSG_CHECKING(for broken nice())
3685 AC_CACHE_VAL(ac_cv_broken_nice, [
3686 AC_TRY_RUN([
3687 int main()
3689         int val1 = nice(1);
3690         if (val1 != -1 && val1 == nice(2))
3691                 exit(0);
3692         exit(1);
3695 ac_cv_broken_nice=yes,
3696 ac_cv_broken_nice=no,
3697 ac_cv_broken_nice=no)])
3698 AC_MSG_RESULT($ac_cv_broken_nice)
3699 if test "$ac_cv_broken_nice" = yes
3700 then
3701   AC_DEFINE(HAVE_BROKEN_NICE, 1,
3702   [Define if nice() returns success/failure instead of the new priority.])
3705 AC_MSG_CHECKING(for broken poll())
3706 AC_TRY_RUN([
3707 #include <poll.h>
3709 int main (void)
3710     {
3711     struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3712     
3713     close (42);
3715     int poll_test = poll (&poll_struct, 1, 0);
3717     if (poll_test < 0)
3718         {
3719         exit(0);
3720         }
3721     else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3722         {
3723         exit(0);
3724         }
3725     else
3726         {
3727         exit(1);
3728         }
3729     }
3731 ac_cv_broken_poll=yes,
3732 ac_cv_broken_poll=no,
3733 ac_cv_broken_poll=no)
3734 AC_MSG_RESULT($ac_cv_broken_poll)
3735 if test "$ac_cv_broken_poll" = yes
3736 then
3737   AC_DEFINE(HAVE_BROKEN_POLL, 1,
3738       [Define if poll() sets errno on invalid file descriptors.])
3741 # Before we can test tzset, we need to check if struct tm has a tm_zone 
3742 # (which is not required by ISO C or UNIX spec) and/or if we support
3743 # tzname[]
3744 AC_STRUCT_TIMEZONE
3746 # check tzset(3) exists and works like we expect it to
3747 AC_MSG_CHECKING(for working tzset())
3748 AC_CACHE_VAL(ac_cv_working_tzset, [
3749 AC_TRY_RUN([
3750 #include <stdlib.h>
3751 #include <time.h>
3752 #include <string.h>
3754 #if HAVE_TZNAME
3755 extern char *tzname[];
3756 #endif
3758 int main()
3760         /* Note that we need to ensure that not only does tzset(3)
3761            do 'something' with localtime, but it works as documented
3762            in the library reference and as expected by the test suite.
3763            This includes making sure that tzname is set properly if
3764            tm->tm_zone does not exist since it is the alternative way
3765            of getting timezone info.
3767            Red Hat 6.2 doesn't understand the southern hemisphere 
3768            after New Year's Day.
3769         */
3771         time_t groundhogday = 1044144000; /* GMT-based */
3772         time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3774         putenv("TZ=UTC+0");
3775         tzset();
3776         if (localtime(&groundhogday)->tm_hour != 0)
3777             exit(1);
3778 #if HAVE_TZNAME
3779         /* For UTC, tzname[1] is sometimes "", sometimes "   " */
3780         if (strcmp(tzname[0], "UTC") || 
3781                 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3782             exit(1);
3783 #endif
3785         putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
3786         tzset();
3787         if (localtime(&groundhogday)->tm_hour != 19)
3788             exit(1);
3789 #if HAVE_TZNAME
3790         if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3791             exit(1);
3792 #endif
3794         putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3795         tzset();
3796         if (localtime(&groundhogday)->tm_hour != 11)
3797             exit(1);
3798 #if HAVE_TZNAME
3799         if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3800             exit(1);
3801 #endif
3803 #if HAVE_STRUCT_TM_TM_ZONE
3804         if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3805             exit(1);
3806         if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3807             exit(1);
3808 #endif
3810         exit(0);
3813 ac_cv_working_tzset=yes,
3814 ac_cv_working_tzset=no,
3815 ac_cv_working_tzset=no)])
3816 AC_MSG_RESULT($ac_cv_working_tzset)
3817 if test "$ac_cv_working_tzset" = yes
3818 then
3819   AC_DEFINE(HAVE_WORKING_TZSET, 1,
3820   [Define if tzset() actually switches the local timezone in a meaningful way.])
3823 # Look for subsecond timestamps in struct stat
3824 AC_MSG_CHECKING(for tv_nsec in struct stat)
3825 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3826 AC_TRY_COMPILE([#include <sys/stat.h>], [
3827 struct stat st;
3828 st.st_mtim.tv_nsec = 1;
3830 ac_cv_stat_tv_nsec=yes,
3831 ac_cv_stat_tv_nsec=no,
3832 ac_cv_stat_tv_nsec=no))
3833 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3834 if test "$ac_cv_stat_tv_nsec" = yes
3835 then
3836   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3837   [Define if you have struct stat.st_mtim.tv_nsec])
3840 # Look for BSD style subsecond timestamps in struct stat
3841 AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3842 AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3843 AC_TRY_COMPILE([#include <sys/stat.h>], [
3844 struct stat st;
3845 st.st_mtimespec.tv_nsec = 1;
3847 ac_cv_stat_tv_nsec2=yes,
3848 ac_cv_stat_tv_nsec2=no,
3849 ac_cv_stat_tv_nsec2=no))
3850 AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3851 if test "$ac_cv_stat_tv_nsec2" = yes
3852 then
3853   AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3854   [Define if you have struct stat.st_mtimensec])
3857 # On HP/UX 11.0, mvwdelch is a block with a return statement
3858 AC_MSG_CHECKING(whether mvwdelch is an expression)
3859 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3860 AC_TRY_COMPILE([#include <curses.h>], [
3861   int rtn;
3862   rtn = mvwdelch(0,0,0);
3863 ], ac_cv_mvwdelch_is_expression=yes,
3864    ac_cv_mvwdelch_is_expression=no,
3865    ac_cv_mvwdelch_is_expression=yes))
3866 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3868 if test "$ac_cv_mvwdelch_is_expression" = yes
3869 then
3870   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3871   [Define if mvwdelch in curses.h is an expression.])
3874 AC_MSG_CHECKING(whether WINDOW has _flags)
3875 AC_CACHE_VAL(ac_cv_window_has_flags,
3876 AC_TRY_COMPILE([#include <curses.h>], [
3877   WINDOW *w;
3878   w->_flags = 0;
3879 ], ac_cv_window_has_flags=yes,
3880    ac_cv_window_has_flags=no,
3881    ac_cv_window_has_flags=no))
3882 AC_MSG_RESULT($ac_cv_window_has_flags)
3885 if test "$ac_cv_window_has_flags" = yes
3886 then
3887   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
3888   [Define if WINDOW in curses.h offers a field _flags.])
3891 AC_MSG_CHECKING(for is_term_resized)
3892 AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3893   AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3894   AC_MSG_RESULT(yes),
3895   AC_MSG_RESULT(no)
3898 AC_MSG_CHECKING(for resize_term)
3899 AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3900   AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3901   AC_MSG_RESULT(yes),
3902   AC_MSG_RESULT(no)
3905 AC_MSG_CHECKING(for resizeterm)
3906 AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3907   AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3908   AC_MSG_RESULT(yes),
3909   AC_MSG_RESULT(no)
3912 AC_MSG_CHECKING(for /dev/ptmx)
3914 if test -r /dev/ptmx
3915 then
3916   AC_MSG_RESULT(yes)
3917   AC_DEFINE(HAVE_DEV_PTMX, 1,
3918   [Define if we have /dev/ptmx.])
3919 else
3920   AC_MSG_RESULT(no)
3923 AC_MSG_CHECKING(for /dev/ptc)
3925 if test -r /dev/ptc
3926 then
3927   AC_MSG_RESULT(yes)
3928   AC_DEFINE(HAVE_DEV_PTC, 1,
3929   [Define if we have /dev/ptc.])
3930 else
3931   AC_MSG_RESULT(no)
3934 AC_MSG_CHECKING(for %zd printf() format support)
3935 AC_TRY_RUN([#include <stdio.h>
3936 #include <stddef.h>
3937 #include <string.h>
3939 #ifdef HAVE_SYS_TYPES_H
3940 #include <sys/types.h>
3941 #endif
3943 #ifdef HAVE_SSIZE_T
3944 typedef ssize_t Py_ssize_t;
3945 #elif SIZEOF_VOID_P == SIZEOF_LONG
3946 typedef long Py_ssize_t;
3947 #else
3948 typedef int Py_ssize_t;
3949 #endif
3951 int main()
3953     char buffer[256];
3955     if(sprintf(buffer, "%zd", (size_t)123) < 0)
3956         return 1;
3958     if (strcmp(buffer, "123"))
3959         return 1;
3961     if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3962         return 1;
3964     if (strcmp(buffer, "-123"))
3965         return 1;
3967     return 0;
3969 [AC_MSG_RESULT(yes)
3970  AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3971  AC_MSG_RESULT(no))
3973 AC_CHECK_TYPE(socklen_t,,
3974   AC_DEFINE(socklen_t,int,
3975             Define to `int' if <sys/socket.h> does not define.),[
3976 #ifdef HAVE_SYS_TYPES_H
3977 #include <sys/types.h>
3978 #endif
3979 #ifdef HAVE_SYS_SOCKET_H
3980 #include <sys/socket.h>
3981 #endif
3984 AC_MSG_CHECKING(for broken mbstowcs)
3985 AC_TRY_RUN([
3986 #include<stdlib.h>
3987 int main() {
3988     size_t len = -1;
3989     const char *str = "text";
3990     len = mbstowcs(NULL, str, 0);
3991     return (len != 4);
3994 ac_cv_broken_mbstowcs=no,
3995 ac_cv_broken_mbstowcs=yes,
3996 ac_cv_broken_mbstowcs=no)
3997 AC_MSG_RESULT($ac_cv_broken_mbstowcs)
3998 if test "$ac_cv_broken_mbstowcs" = yes
3999 then
4000   AC_DEFINE(HAVE_BROKEN_MBSTOWCS, 1,
4001   [Define if mbstowcs(NULL, "text", 0) does not return the number of 
4002    wide chars that would be converted.])
4005 # Check for --with-computed-gotos
4006 AC_MSG_CHECKING(for --with-computed-gotos)
4007 AC_ARG_WITH(computed-gotos,
4008             AC_HELP_STRING(--with-computed-gotos,
4009                            Use computed gotos / threaded dispatch in evaluation loop (not available on all compilers)),
4011 if test "$withval" != no
4012 then 
4013   AC_DEFINE(USE_COMPUTED_GOTOS, 1,
4014   [Define if you want to use computed gotos in ceval.c.]) 
4015   AC_MSG_RESULT(yes)
4016 else AC_MSG_RESULT(no)
4017 fi],
4018 [AC_MSG_RESULT(no)])
4020 if test $ac_sys_system = Darwin
4021 then
4022         LIBS="$LIBS -framework CoreFoundation"
4027 AC_SUBST(THREADHEADERS)
4029 for h in `(cd $srcdir;echo Python/thread_*.h)`
4031   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4032 done
4034 AC_SUBST(SRCDIRS)
4035 SRCDIRS="Parser Grammar Objects Python Modules Mac"
4036 AC_MSG_CHECKING(for build directories)
4037 for dir in $SRCDIRS; do
4038     if test ! -d $dir; then
4039         mkdir $dir
4040     fi
4041 done
4042 AC_MSG_RESULT(done)
4044 # generate output files
4045 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
4046 AC_OUTPUT
4048 echo "creating Modules/Setup"
4049 if test ! -f Modules/Setup
4050 then
4051         cp $srcdir/Modules/Setup.dist Modules/Setup
4054 echo "creating Modules/Setup.local"
4055 if test ! -f Modules/Setup.local
4056 then
4057         echo "# Edit this file for local setup changes" >Modules/Setup.local
4060 echo "creating Makefile"
4061 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4062                         -s Modules Modules/Setup.config \
4063                         Modules/Setup.local Modules/Setup
4064 mv config.c Modules