move sections
[python/dscho.git] / configure.in
blob13fbbede68d04cc4f169c3941438951ae2c9e370
1 dnl ***********************************************
2 dnl * Please run autoreconf to test your changes! *
3 dnl ***********************************************
5 # Set VERSION so we only need to edit in one place (i.e., here)
6 m4_define(PYTHON_VERSION, 2.7)
8 dnl Some m4 magic to ensure that the configure script is generated
9 dnl by the correct autoconf version.
10 m4_define([version_required],
11 [m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]), [$1]), 0,
12        [],
13        [m4_fatal([Autoconf version $1 is required for Python], 63)])
15 version_required(2.65)
17 AC_REVISION($Revision$)
18 AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
19 AC_CONFIG_SRCDIR([Include/object.h])
20 AC_CONFIG_HEADER(pyconfig.h)
22 dnl Ensure that if prefix is specified, it does not end in a slash. If
23 dnl it does, we get path names containing '//' which is both ugly and
24 dnl can cause trouble.
26 dnl Last slash shouldn't be stripped if prefix=/
27 if test "$prefix" != "/"; then
28     prefix=`echo "$prefix" | sed -e 's/\/$//g'`
29 fi    
31 dnl This is for stuff that absolutely must end up in pyconfig.h.
32 dnl Please use pyport.h instead, if possible.
33 AH_TOP([
34 #ifndef Py_PYCONFIG_H
35 #define Py_PYCONFIG_H
37 AH_BOTTOM([
38 /* Define the macros needed if on a UnixWare 7.x system. */
39 #if defined(__USLC__) && defined(__SCO_VERSION__)
40 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
41 #endif
43 #endif /*Py_PYCONFIG_H*/
46 # We don't use PACKAGE_ variables, and they cause conflicts
47 # with other autoconf-based packages that include Python.h
48 grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
49 rm confdefs.h
50 mv confdefs.h.new confdefs.h
52 AC_SUBST(VERSION)
53 VERSION=PYTHON_VERSION
55 AC_SUBST(SOVERSION)
56 SOVERSION=1.0
58 # The later defininition of _XOPEN_SOURCE disables certain features
59 # on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
60 AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
62 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
63 # certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
64 # them.
65 AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
67 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
68 # certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
69 # them.
70 AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
72 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
73 # u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
74 AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
76 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
77 # certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
78 # them.
79 AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])
82 define_xopen_source=yes
84 # Arguments passed to configure.
85 AC_SUBST(CONFIG_ARGS)
86 CONFIG_ARGS="$ac_configure_args"
88 AC_MSG_CHECKING([for --enable-universalsdk])
89 AC_ARG_ENABLE(universalsdk,
90         AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
92         case $enableval in
93         yes)
94                 enableval=/Developer/SDKs/MacOSX10.4u.sdk
95                 if test ! -d "${enableval}"
96                 then
97                         enableval=/
98                 fi
99                 ;;
100         esac
101         case $enableval in
102         no)
103                 UNIVERSALSDK=
104                 enable_universalsdk=
105                 ;;
106         *)
107                 UNIVERSALSDK=$enableval
108                 if test ! -d "${UNIVERSALSDK}"
109                 then
110                         AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
111                 fi
112                 ;;
113         esac
114         
116         UNIVERSALSDK=
117         enable_universalsdk=
119 if test -n "${UNIVERSALSDK}"
120 then
121         AC_MSG_RESULT(${UNIVERSALSDK})
122 else
123         AC_MSG_RESULT(no)
125 AC_SUBST(UNIVERSALSDK)
127 AC_SUBST(ARCH_RUN_32BIT)
129 UNIVERSAL_ARCHS="32-bit"
130 AC_SUBST(LIPO_32BIT_FLAGS)
131 AC_MSG_CHECKING(for --with-universal-archs)
132 AC_ARG_WITH(universal-archs,
133     AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
135         AC_MSG_RESULT($withval)
136         UNIVERSAL_ARCHS="$withval"
137         if test "${enable_universalsdk}" ; then
138                 :
139         else
140                 AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk. See Mac/README])
141         fi
144         AC_MSG_RESULT(32-bit)
149 AC_ARG_WITH(framework-name,
150               AS_HELP_STRING([--with-framework-name=FRAMEWORK],
151                              [specify an alternate name of the framework built with --enable-framework]),
153     if test "${enable_framework}"; then
154             :
155     else
156         AC_MSG_ERROR([--with-framework-name without --enable-framework. See Mac/README])
157     fi
158     PYTHONFRAMEWORK=${withval}
159     PYTHONFRAMEWORKDIR=${withval}.framework
160     PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
161     ],[
162     PYTHONFRAMEWORK=Python
163     PYTHONFRAMEWORKDIR=Python.framework
164     PYTHONFRAMEWORKIDENTIFIER=org.python.python
166 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
167 AC_ARG_ENABLE(framework,
168               AS_HELP_STRING([--enable-framework@<:@=INSTALLDIR@:>@], [Build (MacOSX|Darwin) framework]),
170         case $enableval in
171         yes) 
172                 enableval=/Library/Frameworks
173         esac
174         case $enableval in
175         no)
176                 PYTHONFRAMEWORK=
177                 PYTHONFRAMEWORKDIR=no-framework
178                 PYTHONFRAMEWORKPREFIX=
179                 PYTHONFRAMEWORKINSTALLDIR=
180                 FRAMEWORKINSTALLFIRST=
181                 FRAMEWORKINSTALLLAST=
182                 FRAMEWORKALTINSTALLFIRST=
183                 FRAMEWORKALTINSTALLLAST=
184                 if test "x${prefix}" = "xNONE"; then
185                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
186                 else
187                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
188                 fi
189                 enable_framework=
190                 ;;
191         *)
192                 PYTHONFRAMEWORKPREFIX="${enableval}"
193                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
194                 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
195                 FRAMEWORKALTINSTALLFIRST="frameworkinstallstructure bininstall maninstall"
196                 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
197                 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
198                 FRAMEWORKINSTALLAPPSPREFIX="/Applications"
200                 if test "x${prefix}" = "xNONE" ; then
201                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
203                 else
204                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
205                 fi
207                 case "${enableval}" in
208                 /System*)
209                         FRAMEWORKINSTALLAPPSPREFIX="/Applications"
210                         if test "${prefix}" = "NONE" ; then
211                                 # See below
212                                 FRAMEWORKUNIXTOOLSPREFIX="/usr"
213                         fi
214                         ;;
216                 /Library*)
217                         FRAMEWORKINSTALLAPPSPREFIX="/Applications"
218                         ;;
220                 */Library/Frameworks)
221                         MDIR="`dirname "${enableval}"`"
222                         MDIR="`dirname "${MDIR}"`"
223                         FRAMEWORKINSTALLAPPSPREFIX="${MDIR}/Applications"
225                         if test "${prefix}" = "NONE"; then
226                                 # User hasn't specified the 
227                                 # --prefix option, but wants to install
228                                 # the framework in a non-default location,
229                                 # ensure that the compatibility links get
230                                 # installed relative to that prefix as well
231                                 # instead of in /usr/local.
232                                 FRAMEWORKUNIXTOOLSPREFIX="${MDIR}"
233                         fi
234                         ;;
236                 *)
237                         FRAMEWORKINSTALLAPPSPREFIX="/Applications"
238                         ;;
239                 esac
241                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
243                 # Add files for Mac specific code to the list of output
244                 # files:
245                 AC_CONFIG_FILES(Mac/Makefile)
246                 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
247                 AC_CONFIG_FILES(Mac/IDLE/Makefile)
248                 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
249                 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
250         esac
251         ],[
252         PYTHONFRAMEWORK=
253         PYTHONFRAMEWORKDIR=no-framework
254         PYTHONFRAMEWORKPREFIX=
255         PYTHONFRAMEWORKINSTALLDIR=
256         FRAMEWORKINSTALLFIRST=
257         FRAMEWORKINSTALLLAST=
258         FRAMEWORKALTINSTALLFIRST=
259         FRAMEWORKALTINSTALLLAST=
260         if test "x${prefix}" = "xNONE" ; then
261                 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
262         else
263                 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
264         fi
265         enable_framework=
268 AC_SUBST(PYTHONFRAMEWORK)
269 AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
270 AC_SUBST(PYTHONFRAMEWORKDIR)
271 AC_SUBST(PYTHONFRAMEWORKPREFIX)
272 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
273 AC_SUBST(FRAMEWORKINSTALLFIRST)
274 AC_SUBST(FRAMEWORKINSTALLLAST)
275 AC_SUBST(FRAMEWORKALTINSTALLFIRST)
276 AC_SUBST(FRAMEWORKALTINSTALLLAST)
277 AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
278 AC_SUBST(FRAMEWORKINSTALLAPPSPREFIX)
280 ##AC_ARG_WITH(dyld,
281 ##            AS_HELP_STRING([--with-dyld],
282 ##                           [Use (OpenStep|Rhapsody) dynamic linker]))
284 # Set name for machine-dependent library files
285 AC_SUBST(MACHDEP)
286 AC_MSG_CHECKING(MACHDEP)
287 if test -z "$MACHDEP"
288 then
289         ac_sys_system=`uname -s`
290         if test "$ac_sys_system" = "AIX" \
291         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
292                 ac_sys_release=`uname -v`
293         else
294                 ac_sys_release=`uname -r`
295         fi
296         ac_md_system=`echo $ac_sys_system |
297                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
298         ac_md_release=`echo $ac_sys_release |
299                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
300         MACHDEP="$ac_md_system$ac_md_release"
302         case $MACHDEP in
303         cygwin*) MACHDEP="cygwin";;
304         darwin*) MACHDEP="darwin";;
305         atheos*) MACHDEP="atheos";;
306         irix646) MACHDEP="irix6";;
307         '')     MACHDEP="unknown";;
308         esac
310         
311 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
312 # disable features if it is defined, without any means to access these
313 # features as extensions. For these systems, we skip the definition of
314 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
315 # some feature, make sure there is no alternative way to access this
316 # feature. Also, when using wildcards, make sure you have verified the
317 # need for not defining _XOPEN_SOURCE on all systems matching the
318 # wildcard, and that the wildcard does not include future systems
319 # (which may remove their limitations).
320 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
321 case $ac_sys_system/$ac_sys_release in
322   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
323   # even though select is a POSIX function. Reported by J. Ribbens.
324   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
325   # In addition, Stefan Krah confirms that issue #1244610 exists through
326   # OpenBSD 4.6, but is fixed in 4.7.
327   OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0123456@:>@) 
328     define_xopen_source=no
329     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
330     # also defined. This can be overridden by defining _BSD_SOURCE
331     # As this has a different meaning on Linux, only define it on OpenBSD
332     AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
333     ;;
334   OpenBSD/4.@<:@789@:>@)
335     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
336     # also defined. This can be overridden by defining _BSD_SOURCE
337     # As this has a different meaning on Linux, only define it on OpenBSD
338     AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
339     ;;
340   # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
341   # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
342   # Marc Recht
343   NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
344     define_xopen_source=no;;
345   # From the perspective of Solaris, _XOPEN_SOURCE is not so much a
346   # request to enable features supported by the standard as a request
347   # to disable features not supported by the standard.  The best way
348   # for Python to use Solaris is simply to leave _XOPEN_SOURCE out
349   # entirely and define __EXTENSIONS__ instead.
350   SunOS/*)
351     define_xopen_source=no;;
352   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
353   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
354   # Reconfirmed for 7.1.4 by Martin v. Loewis.
355   OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
356     define_xopen_source=no;;
357   # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
358   # but used in struct sockaddr.sa_family. Reported by Tim Rice.
359   SCO_SV/3.2)
360     define_xopen_source=no;;
361   # On FreeBSD 4, the math functions C89 does not cover are never defined
362   # with _XOPEN_SOURCE and __BSD_VISIBLE does not re-enable them.
363   FreeBSD/4.*)
364     define_xopen_source=no;;
365   # On MacOS X 10.2, a bug in ncurses.h means that it craps out if 
366   # _XOPEN_EXTENDED_SOURCE is defined. Apparently, this is fixed in 10.3, which
367   # identifies itself as Darwin/7.*
368   # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
369   # disables platform specific features beyond repair.
370   # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE 
371   # has no effect, don't bother defining them
372   Darwin/@<:@6789@:>@.*)
373     define_xopen_source=no;;
374   Darwin/1@<:@0-9@:>@.*)
375     define_xopen_source=no;;
376   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
377   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
378   # or has another value. By not (re)defining it, the defaults come in place.
379   AIX/4)
380     define_xopen_source=no;;
381   AIX/5)
382     if test `uname -r` -eq 1; then
383       define_xopen_source=no
384     fi
385     ;;
386   # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
387   # defining NI_NUMERICHOST.
388   QNX/6.3.2)
389     define_xopen_source=no
390     ;;
392 esac
394 if test $define_xopen_source = yes
395 then
396   AC_DEFINE(_XOPEN_SOURCE, 600, 
397             Define to the level of X/Open that your system supports)
399   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
400   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
401   # several APIs are not declared. Since this is also needed in some
402   # cases for HP-UX, we define it globally.
403   AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
404             Define to activate Unix95-and-earlier features)
406   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
407   
411 # SGI compilers allow the specification of the both the ABI and the
412 # ISA on the command line.  Depending on the values of these switches,
413 # different and often incompatable code will be generated.
415 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
416 # thus supply support for various ABI/ISA combinations.  The MACHDEP
417 # variable is also adjusted.
419 AC_SUBST(SGI_ABI)
420 if test ! -z "$SGI_ABI"
421 then
422         CC="cc $SGI_ABI"
423         LDFLAGS="$SGI_ABI $LDFLAGS"
424         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
426 AC_MSG_RESULT($MACHDEP)
428 # And add extra plat-mac for darwin
429 AC_SUBST(EXTRAPLATDIR)
430 AC_SUBST(EXTRAMACHDEPPATH)
431 AC_MSG_CHECKING(EXTRAPLATDIR)
432 if test -z "$EXTRAPLATDIR"
433 then
434         case $MACHDEP in
435         darwin) 
436                 EXTRAPLATDIR="\$(PLATMACDIRS)"
437                 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
438                 ;;
439         *) 
440                 EXTRAPLATDIR=""
441                 EXTRAMACHDEPPATH=""
442                 ;;
443         esac
445 AC_MSG_RESULT($EXTRAPLATDIR)
447 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
448 # it may influence the way we can build extensions, so distutils
449 # needs to check it
450 AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
451 AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
452 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
453 EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
455 AC_MSG_CHECKING(machine type as reported by uname -m)
456 ac_sys_machine=`uname -m`
457 AC_MSG_RESULT($ac_sys_machine)
459 # checks for alternative programs
461 # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
462 # for debug/optimization stuff.  BASECFLAGS is for flags that are required
463 # just to get things to compile and link.  Users are free to override OPT
464 # when running configure or make.  The build should not break if they do.
465 # BASECFLAGS should generally not be messed with, however.
467 # XXX shouldn't some/most/all of this code be merged with the stuff later
468 # on that fiddles with OPT and BASECFLAGS?
469 AC_MSG_CHECKING(for --without-gcc)
470 AC_ARG_WITH(gcc,
471             AS_HELP_STRING([--without-gcc], [never use gcc]),
473         case $withval in
474         no)     CC=${CC:-cc}
475                 without_gcc=yes;;
476         yes)    CC=gcc
477                 without_gcc=no;;
478         *)      CC=$withval
479                 without_gcc=$withval;;
480         esac], [
481         case $ac_sys_system in
482         AIX*)   CC=cc_r
483                 without_gcc=;;
484         BeOS*)
485                 case $BE_HOST_CPU in
486                 ppc)
487                         CC=mwcc
488                         without_gcc=yes
489                         BASECFLAGS="$BASECFLAGS -export pragma"
490                         OPT="$OPT -O"
491                         LDFLAGS="$LDFLAGS -nodup"
492                         ;;
493                 x86)
494                         CC=gcc
495                         without_gcc=no
496                         OPT="$OPT -O"
497                         ;;
498                 *)
499                         AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
500                         ;;
501                 esac
502                 AR="\$(srcdir)/Modules/ar_beos"
503                 RANLIB=:
504                 ;;
505         *)      without_gcc=no;;
506         esac])
507 AC_MSG_RESULT($without_gcc)
509 # If the user switches compilers, we can't believe the cache
510 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
511 then
512   AC_MSG_ERROR([cached CC is different -- throw away $cache_file
513 (it is also a good idea to do 'make clean' before compiling)])
516 # If the user set CFLAGS, use this instead of the automatically
517 # determined setting
518 preset_cflags="$CFLAGS"
519 AC_PROG_CC
520 if test ! -z "$preset_cflags"
521 then
522         CFLAGS=$preset_cflags
525 AC_SUBST(CXX)
526 AC_SUBST(MAINCC)
527 AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
528 AC_ARG_WITH(cxx_main,
529             AS_HELP_STRING([--with-cxx-main=<compiler>],
530                            [compile main() and link python executable with C++ compiler]),
532         
533         case $withval in
534         no)     with_cxx_main=no
535                 MAINCC='$(CC)';;
536         yes)    with_cxx_main=yes
537                 MAINCC='$(CXX)';;
538         *)      with_cxx_main=yes
539                 MAINCC=$withval
540                 if test -z "$CXX"
541                 then
542                         CXX=$withval
543                 fi;;
544         esac], [
545         with_cxx_main=no
546         MAINCC='$(CC)'
548 AC_MSG_RESULT($with_cxx_main)
550 preset_cxx="$CXX"
551 if test -z "$CXX"
552 then
553         case "$CC" in
554         gcc)    AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
555         cc)     AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
556         esac
557         if test "$CXX" = "notfound"
558         then
559                 CXX=""
560         fi
562 if test -z "$CXX"
563 then
564         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
565         if test "$CXX" = "notfound"
566         then
567                 CXX=""
568         fi
570 if test "$preset_cxx" != "$CXX"
571 then
572         AC_MSG_WARN([
574   By default, distutils will build C++ extension modules with "$CXX".
575   If this is not intended, then set CXX on the configure command line.
576   ])
580 # checks for UNIX variants that set C preprocessor variables
581 AC_USE_SYSTEM_EXTENSIONS
583 # Check for unsupported systems
584 case $ac_sys_system/$ac_sys_release in
585 atheos*|Linux*/1*)
586    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
587    echo See README for details.
588    exit 1;;
589 esac
591 AC_EXEEXT
592 AC_MSG_CHECKING(for --with-suffix)
593 AC_ARG_WITH(suffix,
594             AS_HELP_STRING([--with-suffix=.exe], [set executable suffix]),
596         case $withval in
597         no)     EXEEXT=;;
598         yes)    EXEEXT=.exe;;
599         *)      EXEEXT=$withval;;
600         esac])
601 AC_MSG_RESULT($EXEEXT)
603 # Test whether we're running on a non-case-sensitive system, in which
604 # case we give a warning if no ext is given
605 AC_SUBST(BUILDEXEEXT)
606 AC_MSG_CHECKING(for case-insensitive build directory)
607 if test ! -d CaseSensitiveTestDir; then
608 mkdir CaseSensitiveTestDir
611 if test -d casesensitivetestdir
612 then
613     AC_MSG_RESULT(yes)
614     BUILDEXEEXT=.exe
615 else
616         AC_MSG_RESULT(no)
617         BUILDEXEEXT=$EXEEXT
619 rmdir CaseSensitiveTestDir
621 case $MACHDEP in
622 bsdos*)
623     case $CC in
624     gcc) CC="$CC -D_HAVE_BSDI";;
625     esac;;
626 esac
628 case $ac_sys_system in
629 hp*|HP*)
630     case $CC in
631     cc|*/cc) CC="$CC -Ae";;
632     esac;;
633 SunOS*)
634     # Some functions have a prototype only with that define, e.g. confstr
635     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
636     ;;
637 esac
640 AC_SUBST(LIBRARY)
641 AC_MSG_CHECKING(LIBRARY)
642 if test -z "$LIBRARY"
643 then
644         LIBRARY='libpython$(VERSION).a'
646 AC_MSG_RESULT($LIBRARY)
648 # LDLIBRARY is the name of the library to link against (as opposed to the
649 # name of the library into which to insert object files). BLDLIBRARY is also
650 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
651 # is blank as the main program is not linked directly against LDLIBRARY.
652 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
653 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
654 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
655 # DLLLIBRARY is the shared (i.e., DLL) library.
657 # RUNSHARED is used to run shared python without installed libraries
659 # INSTSONAME is the name of the shared library that will be use to install
660 # on the system - some systems like version suffix, others don't
661 AC_SUBST(LDLIBRARY)
662 AC_SUBST(DLLLIBRARY)
663 AC_SUBST(BLDLIBRARY)
664 AC_SUBST(LDLIBRARYDIR)
665 AC_SUBST(INSTSONAME)
666 AC_SUBST(RUNSHARED)
667 LDLIBRARY="$LIBRARY"
668 BLDLIBRARY='$(LDLIBRARY)'
669 INSTSONAME='$(LDLIBRARY)'
670 DLLLIBRARY=''
671 LDLIBRARYDIR=''
672 RUNSHARED=''
674 # LINKCC is the command that links the python executable -- default is $(CC).
675 # If CXX is set, and if it is needed to link a main function that was
676 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
677 # python might then depend on the C++ runtime
678 # This is altered for AIX in order to build the export list before 
679 # linking.
680 AC_SUBST(LINKCC)
681 AC_MSG_CHECKING(LINKCC)
682 if test -z "$LINKCC"
683 then
684         LINKCC='$(PURIFY) $(MAINCC)'
685         case $ac_sys_system in
686         AIX*)
687            exp_extra="\"\""
688            if test $ac_sys_release -ge 5 -o \
689                    $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
690                exp_extra="."
691            fi
692            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
693         QNX*)
694            # qcc must be used because the other compilers do not
695            # support -N.
696            LINKCC=qcc;;
697         esac
699 AC_MSG_RESULT($LINKCC)
701 # GNULD is set to "yes" if the GNU linker is used.  If this goes wrong
702 # make sure we default having it set to "no": this is used by
703 # distutils.unixccompiler to know if it should add --enable-new-dtags
704 # to linker command lines, and failing to detect GNU ld simply results
705 # in the same bahaviour as before.
706 AC_SUBST(GNULD)
707 AC_MSG_CHECKING(for GNU ld)
708 ac_prog=ld
709 if test "$GCC" = yes; then
710        ac_prog=`$CC -print-prog-name=ld`
712 case `"$ac_prog" -V 2>&1 < /dev/null` in
713       *GNU*)
714           GNULD=yes;;
715       *)
716           GNULD=no;;
717 esac
718 AC_MSG_RESULT($GNULD)
720 AC_MSG_CHECKING(for --enable-shared)
721 AC_ARG_ENABLE(shared,
722               AS_HELP_STRING([--enable-shared], [disable/enable building shared python library]))
724 if test -z "$enable_shared"
725 then 
726   case $ac_sys_system in
727   CYGWIN* | atheos*)
728     enable_shared="yes";;
729   *)
730     enable_shared="no";;
731   esac
733 AC_MSG_RESULT($enable_shared)
735 AC_MSG_CHECKING(for --enable-profiling)
736 AC_ARG_ENABLE(profiling,
737               AS_HELP_STRING([--enable-profiling], [enable C-level code profiling]),
738 [ac_save_cc="$CC"
739  CC="$CC -pg"
740  AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
741    [ac_enable_profiling="yes"],
742    [ac_enable_profiling="no"],
743    [ac_enable_profiling="no"])
744  CC="$ac_save_cc"])
745 AC_MSG_RESULT($ac_enable_profiling)
747 case "$ac_enable_profiling" in
748     "yes")
749         BASECFLAGS="-pg $BASECFLAGS"
750         LDFLAGS="-pg $LDFLAGS"
751     ;;
752 esac
754 AC_MSG_CHECKING(LDLIBRARY)
756 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
757 # library that we build, but we do not want to link against it (we
758 # will find it with a -framework option). For this reason there is an
759 # extra variable BLDLIBRARY against which Python and the extension
760 # modules are linked, BLDLIBRARY. This is normally the same as
761 # LDLIBRARY, but empty for MacOSX framework builds.
762 if test "$enable_framework"
763 then
764   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
765   RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
766   BLDLIBRARY=''
767 else
768   BLDLIBRARY='$(LDLIBRARY)'
769 fi  
771 # Other platforms follow
772 if test $enable_shared = "yes"; then
773   AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
774   case $ac_sys_system in
775     BeOS*)
776           LDLIBRARY='libpython$(VERSION).so'
777           ;;
778     CYGWIN*)
779           LDLIBRARY='libpython$(VERSION).dll.a'
780           DLLLIBRARY='libpython$(VERSION).dll'
781           ;;
782     SunOS*)
783           LDLIBRARY='libpython$(VERSION).so'
784           BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
785           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
786           INSTSONAME="$LDLIBRARY".$SOVERSION
787           ;;
788     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
789           LDLIBRARY='libpython$(VERSION).so'
790           BLDLIBRARY='-L. -lpython$(VERSION)'
791           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
792           case $ac_sys_system in
793               FreeBSD*)
794                 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
795                 ;;
796           esac
797           INSTSONAME="$LDLIBRARY".$SOVERSION
798           ;;
799     hp*|HP*)
800           case `uname -m` in
801                 ia64)
802                         LDLIBRARY='libpython$(VERSION).so'
803                         ;;
804                 *)
805                         LDLIBRARY='libpython$(VERSION).sl'
806                         ;;
807           esac
808           BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
809           RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
810           ;;
811     OSF*)
812           LDLIBRARY='libpython$(VERSION).so'
813           BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
814           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
815           ;;
816     atheos*)
817           LDLIBRARY='libpython$(VERSION).so'
818           BLDLIBRARY='-L. -lpython$(VERSION)'
819           RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
820           ;;
821     Darwin*)
822         LDLIBRARY='libpython$(VERSION).dylib'
823         BLDLIBRARY='-L. -lpython$(VERSION)'
824         RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}'
825         ;;
827   esac
828 else # shared is disabled
829   case $ac_sys_system in
830     CYGWIN*)
831           BLDLIBRARY='$(LIBRARY)'
832           LDLIBRARY='libpython$(VERSION).dll.a'
833           ;;
834   esac
837 AC_MSG_RESULT($LDLIBRARY)
839 AC_PROG_RANLIB
840 AC_SUBST(AR)
841 AC_CHECK_PROGS(AR, ar aal, ar)
843 # tweak ARFLAGS only if the user didn't set it on the command line
844 AC_SUBST(ARFLAGS)
845 if test -z "$ARFLAGS"
846 then
847         ARFLAGS="rc"
850 AC_SUBST(SVNVERSION)
851 AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
852 if test $SVNVERSION = found
853 then
854         SVNVERSION="svnversion \$(srcdir)"
855 else
856         SVNVERSION="echo Unversioned directory"
859 case $MACHDEP in
860 bsdos*|hp*|HP*)
861         # install -d does not work on BSDI or HP-UX
862         if test -z "$INSTALL"
863         then
864                 INSTALL="${srcdir}/install-sh -c"
865         fi
866 esac
867 AC_PROG_INSTALL
869 # Not every filesystem supports hard links
870 AC_SUBST(LN)
871 if test -z "$LN" ; then
872         case $ac_sys_system in
873                 BeOS*) LN="ln -s";;
874                 CYGWIN*) LN="ln -s";;
875                 atheos*) LN="ln -s";;
876                 *) LN=ln;;
877         esac
880 # Check for --with-pydebug
881 AC_MSG_CHECKING(for --with-pydebug)
882 AC_ARG_WITH(pydebug, 
883             AS_HELP_STRING([--with-pydebug], [build with Py_DEBUG defined]),
885 if test "$withval" != no
886 then 
887   AC_DEFINE(Py_DEBUG, 1, 
888   [Define if you want to build an interpreter with many run-time checks.]) 
889   AC_MSG_RESULT(yes); 
890   Py_DEBUG='true'
891 else AC_MSG_RESULT(no); Py_DEBUG='false'
892 fi],
893 [AC_MSG_RESULT(no)])
895 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
896 # merged with this chunk of code?
898 # Optimizer/debugger flags
899 # ------------------------
900 # (The following bit of code is complicated enough - please keep things
901 # indented properly.  Just pretend you're editing Python code. ;-)
903 # There are two parallel sets of case statements below, one that checks to
904 # see if OPT was set and one that does BASECFLAGS setting based upon
905 # compiler and platform.  BASECFLAGS tweaks need to be made even if the
906 # user set OPT.
908 # tweak OPT based on compiler and platform, only if the user didn't set
909 # it on the command line
910 AC_SUBST(OPT)
911 if test "${OPT-unset}" = "unset"
912 then
913     case $GCC in
914     yes)
915         if test "$CC" != 'g++' ; then
916             STRICT_PROTO="-Wstrict-prototypes"
917         fi
918         # For gcc 4.x we need to use -fwrapv so lets check if its supported
919         if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
920            WRAP="-fwrapv"
921         fi
922         case $ac_cv_prog_cc_g in
923         yes)
924             if test "$Py_DEBUG" = 'true' ; then
925                 # Optimization messes up debuggers, so turn it off for
926                 # debug builds.
927                 OPT="-g -O0 -Wall $STRICT_PROTO"
928             else
929                 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
930             fi
931             ;;
932         *)
933             OPT="-O3 -Wall $STRICT_PROTO"
934             ;;
935         esac
936         case $ac_sys_system in
937             SCO_SV*) OPT="$OPT -m486 -DSCO5"
938             ;;
939         esac
940         ;;
942     *)
943         OPT="-O"
944         ;;
945     esac
948 AC_SUBST(BASECFLAGS)
950 # The -arch flags for universal builds on OSX
951 UNIVERSAL_ARCH_FLAGS=
952 AC_SUBST(UNIVERSAL_ARCH_FLAGS)
954 # tweak BASECFLAGS based on compiler and platform
955 case $GCC in
956 yes)
957     # Python violates C99 rules, by casting between incompatible
958     # pointer types. GCC may generate bad code as a result of that,
959     # so use -fno-strict-aliasing if supported.
960     AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
961      ac_save_cc="$CC"
962      CC="$CC -fno-strict-aliasing"
963      AC_CACHE_VAL(ac_cv_no_strict_aliasing_ok,
964        AC_COMPILE_IFELSE(
965          [AC_LANG_PROGRAM([[]], [[]])],
966          [ac_cv_no_strict_aliasing_ok=yes],
967          [ac_cv_no_strict_aliasing_ok=no]))
968      CC="$ac_save_cc"
969     AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
970     if test $ac_cv_no_strict_aliasing_ok = yes
971     then
972       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
973     fi
975     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
976     # support.  Without this, treatment of subnormals doesn't follow
977     # the standard.
978     case $ac_sys_machine in
979          alpha*)
980                 BASECFLAGS="$BASECFLAGS -mieee"
981                 ;;
982     esac
984     case $ac_sys_system in
985         SCO_SV*)
986             BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
987             ;;
988         # is there any other compiler on Darwin besides gcc?
989         Darwin*)
990             # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
991             # used to be here, but non-Apple gcc doesn't accept them.
992             if test "${CC}" = gcc
993             then
994                 AC_MSG_CHECKING(which compiler should be used)
995                 case "${UNIVERSALSDK}" in
996                 */MacOSX10.4u.sdk)
997                         # Build using 10.4 SDK, force usage of gcc when the 
998                         # compiler is gcc, otherwise the user will get very
999                         # confusing error messages when building on OSX 10.6
1000                         CC=gcc-4.0
1001                         CPP=cpp-4.0
1002                         ;;
1003                 esac
1004                 AC_MSG_RESULT($CC)
1005             fi
1007             # Calculate the right deployment target for this build.
1008             #
1009             cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1010             if test ${cur_target} '>' 10.2; then
1011                     cur_target=10.3
1012                     if test ${enable_universalsdk}; then
1013                             if test "${UNIVERSAL_ARCHS}" = "all"; then
1014                                     # Ensure that the default platform for a 
1015                                     # 4-way universal build is OSX 10.5, 
1016                                     # that's the first OS release where 
1017                                     # 4-way builds make sense.
1018                                     cur_target='10.5'
1020                             elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
1021                                     cur_target='10.5'
1023                             elif test "${UNIVERSAL_ARCHS}" = "intel"; then
1024                                     cur_target='10.5'
1026                             elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
1027                                     cur_target='10.5'
1028                             fi
1029                     else
1030                             if test `/usr/bin/arch` = "i386"; then
1031                                     # On Intel macs default to a deployment
1032                                     # target of 10.4, that's the first OSX
1033                                     # release with Intel support.
1034                                     cur_target="10.4"
1035                             fi
1036                     fi
1037             fi
1038             CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1039             
1040             # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
1041             # environment with a value that is the same as what we'll use
1042             # in the Makefile to ensure that we'll get the same compiler
1043             # environment during configure and build time.
1044             MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1045             export MACOSX_DEPLOYMENT_TARGET
1046             EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1048             if test "${enable_universalsdk}"; then
1049                 UNIVERSAL_ARCH_FLAGS=""
1050                 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
1051                    UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
1052                    ARCH_RUN_32BIT=""
1053                    LIPO_32BIT_FLAGS=""
1055                  elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
1056                    UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
1057                    LIPO_32BIT_FLAGS=""
1058                    ARCH_RUN_32BIT="true"
1060                  elif test "$UNIVERSAL_ARCHS" = "all" ; then
1061                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
1062                    LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1063                    ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1065                  elif test "$UNIVERSAL_ARCHS" = "intel" ; then
1066                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
1067                    LIPO_32BIT_FLAGS="-extract i386"
1068                    ARCH_RUN_32BIT="/usr/bin/arch -i386"
1070                  elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
1071                    UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
1072                    LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
1073                    ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
1075                  else
1076                    AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
1078                  fi
1081                 CFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CFLAGS}"
1082                 if test "${UNIVERSALSDK}" != "/" 
1083                 then
1084                         CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
1085                         LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1086                         CFLAGS="-isysroot ${UNIVERSALSDK} ${CFLAGS}"
1087                 fi
1089             fi
1092             ;;
1093         OSF*)
1094             BASECFLAGS="$BASECFLAGS -mieee"
1095             ;;
1096     esac
1097     ;;
1100     case $ac_sys_system in
1101     OpenUNIX*|UnixWare*)
1102         BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
1103         ;;
1104     OSF*)
1105         BASECFLAGS="$BASECFLAGS -ieee -std"
1106         ;;
1107     SCO_SV*)
1108         BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
1109         ;;
1110     esac
1111     ;;
1112 esac
1114 if test "$Py_DEBUG" = 'true'; then
1115   :
1116 else
1117   OPT="-DNDEBUG $OPT"
1120 if test "$ac_arch_flags"
1121 then
1122         BASECFLAGS="$BASECFLAGS $ac_arch_flags"
1125 # disable check for icc since it seems to pass, but generates a warning
1126 if test "$CC" = icc
1127 then
1128   ac_cv_opt_olimit_ok=no
1131 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
1132 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
1133 [ac_save_cc="$CC"
1134 CC="$CC -OPT:Olimit=0"
1135 AC_COMPILE_IFELSE(
1136   [AC_LANG_PROGRAM([[]], [[]])],
1137   [ac_cv_opt_olimit_ok=yes],
1138   [ac_cv_opt_olimit_ok=no]
1139   )
1140 CC="$ac_save_cc"])
1141 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
1142 if test $ac_cv_opt_olimit_ok = yes; then
1143     case $ac_sys_system in
1144         # XXX is this branch needed? On MacOSX 10.2.2 the result of the
1145         # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
1146         # environment?
1147         Darwin*)
1148             ;;
1149         *)
1150             BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
1151             ;;
1152     esac
1153 else
1154   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
1155   AC_CACHE_VAL(ac_cv_olimit_ok,
1156   [ac_save_cc="$CC"
1157   CC="$CC -Olimit 1500"
1158   AC_COMPILE_IFELSE(
1159     [AC_LANG_PROGRAM([[]], [[]])],
1160     [ac_cv_olimit_ok=yes],
1161     [ac_cv_olimit_ok=no]
1162     )
1163   CC="$ac_save_cc"])
1164   AC_MSG_RESULT($ac_cv_olimit_ok)
1165   if test $ac_cv_olimit_ok = yes; then
1166     BASECFLAGS="$BASECFLAGS -Olimit 1500"
1167   fi
1170 # Check whether GCC supports PyArg_ParseTuple format
1171 if test "$GCC" = "yes"
1172 then
1173   AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
1174   save_CFLAGS=$CFLAGS
1175   CFLAGS="$CFLAGS -Werror"
1176   AC_COMPILE_IFELSE([
1177     AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
1178   ],[
1179     AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1,
1180       [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
1181     AC_MSG_RESULT(yes)
1182   ],[
1183     AC_MSG_RESULT(no)
1184   ])
1185   CFLAGS=$save_CFLAGS
1188 # On some compilers, pthreads are available without further options
1189 # (e.g. MacOS X). On some of these systems, the compiler will not
1190 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
1191 # So we have to see first whether pthreads are available without
1192 # options before we can check whether -Kpthread improves anything.
1193 AC_MSG_CHECKING(whether pthreads are available without options)
1194 AC_CACHE_VAL(ac_cv_pthread_is_default,
1195 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1196 #include <pthread.h>
1198 void* routine(void* p){return NULL;}
1200 int main(){
1201   pthread_t p;
1202   if(pthread_create(&p,NULL,routine,NULL)!=0)
1203     return 1;
1204   (void)pthread_detach(p);
1205   return 0;
1207 ]])],[
1208   ac_cv_pthread_is_default=yes
1209   ac_cv_kthread=no
1210   ac_cv_pthread=no
1211 ],[ac_cv_pthread_is_default=no],[ac_cv_pthread_is_default=no])
1213 AC_MSG_RESULT($ac_cv_pthread_is_default)
1216 if test $ac_cv_pthread_is_default = yes 
1217 then
1218   ac_cv_kpthread=no
1219 else
1220 # -Kpthread, if available, provides the right #defines
1221 # and linker options to make pthread_create available
1222 # Some compilers won't report that they do not support -Kpthread,
1223 # so we need to run a program to see whether it really made the
1224 # function available.
1225 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
1226 AC_CACHE_VAL(ac_cv_kpthread,
1227 [ac_save_cc="$CC"
1228 CC="$CC -Kpthread"
1229 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1230 #include <pthread.h>
1232 void* routine(void* p){return NULL;}
1234 int main(){
1235   pthread_t p;
1236   if(pthread_create(&p,NULL,routine,NULL)!=0)
1237     return 1;
1238   (void)pthread_detach(p);
1239   return 0;
1241 ]])],[ac_cv_kpthread=yes],[ac_cv_kpthread=no],[ac_cv_kpthread=no])
1242 CC="$ac_save_cc"])
1243 AC_MSG_RESULT($ac_cv_kpthread)
1246 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
1247 then
1248 # -Kthread, if available, provides the right #defines
1249 # and linker options to make pthread_create available
1250 # Some compilers won't report that they do not support -Kthread,
1251 # so we need to run a program to see whether it really made the
1252 # function available.
1253 AC_MSG_CHECKING(whether $CC accepts -Kthread)
1254 AC_CACHE_VAL(ac_cv_kthread,
1255 [ac_save_cc="$CC"
1256 CC="$CC -Kthread"
1257 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1258 #include <pthread.h>
1260 void* routine(void* p){return NULL;}
1262 int main(){
1263   pthread_t p;
1264   if(pthread_create(&p,NULL,routine,NULL)!=0)
1265     return 1;
1266   (void)pthread_detach(p);
1267   return 0;
1269 ]])],[ac_cv_kthread=yes],[ac_cv_kthread=no],[ac_cv_kthread=no])
1270 CC="$ac_save_cc"])
1271 AC_MSG_RESULT($ac_cv_kthread)
1274 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
1275 then
1276 # -pthread, if available, provides the right #defines
1277 # and linker options to make pthread_create available
1278 # Some compilers won't report that they do not support -pthread,
1279 # so we need to run a program to see whether it really made the
1280 # function available.
1281 AC_MSG_CHECKING(whether $CC accepts -pthread)
1282 AC_CACHE_VAL(ac_cv_thread,
1283 [ac_save_cc="$CC"
1284 CC="$CC -pthread"
1285 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1286 #include <pthread.h>
1288 void* routine(void* p){return NULL;}
1290 int main(){
1291   pthread_t p;
1292   if(pthread_create(&p,NULL,routine,NULL)!=0)
1293     return 1;
1294   (void)pthread_detach(p);
1295   return 0;
1297 ]])],[ac_cv_pthread=yes],[ac_cv_pthread=no],[ac_cv_pthread=no])
1298 CC="$ac_save_cc"])
1299 AC_MSG_RESULT($ac_cv_pthread)
1302 # If we have set a CC compiler flag for thread support then
1303 # check if it works for CXX, too.
1304 ac_cv_cxx_thread=no
1305 if test ! -z "$CXX"
1306 then
1307 AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1308 ac_save_cxx="$CXX"
1310 if test "$ac_cv_kpthread" = "yes"
1311 then
1312   CXX="$CXX -Kpthread"  
1313   ac_cv_cxx_thread=yes
1314 elif test "$ac_cv_kthread" = "yes"
1315 then
1316   CXX="$CXX -Kthread"
1317   ac_cv_cxx_thread=yes
1318 elif test "$ac_cv_pthread" = "yes"
1319 then 
1320   CXX="$CXX -pthread"
1321   ac_cv_cxx_thread=yes
1324 if test $ac_cv_cxx_thread = yes
1325 then
1326   echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1327   $CXX -c conftest.$ac_ext 2>&5
1328   if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1329      && test -s conftest$ac_exeext && ./conftest$ac_exeext
1330   then
1331     ac_cv_cxx_thread=yes
1332   else
1333     ac_cv_cxx_thread=no
1334   fi
1335   rm -fr conftest*
1337 AC_MSG_RESULT($ac_cv_cxx_thread)
1339 CXX="$ac_save_cxx"
1341 dnl # check for ANSI or K&R ("traditional") preprocessor
1342 dnl AC_MSG_CHECKING(for C preprocessor type)
1343 dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1344 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1345 dnl int foo;
1346 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1347 dnl ]], [[;]])],[cpp_type=ansi],[AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional])
1348 dnl AC_MSG_RESULT($cpp_type)
1350 # checks for header files
1351 AC_HEADER_STDC
1352 AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1353 fcntl.h grp.h \
1354 ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
1355 shadow.h signal.h stdint.h stropts.h termios.h thread.h \
1356 unistd.h utime.h \
1357 sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1358 sys/lock.h sys/mkdev.h sys/modem.h \
1359 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
1360 sys/termio.h sys/time.h \
1361 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
1362 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
1363 bluetooth/bluetooth.h linux/tipc.h spawn.h util.h)
1364 AC_HEADER_DIRENT
1365 AC_HEADER_MAJOR
1367 # On Solaris, term.h requires curses.h
1368 AC_CHECK_HEADERS(term.h,,,[
1369 #ifdef HAVE_CURSES_H
1370 #include <curses.h>
1371 #endif
1374 # On Linux, netlink.h requires asm/types.h
1375 AC_CHECK_HEADERS(linux/netlink.h,,,[
1376 #ifdef HAVE_ASM_TYPES_H
1377 #include <asm/types.h>
1378 #endif
1379 #ifdef HAVE_SYS_SOCKET_H
1380 #include <sys/socket.h>
1381 #endif
1384 # checks for typedefs
1385 was_it_defined=no
1386 AC_MSG_CHECKING(for clock_t in time.h)
1387 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1388     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1390 AC_MSG_RESULT($was_it_defined)
1392 # Check whether using makedev requires defining _OSF_SOURCE
1393 AC_MSG_CHECKING(for makedev)
1394 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1395 #if defined(MAJOR_IN_MKDEV)
1396 #include <sys/mkdev.h>
1397 #elif defined(MAJOR_IN_SYSMACROS)
1398 #include <sys/sysmacros.h>
1399 #else
1400 #include <sys/types.h>
1401 #endif ]], [[ makedev(0, 0) ]])],
1402 [ac_cv_has_makedev=yes],
1403 [ac_cv_has_makedev=no])
1404 if test "$ac_cv_has_makedev" = "no"; then
1405     # we didn't link, try if _OSF_SOURCE will allow us to link
1406     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1407 #define _OSF_SOURCE 1
1408 #include <sys/types.h>
1409     ]], [[ makedev(0, 0) ]])],
1410 [ac_cv_has_makedev=yes],
1411 [ac_cv_has_makedev=no])
1412     if test "$ac_cv_has_makedev" = "yes"; then
1413         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1414     fi
1416 AC_MSG_RESULT($ac_cv_has_makedev)
1417 if test "$ac_cv_has_makedev" = "yes"; then
1418     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1421 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1422 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1423 # defined, but the compiler does not support pragma redefine_extname,
1424 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1425 # structures (such as rlimit64) without declaring them. As a
1426 # work-around, disable LFS on such configurations
1428 use_lfs=yes
1429 AC_MSG_CHECKING(Solaris LFS bug)
1430 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1431 #define _LARGEFILE_SOURCE 1
1432 #define _FILE_OFFSET_BITS 64
1433 #include <sys/resource.h>
1434 ]], [[struct rlimit foo;]])],[sol_lfs_bug=no],[sol_lfs_bug=yes])
1435 AC_MSG_RESULT($sol_lfs_bug)
1436 if test "$sol_lfs_bug" = "yes"; then
1437   use_lfs=no
1440 if test "$use_lfs" = "yes"; then
1441 # Two defines needed to enable largefile support on various platforms
1442 # These may affect some typedefs
1443 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
1444 [This must be defined on some systems to enable large file support.])
1445 AC_DEFINE(_FILE_OFFSET_BITS, 64,
1446 [This must be set to 64 on some systems to enable large file support.])
1449 # Add some code to confdefs.h so that the test for off_t works on SCO
1450 cat >> confdefs.h <<\EOF
1451 #if defined(SCO_DS)
1452 #undef _OFF_T
1453 #endif
1456 # Type availability checks
1457 AC_TYPE_MODE_T
1458 AC_TYPE_OFF_T
1459 AC_TYPE_PID_T
1460 AC_DEFINE_UNQUOTED([RETSIGTYPE],[void],[assume C89 semantics that RETSIGTYPE is always void])
1461 AC_TYPE_SIZE_T
1462 AC_TYPE_UID_T
1463 AC_TYPE_UINT32_T
1464 AC_TYPE_UINT64_T
1465 AC_TYPE_INT32_T
1466 AC_TYPE_INT64_T
1467 AC_CHECK_TYPE(ssize_t,
1468   AC_DEFINE(HAVE_SSIZE_T, 1, [Define if your compiler provides ssize_t]),,)
1470 # Sizes of various common basic types
1471 # ANSI C requires sizeof(char) == 1, so no need to check it
1472 AC_CHECK_SIZEOF(int, 4)
1473 AC_CHECK_SIZEOF(long, 4)
1474 AC_CHECK_SIZEOF(void *, 4)
1475 AC_CHECK_SIZEOF(short, 2)
1476 AC_CHECK_SIZEOF(float, 4)
1477 AC_CHECK_SIZEOF(double, 8)
1478 AC_CHECK_SIZEOF(fpos_t, 4)
1479 AC_CHECK_SIZEOF(size_t, 4)
1480 AC_CHECK_SIZEOF(pid_t, 4)
1482 AC_MSG_CHECKING(for long long support)
1483 have_long_long=no
1484 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long long x; x = (long long)0;]])],[
1485   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
1486   have_long_long=yes
1487 ],[])
1488 AC_MSG_RESULT($have_long_long)
1489 if test "$have_long_long" = yes ; then
1490 AC_CHECK_SIZEOF(long long, 8)
1493 AC_MSG_CHECKING(for long double support)
1494 have_long_double=no
1495 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[long double x; x = (long double)0;]])],[
1496   AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.])
1497   have_long_double=yes
1498 ],[])
1499 AC_MSG_RESULT($have_long_double)
1500 if test "$have_long_double" = yes ; then
1501 AC_CHECK_SIZEOF(long double, 12)
1504 AC_MSG_CHECKING(for _Bool support)
1505 have_c99_bool=no
1506 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[_Bool x; x = (_Bool)0;]])],[
1507   AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) 
1508   have_c99_bool=yes
1509 ],[])
1510 AC_MSG_RESULT($have_c99_bool)
1511 if test "$have_c99_bool" = yes ; then
1512 AC_CHECK_SIZEOF(_Bool, 1)
1515 AC_CHECK_TYPES(uintptr_t, 
1516    [AC_CHECK_SIZEOF(uintptr_t, 4)], 
1517    [], [#ifdef HAVE_STDINT_H
1518         #include <stdint.h>
1519         #endif])
1521 AC_CHECK_SIZEOF(off_t, [], [
1522 #ifdef HAVE_SYS_TYPES_H
1523 #include <sys/types.h>
1524 #endif
1527 AC_MSG_CHECKING(whether to enable large file support)
1528 if test "$have_long_long" = yes
1529 then
1530 if test "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1531         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1532   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
1533   [Defined to enable large file support when an off_t is bigger than a long
1534    and long long is available and at least as big as an off_t. You may need
1535    to add some flags for configuration and compilation to enable this mode.
1536    (For Solaris and Linux, the necessary defines are already defined.)])
1537   AC_MSG_RESULT(yes)
1538 else
1539   AC_MSG_RESULT(no)
1541 else
1542   AC_MSG_RESULT(no)
1545 AC_CHECK_SIZEOF(time_t, [], [
1546 #ifdef HAVE_SYS_TYPES_H
1547 #include <sys/types.h>
1548 #endif
1549 #ifdef HAVE_TIME_H
1550 #include <time.h>
1551 #endif
1554 # if have pthread_t then define SIZEOF_PTHREAD_T
1555 ac_save_cc="$CC"
1556 if test "$ac_cv_kpthread" = "yes"
1557 then CC="$CC -Kpthread"
1558 elif test "$ac_cv_kthread" = "yes"
1559 then CC="$CC -Kthread"
1560 elif test "$ac_cv_pthread" = "yes"
1561 then CC="$CC -pthread"
1563 AC_MSG_CHECKING(for pthread_t)
1564 have_pthread_t=no
1565 AC_COMPILE_IFELSE([
1566   AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t x; x = *(pthread_t*)0;]])
1567 ],[have_pthread_t=yes],[])
1568 AC_MSG_RESULT($have_pthread_t)
1569 if test "$have_pthread_t" = yes ; then
1570   AC_CHECK_SIZEOF(pthread_t, [], [
1571 #ifdef HAVE_PTHREAD_H
1572 #include <pthread.h>
1573 #endif
1574   ])
1576 CC="$ac_save_cc"
1578 AC_MSG_CHECKING(for --enable-toolbox-glue)
1579 AC_ARG_ENABLE(toolbox-glue,
1580               AS_HELP_STRING([--enable-toolbox-glue], [disable/enable MacOSX glue code for extensions]))
1582 if test -z "$enable_toolbox_glue"
1583 then 
1584         case $ac_sys_system/$ac_sys_release in
1585         Darwin/*)
1586                 enable_toolbox_glue="yes";;
1587         *)
1588                 enable_toolbox_glue="no";;
1589         esac
1591 case "$enable_toolbox_glue" in
1592 yes)
1593         extra_machdep_objs="Python/mactoolboxglue.o"
1594         extra_undefs="-u _PyMac_Error"
1595         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1596          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1597         ;;
1599         extra_machdep_objs=""
1600         extra_undefs=""
1601         ;;
1602 esac
1603 AC_MSG_RESULT($enable_toolbox_glue)
1606 AC_SUBST(OTHER_LIBTOOL_OPT)
1607 case $ac_sys_system/$ac_sys_release in
1608   Darwin/@<:@01567@:>@\..*) 
1609     OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1610     ;;
1611   Darwin/*)
1612     OTHER_LIBTOOL_OPT=""
1613     ;;
1614 esac
1617 ARCH_RUN_32BIT=""
1618 AC_SUBST(LIBTOOL_CRUFT)
1619 case $ac_sys_system/$ac_sys_release in
1620   Darwin/@<:@01567@:>@\..*) 
1621     LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1622     if test "${enable_universalsdk}"; then
1623             :
1624     else
1625         LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `/usr/bin/arch`"
1626     fi
1627     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1628     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1629   Darwin/*)
1630     gcc_version=`gcc -dumpversion`
1631     if test ${gcc_version} '<' 4.0
1632         then
1633             LIBTOOL_CRUFT="-lcc_dynamic"
1634         else 
1635             LIBTOOL_CRUFT=""
1636     fi
1637     AC_RUN_IFELSE([AC_LANG_SOURCE([[
1638     #include <unistd.h>
1639     int main(int argc, char*argv[])
1640     {
1641       if (sizeof(long) == 4) {
1642           return 0;
1643       } else {
1644           return 1;
1645       }
1646     }
1647     ]])],[ac_osx_32bit=yes],[ac_osx_32bit=no],[ac_osx_32bit=yes])
1648     
1649     if test "${ac_osx_32bit}" = "yes"; then
1650         case `/usr/bin/arch` in
1651         i386) 
1652                 MACOSX_DEFAULT_ARCH="i386" 
1653                 ;;
1654         ppc) 
1655                 MACOSX_DEFAULT_ARCH="ppc" 
1656                 ;;
1657         *)
1658                 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1659                 ;;
1660         esac
1661     else
1662         case `/usr/bin/arch` in
1663         i386) 
1664                 MACOSX_DEFAULT_ARCH="x86_64" 
1665                 ;;
1666         ppc) 
1667                 MACOSX_DEFAULT_ARCH="ppc64" 
1668                 ;;
1669         *)
1670                 AC_MSG_ERROR([Unexpected output of 'arch' on OSX])
1671                 ;;
1672         esac
1674         #ARCH_RUN_32BIT="true"
1675     fi
1677     LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only ${MACOSX_DEFAULT_ARCH}"
1678     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1679     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1680 esac
1682 AC_MSG_CHECKING(for --enable-framework)
1683 if test "$enable_framework"
1684 then
1685         BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1686         # -F. is needed to allow linking to the framework while 
1687         # in the build location.
1688         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
1689          [Define if you want to produce an OpenStep/Rhapsody framework
1690          (shared library plus accessory files).])
1691         AC_MSG_RESULT(yes)
1692         if test $enable_shared = "yes"
1693         then
1694                 AC_MSG_ERROR([Specifying both --enable-shared and --enable-framework is not supported, use only --enable-framework instead. See Mac/README.])
1695         fi
1696 else
1697         AC_MSG_RESULT(no)
1700 AC_MSG_CHECKING(for dyld)
1701 case $ac_sys_system/$ac_sys_release in
1702   Darwin/*)
1703         AC_DEFINE(WITH_DYLD, 1, 
1704         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1705          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1706          linker (rld). Dyld is necessary to support frameworks.])
1707         AC_MSG_RESULT(always on for Darwin)
1708         ;;
1709   *)
1710         AC_MSG_RESULT(no)
1711         ;;
1712 esac
1714 # Set info about shared libraries.
1715 AC_SUBST(SO)
1716 AC_SUBST(LDSHARED)
1717 AC_SUBST(LDCXXSHARED)
1718 AC_SUBST(BLDSHARED)
1719 AC_SUBST(CCSHARED)
1720 AC_SUBST(LINKFORSHARED)
1721 # SO is the extension of shared libraries `(including the dot!)
1722 # -- usually .so, .sl on HP-UX, .dll on Cygwin
1723 AC_MSG_CHECKING(SO)
1724 if test -z "$SO"
1725 then
1726         case $ac_sys_system in
1727         hp*|HP*)
1728                 case `uname -m` in
1729                         ia64) SO=.so;;
1730                         *)    SO=.sl;;
1731                 esac
1732                 ;;
1733         CYGWIN*)   SO=.dll;;
1734         *)         SO=.so;;
1735         esac
1736 else
1737         # this might also be a termcap variable, see #610332
1738         echo
1739         echo '====================================================================='
1740         echo '+                                                                   +'
1741         echo '+ WARNING: You have set SO in your environment.                     +'
1742         echo '+ Do you really mean to change the extension for shared libraries?  +'
1743         echo '+ Continuing in 10 seconds to let you to ponder.                    +'
1744         echo '+                                                                   +'
1745         echo '====================================================================='
1746         sleep 10
1748 AC_MSG_RESULT($SO)
1750 AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
1751 # LDSHARED is the ld *command* used to create shared library
1752 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1753 # (Shared libraries in this instance are shared modules to be loaded into
1754 # Python, as opposed to building Python itself as a shared library.)
1755 AC_MSG_CHECKING(LDSHARED)
1756 if test -z "$LDSHARED"
1757 then
1758         case $ac_sys_system/$ac_sys_release in
1759         AIX*)
1760                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1761                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1762                 ;;
1763         BeOS*)
1764                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1765                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1766                 ;;
1767         IRIX/5*) LDSHARED="ld -shared";;
1768         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1769         SunOS/5*) 
1770                 if test "$GCC" = "yes" ; then
1771                         LDSHARED='$(CC) -shared'
1772                         LDCXXSHARED='$(CXX) -shared'
1773                 else
1774                         LDSHARED='$(CC) -G'
1775                         LDCXXSHARED='$(CXX) -G'
1776                 fi ;;
1777         hp*|HP*)
1778                 if test "$GCC" = "yes" ; then
1779                         LDSHARED='$(CC) -shared'
1780                         LDCXXSHARED='$(CXX) -shared'
1781                 else
1782                         LDSHARED='ld -b'
1783                 fi ;;
1784         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1785         Darwin/1.3*)
1786                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1787                 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
1788                 if test "$enable_framework" ; then
1789                         # Link against the framework. All externals should be defined.
1790                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1791                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1792                         LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1793                 else
1794                         # No framework. Ignore undefined symbols, assuming they come from Python
1795                         LDSHARED="$LDSHARED -undefined suppress"
1796                         LDCXXSHARED="$LDCXXSHARED -undefined suppress"
1797                 fi ;;
1798         Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1799                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1800                 LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
1801                 if test "$enable_framework" ; then
1802                         # Link against the framework. All externals should be defined.
1803                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1804                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1805                         LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1806                 else
1807                         # No framework, use the Python app as bundle-loader
1808                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1809                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1810                         LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1811                 fi ;;
1812         Darwin/*)
1813                 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1814                 # This allows an extension to be used in any Python
1816                 if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2
1817                 then
1818                         if test "${enable_universalsdk}"; then
1819                                 LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1820                         fi
1821                         LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1822                         LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1823                         BLDSHARED="$LDSHARED"
1824                 else
1825                         LDSHARED='$(CC) $(LDFLAGS) -bundle'
1826                         LDCXXSHARED='$(CXX) $(LDFLAGS) -bundle'
1827                         if test "$enable_framework" ; then
1828                                 # Link against the framework. All externals should be defined.
1829                                 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1830                                 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1831                                 LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1832                         else
1833                                 # No framework, use the Python app as bundle-loader
1834                                 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1835                                 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1836                                 LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1837                         fi
1838                 fi
1839                 ;;
1840         Linux*|GNU*|QNX*)
1841                 LDSHARED='$(CC) -shared'
1842                 LDCXXSHARED='$(CXX) -shared';;
1843         BSD/OS*/4*)
1844                 LDSHARED="gcc -shared"
1845                 LDCXXSHARED="g++ -shared";;
1846         FreeBSD*)
1847                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1848                 then
1849                         LDSHARED='$(CC) -shared ${LDFLAGS}'
1850                         LDCXXSHARED='$(CXX) -shared ${LDFLAGS}'
1851                 else
1852                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1853                 fi;;
1854         OpenBSD*)
1855                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1856                 then
1857                                 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1858                                 LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
1859                 else
1860                                 case `uname -r` in
1861                                 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1862                                    LDSHARED="ld -Bshareable ${LDFLAGS}"
1863                                    ;;
1864                                 *)
1865                                    LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1866                                    LDCXXSHARED='$(CXX) -shared $(CCSHARED) ${LDFLAGS}'
1867                                    ;;
1868                                 esac
1869                 fi;;
1870         NetBSD*|DragonFly*)
1871                 LDSHARED="cc -shared ${LDFLAGS}"
1872                 LDCXXSHARED="c++ -shared ${LDFLAGS}";;
1873         OpenUNIX*|UnixWare*)
1874                 if test "$GCC" = "yes" ; then
1875                         LDSHARED='$(CC) -shared'
1876                         LDCXXSHARED='$(CXX) -shared'
1877                 else
1878                         LDSHARED='$(CC) -G'
1879                         LDCXXSHARED='$(CXX) -G'
1880                 fi;;
1881         SCO_SV*)
1882                 LDSHARED='$(CC) -Wl,-G,-Bexport'
1883                 LDCXXSHARED='$(CXX) -Wl,-G,-Bexport';;
1884         CYGWIN*)
1885                 LDSHARED="gcc -shared -Wl,--enable-auto-image-base"
1886                 LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";;
1887         atheos*)
1888                 LDSHARED="gcc -shared"
1889                 LDCXXSHARED="g++ -shared";;
1890         *)      LDSHARED="ld";;
1891         esac
1893 AC_MSG_RESULT($LDSHARED)
1894 LDCXXSHARED=${LDCXXSHARED-$LDSHARED}
1895 BLDSHARED=${BLDSHARED-$LDSHARED}
1896 # CCSHARED are the C *flags* used to create objects to go into a shared
1897 # library (module) -- this is only needed for a few systems
1898 AC_MSG_CHECKING(CCSHARED)
1899 if test -z "$CCSHARED"
1900 then
1901         case $ac_sys_system/$ac_sys_release in
1902         SunOS*) if test "$GCC" = yes;
1903                 then CCSHARED="-fPIC";
1904                 elif test `uname -p` = sparc;
1905                 then CCSHARED="-xcode=pic32";
1906                 else CCSHARED="-Kpic";
1907                 fi;;
1908         hp*|HP*) if test "$GCC" = yes;
1909                  then CCSHARED="-fPIC";
1910                  else CCSHARED="+z";
1911                  fi;;
1912         Linux*|GNU*) CCSHARED="-fPIC";;
1913         BSD/OS*/4*) CCSHARED="-fpic";;
1914         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
1915         OpenUNIX*|UnixWare*)
1916                 if test "$GCC" = "yes"
1917                 then CCSHARED="-fPIC"
1918                 else CCSHARED="-KPIC"
1919                 fi;;
1920         SCO_SV*)
1921                 if test "$GCC" = "yes"
1922                 then CCSHARED="-fPIC"
1923                 else CCSHARED="-Kpic -belf"
1924                 fi;;
1925         IRIX*/6*)  case $CC in
1926                    *gcc*) CCSHARED="-shared";;
1927                    *) CCSHARED="";;
1928                    esac;;
1929         atheos*) CCSHARED="-fPIC";;
1930         esac
1932 AC_MSG_RESULT($CCSHARED)
1933 # LINKFORSHARED are the flags passed to the $(CC) command that links
1934 # the python executable -- this is only needed for a few systems
1935 AC_MSG_CHECKING(LINKFORSHARED)
1936 if test -z "$LINKFORSHARED"
1937 then
1938         case $ac_sys_system/$ac_sys_release in
1939         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1940         hp*|HP*)
1941             LINKFORSHARED="-Wl,-E -Wl,+s";;
1942 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1943         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1944         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1945         # -u libsys_s pulls in all symbols in libsys
1946         Darwin/*) 
1947                 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1948                 # which is
1949                 # not used by the core itself but which needs to be in the core so
1950                 # that dynamically loaded extension modules have access to it.
1951                 # -prebind is no longer used, because it actually seems to give a
1952                 # slowdown in stead of a speedup, maybe due to the large number of
1953                 # dynamic loads Python does.
1955                 LINKFORSHARED="$extra_undefs"
1956                 if test "$enable_framework"
1957                 then
1958                         LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1959                 fi
1960                 LINKFORSHARED="$LINKFORSHARED";;
1961         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1962         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1963         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1964         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) 
1965                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1966                 then
1967                         LINKFORSHARED="-Wl,--export-dynamic"
1968                 fi;;
1969         SunOS/5*) case $CC in
1970                   *gcc*)
1971                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1972                     then
1973                         LINKFORSHARED="-Xlinker --export-dynamic"
1974                     fi;;
1975                   esac;;
1976         CYGWIN*)
1977                 if test $enable_shared = "no"
1978                 then
1979                         LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1980                 fi;;
1981         QNX*)
1982                 # -Wl,-E causes the symbols to be added to the dynamic
1983                 # symbol table so that they can be found when a module
1984                 # is loaded.  -N 2048K causes the stack size to be set
1985                 # to 2048 kilobytes so that the stack doesn't overflow
1986                 # when running test_compile.py.
1987                 LINKFORSHARED='-Wl,-E -N 2048K';;
1988         esac
1990 AC_MSG_RESULT($LINKFORSHARED)
1993 AC_SUBST(CFLAGSFORSHARED)
1994 AC_MSG_CHECKING(CFLAGSFORSHARED)
1995 if test ! "$LIBRARY" = "$LDLIBRARY"
1996 then
1997         case $ac_sys_system in
1998         CYGWIN*)
1999                 # Cygwin needs CCSHARED when building extension DLLs
2000                 # but not when building the interpreter DLL.
2001                 CFLAGSFORSHARED='';;
2002         *)
2003                 CFLAGSFORSHARED='$(CCSHARED)'
2004         esac
2006 AC_MSG_RESULT($CFLAGSFORSHARED)
2008 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
2009 # library (with --enable-shared).
2010 # For platforms on which shared libraries are not allowed to have unresolved
2011 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
2012 # if it is not required, since it creates a dependency of the shared library
2013 # to LIBS. This, in turn, means that applications linking the shared libpython
2014 # don't need to link LIBS explicitly. The default should be only changed
2015 # on systems where this approach causes problems.
2016 AC_SUBST(SHLIBS)
2017 AC_MSG_CHECKING(SHLIBS)
2018 case "$ac_sys_system" in
2019         *)
2020                 SHLIBS='$(LIBS)';;
2021 esac
2022 AC_MSG_RESULT($SHLIBS)
2025 # checks for libraries
2026 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
2027 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
2029 # only check for sem_init if thread support is requested
2030 if test "$with_threads" = "yes" -o -z "$with_threads"; then
2031     AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2032                                                 # posix4 on Solaris 2.6
2033                                                 # pthread (first!) on Linux
2036 # check if we need libintl for locale functions
2037 AC_CHECK_LIB(intl, textdomain,
2038         AC_DEFINE(WITH_LIBINTL, 1,
2039         [Define to 1 if libintl is needed for locale functions.]))
2041 # checks for system dependent C++ extensions support
2042 case "$ac_sys_system" in
2043         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
2044                 AC_LINK_IFELSE([
2045                   AC_LANG_PROGRAM([[#include "/usr/lpp/xlC/include/load.h"]],
2046                                   [[loadAndInit("", 0, "")]])
2047                 ],[
2048                   AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
2049                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
2050                        and you want support for AIX C++ shared extension modules.])
2051                   AC_MSG_RESULT(yes)
2052                 ],[
2053                   AC_MSG_RESULT(no)
2054                 ]);;
2055         *) ;;
2056 esac
2058 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
2059 # BeOS' sockets are stashed in libnet.
2060 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
2061 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
2063 case "$ac_sys_system" in
2064 BeOS*)
2065 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
2067 esac
2069 AC_MSG_CHECKING(for --with-libs)
2070 AC_ARG_WITH(libs,
2071             AS_HELP_STRING([--with-libs='lib1 ...'], [link against additional libs]),
2073 AC_MSG_RESULT($withval)
2074 LIBS="$withval $LIBS"
2076 [AC_MSG_RESULT(no)])
2078 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2080 # Check for use of the system expat library
2081 AC_MSG_CHECKING(for --with-system-expat)
2082 AC_ARG_WITH(system_expat,
2083             AS_HELP_STRING([--with-system-expat], [build pyexpat module using an installed expat library]))
2085 AC_MSG_RESULT($with_system_expat)
2087 # Check for use of the system libffi library
2088 AC_MSG_CHECKING(for --with-system-ffi)
2089 AC_ARG_WITH(system_ffi,
2090             AS_HELP_STRING([--with-system-ffi], [build _ctypes module using an installed ffi library]))
2092 if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG"; then
2093     LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
2094 else
2095     LIBFFI_INCLUDEDIR=""
2097 AC_SUBST(LIBFFI_INCLUDEDIR)
2099 AC_MSG_RESULT($with_system_ffi)
2101 # Check for --with-dbmliborder
2102 AC_MSG_CHECKING(for --with-dbmliborder)
2103 AC_ARG_WITH(dbmliborder,
2104             AS_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'.]),
2106 if test x$with_dbmliborder = xyes
2107 then
2108 AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2109 else
2110   for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do
2111     if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb
2112     then
2113       AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...])
2114     fi
2115   done
2116 fi])
2117 AC_MSG_RESULT($with_dbmliborder)
2119 # Determine if signalmodule should be used.
2120 AC_SUBST(USE_SIGNAL_MODULE)
2121 AC_SUBST(SIGNAL_OBJS)
2122 AC_MSG_CHECKING(for --with-signal-module)
2123 AC_ARG_WITH(signal-module,
2124             AS_HELP_STRING([--with-signal-module], [disable/enable signal module]))
2126 if test -z "$with_signal_module"
2127 then with_signal_module="yes"
2129 AC_MSG_RESULT($with_signal_module)
2131 if test "${with_signal_module}" = "yes"; then
2132         USE_SIGNAL_MODULE=""
2133         SIGNAL_OBJS=""
2134 else
2135         USE_SIGNAL_MODULE="#"
2136         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
2139 # This is used to generate Setup.config
2140 AC_SUBST(USE_THREAD_MODULE)
2141 USE_THREAD_MODULE=""
2143 AC_MSG_CHECKING(for --with-dec-threads)
2144 AC_SUBST(LDLAST)
2145 AC_ARG_WITH(dec-threads,
2146             AS_HELP_STRING([--with-dec-threads], [use DEC Alpha/OSF1 thread-safe libraries]),
2148 AC_MSG_RESULT($withval)
2149 LDLAST=-threads
2150 if test "${with_thread+set}" != set; then
2151    with_thread="$withval";
2152 fi],
2153 [AC_MSG_RESULT(no)])
2155 # Templates for things AC_DEFINEd more than once.
2156 # For a single AC_DEFINE, no template is needed.
2157 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
2158 AH_TEMPLATE(_REENTRANT,
2159   [Define to force use of thread-safe errno, h_errno, and other functions])
2160 AH_TEMPLATE(WITH_THREAD,
2161   [Define if you want to compile in rudimentary thread support])
2163 AC_MSG_CHECKING(for --with-threads)
2164 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2165 AC_ARG_WITH(threads,
2166             AS_HELP_STRING([--with(out)-threads@<:@=DIRECTORY@:>@], [disable/enable thread support]))
2168 # --with-thread is deprecated, but check for it anyway
2169 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2170 AC_ARG_WITH(thread,
2171             AS_HELP_STRING([--with(out)-thread@<:@=DIRECTORY@:>@], [deprecated; use --with(out)-threads]),
2172             [with_threads=$with_thread])
2174 if test -z "$with_threads"
2175 then with_threads="yes"
2177 AC_MSG_RESULT($with_threads)
2179 AC_SUBST(THREADOBJ)
2180 if test "$with_threads" = "no"
2181 then
2182     USE_THREAD_MODULE="#"
2183 elif test "$ac_cv_pthread_is_default" = yes
2184 then
2185     AC_DEFINE(WITH_THREAD)
2186     # Defining _REENTRANT on system with POSIX threads should not hurt.
2187     AC_DEFINE(_REENTRANT)
2188     posix_threads=yes
2189     THREADOBJ="Python/thread.o"    
2190 elif test "$ac_cv_kpthread" = "yes"
2191 then
2192     CC="$CC -Kpthread"
2193     if test "$ac_cv_cxx_thread" = "yes"; then
2194         CXX="$CXX -Kpthread"
2195     fi
2196     AC_DEFINE(WITH_THREAD)
2197     posix_threads=yes
2198     THREADOBJ="Python/thread.o"
2199 elif test "$ac_cv_kthread" = "yes"
2200 then
2201     CC="$CC -Kthread"
2202     if test "$ac_cv_cxx_thread" = "yes"; then
2203         CXX="$CXX -Kthread"
2204     fi
2205     AC_DEFINE(WITH_THREAD)
2206     posix_threads=yes
2207     THREADOBJ="Python/thread.o"
2208 elif test "$ac_cv_pthread" = "yes"
2209 then
2210     CC="$CC -pthread"
2211     if test "$ac_cv_cxx_thread" = "yes"; then
2212         CXX="$CXX -pthread"
2213     fi
2214     AC_DEFINE(WITH_THREAD)
2215     posix_threads=yes
2216     THREADOBJ="Python/thread.o"
2217 else
2218     if test ! -z "$with_threads" -a -d "$with_threads"
2219     then LDFLAGS="$LDFLAGS -L$with_threads"
2220     fi
2221     if test ! -z "$withval" -a -d "$withval"
2222     then LDFLAGS="$LDFLAGS -L$withval"
2223     fi
2225     # According to the POSIX spec, a pthreads implementation must
2226     # define _POSIX_THREADS in unistd.h. Some apparently don't
2227     # (e.g. gnu pth with pthread emulation)
2228     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
2229     AC_EGREP_CPP(yes,
2230     [
2231 #include <unistd.h>
2232 #ifdef _POSIX_THREADS
2234 #endif
2235     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
2236     AC_MSG_RESULT($unistd_defines_pthreads)
2238     AC_DEFINE(_REENTRANT)
2239     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
2240     AC_DEFINE(C_THREADS)
2241     AC_DEFINE(HURD_C_THREADS, 1,
2242     [Define if you are using Mach cthreads directly under /include])
2243     LIBS="$LIBS -lthreads"
2244     THREADOBJ="Python/thread.o"],[
2245     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
2246     AC_DEFINE(C_THREADS)
2247     AC_DEFINE(MACH_C_THREADS, 1,
2248     [Define if you are using Mach cthreads under mach /])
2249     THREADOBJ="Python/thread.o"],[
2250     AC_MSG_CHECKING(for --with-pth)
2251     AC_ARG_WITH([pth],
2252                 AS_HELP_STRING([--with-pth], [use GNU pth threading libraries]),
2253                 [AC_MSG_RESULT($withval)
2254                   AC_DEFINE([WITH_THREAD])
2255                   AC_DEFINE([HAVE_PTH], 1,
2256                             [Define if you have GNU PTH threads.])
2257                   LIBS="-lpth $LIBS"
2258                   THREADOBJ="Python/thread.o"],
2259                 [AC_MSG_RESULT(no)
2261     # Just looking for pthread_create in libpthread is not enough:
2262     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
2263     # So we really have to include pthread.h, and then link.
2264     _libs=$LIBS
2265     LIBS="$LIBS -lpthread"
2266     AC_MSG_CHECKING([for pthread_create in -lpthread])
2267     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>
2269 void * start_routine (void *arg) { exit (0); }]], [[
2270 pthread_create (NULL, NULL, start_routine, NULL)]])],[
2271     AC_MSG_RESULT(yes)
2272     AC_DEFINE(WITH_THREAD)
2273     posix_threads=yes
2274     THREADOBJ="Python/thread.o"],[
2275     LIBS=$_libs
2276     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
2277     posix_threads=yes
2278     THREADOBJ="Python/thread.o"],[
2279     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
2280     AC_DEFINE(ATHEOS_THREADS, 1,
2281     [Define this if you have AtheOS threads.])
2282     THREADOBJ="Python/thread.o"],[
2283     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
2284     AC_DEFINE(BEOS_THREADS, 1,
2285     [Define this if you have BeOS threads.])
2286     THREADOBJ="Python/thread.o"],[
2287     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
2288     posix_threads=yes
2289     LIBS="$LIBS -lpthreads"
2290     THREADOBJ="Python/thread.o"], [
2291     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
2292     posix_threads=yes
2293     LIBS="$LIBS -lc_r"
2294     THREADOBJ="Python/thread.o"], [
2295     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
2296     posix_threads=yes
2297     LIBS="$LIBS -lpthread"
2298     THREADOBJ="Python/thread.o"], [
2299     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
2300     posix_threads=yes
2301     LIBS="$LIBS -lcma"
2302     THREADOBJ="Python/thread.o"],[
2303     USE_THREAD_MODULE="#"])
2304     ])])])])])])])])])])
2306     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
2307     LIBS="$LIBS -lmpc"
2308     THREADOBJ="Python/thread.o"
2309     USE_THREAD_MODULE=""])
2311     if test "$posix_threads" != "yes"; then     
2312       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
2313       LIBS="$LIBS -lthread"
2314       THREADOBJ="Python/thread.o"
2315       USE_THREAD_MODULE=""])
2316     fi
2318     if test "$USE_THREAD_MODULE" != "#"
2319     then
2320         # If the above checks didn't disable threads, (at least) OSF1
2321         # needs this '-threads' argument during linking.
2322         case $ac_sys_system in
2323         OSF1) LDLAST=-threads;;
2324         esac
2325     fi
2328 if test "$posix_threads" = "yes"; then
2329       if test "$unistd_defines_pthreads" = "no"; then
2330          AC_DEFINE(_POSIX_THREADS, 1,
2331          [Define if you have POSIX threads, 
2332           and your system does not define that.])
2333       fi
2335       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2336       case  $ac_sys_system/$ac_sys_release in
2337   SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2338                        [Defined for Solaris 2.6 bug in pthread header.])
2339                        ;;
2340       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2341                        [Define if the Posix semaphores do not work on your system])
2342                        ;;
2343       AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2344                        [Define if the Posix semaphores do not work on your system])
2345                        ;;
2346       esac
2348       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2349       AC_CACHE_VAL(ac_cv_pthread_system_supported,
2350       [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <pthread.h>
2351       void *foo(void *parm) {
2352         return NULL;
2353       }
2354       main() {
2355         pthread_attr_t attr;
2356         pthread_t id;
2357         if (pthread_attr_init(&attr)) exit(-1);
2358         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
2359         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
2360         exit(0);
2361       }]])],
2362       [ac_cv_pthread_system_supported=yes],
2363       [ac_cv_pthread_system_supported=no],
2364       [ac_cv_pthread_system_supported=no])
2365       ])
2366       AC_MSG_RESULT($ac_cv_pthread_system_supported)
2367       if test "$ac_cv_pthread_system_supported" = "yes"; then
2368         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
2369       fi
2370       AC_CHECK_FUNCS(pthread_sigmask,
2371         [case $ac_sys_system in
2372         CYGWIN*)
2373           AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2374             [Define if pthread_sigmask() does not work on your system.])
2375             ;;
2376         esac])
2380 # Check for enable-ipv6
2381 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
2382 AC_MSG_CHECKING([if --enable-ipv6 is specified])
2383 AC_ARG_ENABLE(ipv6,
2384 [  --enable-ipv6           Enable ipv6 (with ipv4) support
2385   --disable-ipv6          Disable ipv6 support],
2386 [ case "$enableval" in
2387   no)
2388        AC_MSG_RESULT(no)
2389        ipv6=no
2390        ;;
2391   *)   AC_MSG_RESULT(yes)
2392        AC_DEFINE(ENABLE_IPV6)
2393        ipv6=yes
2394        ;;
2395   esac ],
2398 dnl the check does not work on cross compilation case...
2399   AC_RUN_IFELSE([AC_LANG_SOURCE([[ /* AF_INET6 available check */
2400 #include <sys/types.h>
2401 #include <sys/socket.h>
2402 main()
2404  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2405    exit(1);
2406  else
2407    exit(0);
2409 ]])],[
2410   AC_MSG_RESULT(yes)
2411   ipv6=yes
2413   AC_MSG_RESULT(no)
2414   ipv6=no
2416   AC_MSG_RESULT(no)
2417   ipv6=no
2420 if test "$ipv6" = "yes"; then
2421         AC_MSG_CHECKING(if RFC2553 API is available)
2422         AC_COMPILE_IFELSE([
2423           AC_LANG_PROGRAM([[#include <sys/types.h>
2424 #include <netinet/in.h>]],
2425                           [[struct sockaddr_in6 x;
2426                             x.sin6_scope_id;]])
2427         ],[
2428           AC_MSG_RESULT(yes)
2429           ipv6=yes
2430         ],[
2431           AC_MSG_RESULT(no, IPv6 disabled)
2432           ipv6=no
2433         ])
2436 if test "$ipv6" = "yes"; then
2437         AC_DEFINE(ENABLE_IPV6)
2441 ipv6type=unknown
2442 ipv6lib=none
2443 ipv6trylibc=no
2445 if test "$ipv6" = "yes"; then
2446         AC_MSG_CHECKING([ipv6 stack type])
2447         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2448         do
2449                 case $i in
2450                 inria)
2451                         dnl http://www.kame.net/
2452                         AC_EGREP_CPP(yes, [
2453 #include <netinet/in.h>
2454 #ifdef IPV6_INRIA_VERSION
2456 #endif],
2457                                 [ipv6type=$i])
2458                         ;;
2459                 kame)
2460                         dnl http://www.kame.net/
2461                         AC_EGREP_CPP(yes, [
2462 #include <netinet/in.h>
2463 #ifdef __KAME__
2465 #endif],
2466                                 [ipv6type=$i;
2467                                 ipv6lib=inet6
2468                                 ipv6libdir=/usr/local/v6/lib
2469                                 ipv6trylibc=yes])
2470                         ;;
2471                 linux-glibc)
2472                         dnl http://www.v6.linux.or.jp/
2473                         AC_EGREP_CPP(yes, [
2474 #include <features.h>
2475 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2477 #endif],
2478                                 [ipv6type=$i;
2479                                 ipv6trylibc=yes])
2480                         ;;
2481                 linux-inet6)
2482                         dnl http://www.v6.linux.or.jp/
2483                         if test -d /usr/inet6; then
2484                                 ipv6type=$i
2485                                 ipv6lib=inet6
2486                                 ipv6libdir=/usr/inet6/lib
2487                                 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
2488                         fi
2489                         ;;
2490                 solaris)
2491                         if test -f /etc/netconfig; then
2492                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2493                                 ipv6type=$i
2494                                 ipv6trylibc=yes
2495                           fi
2496                         fi
2497                         ;;
2498                 toshiba)
2499                         AC_EGREP_CPP(yes, [
2500 #include <sys/param.h>
2501 #ifdef _TOSHIBA_INET6
2503 #endif],
2504                                 [ipv6type=$i;
2505                                 ipv6lib=inet6;
2506                                 ipv6libdir=/usr/local/v6/lib])
2507                         ;;
2508                 v6d)
2509                         AC_EGREP_CPP(yes, [
2510 #include </usr/local/v6/include/sys/v6config.h>
2511 #ifdef __V6D__
2513 #endif],
2514                                 [ipv6type=$i;
2515                                 ipv6lib=v6;
2516                                 ipv6libdir=/usr/local/v6/lib;
2517                                 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
2518                         ;;
2519                 zeta)
2520                         AC_EGREP_CPP(yes, [
2521 #include <sys/param.h>
2522 #ifdef _ZETA_MINAMI_INET6
2524 #endif],
2525                                 [ipv6type=$i;
2526                                 ipv6lib=inet6;
2527                                 ipv6libdir=/usr/local/v6/lib])
2528                         ;;
2529                 esac
2530                 if test "$ipv6type" != "unknown"; then
2531                         break
2532                 fi
2533         done
2534         AC_MSG_RESULT($ipv6type)
2537 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2538         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2539                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2540                 echo "using lib$ipv6lib"
2541         else
2542                 if test $ipv6trylibc = "yes"; then
2543                         echo "using libc"
2544                 else
2545                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
2546                         echo "You need to fetch lib$ipv6lib.a from appropriate"
2547                         echo 'ipv6 kit and compile beforehand.'
2548                         exit 1
2549                 fi
2550         fi
2553 AC_MSG_CHECKING(for OSX 10.5 SDK or later)
2554 AC_COMPILE_IFELSE([
2555   AC_LANG_PROGRAM([[#include <Carbon/Carbon.h>]], [[FSIORefNum fRef = 0]])
2557   AC_DEFINE(HAVE_OSX105_SDK, 1, [Define if compiling using MacOS X 10.5 SDK or later.])
2558   AC_MSG_RESULT(yes)
2560   AC_MSG_RESULT(no)
2563 # Check for --with-doc-strings
2564 AC_MSG_CHECKING(for --with-doc-strings)
2565 AC_ARG_WITH(doc-strings,
2566             AS_HELP_STRING([--with(out)-doc-strings], [disable/enable documentation strings]))
2568 if test -z "$with_doc_strings"
2569 then with_doc_strings="yes"
2571 if test "$with_doc_strings" != "no"
2572 then
2573     AC_DEFINE(WITH_DOC_STRINGS, 1,
2574       [Define if you want documentation strings in extension modules])
2576 AC_MSG_RESULT($with_doc_strings)
2578 # Check for Python-specific malloc support
2579 AC_MSG_CHECKING(for --with-tsc)
2580 AC_ARG_WITH(tsc,
2581             AS_HELP_STRING([--with(out)-tsc],[enable/disable timestamp counter profile]),[
2582 if test "$withval" != no
2583 then 
2584   AC_DEFINE(WITH_TSC, 1, 
2585     [Define to profile with the Pentium timestamp counter]) 
2586     AC_MSG_RESULT(yes)
2587 else AC_MSG_RESULT(no)
2588 fi],
2589 [AC_MSG_RESULT(no)])
2591 # Check for Python-specific malloc support
2592 AC_MSG_CHECKING(for --with-pymalloc)
2593 AC_ARG_WITH(pymalloc,
2594             AS_HELP_STRING([--with(out)-pymalloc], [disable/enable specialized mallocs]))
2596 if test -z "$with_pymalloc"
2597 then with_pymalloc="yes"
2599 if test "$with_pymalloc" != "no"
2600 then
2601     AC_DEFINE(WITH_PYMALLOC, 1, 
2602      [Define if you want to compile in Python-specific mallocs])
2604 AC_MSG_RESULT($with_pymalloc)
2606 # Check for Valgrind support
2607 AC_MSG_CHECKING([for --with-valgrind])
2608 AC_ARG_WITH([valgrind],
2609   AS_HELP_STRING([--with-valgrind], [Enable Valgrind support]),,
2610   with_valgrind=no)
2611 AC_MSG_RESULT([$with_valgrind])
2612 if test "$with_valgrind" != no; then
2613     AC_CHECK_HEADER([valgrind/valgrind.h],
2614       [AC_DEFINE([WITH_VALGRIND], 1, [Define if you want pymalloc to be disabled when running under valgrind])],
2615       [AC_MSG_ERROR([Valgrind support requested but headers not available])]
2616     )
2619 # Check for --with-wctype-functions
2620 AC_MSG_CHECKING(for --with-wctype-functions)
2621 AC_ARG_WITH(wctype-functions, 
2622             AS_HELP_STRING([--with-wctype-functions], [use wctype.h functions]),
2624 if test "$withval" != no
2625 then 
2626   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2627   [Define if you want wctype.h functions to be used instead of the
2628    one supplied by Python itself. (see Include/unicodectype.h).]) 
2629   AC_MSG_RESULT(yes)
2630 else AC_MSG_RESULT(no)
2631 fi],
2632 [AC_MSG_RESULT(no)])
2634 # -I${DLINCLDIR} is added to the compile rule for importdl.o
2635 AC_SUBST(DLINCLDIR)
2636 DLINCLDIR=.
2638 # the dlopen() function means we might want to use dynload_shlib.o. some
2639 # platforms, such as AIX, have dlopen(), but don't want to use it.
2640 AC_CHECK_FUNCS(dlopen)
2642 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2643 # loading of modules.
2644 AC_SUBST(DYNLOADFILE)
2645 AC_MSG_CHECKING(DYNLOADFILE)
2646 if test -z "$DYNLOADFILE"
2647 then
2648         case $ac_sys_system/$ac_sys_release in
2649         AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2650         if test "$ac_cv_func_dlopen" = yes
2651         then DYNLOADFILE="dynload_shlib.o"
2652         else DYNLOADFILE="dynload_aix.o"
2653         fi
2654         ;;
2655         BeOS*) DYNLOADFILE="dynload_beos.o";;
2656         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2657         # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2658         Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
2659         atheos*) DYNLOADFILE="dynload_atheos.o";;
2660         *)
2661         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2662         # out any dynamic loading
2663         if test "$ac_cv_func_dlopen" = yes
2664         then DYNLOADFILE="dynload_shlib.o"
2665         else DYNLOADFILE="dynload_stub.o"
2666         fi
2667         ;;
2668         esac
2670 AC_MSG_RESULT($DYNLOADFILE)
2671 if test "$DYNLOADFILE" != "dynload_stub.o"
2672 then
2673         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2674         [Defined when any dynamic module loading is enabled.])
2677 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
2679 AC_SUBST(MACHDEP_OBJS)
2680 AC_MSG_CHECKING(MACHDEP_OBJS)
2681 if test -z "$MACHDEP_OBJS"
2682 then
2683         MACHDEP_OBJS=$extra_machdep_objs
2684 else
2685         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2687 AC_MSG_RESULT(MACHDEP_OBJS)
2689 # checks for library functions
2690 AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2691  clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
2692  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2693  getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
2694  initgroups kill killpg lchmod lchown lstat mkfifo mknod mktime \
2695  mremap nice pathconf pause plock poll pthread_init \
2696  putenv readlink realpath \
2697  select sem_open sem_timedwait sem_getvalue sem_unlink setegid seteuid \
2698  setgid \
2699  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2700  setlocale setregid setreuid setresuid setresgid \
2701  setsid setpgid setpgrp setuid setvbuf snprintf \
2702  sigaction siginterrupt sigrelse strftime \
2703  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2704  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
2706 # For some functions, having a definition is not sufficient, since
2707 # we want to take their address.
2708 AC_MSG_CHECKING(for chroot)
2709 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=chroot]])],
2710   [AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2711    AC_MSG_RESULT(yes)],
2712   [AC_MSG_RESULT(no)
2714 AC_MSG_CHECKING(for link)
2715 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=link]])],
2716   [AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2717    AC_MSG_RESULT(yes)],
2718   [AC_MSG_RESULT(no)
2720 AC_MSG_CHECKING(for symlink)
2721 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=symlink]])],
2722   [AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2723    AC_MSG_RESULT(yes)],
2724   [AC_MSG_RESULT(no)
2726 AC_MSG_CHECKING(for fchdir)
2727 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fchdir]])],
2728   [AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2729    AC_MSG_RESULT(yes)],
2730   [AC_MSG_RESULT(no)
2732 AC_MSG_CHECKING(for fsync)
2733 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fsync]])],
2734   [AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2735    AC_MSG_RESULT(yes)],
2736   [AC_MSG_RESULT(no)
2738 AC_MSG_CHECKING(for fdatasync)
2739 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[void *x=fdatasync]])],
2740   [AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2741    AC_MSG_RESULT(yes)],
2742   [AC_MSG_RESULT(no)
2744 AC_MSG_CHECKING(for epoll)
2745 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create]])],
2746   [AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2747    AC_MSG_RESULT(yes)],
2748   [AC_MSG_RESULT(no)
2750 AC_MSG_CHECKING(for kqueue)
2751 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2752 #include <sys/types.h>
2753 #include <sys/event.h>
2754     ]], [[int x=kqueue()]])],
2755   [AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2756    AC_MSG_RESULT(yes)],
2757   [AC_MSG_RESULT(no)
2759 # On some systems (eg. FreeBSD 5), we would find a definition of the
2760 # functions ctermid_r, setgroups in the library, but no prototype
2761 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2762 # address to avoid compiler warnings and potential miscompilations
2763 # because of the missing prototypes.
2765 AC_MSG_CHECKING(for ctermid_r)
2766 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2767 #include <stdio.h>
2768 ]], [[void* p = ctermid_r]])],
2769   [AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2770    AC_MSG_RESULT(yes)],
2771   [AC_MSG_RESULT(no)
2774 AC_MSG_CHECKING(for flock)
2775 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2776 #include <sys/file.h>
2777 ]], [[void* p = flock]])],
2778   [AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2779    AC_MSG_RESULT(yes)],
2780   [AC_MSG_RESULT(no)
2783 AC_MSG_CHECKING(for getpagesize)
2784 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2785 #include <unistd.h>
2786 ]], [[void* p = getpagesize]])],
2787   [AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2788    AC_MSG_RESULT(yes)],
2789   [AC_MSG_RESULT(no)
2792 dnl check for true
2793 AC_CHECK_PROGS(TRUE, true, /bin/true)
2795 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2796 dnl On others, they are in the C library, so we to take no action
2797 AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2798   AC_CHECK_LIB(resolv, inet_aton)
2801 # On Tru64, chflags seems to be present, but calling it will
2802 # exit Python
2803 AC_CACHE_CHECK([for chflags], [ac_cv_have_chflags], [dnl
2804 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
2805 #include <sys/stat.h>
2806 #include <unistd.h>
2807 int main(int argc, char*argv[])
2809   if(chflags(argv[0], 0) != 0)
2810     return 1;
2811   return 0;
2813 ]]])],
2814 [ac_cv_have_chflags=yes],
2815 [ac_cv_have_chflags=no],
2816 [ac_cv_have_chflags=cross])
2818 if test "$ac_cv_have_chflags" = cross ; then
2819   AC_CHECK_FUNC([chflags], [ac_cv_have_chflags="yes"], [ac_cv_have_chflags="no"])
2821 if test "$ac_cv_have_chflags" = yes ; then
2822   AC_DEFINE(HAVE_CHFLAGS, 1, [Define to 1 if you have the `chflags' function.])
2825 AC_CACHE_CHECK([for lchflags], [ac_cv_have_lchflags], [dnl
2826 AC_RUN_IFELSE([AC_LANG_SOURCE([[[
2827 #include <sys/stat.h>
2828 #include <unistd.h>
2829 int main(int argc, char*argv[])
2831   if(lchflags(argv[0], 0) != 0)
2832     return 1;
2833   return 0;
2835 ]]])],[ac_cv_have_lchflags=yes],[ac_cv_have_lchflags=no],[ac_cv_have_lchflags=cross])
2837 if test "$ac_cv_have_lchflags" = cross ; then
2838   AC_CHECK_FUNC([lchflags], [ac_cv_have_lchflags="yes"], [ac_cv_have_lchflags="no"])
2840 if test "$ac_cv_have_lchflags" = yes ; then
2841   AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the `lchflags' function.])
2844 dnl Check if system zlib has *Copy() functions
2846 dnl On MacOSX the linker will search for dylibs on the entire linker path
2847 dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2848 dnl to revert to a more traditional unix behaviour and make it possible to
2849 dnl override the system libz with a local static library of libz. Temporarily
2850 dnl add that flag to our CFLAGS as well to ensure that we check the version
2851 dnl of libz that will be used by setup.py. 
2852 dnl The -L/usr/local/lib is needed as wel to get the same compilation 
2853 dnl environment as setup.py (and leaving it out can cause configure to use the
2854 dnl wrong version of the library)
2855 case $ac_sys_system/$ac_sys_release in
2856 Darwin/*) 
2857         _CUR_CFLAGS="${CFLAGS}"
2858         _CUR_LDFLAGS="${LDFLAGS}"
2859         CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2860         LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2861         ;;
2862 esac
2864 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
2866 case $ac_sys_system/$ac_sys_release in
2867 Darwin/*) 
2868         CFLAGS="${_CUR_CFLAGS}"
2869         LDFLAGS="${_CUR_LDFLAGS}"
2870         ;;
2871 esac
2873 AC_MSG_CHECKING(for hstrerror)
2874 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2875 #include <netdb.h>
2876 ]], [[void* p = hstrerror; hstrerror(0)]])],
2877   [AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2878    AC_MSG_RESULT(yes)],
2879   [AC_MSG_RESULT(no)
2882 AC_MSG_CHECKING(for inet_aton)
2883 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2884 #include <sys/types.h>
2885 #include <sys/socket.h>
2886 #include <netinet/in.h>
2887 #include <arpa/inet.h>
2888 ]], [[void* p = inet_aton;inet_aton(0,0)]])],
2889   [AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2890    AC_MSG_RESULT(yes)],
2891   [AC_MSG_RESULT(no)
2894 AC_MSG_CHECKING(for inet_pton)
2895 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2896 #include <sys/types.h>
2897 #include <sys/socket.h>
2898 #include <netinet/in.h>
2899 #include <arpa/inet.h>
2900 ]], [[void* p = inet_pton]])],
2901   [AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2902    AC_MSG_RESULT(yes)],
2903   [AC_MSG_RESULT(no)
2906 # On some systems, setgroups is in unistd.h, on others, in grp.h
2907 AC_MSG_CHECKING(for setgroups)
2908 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2909 #include <unistd.h>
2910 #ifdef HAVE_GRP_H
2911 #include <grp.h>
2912 #endif
2913 ]], [[void* p = setgroups]])],
2914   [AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2915    AC_MSG_RESULT(yes)],
2916   [AC_MSG_RESULT(no)
2919 # check for openpty and forkpty
2921 AC_CHECK_FUNCS(openpty,, 
2922    AC_CHECK_LIB(util,openpty,
2923      [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2924      AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2925    )
2927 AC_CHECK_FUNCS(forkpty,, 
2928    AC_CHECK_LIB(util,forkpty, 
2929      [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2930      AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2931    )
2934 # Stuff for expat.
2935 AC_CHECK_FUNCS(memmove)
2937 # check for long file support functions
2938 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2940 AC_REPLACE_FUNCS(dup2 getcwd strdup)
2941 AC_CHECK_FUNCS(getpgrp, 
2942   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
2943     [AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
2944     [])
2946 AC_CHECK_FUNCS(setpgrp,
2947   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[setpgrp(0,0);]])],
2948     [AC_DEFINE(SETPGRP_HAVE_ARG, 1, [Define if setpgrp() must be called as setpgrp(0, 0).])],
2949     [])
2951 AC_CHECK_FUNCS(gettimeofday, 
2952   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h>]],
2953                                      [[gettimeofday((struct timeval*)0,(struct timezone*)0);]])],
2954     [],
2955     [AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2956       [Define if gettimeofday() does not have second (timezone) argument
2957        This is the case on Motorola V4 (R40V4.2)])
2958     ])
2961 AC_MSG_CHECKING(for major, minor, and makedev)
2962 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2963 #if defined(MAJOR_IN_MKDEV)
2964 #include <sys/mkdev.h>
2965 #elif defined(MAJOR_IN_SYSMACROS)
2966 #include <sys/sysmacros.h>
2967 #else
2968 #include <sys/types.h>
2969 #endif
2970 ]], [[
2971   makedev(major(0),minor(0));
2972 ]])],[
2973   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2974             [Define to 1 if you have the device macros.])
2975   AC_MSG_RESULT(yes)
2977   AC_MSG_RESULT(no)
2980 # On OSF/1 V5.1, getaddrinfo is available, but a define
2981 # for [no]getaddrinfo in netdb.h. 
2982 AC_MSG_CHECKING(for getaddrinfo)
2983 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2984 #include <sys/types.h>
2985 #include <sys/socket.h>
2986 #include <netdb.h>
2987 #include <stdio.h>
2988 ]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])],
2989 [have_getaddrinfo=yes],
2990 [have_getaddrinfo=no])
2991 AC_MSG_RESULT($have_getaddrinfo)
2992 if test $have_getaddrinfo = yes
2993 then
2994   AC_MSG_CHECKING(getaddrinfo bug)
2995   AC_CACHE_VAL(ac_cv_buggy_getaddrinfo,
2996   AC_RUN_IFELSE([AC_LANG_SOURCE([[[
2997 #include <sys/types.h>
2998 #include <netdb.h>
2999 #include <string.h>
3000 #include <sys/socket.h>
3001 #include <netinet/in.h>
3003 int main()
3005   int passive, gaierr, inet4 = 0, inet6 = 0;
3006   struct addrinfo hints, *ai, *aitop;
3007   char straddr[INET6_ADDRSTRLEN], strport[16];
3009   for (passive = 0; passive <= 1; passive++) {
3010     memset(&hints, 0, sizeof(hints));
3011     hints.ai_family = AF_UNSPEC;
3012     hints.ai_flags = passive ? AI_PASSIVE : 0;
3013     hints.ai_socktype = SOCK_STREAM;
3014     hints.ai_protocol = IPPROTO_TCP;
3015     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
3016       (void)gai_strerror(gaierr);
3017       goto bad;
3018     }
3019     for (ai = aitop; ai; ai = ai->ai_next) {
3020       if (ai->ai_addr == NULL ||
3021           ai->ai_addrlen == 0 ||
3022           getnameinfo(ai->ai_addr, ai->ai_addrlen,
3023                       straddr, sizeof(straddr), strport, sizeof(strport),
3024                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
3025         goto bad;
3026       }
3027       switch (ai->ai_family) {
3028       case AF_INET:
3029         if (strcmp(strport, "54321") != 0) {
3030           goto bad;
3031         }
3032         if (passive) {
3033           if (strcmp(straddr, "0.0.0.0") != 0) {
3034             goto bad;
3035           }
3036         } else {
3037           if (strcmp(straddr, "127.0.0.1") != 0) {
3038             goto bad;
3039           }
3040         }
3041         inet4++;
3042         break;
3043       case AF_INET6:
3044         if (strcmp(strport, "54321") != 0) {
3045           goto bad;
3046         }
3047         if (passive) {
3048           if (strcmp(straddr, "::") != 0) {
3049             goto bad;
3050           }
3051         } else {
3052           if (strcmp(straddr, "::1") != 0) {
3053             goto bad;
3054           }
3055         }
3056         inet6++;
3057         break;
3058       case AF_UNSPEC:
3059         goto bad;
3060         break;
3061       default:
3062         /* another family support? */
3063         break;
3064       }
3065     }
3066   }
3068   if (!(inet4 == 0 || inet4 == 2))
3069     goto bad;
3070   if (!(inet6 == 0 || inet6 == 2))
3071     goto bad;
3073   if (aitop)
3074     freeaddrinfo(aitop);
3075   return 0;
3077  bad:
3078   if (aitop)
3079     freeaddrinfo(aitop);
3080   return 1;
3082 ]]])],
3083 [ac_cv_buggy_getaddrinfo=no],
3084 [ac_cv_buggy_getaddrinfo=yes],
3085 [ac_cv_buggy_getaddrinfo=yes]))
3088 if test $have_getaddrinfo = no -o "$ac_cv_buggy_getaddrinfo" = yes
3089 then
3090         if test $ipv6 = yes
3091         then
3092                 echo 'Fatal: You must get working getaddrinfo() function.'
3093                 echo '       or you can specify "--disable-ipv6"'.
3094                 exit 1
3095         fi
3096 else
3097         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
3099 AC_CHECK_FUNCS(getnameinfo)
3101 # checks for structures
3102 AC_HEADER_TIME
3103 AC_STRUCT_TM
3104 AC_STRUCT_TIMEZONE
3105 AC_CHECK_MEMBERS([struct stat.st_rdev])
3106 AC_CHECK_MEMBERS([struct stat.st_blksize])
3107 AC_CHECK_MEMBERS([struct stat.st_flags])
3108 AC_CHECK_MEMBERS([struct stat.st_gen])
3109 AC_CHECK_MEMBERS([struct stat.st_birthtime])
3110 AC_STRUCT_ST_BLOCKS
3112 AC_MSG_CHECKING(for time.h that defines altzone)
3113 AC_CACHE_VAL(ac_cv_header_time_altzone,[
3114   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[return altzone;]])],
3115     [ac_cv_header_time_altzone=yes],
3116     [ac_cv_header_time_altzone=no])
3117   ])
3118 AC_MSG_RESULT($ac_cv_header_time_altzone)
3119 if test $ac_cv_header_time_altzone = yes; then
3120   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
3123 was_it_defined=no
3124 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
3125 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3126 #include <sys/types.h>
3127 #include <sys/select.h>
3128 #include <sys/time.h>
3129 ]], [[;]])],[
3130   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
3131   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
3132    (which you can't on SCO ODT 3.0).]) 
3133   was_it_defined=yes
3134 ],[])
3135 AC_MSG_RESULT($was_it_defined)
3137 AC_MSG_CHECKING(for addrinfo)
3138 AC_CACHE_VAL(ac_cv_struct_addrinfo,
3139 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[struct addrinfo a]])],
3140   [ac_cv_struct_addrinfo=yes],
3141   [ac_cv_struct_addrinfo=no]))
3142 AC_MSG_RESULT($ac_cv_struct_addrinfo)
3143 if test $ac_cv_struct_addrinfo = yes; then
3144         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
3147 AC_MSG_CHECKING(for sockaddr_storage)
3148 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
3149 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3150 #               include <sys/types.h>
3151 #               include <sys/socket.h>]], [[struct sockaddr_storage s]])],
3152   [ac_cv_struct_sockaddr_storage=yes],
3153   [ac_cv_struct_sockaddr_storage=no]))
3154 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
3155 if test $ac_cv_struct_sockaddr_storage = yes; then
3156         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
3159 # checks for compiler characteristics
3161 AC_C_CHAR_UNSIGNED
3162 AC_C_CONST
3164 works=no
3165 AC_MSG_CHECKING(for working volatile)
3166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[volatile int x; x = 0;]])],
3167   [works=yes],
3168   [AC_DEFINE(volatile, , [Define to empty if the keyword does not work.])]
3170 AC_MSG_RESULT($works)
3172 works=no
3173 AC_MSG_CHECKING(for working signed char)
3174 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[signed char c;]])],
3175   [works=yes],
3176   [AC_DEFINE(signed, , [Define to empty if the keyword does not work.])]
3178 AC_MSG_RESULT($works)
3180 have_prototypes=no
3181 AC_MSG_CHECKING(for prototypes)
3182 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(int x) { return 0; }]], [[return foo(10);]])],
3183   [AC_DEFINE(HAVE_PROTOTYPES, 1, 
3184      [Define if your compiler supports function prototype]) 
3185    have_prototypes=yes],
3186   []
3188 AC_MSG_RESULT($have_prototypes)
3190 works=no
3191 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
3192 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3193 #include <stdarg.h>
3194 int foo(int x, ...) {
3195         va_list va;
3196         va_start(va, x);
3197         va_arg(va, int);
3198         va_arg(va, char *);
3199         va_arg(va, double);
3200         return 0;
3202 ]], [[return foo(10, "", 3.14);]])],[
3203   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
3204    [Define if your compiler supports variable length function prototypes
3205    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
3206   works=yes
3207 ],[])
3208 AC_MSG_RESULT($works)
3210 # check for socketpair
3211 AC_MSG_CHECKING(for socketpair)
3212 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3213 #include <sys/types.h>
3214 #include <sys/socket.h>
3215 ]], [[void *x=socketpair]])],
3216   [AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define if you have the 'socketpair' function.])
3217    AC_MSG_RESULT(yes)],
3218   [AC_MSG_RESULT(no)]
3221 # check if sockaddr has sa_len member
3222 AC_MSG_CHECKING(if sockaddr has sa_len member)
3223 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
3224 #include <sys/socket.h>]], [[struct sockaddr x;
3225 x.sa_len = 0;]])],
3226   [AC_MSG_RESULT(yes)
3227    AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member])],
3228   [AC_MSG_RESULT(no)]
3231 va_list_is_array=no
3232 AC_MSG_CHECKING(whether va_list is an array)
3233 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3234 #ifdef HAVE_STDARG_PROTOTYPES
3235 #include <stdarg.h>
3236 #else
3237 #include <varargs.h>
3238 #endif
3239 ]], [[va_list list1, list2; list1 = list2;]])],[],[
3240  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
3241  va_list_is_array=yes
3243 AC_MSG_RESULT($va_list_is_array)
3245 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
3246 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
3247   [Define this if you have some version of gethostbyname_r()])
3249 AC_CHECK_FUNC(gethostbyname_r, [
3250   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3251   AC_MSG_CHECKING([gethostbyname_r with 6 args])
3252   OLD_CFLAGS=$CFLAGS
3253   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
3254   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3255 #   include <netdb.h>
3256   ]], [[
3257     char *name;
3258     struct hostent *he, *res;
3259     char buffer[2048];
3260     int buflen = 2048;
3261     int h_errnop;
3263     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
3264   ]])],[
3265     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3266     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
3267     [Define this if you have the 6-arg version of gethostbyname_r().])
3268     AC_MSG_RESULT(yes)
3269   ],[
3270     AC_MSG_RESULT(no)
3271     AC_MSG_CHECKING([gethostbyname_r with 5 args])
3272     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3273 #       include <netdb.h>
3274       ]], [[
3275         char *name;
3276         struct hostent *he;
3277         char buffer[2048];
3278         int buflen = 2048;
3279         int h_errnop;
3281         (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
3282       ]])],
3283       [
3284         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3285         AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
3286           [Define this if you have the 5-arg version of gethostbyname_r().])
3287         AC_MSG_RESULT(yes)
3288       ], [
3289         AC_MSG_RESULT(no)
3290         AC_MSG_CHECKING([gethostbyname_r with 3 args])
3291         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3292 #           include <netdb.h>
3293           ]], [[
3294             char *name;
3295             struct hostent *he;
3296             struct hostent_data data;
3298             (void) gethostbyname_r(name, he, &data);
3299           ]])],
3300           [
3301             AC_DEFINE(HAVE_GETHOSTBYNAME_R)
3302             AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
3303               [Define this if you have the 3-arg version of gethostbyname_r().])
3304             AC_MSG_RESULT(yes)
3305           ], [
3306            AC_MSG_RESULT(no)
3307         ])
3308     ])
3309   ])
3310   CFLAGS=$OLD_CFLAGS
3311 ], [
3312   AC_CHECK_FUNCS(gethostbyname)
3314 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
3315 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
3316 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
3317 AC_SUBST(HAVE_GETHOSTBYNAME_R)
3318 AC_SUBST(HAVE_GETHOSTBYNAME)
3320 # checks for system services
3321 # (none yet)
3323 # Linux requires this for correct f.p. operations
3324 AC_CHECK_FUNC(__fpu_control,
3325   [],
3326   [AC_CHECK_LIB(ieee, __fpu_control)
3329 # Check for --with-fpectl
3330 AC_MSG_CHECKING(for --with-fpectl)
3331 AC_ARG_WITH(fpectl,
3332             AS_HELP_STRING([--with-fpectl], [enable SIGFPE catching]),
3334 if test "$withval" != no
3335 then 
3336   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
3337   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
3338   AC_MSG_RESULT(yes)
3339 else AC_MSG_RESULT(no)
3340 fi],
3341 [AC_MSG_RESULT(no)])
3343 # check for --with-libm=...
3344 AC_SUBST(LIBM)
3345 case $ac_sys_system in
3346 Darwin) ;;
3347 BeOS) ;;
3348 *) LIBM=-lm
3349 esac
3350 AC_MSG_CHECKING(for --with-libm=STRING)
3351 AC_ARG_WITH(libm,
3352             AS_HELP_STRING([--with-libm=STRING], [math library]),
3354 if test "$withval" = no
3355 then LIBM=
3356      AC_MSG_RESULT(force LIBM empty)
3357 elif test "$withval" != yes
3358 then LIBM=$withval
3359      AC_MSG_RESULT(set LIBM="$withval")
3360 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
3361 fi],
3362 [AC_MSG_RESULT(default LIBM="$LIBM")])
3364 # check for --with-libc=...
3365 AC_SUBST(LIBC)
3366 AC_MSG_CHECKING(for --with-libc=STRING)
3367 AC_ARG_WITH(libc,
3368             AS_HELP_STRING([--with-libc=STRING], [C library]),
3370 if test "$withval" = no
3371 then LIBC=
3372      AC_MSG_RESULT(force LIBC empty)
3373 elif test "$withval" != yes
3374 then LIBC=$withval
3375      AC_MSG_RESULT(set LIBC="$withval")
3376 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
3377 fi],
3378 [AC_MSG_RESULT(default LIBC="$LIBC")])
3380 # **************************************************
3381 # * Check for various properties of floating point *
3382 # **************************************************
3384 AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
3385 AC_CACHE_VAL(ac_cv_little_endian_double, [
3386 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3387 #include <string.h>
3388 int main() {
3389     double x = 9006104071832581.0;
3390     if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
3391         return 0;
3392     else
3393         return 1;
3395 ]])],
3396 [ac_cv_little_endian_double=yes],
3397 [ac_cv_little_endian_double=no],
3398 [ac_cv_little_endian_double=no])])
3399 AC_MSG_RESULT($ac_cv_little_endian_double)
3400 if test "$ac_cv_little_endian_double" = yes
3401 then
3402   AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
3403   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3404    with the least significant byte first])
3407 AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
3408 AC_CACHE_VAL(ac_cv_big_endian_double, [
3409 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3410 #include <string.h>
3411 int main() {
3412     double x = 9006104071832581.0;
3413     if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
3414         return 0;
3415     else
3416         return 1;
3418 ]])],
3419 [ac_cv_big_endian_double=yes],
3420 [ac_cv_big_endian_double=no],
3421 [ac_cv_big_endian_double=no])])
3422 AC_MSG_RESULT($ac_cv_big_endian_double)
3423 if test "$ac_cv_big_endian_double" = yes
3424 then
3425   AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
3426   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3427    with the most significant byte first])
3430 # Some ARM platforms use a mixed-endian representation for doubles.
3431 # While Python doesn't currently have full support for these platforms
3432 # (see e.g., issue 1762561), we can at least make sure that float <-> string
3433 # conversions work.
3434 AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
3435 AC_CACHE_VAL(ac_cv_mixed_endian_double, [
3436 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3437 #include <string.h>
3438 int main() {
3439     double x = 9006104071832581.0;
3440     if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
3441         return 0;
3442     else
3443         return 1;
3445 ]])],
3446 [ac_cv_mixed_endian_double=yes],
3447 [ac_cv_mixed_endian_double=no],
3448 [ac_cv_mixed_endian_double=no])])
3449 AC_MSG_RESULT($ac_cv_mixed_endian_double)
3450 if test "$ac_cv_mixed_endian_double" = yes
3451 then
3452   AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
3453   [Define if C doubles are 64-bit IEEE 754 binary format, stored
3454    in ARM mixed-endian order (byte order 45670123)])
3457 # The short float repr introduced in Python 3.1 requires the
3458 # correctly-rounded string <-> double conversion functions from
3459 # Python/dtoa.c, which in turn require that the FPU uses 53-bit
3460 # rounding; this is a problem on x86, where the x87 FPU has a default
3461 # rounding precision of 64 bits.  For gcc/x86, we can fix this by
3462 # using inline assembler to get and set the x87 FPU control word.
3464 # This inline assembler syntax may also work for suncc and icc,
3465 # so we try it on all platforms.
3467 AC_MSG_CHECKING(whether we can use gcc inline assembler to get and set x87 control word)
3468 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3469   unsigned short cw;
3470   __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
3471   __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
3472 ]])],[have_gcc_asm_for_x87=yes],[have_gcc_asm_for_x87=no])
3473 AC_MSG_RESULT($have_gcc_asm_for_x87)
3474 if test "$have_gcc_asm_for_x87" = yes
3475 then
3476     AC_DEFINE(HAVE_GCC_ASM_FOR_X87, 1,
3477     [Define if we can use gcc inline assembler to get and set x87 control word])
3480 # Detect whether system arithmetic is subject to x87-style double
3481 # rounding issues.  The result of this test has little meaning on non
3482 # IEEE 754 platforms.  On IEEE 754, test should return 1 if rounding
3483 # mode is round-to-nearest and double rounding issues are present, and
3484 # 0 otherwise.  See http://bugs.python.org/issue2937 for more info.
3485 AC_MSG_CHECKING(for x87-style double rounding)
3486 # $BASECFLAGS may affect the result
3487 ac_save_cc="$CC"
3488 CC="$CC $BASECFLAGS"
3489 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3490 #include <stdlib.h>
3491 #include <math.h>
3492 int main() {
3493     volatile double x, y, z;
3494     /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
3495     x = 0.99999999999999989; /* 1-2**-53 */
3496     y = 1./x;
3497     if (y != 1.)
3498         exit(0);
3499     /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
3500     x = 1e16;
3501     y = 2.99999;
3502     z = x + y;
3503     if (z != 1e16+4.)
3504         exit(0);
3505     /* both tests show evidence of double rounding */
3506     exit(1);
3508 ]])],
3509 [ac_cv_x87_double_rounding=no],
3510 [ac_cv_x87_double_rounding=yes],
3511 [ac_cv_x87_double_rounding=no])
3512 CC="$ac_save_cc"
3513 AC_MSG_RESULT($ac_cv_x87_double_rounding)
3514 if test "$ac_cv_x87_double_rounding" = yes
3515 then
3516   AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
3517   [Define if arithmetic is subject to x87-style double rounding issue])
3520 # ************************************
3521 # * Check for mathematical functions *
3522 # ************************************
3524 LIBS_SAVE=$LIBS
3525 LIBS="$LIBS $LIBM"
3527 # On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3528 # -0. on some architectures.
3529 AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3530 AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3531 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3532 #include <math.h>
3533 #include <stdlib.h>
3534 int main() {
3535     /* return 0 if either negative zeros don't exist
3536        on this platform or if negative zeros exist
3537        and tanh(-0.) == -0. */
3538   if (atan2(0., -1.) == atan2(-0., -1.) ||
3539       atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3540   else exit(1);
3542 ]])],
3543 [ac_cv_tanh_preserves_zero_sign=yes],
3544 [ac_cv_tanh_preserves_zero_sign=no],
3545 [ac_cv_tanh_preserves_zero_sign=no])])
3546 AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3547 if test "$ac_cv_tanh_preserves_zero_sign" = yes
3548 then
3549   AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3550   [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3553 AC_CHECK_FUNCS([acosh asinh atanh copysign erf erfc expm1 finite gamma])
3554 AC_CHECK_FUNCS([hypot lgamma log1p round tgamma])
3555 AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
3557 LIBS=$LIBS_SAVE
3559 # For multiprocessing module, check that sem_open
3560 # actually works.  For FreeBSD versions <= 7.2,
3561 # the kernel module that provides POSIX semaphores
3562 # isn't loaded by default, so an attempt to call
3563 # sem_open results in a 'Signal 12' error.
3564 AC_MSG_CHECKING(whether POSIX semaphores are enabled)
3565 AC_CACHE_VAL(ac_cv_posix_semaphores_enabled,
3566 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3567 #include <unistd.h>
3568 #include <fcntl.h>
3569 #include <stdio.h>
3570 #include <semaphore.h>
3571 #include <sys/stat.h>
3573 int main(void) {
3574   sem_t *a = sem_open("/autoconf", O_CREAT, S_IRUSR|S_IWUSR, 0);
3575   if (a == SEM_FAILED) {
3576     perror("sem_open");
3577     return 1;
3578   }
3579   sem_close(a);
3580   sem_unlink("/autoconf");
3581   return 0;
3583 ]])],
3584 [ac_cv_posix_semaphores_enabled=yes],
3585 [ac_cv_posix_semaphores_enabled=no],
3586 [ac_cv_posix_semaphores_enabled=yes])
3588 AC_MSG_RESULT($ac_cv_posix_semaphores_enabled)
3589 if test $ac_cv_posix_semaphores_enabled = no
3590 then
3591   AC_DEFINE(POSIX_SEMAPHORES_NOT_ENABLED, 1,
3592             [Define if POSIX semaphores aren't enabled on your system])
3595 # Multiprocessing check for broken sem_getvalue
3596 AC_MSG_CHECKING(for broken sem_getvalue)
3597 AC_CACHE_VAL(ac_cv_broken_sem_getvalue,
3598 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3599 #include <unistd.h>
3600 #include <fcntl.h>
3601 #include <stdio.h>
3602 #include <semaphore.h>
3603 #include <sys/stat.h>
3605 int main(void){
3606   sem_t *a = sem_open("/autocftw", O_CREAT, S_IRUSR|S_IWUSR, 0);
3607   int count;
3608   int res;
3609   if(a==SEM_FAILED){
3610     perror("sem_open");
3611     return 1;
3613   }
3614   res = sem_getvalue(a, &count);
3615   sem_close(a);
3616   sem_unlink("/autocftw");
3617   return res==-1 ? 1 : 0;
3619 ]])],
3620 [ac_cv_broken_sem_getvalue=no],
3621 [ac_cv_broken_sem_getvalue=yes],
3622 [ac_cv_broken_sem_getvalue=yes])
3624 AC_MSG_RESULT($ac_cv_broken_sem_getvalue)
3625 if test $ac_cv_broken_sem_getvalue = yes
3626 then
3627   AC_DEFINE(HAVE_BROKEN_SEM_GETVALUE, 1,
3628   [define to 1 if your sem_getvalue is broken.])
3631 # determine what size digit to use for Python's longs
3632 AC_MSG_CHECKING([digit size for Python's longs])
3633 AC_ARG_ENABLE(big-digits,
3634 AS_HELP_STRING([--enable-big-digits@<:@=BITS@:>@],[use big digits for Python longs [[BITS=30]]]),
3635 [case $enable_big_digits in
3636 yes)
3637   enable_big_digits=30 ;;
3639   enable_big_digits=15 ;;
3640 [15|30])
3641   ;;
3643   AC_MSG_ERROR([bad value $enable_big_digits for --enable-big-digits; value should be 15 or 30]) ;;
3644 esac
3645 AC_MSG_RESULT($enable_big_digits)
3646 AC_DEFINE_UNQUOTED(PYLONG_BITS_IN_DIGIT, $enable_big_digits, [Define as the preferred size in bits of long digits])
3648 [AC_MSG_RESULT(no value specified)])
3650 # check for wchar.h
3651 AC_CHECK_HEADER(wchar.h, [
3652   AC_DEFINE(HAVE_WCHAR_H, 1, 
3653   [Define if the compiler provides a wchar.h header file.]) 
3654   wchar_h="yes"
3656 wchar_h="no"
3659 # determine wchar_t size
3660 if test "$wchar_h" = yes
3661 then
3662   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
3665 AC_MSG_CHECKING(for UCS-4 tcl)
3666 have_ucs4_tcl=no
3667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3668 #include <tcl.h>
3669 #if TCL_UTF_MAX != 6
3670 # error "NOT UCS4_TCL"
3671 #endif]], [[]])],[
3672   AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3673   have_ucs4_tcl=yes
3674 ],[])
3675 AC_MSG_RESULT($have_ucs4_tcl)
3677 # check whether wchar_t is signed or not
3678 if test "$wchar_h" = yes
3679 then
3680   # check whether wchar_t is signed or not
3681   AC_MSG_CHECKING(whether wchar_t is signed)
3682   AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3683   AC_RUN_IFELSE([AC_LANG_SOURCE([[
3684   #include <wchar.h>
3685   int main()
3686   {
3687         /* Success: exit code 0 */
3688         exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
3689   }
3690   ]])],
3691   [ac_cv_wchar_t_signed=yes],
3692   [ac_cv_wchar_t_signed=no],
3693   [ac_cv_wchar_t_signed=yes])])
3694   AC_MSG_RESULT($ac_cv_wchar_t_signed)
3696   
3697 AC_MSG_CHECKING(what type to use for unicode)
3698 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3699 AC_ARG_ENABLE(unicode, 
3700               AS_HELP_STRING([--enable-unicode@<:@=ucs@<:@24@:>@@:>@], [Enable Unicode strings (default is ucs2)]),
3701               [],
3702               [enable_unicode=yes])
3704 if test $enable_unicode = yes
3705 then
3706   # Without any arguments, Py_UNICODE defaults to two-byte mode
3707   case "$have_ucs4_tcl" in
3708   yes) enable_unicode="ucs4"
3709        ;;
3710   *)   enable_unicode="ucs2"
3711        ;;
3712   esac
3715 AH_TEMPLATE(Py_UNICODE_SIZE,
3716   [Define as the size of the unicode type.])
3717 case "$enable_unicode" in
3718 ucs2) unicode_size="2"
3719       AC_DEFINE(Py_UNICODE_SIZE,2)
3720       ;;
3721 ucs4) unicode_size="4"
3722       AC_DEFINE(Py_UNICODE_SIZE,4)
3723       ;;
3724 *) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
3725 esac
3727 AH_TEMPLATE(PY_UNICODE_TYPE,
3728   [Define as the integral type used for Unicode representation.])
3730 AC_SUBST(UNICODE_OBJS)
3731 if test "$enable_unicode" = "no"
3732 then
3733   UNICODE_OBJS=""
3734   AC_MSG_RESULT(not used)
3735 else
3736   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
3737   AC_DEFINE(Py_USING_UNICODE, 1,
3738   [Define if you want to have a Unicode type.])
3740   # wchar_t is only usable if it maps to an unsigned type
3741   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
3742           -a "$ac_cv_wchar_t_signed" = "no"
3743   then
3744     PY_UNICODE_TYPE="wchar_t"
3745     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3746     [Define if you have a useable wchar_t type defined in wchar.h; useable
3747      means wchar_t must be an unsigned type with at least 16 bits. (see
3748      Include/unicodeobject.h).])
3749     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3750   elif test "$ac_cv_sizeof_short" = "$unicode_size"
3751   then
3752        PY_UNICODE_TYPE="unsigned short"
3753        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3754   elif test "$ac_cv_sizeof_long" = "$unicode_size"
3755   then
3756        PY_UNICODE_TYPE="unsigned long"
3757        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3758   else
3759        PY_UNICODE_TYPE="no type found"
3760   fi
3761   AC_MSG_RESULT($PY_UNICODE_TYPE)
3764 # check for endianness
3765 AC_C_BIGENDIAN
3767 # Check whether right shifting a negative integer extends the sign bit
3768 # or fills with zeros (like the Cray J90, according to Tim Peters).
3769 AC_MSG_CHECKING(whether right shift extends the sign bit)
3770 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
3771 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3772 int main()
3774         exit(((-1)>>3 == -1) ? 0 : 1);
3776 ]])],
3777 [ac_cv_rshift_extends_sign=yes],
3778 [ac_cv_rshift_extends_sign=no],
3779 [ac_cv_rshift_extends_sign=yes])])
3780 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3781 if test "$ac_cv_rshift_extends_sign" = no
3782 then
3783   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3784   [Define if i>>j for signed int i does not extend the sign bit
3785    when i < 0])
3788 # check for getc_unlocked and related locking functions
3789 AC_MSG_CHECKING(for getc_unlocked() and friends)
3790 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3791 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[
3792         FILE *f = fopen("/dev/null", "r");
3793         flockfile(f);
3794         getc_unlocked(f);
3795         funlockfile(f);
3796 ]])],[ac_cv_have_getc_unlocked=yes],[ac_cv_have_getc_unlocked=no])])
3797 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3798 if test "$ac_cv_have_getc_unlocked" = yes
3799 then
3800   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3801   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
3804 # check where readline lives
3805 # save the value of LIBS so we don't actually link Python with readline
3806 LIBS_no_readline=$LIBS
3808 # On some systems we need to link readline to a termcap compatible
3809 # library.  NOTE: Keep the precedence of listed libraries synchronised
3810 # with setup.py.
3811 py_cv_lib_readline=no
3812 AC_MSG_CHECKING([how to link readline libs])
3813 for py_libtermcap in "" ncursesw ncurses curses termcap; do
3814   if test -z "$py_libtermcap"; then
3815     READLINE_LIBS="-lreadline"
3816   else
3817     READLINE_LIBS="-lreadline -l$py_libtermcap"
3818   fi
3819   LIBS="$READLINE_LIBS $LIBS_no_readline"
3820   AC_LINK_IFELSE(
3821     [AC_LANG_CALL([],[readline])],
3822     [py_cv_lib_readline=yes])
3823   if test $py_cv_lib_readline = yes; then
3824     break
3825   fi
3826 done
3827 # Uncomment this line if you want to use READINE_LIBS in Makefile or scripts
3828 #AC_SUBST([READLINE_LIBS])
3829 if test $py_cv_lib_readline = no; then
3830   AC_MSG_RESULT([none])
3831 else
3832   AC_MSG_RESULT([$READLINE_LIBS])
3833   AC_DEFINE(HAVE_LIBREADLINE, 1,
3834     [Define if you have the readline library (-lreadline).])
3837 # check for readline 2.1
3838 AC_CHECK_LIB(readline, rl_callback_handler_install,
3839         AC_DEFINE(HAVE_RL_CALLBACK, 1,
3840         [Define if you have readline 2.1]), ,$READLINE_LIBS)
3842 # check for readline 2.2
3843 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3844   [have_readline=yes],
3845   [have_readline=no]
3847 if test $have_readline = yes
3848 then
3849   AC_EGREP_HEADER([extern int rl_completion_append_character;],
3850   [readline/readline.h],
3851   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3852   [Define if you have readline 2.2]), )
3853   AC_EGREP_HEADER([extern int rl_completion_suppress_append;],
3854   [readline/readline.h],
3855   AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_APPEND, 1,
3856   [Define if you have rl_completion_suppress_append]), )
3859 # check for readline 4.0
3860 AC_CHECK_LIB(readline, rl_pre_input_hook,
3861         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
3862         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3864 # also in 4.0
3865 AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3866         AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
3867         [Define if you have readline 4.0]), ,$READLINE_LIBS)
3869 # check for readline 4.2
3870 AC_CHECK_LIB(readline, rl_completion_matches,
3871         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
3872         [Define if you have readline 4.2]), ,$READLINE_LIBS)
3874 # also in readline 4.2
3875 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <readline/readline.h>]])],
3876   [have_readline=yes],
3877   [have_readline=no]
3879 if test $have_readline = yes
3880 then
3881   AC_EGREP_HEADER([extern int rl_catch_signals;],
3882   [readline/readline.h],
3883   AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3884   [Define if you can turn off readline's signal handling.]), )
3887 # End of readline checks: restore LIBS
3888 LIBS=$LIBS_no_readline
3890 AC_MSG_CHECKING(for broken nice())
3891 AC_CACHE_VAL(ac_cv_broken_nice, [
3892 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3893 int main()
3895         int val1 = nice(1);
3896         if (val1 != -1 && val1 == nice(2))
3897                 exit(0);
3898         exit(1);
3900 ]])],
3901 [ac_cv_broken_nice=yes],
3902 [ac_cv_broken_nice=no],
3903 [ac_cv_broken_nice=no])])
3904 AC_MSG_RESULT($ac_cv_broken_nice)
3905 if test "$ac_cv_broken_nice" = yes
3906 then
3907   AC_DEFINE(HAVE_BROKEN_NICE, 1,
3908   [Define if nice() returns success/failure instead of the new priority.])
3911 AC_MSG_CHECKING(for broken poll())
3912 AC_CACHE_VAL(ac_cv_broken_poll,
3913 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3914 #include <poll.h>
3916 int main()
3918     struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3919     int poll_test;
3921     close (42);
3923     poll_test = poll(&poll_struct, 1, 0);
3924     if (poll_test < 0)
3925         return 0;
3926     else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3927         return 0;
3928     else
3929         return 1;
3931 ]])],
3932 [ac_cv_broken_poll=yes],
3933 [ac_cv_broken_poll=no],
3934 [ac_cv_broken_poll=no]))
3935 AC_MSG_RESULT($ac_cv_broken_poll)
3936 if test "$ac_cv_broken_poll" = yes
3937 then
3938   AC_DEFINE(HAVE_BROKEN_POLL, 1,
3939       [Define if poll() sets errno on invalid file descriptors.])
3942 # Before we can test tzset, we need to check if struct tm has a tm_zone 
3943 # (which is not required by ISO C or UNIX spec) and/or if we support
3944 # tzname[]
3945 AC_STRUCT_TIMEZONE
3947 # check tzset(3) exists and works like we expect it to
3948 AC_MSG_CHECKING(for working tzset())
3949 AC_CACHE_VAL(ac_cv_working_tzset, [
3950 AC_RUN_IFELSE([AC_LANG_SOURCE([[
3951 #include <stdlib.h>
3952 #include <time.h>
3953 #include <string.h>
3955 #if HAVE_TZNAME
3956 extern char *tzname[];
3957 #endif
3959 int main()
3961         /* Note that we need to ensure that not only does tzset(3)
3962            do 'something' with localtime, but it works as documented
3963            in the library reference and as expected by the test suite.
3964            This includes making sure that tzname is set properly if
3965            tm->tm_zone does not exist since it is the alternative way
3966            of getting timezone info.
3968            Red Hat 6.2 doesn't understand the southern hemisphere 
3969            after New Year's Day.
3970         */
3972         time_t groundhogday = 1044144000; /* GMT-based */
3973         time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3975         putenv("TZ=UTC+0");
3976         tzset();
3977         if (localtime(&groundhogday)->tm_hour != 0)
3978             exit(1);
3979 #if HAVE_TZNAME
3980         /* For UTC, tzname[1] is sometimes "", sometimes "   " */
3981         if (strcmp(tzname[0], "UTC") || 
3982                 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3983             exit(1);
3984 #endif
3986         putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
3987         tzset();
3988         if (localtime(&groundhogday)->tm_hour != 19)
3989             exit(1);
3990 #if HAVE_TZNAME
3991         if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3992             exit(1);
3993 #endif
3995         putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3996         tzset();
3997         if (localtime(&groundhogday)->tm_hour != 11)
3998             exit(1);
3999 #if HAVE_TZNAME
4000         if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
4001             exit(1);
4002 #endif
4004 #if HAVE_STRUCT_TM_TM_ZONE
4005         if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
4006             exit(1);
4007         if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
4008             exit(1);
4009 #endif
4011         exit(0);
4013 ]])],
4014 [ac_cv_working_tzset=yes],
4015 [ac_cv_working_tzset=no],
4016 [ac_cv_working_tzset=no])])
4017 AC_MSG_RESULT($ac_cv_working_tzset)
4018 if test "$ac_cv_working_tzset" = yes
4019 then
4020   AC_DEFINE(HAVE_WORKING_TZSET, 1,
4021   [Define if tzset() actually switches the local timezone in a meaningful way.])
4024 # Look for subsecond timestamps in struct stat
4025 AC_MSG_CHECKING(for tv_nsec in struct stat)
4026 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
4027 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
4028 struct stat st;
4029 st.st_mtim.tv_nsec = 1;
4030 ]])],
4031 [ac_cv_stat_tv_nsec=yes],
4032 [ac_cv_stat_tv_nsec=no]))
4033 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
4034 if test "$ac_cv_stat_tv_nsec" = yes
4035 then
4036   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
4037   [Define if you have struct stat.st_mtim.tv_nsec])
4040 # Look for BSD style subsecond timestamps in struct stat
4041 AC_MSG_CHECKING(for tv_nsec2 in struct stat)
4042 AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
4043 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h>]], [[
4044 struct stat st;
4045 st.st_mtimespec.tv_nsec = 1;
4046 ]])],
4047 [ac_cv_stat_tv_nsec2=yes],
4048 [ac_cv_stat_tv_nsec2=no]))
4049 AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
4050 if test "$ac_cv_stat_tv_nsec2" = yes
4051 then
4052   AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
4053   [Define if you have struct stat.st_mtimensec])
4056 # On HP/UX 11.0, mvwdelch is a block with a return statement
4057 AC_MSG_CHECKING(whether mvwdelch is an expression)
4058 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
4059 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4060   int rtn;
4061   rtn = mvwdelch(0,0,0);
4062 ]])],
4063 [ac_cv_mvwdelch_is_expression=yes],
4064 [ac_cv_mvwdelch_is_expression=no]))
4065 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
4067 if test "$ac_cv_mvwdelch_is_expression" = yes
4068 then
4069   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
4070   [Define if mvwdelch in curses.h is an expression.])
4073 AC_MSG_CHECKING(whether WINDOW has _flags)
4074 AC_CACHE_VAL(ac_cv_window_has_flags,
4075 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[
4076   WINDOW *w;
4077   w->_flags = 0;
4078 ]])],
4079 [ac_cv_window_has_flags=yes],
4080 [ac_cv_window_has_flags=no]))
4081 AC_MSG_RESULT($ac_cv_window_has_flags)
4084 if test "$ac_cv_window_has_flags" = yes
4085 then
4086   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
4087   [Define if WINDOW in curses.h offers a field _flags.])
4090 AC_MSG_CHECKING(for is_term_resized)
4091 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=is_term_resized]])],
4092   [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
4093    AC_MSG_RESULT(yes)],
4094   [AC_MSG_RESULT(no)]
4097 AC_MSG_CHECKING(for resize_term)
4098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resize_term]])],
4099   [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
4100    AC_MSG_RESULT(yes)],
4101   [AC_MSG_RESULT(no)]
4104 AC_MSG_CHECKING(for resizeterm)
4105 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[void *x=resizeterm]])],
4106   [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
4107    AC_MSG_RESULT(yes)],
4108   [AC_MSG_RESULT(no)]
4111 AC_MSG_CHECKING(for /dev/ptmx)
4113 if test -r /dev/ptmx
4114 then
4115   AC_MSG_RESULT(yes)
4116   AC_DEFINE(HAVE_DEV_PTMX, 1,
4117   [Define if we have /dev/ptmx.])
4118 else
4119   AC_MSG_RESULT(no)
4122 AC_MSG_CHECKING(for /dev/ptc)
4124 if test -r /dev/ptc
4125 then
4126   AC_MSG_RESULT(yes)
4127   AC_DEFINE(HAVE_DEV_PTC, 1,
4128   [Define if we have /dev/ptc.])
4129 else
4130   AC_MSG_RESULT(no)
4133 if test "$have_long_long" = yes
4134 then
4135   AC_MSG_CHECKING(for %lld and %llu printf() format support)
4136   AC_CACHE_VAL(ac_cv_have_long_long_format,
4137   AC_RUN_IFELSE([AC_LANG_SOURCE([[[
4138   #include <stdio.h>
4139   #include <stddef.h>
4140   #include <string.h>
4142   #ifdef HAVE_SYS_TYPES_H
4143   #include <sys/types.h>
4144   #endif
4146   int main()
4147   {
4148       char buffer[256];
4150       if (sprintf(buffer, "%lld", (long long)123) < 0)
4151           return 1;
4152       if (strcmp(buffer, "123"))
4153           return 1;
4155       if (sprintf(buffer, "%lld", (long long)-123) < 0)
4156           return 1;
4157       if (strcmp(buffer, "-123"))
4158           return 1;
4160       if (sprintf(buffer, "%llu", (unsigned long long)123) < 0)
4161           return 1;
4162       if (strcmp(buffer, "123"))
4163           return 1;
4165       return 0;
4166   }
4167   ]]])],
4168   [ac_cv_have_long_long_format=yes],
4169   [ac_cv_have_long_long_format=no],
4170   [ac_cv_have_long_long_format=no])
4171   )
4172   AC_MSG_RESULT($ac_cv_have_long_long_format)
4175 if test "$ac_cv_have_long_long_format" = yes
4176 then
4177   AC_DEFINE(PY_FORMAT_LONG_LONG, "ll",
4178   [Define to printf format modifier for long long type])
4181 if test $ac_sys_system = Darwin
4182 then
4183         LIBS="$LIBS -framework CoreFoundation"
4187 AC_CACHE_CHECK([for %zd printf() format support], ac_cv_have_size_t_format, [dnl
4188 AC_RUN_IFELSE([AC_LANG_SOURCE([[
4189 #include <stdio.h>
4190 #include <stddef.h>
4191 #include <string.h>
4193 #ifdef HAVE_SYS_TYPES_H
4194 #include <sys/types.h>
4195 #endif
4197 #ifdef HAVE_SSIZE_T
4198 typedef ssize_t Py_ssize_t;
4199 #elif SIZEOF_VOID_P == SIZEOF_LONG
4200 typedef long Py_ssize_t;
4201 #else
4202 typedef int Py_ssize_t;
4203 #endif
4205 int main()
4207     char buffer[256];
4209     if(sprintf(buffer, "%zd", (size_t)123) < 0)
4210         return 1;
4212     if (strcmp(buffer, "123"))
4213         return 1;
4215     if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
4216         return 1;
4218     if (strcmp(buffer, "-123"))
4219         return 1;
4221     return 0;
4223 ]])],
4224 [ac_cv_have_size_t_format=yes],
4225 [ac_cv_have_size_t_format=no],
4226 [ac_cv_have_size_t_format="cross -- assuming yes"
4227 ])])
4228 if test "$ac_cv_have_size_t_format" != no ; then
4229   AC_DEFINE(PY_FORMAT_SIZE_T, "z",
4230   [Define to printf format modifier for Py_ssize_t])
4233 AC_CHECK_TYPE(socklen_t,,
4234   AC_DEFINE(socklen_t,int,
4235             [Define to `int' if <sys/socket.h> does not define.]),[
4236 #ifdef HAVE_SYS_TYPES_H
4237 #include <sys/types.h>
4238 #endif
4239 #ifdef HAVE_SYS_SOCKET_H
4240 #include <sys/socket.h>
4241 #endif
4244 AC_SUBST(THREADHEADERS)
4246 for h in `(cd $srcdir;echo Python/thread_*.h)`
4248   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
4249 done
4251 AC_SUBST(SRCDIRS)
4252 SRCDIRS="Parser Grammar Objects Python Modules Mac"
4253 AC_MSG_CHECKING(for build directories)
4254 for dir in $SRCDIRS; do
4255     if test ! -d $dir; then
4256         mkdir $dir
4257     fi
4258 done
4259 AC_MSG_RESULT(done)
4261 # generate output files
4262 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc)
4263 AC_OUTPUT
4265 echo "creating Modules/Setup"
4266 if test ! -f Modules/Setup
4267 then
4268         cp $srcdir/Modules/Setup.dist Modules/Setup
4271 echo "creating Modules/Setup.local"
4272 if test ! -f Modules/Setup.local
4273 then
4274         echo "# Edit this file for local setup changes" >Modules/Setup.local
4277 echo "creating Makefile"
4278 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
4279                         -s Modules Modules/Setup.config \
4280                         Modules/Setup.local Modules/Setup
4282 case $ac_sys_system in
4283 BeOS)
4284         AC_MSG_WARN([
4286   Support for BeOS is deprecated as of Python 2.6.
4287   See PEP 11 for the gory details.
4288   ])
4289   ;;
4290 *) ;;
4291 esac
4293 mv config.c Modules