Add a missing entry on the fix for issue #2790.
[python.git] / configure.in
blobbc9a02e9611530db665f362d5f13103abfab8bba
1 dnl Process this file with autoconf 2.0 or later to make a configure script.
3 # Set VERSION so we only need to edit in one place (i.e., here)
4 m4_define(PYTHON_VERSION, 2.6)
6 AC_REVISION($Revision$)
7 AC_PREREQ(2.61)
8 AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs)
9 AC_CONFIG_SRCDIR([Include/object.h])
10 AC_CONFIG_HEADER(pyconfig.h)
12 dnl This is for stuff that absolutely must end up in pyconfig.h.
13 dnl Please use pyport.h instead, if possible.
14 AH_TOP([
15 #ifndef Py_PYCONFIG_H
16 #define Py_PYCONFIG_H
18 AH_BOTTOM([
19 /* Define the macros needed if on a UnixWare 7.x system. */
20 #if defined(__USLC__) && defined(__SCO_VERSION__)
21 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
22 #endif
24 #endif /*Py_PYCONFIG_H*/
27 # We don't use PACKAGE_ variables, and they cause conflicts
28 # with other autoconf-based packages that include Python.h
29 grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
30 rm confdefs.h
31 mv confdefs.h.new confdefs.h
33 AC_SUBST(VERSION)
34 VERSION=PYTHON_VERSION
36 AC_SUBST(SOVERSION)
37 SOVERSION=1.0
39 # The later defininition of _XOPEN_SOURCE disables certain features
40 # on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
41 AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
43 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
44 # certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
45 # them.
46 AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
48 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
49 # certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
50 # them.
51 AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
53 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
54 # u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
55 AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
57 define_xopen_source=yes
59 # Arguments passed to configure.
60 AC_SUBST(CONFIG_ARGS)
61 CONFIG_ARGS="$ac_configure_args"
63 AC_ARG_ENABLE(universalsdk,
64         AC_HELP_STRING(--enable-universalsdk@<:@=SDKDIR@:>@, Build against Mac OS X 10.4u SDK (ppc/i386)),
66         case $enableval in
67         yes)
68                 enableval=/Developer/SDKs/MacOSX10.4u.sdk
69                 ;;
70         esac
71         case $enableval in
72         no)
73                 UNIVERSALSDK=
74                 enable_universalsdk=
75                 ;;
76         *)
77                 UNIVERSALSDK=$enableval
78                 ;;
79         esac
80 ],[
81         UNIVERSALSDK=
82         enable_universalsdk=
84 AC_SUBST(UNIVERSALSDK)
86 AC_ARG_WITH(framework-name,
87               AC_HELP_STRING(--with-framework-name=FRAMEWORK, 
88                              specify an alternate name of the framework built with --enable-framework),
90     PYTHONFRAMEWORK=${withval}
91     PYTHONFRAMEWORKDIR=${withval}.framework
92     PYTHONFRAMEWORKIDENTIFIER=org.python.`echo $withval | tr '[A-Z]' '[a-z]'`
93     ],[
94     PYTHONFRAMEWORK=Python
95     PYTHONFRAMEWORKDIR=Python.framework
96     PYTHONFRAMEWORKIDENTIFIER=org.python.python
98 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
99 AC_ARG_ENABLE(framework,
100               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
102         case $enableval in
103         yes) 
104                 enableval=/Library/Frameworks
105         esac
106         case $enableval in
107         no)
108                 PYTHONFRAMEWORK=
109                 PYTHONFRAMEWORKDIR=no-framework
110                 PYTHONFRAMEWORKPREFIX=
111                 PYTHONFRAMEWORKINSTALLDIR=
112                 FRAMEWORKINSTALLFIRST=
113                 FRAMEWORKINSTALLLAST=
114                 FRAMEWORKALTINSTALLFIRST=
115                 FRAMEWORKALTINSTALLLAST=
116                 if test "x${prefix}" = "xNONE"; then
117                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
118                 else
119                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
120                 fi
121                 enable_framework=
122                 ;;
123         *)
124                 PYTHONFRAMEWORKPREFIX=$enableval
125                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
126                 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
127                 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
128                 FRAMEWORKALTINSTALLFIRST="${FRAMEWORKINSTALLFIRST} bininstall maninstall"
129                 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
130                 if test "x${prefix}" = "xNONE" ; then
131                         FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
132                 else
133                         FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
134                 fi
135                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
137                 # Add files for Mac specific code to the list of output
138                 # files:
139                 AC_CONFIG_FILES(Mac/Makefile)
140                 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
141                 AC_CONFIG_FILES(Mac/IDLE/Makefile)
142                 AC_CONFIG_FILES(Mac/Resources/framework/Info.plist)
143                 AC_CONFIG_FILES(Mac/Resources/app/Info.plist)
144         esac
145         ],[
146         PYTHONFRAMEWORK=
147         PYTHONFRAMEWORKDIR=no-framework
148         PYTHONFRAMEWORKPREFIX=
149         PYTHONFRAMEWORKINSTALLDIR=
150         FRAMEWORKINSTALLFIRST=
151         FRAMEWORKINSTALLLAST=
152         FRAMEWORKALTINSTALLFIRST=
153         FRAMEWORKALTINSTALLLAST=
154         if test "x${prefix}" = "xNONE" ; then
155                 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
156         else
157                 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
158         fi
159         enable_framework=
161 AC_SUBST(PYTHONFRAMEWORK)
162 AC_SUBST(PYTHONFRAMEWORKIDENTIFIER)
163 AC_SUBST(PYTHONFRAMEWORKDIR)
164 AC_SUBST(PYTHONFRAMEWORKPREFIX)
165 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
166 AC_SUBST(FRAMEWORKINSTALLFIRST)
167 AC_SUBST(FRAMEWORKINSTALLLAST)
168 AC_SUBST(FRAMEWORKALTINSTALLFIRST)
169 AC_SUBST(FRAMEWORKALTINSTALLLAST)
170 AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
172 ##AC_ARG_WITH(dyld,
173 ##            AC_HELP_STRING(--with-dyld,
174 ##                           Use (OpenStep|Rhapsody) dynamic linker))
176 # Set name for machine-dependent library files
177 AC_SUBST(MACHDEP)
178 AC_MSG_CHECKING(MACHDEP)
179 if test -z "$MACHDEP"
180 then
181         ac_sys_system=`uname -s`
182         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
183         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
184                 ac_sys_release=`uname -v`
185         else
186                 ac_sys_release=`uname -r`
187         fi
188         ac_md_system=`echo $ac_sys_system |
189                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
190         ac_md_release=`echo $ac_sys_release |
191                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
192         MACHDEP="$ac_md_system$ac_md_release"
194         case $MACHDEP in
195         cygwin*) MACHDEP="cygwin";;
196         darwin*) MACHDEP="darwin";;
197         atheos*) MACHDEP="atheos";;
198         irix646) MACHDEP="irix6";;
199         '')     MACHDEP="unknown";;
200         esac
202         
203 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
204 # disable features if it is defined, without any means to access these
205 # features as extensions. For these systems, we skip the definition of
206 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
207 # some feature, make sure there is no alternative way to access this
208 # feature. Also, when using wildcards, make sure you have verified the
209 # need for not defining _XOPEN_SOURCE on all systems matching the
210 # wildcard, and that the wildcard does not include future systems
211 # (which may remove their limitations).
212 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
213 case $ac_sys_system/$ac_sys_release in
214   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
215   # even though select is a POSIX function. Reported by J. Ribbens.
216   # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
217   OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) 
218     define_xopen_source=no
219     # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is
220     # also defined. This can be overridden by defining _BSD_SOURCE
221     # As this has a different meaning on Linux, only define it on OpenBSD
222     AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features])
223     ;;
224   # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
225   # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
226   # Marc Recht
227   NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S])
228     define_xopen_source=no;;
229   # On Solaris 2.6, sys/wait.h is inconsistent in the usage
230   # of union __?sigval. Reported by Stuart Bishop.
231   SunOS/5.6)
232     define_xopen_source=no;;
233   # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
234   # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
235   # Reconfirmed for 7.1.4 by Martin v. Loewis.
236   OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
237     define_xopen_source=no;;
238   # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
239   # but used in struct sockaddr.sa_family. Reported by Tim Rice.
240   SCO_SV/3.2)
241     define_xopen_source=no;;
242   # On FreeBSD 4.8 and MacOS X 10.2, a bug in ncurses.h means that
243   # it craps out if _XOPEN_EXTENDED_SOURCE is defined. Apparently,
244   # this is fixed in 10.3, which identifies itself as Darwin/7.*
245   # This should hopefully be fixed in FreeBSD 4.9
246   FreeBSD/4.8* | Darwin/6* )
247     define_xopen_source=no;;
248   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
249   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
250   # or has another value. By not (re)defining it, the defaults come in place.
251   AIX/4)
252     define_xopen_source=no;;
253   AIX/5)
254     if test `uname -r` -eq 1; then
255       define_xopen_source=no
256     fi
257     ;;
258   # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
259   # disables platform specific features beyond repair.
260   # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE 
261   # has no effect, don't bother defining them
262   Darwin/@<:@789@:>@.*)
263     define_xopen_source=no
264     ;;
266 esac
268 if test $define_xopen_source = yes
269 then
270   # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
271   # defined precisely as g++ defines it
272   # Furthermore, on Solaris 10, XPG6 requires the use of a C99
273   # compiler
274   case $ac_sys_system/$ac_sys_release in
275     SunOS/5.8|SunOS/5.9|SunOS/5.10)
276       AC_DEFINE(_XOPEN_SOURCE, 500, 
277                 Define to the level of X/Open that your system supports)
278       ;;
279     *)
280       AC_DEFINE(_XOPEN_SOURCE, 600, 
281                 Define to the level of X/Open that your system supports)
282       ;;
283   esac
285   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
286   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
287   # several APIs are not declared. Since this is also needed in some
288   # cases for HP-UX, we define it globally.
289   # except for Solaris 10, where it must not be defined, 
290   # as it implies XPG4.2
291   case $ac_sys_system/$ac_sys_release in
292     SunOS/5.10)
293       ;;
294     *)
295       AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
296                 Define to activate Unix95-and-earlier features)
297       ;;
298   esac
300   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
301   
305 # SGI compilers allow the specification of the both the ABI and the
306 # ISA on the command line.  Depending on the values of these switches,
307 # different and often incompatable code will be generated.
309 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
310 # thus supply support for various ABI/ISA combinations.  The MACHDEP
311 # variable is also adjusted.
313 AC_SUBST(SGI_ABI)
314 if test ! -z "$SGI_ABI"
315 then
316         CC="cc $SGI_ABI"
317         LDFLAGS="$SGI_ABI $LDFLAGS"
318         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
320 AC_MSG_RESULT($MACHDEP)
322 # And add extra plat-mac for darwin
323 AC_SUBST(EXTRAPLATDIR)
324 AC_SUBST(EXTRAMACHDEPPATH)
325 AC_MSG_CHECKING(EXTRAPLATDIR)
326 if test -z "$EXTRAPLATDIR"
327 then
328         case $MACHDEP in
329         darwin) 
330                 EXTRAPLATDIR="\$(PLATMACDIRS)"
331                 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
332                 ;;
333         *) 
334                 EXTRAPLATDIR=""
335                 EXTRAMACHDEPPATH=""
336                 ;;
337         esac
339 AC_MSG_RESULT($EXTRAPLATDIR)
341 # Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
342 # it may influence the way we can build extensions, so distutils
343 # needs to check it
344 AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
345 AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
346 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
347 EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
349 AC_MSG_CHECKING(machine type as reported by uname -m)
350 ac_sys_machine=`uname -m`
351 AC_MSG_RESULT($ac_sys_machine)
353 # checks for alternative programs
355 # compiler flags are generated in two sets, BASECFLAGS and OPT.  OPT is just
356 # for debug/optimization stuff.  BASECFLAGS is for flags that are required
357 # just to get things to compile and link.  Users are free to override OPT
358 # when running configure or make.  The build should not break if they do.
359 # BASECFLAGS should generally not be messed with, however.
361 # XXX shouldn't some/most/all of this code be merged with the stuff later
362 # on that fiddles with OPT and BASECFLAGS?
363 AC_MSG_CHECKING(for --without-gcc)
364 AC_ARG_WITH(gcc,
365             AC_HELP_STRING(--without-gcc,never use gcc),
367         case $withval in
368         no)     CC=cc
369                 without_gcc=yes;;
370         yes)    CC=gcc
371                 without_gcc=no;;
372         *)      CC=$withval
373                 without_gcc=$withval;;
374         esac], [
375         case $ac_sys_system in
376         AIX*)   CC=cc_r
377                 without_gcc=;;
378         BeOS*)
379                 case $BE_HOST_CPU in
380                 ppc)
381                         CC=mwcc
382                         without_gcc=yes
383                         BASECFLAGS="$BASECFLAGS -export pragma"
384                         OPT="$OPT -O"
385                         LDFLAGS="$LDFLAGS -nodup"
386                         ;;
387                 x86)
388                         CC=gcc
389                         without_gcc=no
390                         OPT="$OPT -O"
391                         ;;
392                 *)
393                         AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
394                         ;;
395                 esac
396                 AR="\$(srcdir)/Modules/ar_beos"
397                 RANLIB=:
398                 ;;
399     Monterey*)
400         RANLIB=:
401         without_gcc=;;
402         *)      without_gcc=no;;
403         esac])
404 AC_MSG_RESULT($without_gcc)
406 # If the user switches compilers, we can't believe the cache
407 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
408 then
409   AC_MSG_ERROR([cached CC is different -- throw away $cache_file
410 (it is also a good idea to do 'make clean' before compiling)])
413 AC_PROG_CC
415 AC_SUBST(CXX)
416 AC_SUBST(MAINCC)
417 AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
418 AC_ARG_WITH(cxx_main,
419             AC_HELP_STRING([--with-cxx-main=<compiler>],
420                            [compile main() and link python executable with C++ compiler]),
422         
423         case $withval in
424         no)     with_cxx_main=no
425                 MAINCC='$(CC)';;
426         yes)    with_cxx_main=yes
427                 MAINCC='$(CXX)';;
428         *)      with_cxx_main=yes
429                 MAINCC=$withval
430                 if test -z "$CXX"
431                 then
432                         CXX=$withval
433                 fi;;
434         esac], [
435         with_cxx_main=no
436         MAINCC='$(CC)'
438 AC_MSG_RESULT($with_cxx_main)
440 preset_cxx="$CXX"
441 if test -z "$CXX"
442 then
443         case "$CC" in
444         gcc)    AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
445         cc)     AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
446         esac
447         if test "$CXX" = "notfound"
448         then
449                 CXX=""
450         fi
452 if test -z "$CXX"
453 then
454         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
455         if test "$CXX" = "notfound"
456         then
457                 CXX=""
458         fi
460 if test "$preset_cxx" != "$CXX"
461 then
462         AC_MSG_WARN([
464   By default, distutils will build C++ extension modules with "$CXX".
465   If this is not intended, then set CXX on the configure command line.
466   ])
470 # checks for UNIX variants that set C preprocessor variables
471 AC_AIX
473 # Check for unsupported systems
474 case $ac_sys_system/$ac_sys_release in
475 atheos*|Linux*/1*)
476    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
477    echo See README for details.
478    exit 1;;
479 esac
481 AC_EXEEXT
482 AC_MSG_CHECKING(for --with-suffix)
483 AC_ARG_WITH(suffix,
484             AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
486         case $withval in
487         no)     EXEEXT=;;
488         yes)    EXEEXT=.exe;;
489         *)      EXEEXT=$withval;;
490         esac])
491 AC_MSG_RESULT($EXEEXT)
493 # Test whether we're running on a non-case-sensitive system, in which
494 # case we give a warning if no ext is given
495 AC_SUBST(BUILDEXEEXT)
496 AC_MSG_CHECKING(for case-insensitive build directory)
497 if test ! -d CaseSensitiveTestDir; then
498 mkdir CaseSensitiveTestDir
501 if test -d casesensitivetestdir
502 then
503     AC_MSG_RESULT(yes)
504     BUILDEXEEXT=.exe
505 else
506         AC_MSG_RESULT(no)
507         BUILDEXEEXT=$EXEEXT
509 rmdir CaseSensitiveTestDir
511 case $MACHDEP in
512 bsdos*)
513     case $CC in
514     gcc) CC="$CC -D_HAVE_BSDI";;
515     esac;;
516 esac
518 case $ac_sys_system in
519 hp*|HP*)
520     case $CC in
521     cc|*/cc) CC="$CC -Ae";;
522     esac;;
523 Monterey*)
524     case $CC in
525     cc) CC="$CC -Wl,-Bexport";;
526     esac;;
527 SunOS*)
528     # Some functions have a prototype only with that define, e.g. confstr
529     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
530     ;;
531 esac
534 AC_SUBST(LIBRARY)
535 AC_MSG_CHECKING(LIBRARY)
536 if test -z "$LIBRARY"
537 then
538         LIBRARY='libpython$(VERSION).a'
540 AC_MSG_RESULT($LIBRARY)
542 # LDLIBRARY is the name of the library to link against (as opposed to the
543 # name of the library into which to insert object files). BLDLIBRARY is also
544 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
545 # is blank as the main program is not linked directly against LDLIBRARY.
546 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
547 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
548 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
549 # DLLLIBRARY is the shared (i.e., DLL) library.
551 # RUNSHARED is used to run shared python without installed libraries
553 # INSTSONAME is the name of the shared library that will be use to install
554 # on the system - some systems like version suffix, others don't
555 AC_SUBST(LDLIBRARY)
556 AC_SUBST(DLLLIBRARY)
557 AC_SUBST(BLDLIBRARY)
558 AC_SUBST(LDLIBRARYDIR)
559 AC_SUBST(INSTSONAME)
560 AC_SUBST(RUNSHARED)
561 LDLIBRARY="$LIBRARY"
562 BLDLIBRARY='$(LDLIBRARY)'
563 INSTSONAME='$(LDLIBRARY)'
564 DLLLIBRARY=''
565 LDLIBRARYDIR=''
566 RUNSHARED=''
568 # LINKCC is the command that links the python executable -- default is $(CC).
569 # If CXX is set, and if it is needed to link a main function that was
570 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
571 # python might then depend on the C++ runtime
572 # This is altered for AIX in order to build the export list before 
573 # linking.
574 AC_SUBST(LINKCC)
575 AC_MSG_CHECKING(LINKCC)
576 if test -z "$LINKCC"
577 then
578         LINKCC='$(PURIFY) $(MAINCC)'
579         case $ac_sys_system in
580         AIX*)
581            exp_extra="\"\""
582            if test $ac_sys_release -ge 5 -o \
583                    $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
584                exp_extra="."
585            fi
586            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
587         Monterey64*)
588            LINKCC="$LINKCC -L/usr/lib/ia64l64";;
589         esac
591 AC_MSG_RESULT($LINKCC)
593 AC_MSG_CHECKING(for --enable-shared)
594 AC_ARG_ENABLE(shared,
595               AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
597 if test -z "$enable_shared"
598 then 
599   case $ac_sys_system in
600   CYGWIN* | atheos*)
601     enable_shared="yes";;
602   *)
603     enable_shared="no";;
604   esac
606 AC_MSG_RESULT($enable_shared)
608 AC_MSG_CHECKING(for --enable-profiling)
609 AC_ARG_ENABLE(profiling,
610               AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
611 [ac_save_cc="$CC"
612  CC="$CC -pg"
613  AC_TRY_RUN([int main() { return 0; }],
614    ac_enable_profiling="yes",
615    ac_enable_profiling="no",
616    ac_enable_profiling="no")
617  CC="$ac_save_cc"])
618 AC_MSG_RESULT($ac_enable_profiling)
620 case "$ac_enable_profiling" in
621     "yes")
622         BASECFLAGS="-pg $BASECFLAGS"
623         LDFLAGS="-pg $LDFLAGS"
624     ;;
625 esac
627 AC_MSG_CHECKING(LDLIBRARY)
629 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
630 # library that we build, but we do not want to link against it (we
631 # will find it with a -framework option). For this reason there is an
632 # extra variable BLDLIBRARY against which Python and the extension
633 # modules are linked, BLDLIBRARY. This is normally the same as
634 # LDLIBRARY, but empty for MacOSX framework builds.
635 if test "$enable_framework"
636 then
637   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
638   RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
639   BLDLIBRARY=''
640 else
641   BLDLIBRARY='$(LDLIBRARY)'
642 fi  
644 # Other platforms follow
645 if test $enable_shared = "yes"; then
646   AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
647   case $ac_sys_system in
648     BeOS*)
649           LDLIBRARY='libpython$(VERSION).so'
650           ;;
651     CYGWIN*)
652           LDLIBRARY='libpython$(VERSION).dll.a'
653           DLLLIBRARY='libpython$(VERSION).dll'
654           ;;
655     SunOS*)
656           LDLIBRARY='libpython$(VERSION).so'
657           BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
658           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
659           INSTSONAME="$LDLIBRARY".$SOVERSION
660           ;;
661     Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
662           LDLIBRARY='libpython$(VERSION).so'
663           BLDLIBRARY='-L. -lpython$(VERSION)'
664           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
665           case $ac_sys_system in
666               FreeBSD*)
667                 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
668                 ;;
669           esac
670           INSTSONAME="$LDLIBRARY".$SOVERSION
671           ;;
672     hp*|HP*)
673           case `uname -m` in
674                 ia64)
675                         LDLIBRARY='libpython$(VERSION).so'
676                         ;;
677                 *)
678                         LDLIBRARY='libpython$(VERSION).sl'
679                         ;;
680           esac
681           BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
682           RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
683           ;;
684     OSF*)
685           LDLIBRARY='libpython$(VERSION).so'
686           BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
687           RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
688           ;;
689     atheos*)
690           LDLIBRARY='libpython$(VERSION).so'
691           BLDLIBRARY='-L. -lpython$(VERSION)'
692           RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
693           ;;
694   esac
695 else # shared is disabled
696   case $ac_sys_system in
697     CYGWIN*)
698           BLDLIBRARY='$(LIBRARY)'
699           LDLIBRARY='libpython$(VERSION).dll.a'
700           ;;
701   esac
704 AC_MSG_RESULT($LDLIBRARY)
706 AC_PROG_RANLIB
707 AC_SUBST(AR)
708 AC_CHECK_PROGS(AR, ar aal, ar)
710 AC_SUBST(SVNVERSION)
711 AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
712 if test $SVNVERSION = found
713 then
714         SVNVERSION="svnversion \$(srcdir)"
715 else
716         SVNVERSION="echo exported"
719 case $MACHDEP in
720 bsdos*|hp*|HP*)
721         # install -d does not work on BSDI or HP-UX
722         if test -z "$INSTALL"
723         then
724                 INSTALL="${srcdir}/install-sh -c"
725         fi
726 esac
727 AC_PROG_INSTALL
729 # Not every filesystem supports hard links
730 AC_SUBST(LN)
731 if test -z "$LN" ; then
732         case $ac_sys_system in
733                 BeOS*) LN="ln -s";;
734                 CYGWIN*) LN="ln -s";;
735                 atheos*) LN="ln -s";;
736                 *) LN=ln;;
737         esac
740 # Check for --with-pydebug
741 AC_MSG_CHECKING(for --with-pydebug)
742 AC_ARG_WITH(pydebug, 
743             AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
745 if test "$withval" != no
746 then 
747   AC_DEFINE(Py_DEBUG, 1, 
748   [Define if you want to build an interpreter with many run-time checks.]) 
749   AC_MSG_RESULT(yes); 
750   Py_DEBUG='true'
751 else AC_MSG_RESULT(no); Py_DEBUG='false'
752 fi],
753 [AC_MSG_RESULT(no)])
755 # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
756 # merged with this chunk of code?
758 # Optimizer/debugger flags
759 # ------------------------
760 # (The following bit of code is complicated enough - please keep things
761 # indented properly.  Just pretend you're editing Python code. ;-)
763 # There are two parallel sets of case statements below, one that checks to
764 # see if OPT was set and one that does BASECFLAGS setting based upon
765 # compiler and platform.  BASECFLAGS tweaks need to be made even if the
766 # user set OPT.
768 # tweak OPT based on compiler and platform, only if the user didn't set
769 # it on the command line
770 AC_SUBST(OPT)
771 if test -z "$OPT"
772 then
773     case $GCC in
774     yes)
775         if test "$CC" != 'g++' ; then
776             STRICT_PROTO="-Wstrict-prototypes"
777         fi
778         # For gcc 4.x we need to use -fwrapv so lets check if its supported
779         if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then
780            WRAP="-fwrapv"
781         fi
782         case $ac_cv_prog_cc_g in
783         yes)
784             if test "$Py_DEBUG" = 'true' ; then
785                 # Optimization messes up debuggers, so turn it off for
786                 # debug builds.
787                 OPT="-g -Wall $STRICT_PROTO"
788             else
789                 OPT="-g $WRAP -O3 -Wall $STRICT_PROTO"
790             fi
791             ;;
792         *)
793             OPT="-O3 -Wall $STRICT_PROTO"
794             ;;
795         esac
796         case $ac_sys_system in
797             SCO_SV*) OPT="$OPT -m486 -DSCO5"
798             ;;
799         esac
800         ;;
802     *)
803         OPT="-O"
804         ;;
805     esac
807     # The current (beta) Monterey compiler dies with optimizations
808     # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
809     case $ac_sys_system in
810         Monterey*)
811             OPT=""
812             ;;
813     esac
817 AC_SUBST(BASECFLAGS)
818 # tweak BASECFLAGS based on compiler and platform
819 case $GCC in
820 yes)
821     # Python violates C99 rules, by casting between incompatible
822     # pointer types. GCC may generate bad code as a result of that,
823     # so use -fno-strict-aliasing if supported.
824     AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
825      ac_save_cc="$CC"
826      CC="$CC -fno-strict-aliasing"
827      AC_TRY_RUN([int main() { return 0; }],
828      ac_cv_no_strict_aliasing_ok=yes,
829      ac_cv_no_strict_aliasing_ok=no,
830      ac_cv_no_strict_aliasing_ok=no)
831      CC="$ac_save_cc"
832     AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
833     if test $ac_cv_no_strict_aliasing_ok = yes
834     then
835       BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
836     fi
838     # if using gcc on alpha, use -mieee to get (near) full IEEE 754
839     # support.  Without this, treatment of subnormals doesn't follow
840     # the standard.
841     case $ac_sys_machine in
842          alpha*)
843                 BASECFLAGS="$BASECFLAGS -mieee"
844                 ;;
845     esac
847     case $ac_sys_system in
848         SCO_SV*)
849             BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
850             ;;
851         # is there any other compiler on Darwin besides gcc?
852         Darwin*)
853             # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
854             # used to be here, but non-Apple gcc doesn't accept them.
855             if test "${enable_universalsdk}"; then
856                 BASECFLAGS="-arch ppc -arch i386 -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
857             fi
859             ;;
860         OSF*)
861             BASECFLAGS="$BASECFLAGS -mieee"
862             ;;
863     esac
864     ;;
867     case $ac_sys_system in
868     OpenUNIX*|UnixWare*)
869         BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
870         ;;
871     OSF*)
872         BASECFLAGS="$BASECFLAGS -ieee -std"
873         ;;
874     SCO_SV*)
875         BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
876         ;;
877     esac
878     ;;
879 esac
881 if test "$Py_DEBUG" = 'true'; then
882   :
883 else
884   OPT="-DNDEBUG $OPT"
887 if test "$ac_arch_flags"
888 then
889         BASECFLAGS="$BASECFLAGS $ac_arch_flags"
892 # disable check for icc since it seems to pass, but generates a warning
893 if test "$CC" = icc
894 then
895   ac_cv_opt_olimit_ok=no
898 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
899 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
900 [ac_save_cc="$CC"
901 CC="$CC -OPT:Olimit=0"
902 AC_TRY_RUN([int main() { return 0; }],
903   ac_cv_opt_olimit_ok=yes,
904   ac_cv_opt_olimit_ok=no,
905   ac_cv_opt_olimit_ok=no)
906 CC="$ac_save_cc"])
907 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
908 if test $ac_cv_opt_olimit_ok = yes; then
909     case $ac_sys_system in
910         # XXX is this branch needed? On MacOSX 10.2.2 the result of the
911         # olimit_ok test is "no".  Is it "yes" in some other Darwin-esque
912         # environment?
913         Darwin*)
914             ;;
915         *)
916             BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
917             ;;
918     esac
919 else
920   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
921   AC_CACHE_VAL(ac_cv_olimit_ok,
922   [ac_save_cc="$CC"
923   CC="$CC -Olimit 1500"
924   AC_TRY_RUN([int main() { return 0; }],
925     ac_cv_olimit_ok=yes,
926     ac_cv_olimit_ok=no,
927     ac_cv_olimit_ok=no)
928   CC="$ac_save_cc"])
929   AC_MSG_RESULT($ac_cv_olimit_ok)
930   if test $ac_cv_olimit_ok = yes; then
931     BASECFLAGS="$BASECFLAGS -Olimit 1500"
932   fi
935 # Check whether GCC supports PyArg_ParseTuple format
936 if test "$GCC" = "yes"
937 then
938   AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
939   save_CFLAGS=$CFLAGS
940   CFLAGS="$CFLAGS -Werror"
941   AC_TRY_COMPILE([
942     void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
943   ],,
944   AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))])
945   AC_MSG_RESULT(yes),
946   AC_MSG_RESULT(no)
947   )
948   CFLAGS=$save_CFLAGS
951 # On some compilers, pthreads are available without further options
952 # (e.g. MacOS X). On some of these systems, the compiler will not
953 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
954 # So we have to see first whether pthreads are available without
955 # options before we can check whether -Kpthread improves anything.
956 AC_MSG_CHECKING(whether pthreads are available without options)
957 AC_CACHE_VAL(ac_cv_pthread_is_default,
958 [AC_TRY_RUN([
959 #include <pthread.h>
961 void* routine(void* p){return NULL;}
963 int main(){
964   pthread_t p;
965   if(pthread_create(&p,NULL,routine,NULL)!=0)
966     return 1;
967   (void)pthread_detach(p);
968   return 0;
972   ac_cv_pthread_is_default=yes
973   ac_cv_kthread=no
974   ac_cv_pthread=no
976   ac_cv_pthread_is_default=no,
977   ac_cv_pthread_is_default=no)
979 AC_MSG_RESULT($ac_cv_pthread_is_default)
982 if test $ac_cv_pthread_is_default = yes 
983 then
984   ac_cv_kpthread=no
985 else
986 # -Kpthread, if available, provides the right #defines
987 # and linker options to make pthread_create available
988 # Some compilers won't report that they do not support -Kpthread,
989 # so we need to run a program to see whether it really made the
990 # function available.
991 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
992 AC_CACHE_VAL(ac_cv_kpthread,
993 [ac_save_cc="$CC"
994 CC="$CC -Kpthread"
995 AC_TRY_RUN([
996 #include <pthread.h>
998 void* routine(void* p){return NULL;}
1000 int main(){
1001   pthread_t p;
1002   if(pthread_create(&p,NULL,routine,NULL)!=0)
1003     return 1;
1004   (void)pthread_detach(p);
1005   return 0;
1008   ac_cv_kpthread=yes,
1009   ac_cv_kpthread=no,
1010   ac_cv_kpthread=no)
1011 CC="$ac_save_cc"])
1012 AC_MSG_RESULT($ac_cv_kpthread)
1015 if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
1016 then
1017 # -Kthread, if available, provides the right #defines
1018 # and linker options to make pthread_create available
1019 # Some compilers won't report that they do not support -Kthread,
1020 # so we need to run a program to see whether it really made the
1021 # function available.
1022 AC_MSG_CHECKING(whether $CC accepts -Kthread)
1023 AC_CACHE_VAL(ac_cv_kthread,
1024 [ac_save_cc="$CC"
1025 CC="$CC -Kthread"
1026 AC_TRY_RUN([
1027 #include <pthread.h>
1029 void* routine(void* p){return NULL;}
1031 int main(){
1032   pthread_t p;
1033   if(pthread_create(&p,NULL,routine,NULL)!=0)
1034     return 1;
1035   (void)pthread_detach(p);
1036   return 0;
1039   ac_cv_kthread=yes,
1040   ac_cv_kthread=no,
1041   ac_cv_kthread=no)
1042 CC="$ac_save_cc"])
1043 AC_MSG_RESULT($ac_cv_kthread)
1046 if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
1047 then
1048 # -pthread, if available, provides the right #defines
1049 # and linker options to make pthread_create available
1050 # Some compilers won't report that they do not support -pthread,
1051 # so we need to run a program to see whether it really made the
1052 # function available.
1053 AC_MSG_CHECKING(whether $CC accepts -pthread)
1054 AC_CACHE_VAL(ac_cv_thread,
1055 [ac_save_cc="$CC"
1056 CC="$CC -pthread"
1057 AC_TRY_RUN([
1058 #include <pthread.h>
1060 void* routine(void* p){return NULL;}
1062 int main(){
1063   pthread_t p;
1064   if(pthread_create(&p,NULL,routine,NULL)!=0)
1065     return 1;
1066   (void)pthread_detach(p);
1067   return 0;
1070   ac_cv_pthread=yes,
1071   ac_cv_pthread=no,
1072   ac_cv_pthread=no)
1073 CC="$ac_save_cc"])
1074 AC_MSG_RESULT($ac_cv_pthread)
1077 # If we have set a CC compiler flag for thread support then
1078 # check if it works for CXX, too.
1079 ac_cv_cxx_thread=no
1080 if test ! -z "$CXX"
1081 then
1082 AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1083 ac_save_cxx="$CXX"
1085 if test "$ac_cv_kpthread" = "yes"
1086 then
1087   CXX="$CXX -Kpthread"  
1088   ac_cv_cxx_thread=yes
1089 elif test "$ac_cv_kthread" = "yes"
1090 then
1091   CXX="$CXX -Kthread"
1092   ac_cv_cxx_thread=yes
1093 elif test "$ac_cv_pthread" = "yes"
1094 then 
1095   CXX="$CXX -pthread"
1096   ac_cv_cxx_thread=yes
1099 if test $ac_cv_cxx_thread = yes
1100 then
1101   echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1102   $CXX -c conftest.$ac_ext 2>&5
1103   if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1104      && test -s conftest$ac_exeext && ./conftest$ac_exeext
1105   then
1106     ac_cv_cxx_thread=yes
1107   else
1108     ac_cv_cxx_thread=no
1109   fi
1110   rm -fr conftest*
1112 AC_MSG_RESULT($ac_cv_cxx_thread)
1114 CXX="$ac_save_cxx"
1116 dnl # check for ANSI or K&R ("traditional") preprocessor
1117 dnl AC_MSG_CHECKING(for C preprocessor type)
1118 dnl AC_TRY_COMPILE([
1119 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1120 dnl int foo;
1121 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1122 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1123 dnl AC_MSG_RESULT($cpp_type)
1125 # checks for header files
1126 AC_HEADER_STDC
1127 AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1128 fcntl.h grp.h \
1129 ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
1130 shadow.h signal.h stdint.h stropts.h termios.h thread.h \
1131 unistd.h utime.h \
1132 sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \
1133 sys/lock.h sys/mkdev.h sys/modem.h \
1134 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
1135 sys/time.h \
1136 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
1137 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
1138 bluetooth/bluetooth.h linux/tipc.h)
1139 AC_HEADER_DIRENT
1140 AC_HEADER_MAJOR
1142 # On Solaris, term.h requires curses.h
1143 AC_CHECK_HEADERS(term.h,,,[
1144 #ifdef HAVE_CURSES_H
1145 #include <curses.h>
1146 #endif
1149 # On Linux, netlink.h requires asm/types.h
1150 AC_CHECK_HEADERS(linux/netlink.h,,,[
1151 #ifdef HAVE_ASM_TYPES_H
1152 #include <asm/types.h>
1153 #endif
1154 #ifdef HAVE_SYS_SOCKET_H
1155 #include <sys/socket.h>
1156 #endif
1159 # checks for typedefs
1160 was_it_defined=no
1161 AC_MSG_CHECKING(for clock_t in time.h)
1162 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1163     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1165 AC_MSG_RESULT($was_it_defined)
1167 # Check whether using makedev requires defining _OSF_SOURCE
1168 AC_MSG_CHECKING(for makedev)
1169 AC_TRY_LINK([#include <sys/types.h> ],
1170             [ makedev(0, 0) ],
1171             ac_cv_has_makedev=yes,
1172             ac_cv_has_makedev=no)
1173 if test "$ac_cv_has_makedev" = "no"; then
1174     # we didn't link, try if _OSF_SOURCE will allow us to link
1175     AC_TRY_LINK([
1176 #define _OSF_SOURCE 1
1177 #include <sys/types.h>
1178     ],
1179     [ makedev(0, 0) ],
1180     ac_cv_has_makedev=yes,
1181     ac_cv_has_makedev=no)
1182     if test "$ac_cv_has_makedev" = "yes"; then
1183         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1184     fi
1186 AC_MSG_RESULT($ac_cv_has_makedev)
1187 if test "$ac_cv_has_makedev" = "yes"; then
1188     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1191 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1192 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1193 # defined, but the compiler does not support pragma redefine_extname,
1194 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1195 # structures (such as rlimit64) without declaring them. As a
1196 # work-around, disable LFS on such configurations
1198 use_lfs=yes
1199 AC_MSG_CHECKING(Solaris LFS bug)
1200 AC_TRY_COMPILE([
1201 #define _LARGEFILE_SOURCE 1
1202 #define _FILE_OFFSET_BITS 64
1203 #include <sys/resource.h>
1204 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1205 AC_MSG_RESULT($sol_lfs_bug)
1206 if test "$sol_lfs_bug" = "yes"; then
1207   use_lfs=no
1210 if test "$use_lfs" = "yes"; then
1211 # Two defines needed to enable largefile support on various platforms
1212 # These may affect some typedefs
1213 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
1214 [This must be defined on some systems to enable large file support.])
1215 AC_DEFINE(_FILE_OFFSET_BITS, 64,
1216 [This must be set to 64 on some systems to enable large file support.])
1219 # Add some code to confdefs.h so that the test for off_t works on SCO
1220 cat >> confdefs.h <<\EOF
1221 #if defined(SCO_DS)
1222 #undef _OFF_T
1223 #endif
1226 # Type availability checks
1227 AC_TYPE_MODE_T
1228 AC_TYPE_OFF_T
1229 AC_TYPE_PID_T
1230 AC_TYPE_SIGNAL
1231 AC_TYPE_SIZE_T
1232 AC_TYPE_UID_T
1233 AC_CHECK_TYPE(ssize_t,
1234   AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
1236 # Sizes of various common basic types
1237 # ANSI C requires sizeof(char) == 1, so no need to check it
1238 AC_CHECK_SIZEOF(int, 4)
1239 AC_CHECK_SIZEOF(long, 4)
1240 AC_CHECK_SIZEOF(void *, 4)
1241 AC_CHECK_SIZEOF(short, 2)
1242 AC_CHECK_SIZEOF(float, 4)
1243 AC_CHECK_SIZEOF(double, 8)
1244 AC_CHECK_SIZEOF(fpos_t, 4)
1245 AC_CHECK_SIZEOF(size_t, 4)
1246 AC_CHECK_SIZEOF(pid_t, 4)
1248 AC_MSG_CHECKING(for long long support)
1249 have_long_long=no
1250 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1251   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
1252   have_long_long=yes
1254 AC_MSG_RESULT($have_long_long)
1255 if test "$have_long_long" = yes ; then
1256 AC_CHECK_SIZEOF(long long, 8)
1259 AC_MSG_CHECKING(for _Bool support)
1260 have_c99_bool=no
1261 AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
1262   AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.]) 
1263   have_c99_bool=yes
1265 AC_MSG_RESULT($have_c99_bool)
1266 if test "$have_c99_bool" = yes ; then
1267 AC_CHECK_SIZEOF(_Bool, 1)
1270 AC_CHECK_TYPES(uintptr_t, 
1271    [AC_CHECK_SIZEOF(uintptr_t, 4)], 
1272    [], [#ifdef HAVE_STDINT_H
1273         #include <stdint.h>
1274         #endif])
1277 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1278 AC_MSG_CHECKING(size of off_t)
1279 AC_CACHE_VAL(ac_cv_sizeof_off_t,
1280 [AC_TRY_RUN([#include <stdio.h>
1281 #include <sys/types.h>
1282 main()
1284   FILE *f=fopen("conftestval", "w");
1285   if (!f) exit(1);
1286   fprintf(f, "%d\n", sizeof(off_t));
1287   exit(0);
1289 ac_cv_sizeof_off_t=`cat conftestval`,
1290 ac_cv_sizeof_off_t=0,
1291 ac_cv_sizeof_off_t=4)
1293 AC_MSG_RESULT($ac_cv_sizeof_off_t)
1294 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1295 [The number of bytes in an off_t.])
1297 AC_MSG_CHECKING(whether to enable large file support)
1298 if test "$have_long_long" = yes -a \
1299         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1300         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1301   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
1302   [Defined to enable large file support when an off_t is bigger than a long
1303    and long long is available and at least as big as an off_t. You may need
1304    to add some flags for configuration and compilation to enable this mode.
1305    (For Solaris and Linux, the necessary defines are already defined.)])
1306   AC_MSG_RESULT(yes)
1307 else
1308   AC_MSG_RESULT(no)
1311 # AC_CHECK_SIZEOF() doesn't include <time.h>.
1312 AC_MSG_CHECKING(size of time_t)
1313 AC_CACHE_VAL(ac_cv_sizeof_time_t,
1314 [AC_TRY_RUN([#include <stdio.h>
1315 #include <time.h>
1316 main()
1318   FILE *f=fopen("conftestval", "w");
1319   if (!f) exit(1);
1320   fprintf(f, "%d\n", sizeof(time_t));
1321   exit(0);
1323 ac_cv_sizeof_time_t=`cat conftestval`,
1324 ac_cv_sizeof_time_t=0,
1325 ac_cv_sizeof_time_t=4)
1327 AC_MSG_RESULT($ac_cv_sizeof_time_t)
1328 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
1329 [The number of bytes in a time_t.])
1332 # if have pthread_t then define SIZEOF_PTHREAD_T
1333 ac_save_cc="$CC"
1334 if test "$ac_cv_kpthread" = "yes"
1335 then CC="$CC -Kpthread"
1336 elif test "$ac_cv_kthread" = "yes"
1337 then CC="$CC -Kthread"
1338 elif test "$ac_cv_pthread" = "yes"
1339 then CC="$CC -pthread"
1341 AC_MSG_CHECKING(for pthread_t)
1342 have_pthread_t=no
1343 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
1344 AC_MSG_RESULT($have_pthread_t)
1345 if test "$have_pthread_t" = yes ; then
1346   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1347   AC_MSG_CHECKING(size of pthread_t)
1348   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1349   [AC_TRY_RUN([#include <stdio.h>
1350 #include <pthread.h>
1351   main()
1352   {
1353     FILE *f=fopen("conftestval", "w");
1354     if (!f) exit(1);
1355     fprintf(f, "%d\n", sizeof(pthread_t));
1356     exit(0);
1357   }],
1358   ac_cv_sizeof_pthread_t=`cat conftestval`,
1359   ac_cv_sizeof_pthread_t=0,
1360   ac_cv_sizeof_pthread_t=4)
1361   ])
1362   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
1363   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1364    [The number of bytes in a pthread_t.])
1366 CC="$ac_save_cc"
1368 AC_MSG_CHECKING(for --enable-toolbox-glue)
1369 AC_ARG_ENABLE(toolbox-glue,
1370               AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
1372 if test -z "$enable_toolbox_glue"
1373 then 
1374         case $ac_sys_system/$ac_sys_release in
1375         Darwin/*)
1376                 enable_toolbox_glue="yes";;
1377         *)
1378                 enable_toolbox_glue="no";;
1379         esac
1381 case "$enable_toolbox_glue" in
1382 yes)
1383         extra_machdep_objs="Python/mactoolboxglue.o"
1384         extra_undefs="-u _PyMac_Error"
1385         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1386          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1387         ;;
1389         extra_machdep_objs=""
1390         extra_undefs=""
1391         ;;
1392 esac
1393 AC_MSG_RESULT($enable_toolbox_glue)
1395 AC_SUBST(OTHER_LIBTOOL_OPT)
1396 case $ac_sys_system/$ac_sys_release in
1397   Darwin/@<:@01567@:>@\..*) 
1398     OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1399     ;;
1400   Darwin/*)
1401     OTHER_LIBTOOL_OPT=""
1402     ;;
1403 esac
1405 AC_SUBST(LIBTOOL_CRUFT)
1406 case $ac_sys_system/$ac_sys_release in
1407   Darwin/@<:@01567@:>@\..*) 
1408     LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1409     if test "${enable_universalsdk}"; then
1410             :
1411     else
1412         LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
1413     fi
1414     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1415     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1416   Darwin/*)
1417     gcc_version=`gcc -v 2>&1 |  grep version | cut -d\  -f3`
1418     if test ${gcc_version} '<' 4.0
1419         then
1420             LIBTOOL_CRUFT="-lcc_dynamic"
1421         else 
1422             LIBTOOL_CRUFT=""
1423     fi
1424     LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only `arch`"
1425     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1426     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1427 esac
1429 AC_MSG_CHECKING(for --enable-framework)
1430 if test "$enable_framework"
1431 then
1432         BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1433         # -F. is needed to allow linking to the framework while 
1434         # in the build location.
1435         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
1436          [Define if you want to produce an OpenStep/Rhapsody framework
1437          (shared library plus accessory files).])
1438         AC_MSG_RESULT(yes)
1439 else
1440         AC_MSG_RESULT(no)
1443 AC_MSG_CHECKING(for dyld)
1444 case $ac_sys_system/$ac_sys_release in
1445   Darwin/*)
1446         AC_DEFINE(WITH_DYLD, 1, 
1447         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1448          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1449          linker (rld). Dyld is necessary to support frameworks.])
1450         AC_MSG_RESULT(always on for Darwin)
1451         ;;
1452   *)
1453         AC_MSG_RESULT(no)
1454         ;;
1455 esac
1457 # Set info about shared libraries.
1458 AC_SUBST(SO)
1459 AC_SUBST(LDSHARED)
1460 AC_SUBST(BLDSHARED)
1461 AC_SUBST(CCSHARED)
1462 AC_SUBST(LINKFORSHARED)
1463 # SO is the extension of shared libraries `(including the dot!)
1464 # -- usually .so, .sl on HP-UX, .dll on Cygwin
1465 AC_MSG_CHECKING(SO)
1466 if test -z "$SO"
1467 then
1468         case $ac_sys_system in
1469         hp*|HP*)
1470                 case `uname -m` in
1471                         ia64) SO=.so;;
1472                         *)    SO=.sl;;
1473                 esac
1474                 ;;
1475         CYGWIN*)   SO=.dll;;
1476         *)         SO=.so;;
1477         esac
1478 else
1479         # this might also be a termcap variable, see #610332
1480         echo
1481         echo '====================================================================='
1482         echo '+                                                                   +'
1483         echo '+ WARNING: You have set SO in your environment.                     +'
1484         echo '+ Do you really mean to change the extension for shared libraries?  +'
1485         echo '+ Continuing in 10 seconds to let you to ponder.                    +'
1486         echo '+                                                                   +'
1487         echo '====================================================================='
1488         sleep 10
1490 AC_MSG_RESULT($SO)
1491 AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
1492 # LDSHARED is the ld *command* used to create shared library
1493 # -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1494 # (Shared libraries in this instance are shared modules to be loaded into
1495 # Python, as opposed to building Python itself as a shared library.)
1496 AC_MSG_CHECKING(LDSHARED)
1497 if test -z "$LDSHARED"
1498 then
1499         case $ac_sys_system/$ac_sys_release in
1500         AIX*)
1501                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1502                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1503                 ;;
1504         BeOS*)
1505                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1506                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1507                 ;;
1508         IRIX/5*) LDSHARED="ld -shared";;
1509         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1510         SunOS/5*) 
1511                 if test "$GCC" = "yes"
1512                 then LDSHARED='$(CC) -shared'
1513                 else LDSHARED='$(CC) -G';
1514                 fi ;;
1515         hp*|HP*)
1516                 if test "$GCC" = "yes"
1517                 then LDSHARED='$(CC) -shared'
1518                 else LDSHARED='ld -b';
1519                 fi ;;
1520         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1521         Darwin/1.3*)
1522                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1523                 if test "$enable_framework" ; then
1524                         # Link against the framework. All externals should be defined.
1525                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1526                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1527                 else
1528                         # No framework. Ignore undefined symbols, assuming they come from Python
1529                         LDSHARED="$LDSHARED -undefined suppress"
1530                 fi ;;
1531         Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1532                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1533                 if test "$enable_framework" ; then
1534                         # Link against the framework. All externals should be defined.
1535                         BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1536                         LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1537                 else
1538                         # No framework, use the Python app as bundle-loader
1539                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1540                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1541                 fi ;;
1542         Darwin/*)
1543                 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1544                 # This allows an extension to be used in any Python
1545                 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1546                 if test ${cur_target} '>' 10.2; then
1547                         cur_target=10.3
1548                 fi
1549                 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1551                 # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the 
1552                 # environment with a value that is the same as what we'll use
1553                 # in the Makefile to ensure that we'll get the same compiler
1554                 # environment during configure and build time.
1555                 MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
1556                 export MACOSX_DEPLOYMENT_TARGET
1558                 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1559                 if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2
1560                 then
1561                         if test "${enable_universalsdk}"; then
1562                                 LDFLAGS="-arch i386 -arch ppc -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1563                         fi
1564                         LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1565                         BLDSHARED="$LDSHARED"
1566                 else
1567                         LDSHARED='$(CC) $(LDFLAGS) -bundle'
1568                         if test "$enable_framework" ; then
1569                                 # Link against the framework. All externals should be defined.
1570                                 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1571                                 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1572                         else
1573                                 # No framework, use the Python app as bundle-loader
1574                                 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1575                                 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1576                         fi
1577                 fi
1578                 ;;
1579         Linux*|GNU*) LDSHARED='$(CC) -shared';;
1580         BSD/OS*/4*) LDSHARED="gcc -shared";;
1581         FreeBSD*)
1582                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1583                 then
1584                         LDSHARED="$CC -shared ${LDFLAGS}"
1585                 else
1586                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1587                 fi;;
1588         OpenBSD*)
1589                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1590                 then
1591                                 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1592                 else
1593                                 case `uname -r` in
1594                                 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1595                                    LDSHARED="ld -Bshareable ${LDFLAGS}"
1596                                    ;;
1597                                 *)
1598                                    LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1599                                    ;;
1600                                 esac
1601                 fi;;
1602         NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
1603         OpenUNIX*|UnixWare*)
1604                 if test "$GCC" = "yes"
1605                 then LDSHARED='$(CC) -shared'
1606                 else LDSHARED='$(CC) -G'
1607                 fi;;
1608         SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1609         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
1610         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1611         atheos*) LDSHARED="gcc -shared";;
1612         *)      LDSHARED="ld";;
1613         esac
1615 AC_MSG_RESULT($LDSHARED)
1616 BLDSHARED=${BLDSHARED-$LDSHARED}
1617 # CCSHARED are the C *flags* used to create objects to go into a shared
1618 # library (module) -- this is only needed for a few systems
1619 AC_MSG_CHECKING(CCSHARED)
1620 if test -z "$CCSHARED"
1621 then
1622         case $ac_sys_system/$ac_sys_release in
1623         SunOS*) if test "$GCC" = yes;
1624                 then CCSHARED="-fPIC";
1625                 elif test `uname -p` = sparc;
1626                 then CCSHARED="-xcode=pic32";
1627                 else CCSHARED="-Kpic";
1628                 fi;;
1629         hp*|HP*) if test "$GCC" = yes;
1630                  then CCSHARED="-fPIC";
1631                  else CCSHARED="+z";
1632                  fi;;
1633         Linux*|GNU*) CCSHARED="-fPIC";;
1634         BSD/OS*/4*) CCSHARED="-fpic";;
1635         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
1636         OpenUNIX*|UnixWare*)
1637                 if test "$GCC" = "yes"
1638                 then CCSHARED="-fPIC"
1639                 else CCSHARED="-KPIC"
1640                 fi;;
1641         SCO_SV*)
1642                 if test "$GCC" = "yes"
1643                 then CCSHARED="-fPIC"
1644                 else CCSHARED="-Kpic -belf"
1645                 fi;;
1646         Monterey*) CCSHARED="-G";;
1647         IRIX*/6*)  case $CC in
1648                    *gcc*) CCSHARED="-shared";;
1649                    *) CCSHARED="";;
1650                    esac;;
1651         atheos*) CCSHARED="-fPIC";;
1652         esac
1654 AC_MSG_RESULT($CCSHARED)
1655 # LINKFORSHARED are the flags passed to the $(CC) command that links
1656 # the python executable -- this is only needed for a few systems
1657 AC_MSG_CHECKING(LINKFORSHARED)
1658 if test -z "$LINKFORSHARED"
1659 then
1660         case $ac_sys_system/$ac_sys_release in
1661         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1662         hp*|HP*)
1663             LINKFORSHARED="-Wl,-E -Wl,+s";;
1664 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1665         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1666         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1667         # -u libsys_s pulls in all symbols in libsys
1668         Darwin/*) 
1669                 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1670                 # which is
1671                 # not used by the core itself but which needs to be in the core so
1672                 # that dynamically loaded extension modules have access to it.
1673                 # -prebind is no longer used, because it actually seems to give a
1674                 # slowdown in stead of a speedup, maybe due to the large number of
1675                 # dynamic loads Python does.
1677                 LINKFORSHARED="$extra_undefs"
1678                 if test "$enable_framework"
1679                 then
1680                         LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1681                 fi
1682                 LINKFORSHARED="$LINKFORSHARED";;
1683         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1684         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1685         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1686         FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) 
1687                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1688                 then
1689                         LINKFORSHARED="-Wl,--export-dynamic"
1690                 fi;;
1691         SunOS/5*) case $CC in
1692                   *gcc*)
1693                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1694                     then
1695                         LINKFORSHARED="-Xlinker --export-dynamic"
1696                     fi;;
1697                   esac;;
1698         CYGWIN*)
1699                 if test $enable_shared = "no"
1700                 then
1701                         LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1702                 fi;;
1703         esac
1705 AC_MSG_RESULT($LINKFORSHARED)
1707 AC_SUBST(CFLAGSFORSHARED)
1708 AC_MSG_CHECKING(CFLAGSFORSHARED)
1709 if test ! "$LIBRARY" = "$LDLIBRARY"
1710 then
1711         case $ac_sys_system in
1712         CYGWIN*)
1713                 # Cygwin needs CCSHARED when building extension DLLs
1714                 # but not when building the interpreter DLL.
1715                 CFLAGSFORSHARED='';;
1716         *)
1717                 CFLAGSFORSHARED='$(CCSHARED)'
1718         esac
1720 AC_MSG_RESULT($CFLAGSFORSHARED)
1722 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1723 # library (with --enable-shared).
1724 # For platforms on which shared libraries are not allowed to have unresolved
1725 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1726 # if it is not required, since it creates a dependency of the shared library
1727 # to LIBS. This, in turn, means that applications linking the shared libpython
1728 # don't need to link LIBS explicitly. The default should be only changed
1729 # on systems where this approach causes problems.
1730 AC_SUBST(SHLIBS)
1731 AC_MSG_CHECKING(SHLIBS)
1732 case "$ac_sys_system" in
1733         *)
1734                 SHLIBS='$(LIBS)';;
1735 esac
1736 AC_MSG_RESULT($SHLIBS)
1739 # checks for libraries
1740 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1741 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1743 # only check for sem_ini if thread support is requested
1744 if test "$with_threads" = "yes" -o -z "$with_threads"; then
1745     AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1746                                                 # posix4 on Solaris 2.6
1747                                                 # pthread (first!) on Linux
1750 # check if we need libintl for locale functions
1751 AC_CHECK_LIB(intl, textdomain,
1752         AC_DEFINE(WITH_LIBINTL, 1,
1753         [Define to 1 if libintl is needed for locale functions.]))
1755 # checks for system dependent C++ extensions support
1756 case "$ac_sys_system" in
1757         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1758                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1759                             [loadAndInit("", 0, "")],
1760                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1761                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1762                        and you want support for AIX C++ shared extension modules.])
1763                              AC_MSG_RESULT(yes)],
1764                             [AC_MSG_RESULT(no)]);;
1765         *) ;;
1766 esac
1768 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1769 # BeOS' sockets are stashed in libnet.
1770 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1771 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1773 case "$ac_sys_system" in
1774 BeOS*)
1775 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1777 esac
1779 AC_MSG_CHECKING(for --with-libs)
1780 AC_ARG_WITH(libs,
1781             AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1783 AC_MSG_RESULT($withval)
1784 LIBS="$withval $LIBS"
1786 [AC_MSG_RESULT(no)])
1788 # Check for use of the system libffi library
1789 AC_MSG_CHECKING(for --with-system-ffi)
1790 AC_ARG_WITH(system_ffi,
1791             AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1793 AC_MSG_RESULT($with_system_ffi)
1795 # Determine if signalmodule should be used.
1796 AC_SUBST(USE_SIGNAL_MODULE)
1797 AC_SUBST(SIGNAL_OBJS)
1798 AC_MSG_CHECKING(for --with-signal-module)
1799 AC_ARG_WITH(signal-module,
1800             AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1802 if test -z "$with_signal_module"
1803 then with_signal_module="yes"
1805 AC_MSG_RESULT($with_signal_module)
1807 if test "${with_signal_module}" = "yes"; then
1808         USE_SIGNAL_MODULE=""
1809         SIGNAL_OBJS=""
1810 else
1811         USE_SIGNAL_MODULE="#"
1812         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1815 # This is used to generate Setup.config
1816 AC_SUBST(USE_THREAD_MODULE)
1817 USE_THREAD_MODULE=""
1819 AC_MSG_CHECKING(for --with-dec-threads)
1820 AC_SUBST(LDLAST)
1821 AC_ARG_WITH(dec-threads,
1822             AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1824 AC_MSG_RESULT($withval)
1825 LDLAST=-threads
1826 if test "${with_thread+set}" != set; then
1827    with_thread="$withval";
1828 fi],
1829 [AC_MSG_RESULT(no)])
1831 # Templates for things AC_DEFINEd more than once.
1832 # For a single AC_DEFINE, no template is needed.
1833 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1834 AH_TEMPLATE(_REENTRANT,
1835   [Define to force use of thread-safe errno, h_errno, and other functions])
1836 AH_TEMPLATE(WITH_THREAD,
1837   [Define if you want to compile in rudimentary thread support])
1839 AC_MSG_CHECKING(for --with-threads)
1840 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1841 AC_ARG_WITH(threads,
1842             AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
1844 # --with-thread is deprecated, but check for it anyway
1845 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1846 AC_ARG_WITH(thread,
1847             AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1848             [with_threads=$with_thread])
1850 if test -z "$with_threads"
1851 then with_threads="yes"
1853 AC_MSG_RESULT($with_threads)
1855 AC_SUBST(THREADOBJ)
1856 if test "$with_threads" = "no"
1857 then
1858     USE_THREAD_MODULE="#"
1859 elif test "$ac_cv_pthread_is_default" = yes
1860 then
1861     AC_DEFINE(WITH_THREAD)
1862     # Defining _REENTRANT on system with POSIX threads should not hurt.
1863     AC_DEFINE(_REENTRANT)
1864     posix_threads=yes
1865     THREADOBJ="Python/thread.o"    
1866 elif test "$ac_cv_kpthread" = "yes"
1867 then
1868     CC="$CC -Kpthread"
1869     if test "$ac_cv_cxx_thread" = "yes"; then
1870         CXX="$CXX -Kpthread"
1871     fi
1872     AC_DEFINE(WITH_THREAD)
1873     posix_threads=yes
1874     THREADOBJ="Python/thread.o"
1875 elif test "$ac_cv_kthread" = "yes"
1876 then
1877     CC="$CC -Kthread"
1878     if test "$ac_cv_cxx_thread" = "yes"; then
1879         CXX="$CXX -Kthread"
1880     fi
1881     AC_DEFINE(WITH_THREAD)
1882     posix_threads=yes
1883     THREADOBJ="Python/thread.o"
1884 elif test "$ac_cv_pthread" = "yes"
1885 then
1886     CC="$CC -pthread"
1887     if test "$ac_cv_cxx_thread" = "yes"; then
1888         CXX="$CXX -pthread"
1889     fi
1890     AC_DEFINE(WITH_THREAD)
1891     posix_threads=yes
1892     THREADOBJ="Python/thread.o"
1893 else
1894     if test ! -z "$with_threads" -a -d "$with_threads"
1895     then LDFLAGS="$LDFLAGS -L$with_threads"
1896     fi
1897     if test ! -z "$withval" -a -d "$withval"
1898     then LDFLAGS="$LDFLAGS -L$withval"
1899     fi
1901     # According to the POSIX spec, a pthreads implementation must
1902     # define _POSIX_THREADS in unistd.h. Some apparently don't
1903     # (e.g. gnu pth with pthread emulation)
1904     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1905     AC_EGREP_CPP(yes,
1906     [
1907 #include <unistd.h>
1908 #ifdef _POSIX_THREADS
1910 #endif
1911     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1912     AC_MSG_RESULT($unistd_defines_pthreads)
1914     AC_DEFINE(_REENTRANT)
1915     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1916     AC_DEFINE(C_THREADS)
1917     AC_DEFINE(HURD_C_THREADS, 1,
1918     [Define if you are using Mach cthreads directly under /include])
1919     LIBS="$LIBS -lthreads"
1920     THREADOBJ="Python/thread.o"],[
1921     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1922     AC_DEFINE(C_THREADS)
1923     AC_DEFINE(MACH_C_THREADS, 1,
1924     [Define if you are using Mach cthreads under mach /])
1925     THREADOBJ="Python/thread.o"],[
1926     AC_MSG_CHECKING(for --with-pth)
1927     AC_ARG_WITH([pth],
1928                 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
1929                 [AC_MSG_RESULT($withval)
1930                   AC_DEFINE([WITH_THREAD])
1931                   AC_DEFINE([HAVE_PTH], 1,
1932                             [Define if you have GNU PTH threads.])
1933                   LIBS="-lpth $LIBS"
1934                   THREADOBJ="Python/thread.o"],
1935                 [AC_MSG_RESULT(no)
1937     # Just looking for pthread_create in libpthread is not enough:
1938     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1939     # So we really have to include pthread.h, and then link.
1940     _libs=$LIBS
1941     LIBS="$LIBS -lpthread"
1942     AC_MSG_CHECKING([for pthread_create in -lpthread])
1943     AC_TRY_LINK([#include <pthread.h>
1945 void * start_routine (void *arg) { exit (0); }], [
1946 pthread_create (NULL, NULL, start_routine, NULL)], [
1947     AC_MSG_RESULT(yes)
1948     AC_DEFINE(WITH_THREAD)
1949     posix_threads=yes
1950     THREADOBJ="Python/thread.o"],[
1951     LIBS=$_libs
1952     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
1953     posix_threads=yes
1954     THREADOBJ="Python/thread.o"],[
1955     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1956     AC_DEFINE(ATHEOS_THREADS, 1,
1957     [Define this if you have AtheOS threads.])
1958     THREADOBJ="Python/thread.o"],[
1959     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1960     AC_DEFINE(BEOS_THREADS, 1,
1961     [Define this if you have BeOS threads.])
1962     THREADOBJ="Python/thread.o"],[
1963     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
1964     posix_threads=yes
1965     LIBS="$LIBS -lpthreads"
1966     THREADOBJ="Python/thread.o"], [
1967     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
1968     posix_threads=yes
1969     LIBS="$LIBS -lc_r"
1970     THREADOBJ="Python/thread.o"], [
1971     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
1972     posix_threads=yes
1973     LIBS="$LIBS -lpthread"
1974     THREADOBJ="Python/thread.o"], [
1975     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
1976     posix_threads=yes
1977     LIBS="$LIBS -lcma"
1978     THREADOBJ="Python/thread.o"],[
1979     USE_THREAD_MODULE="#"])
1980     ])])])])])])])])])])
1982     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1983     LIBS="$LIBS -lmpc"
1984     THREADOBJ="Python/thread.o"
1985     USE_THREAD_MODULE=""])
1987     if test "$posix_threads" != "yes"; then     
1988       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1989       LIBS="$LIBS -lthread"
1990       THREADOBJ="Python/thread.o"
1991       USE_THREAD_MODULE=""])
1992     fi
1994     if test "$USE_THREAD_MODULE" != "#"
1995     then
1996         # If the above checks didn't disable threads, (at least) OSF1
1997         # needs this '-threads' argument during linking.
1998         case $ac_sys_system in
1999         OSF1) LDLAST=-threads;;
2000         esac
2001     fi
2004 if test "$posix_threads" = "yes"; then
2005       if test "$unistd_defines_pthreads" = "no"; then
2006          AC_DEFINE(_POSIX_THREADS, 1,
2007          [Define if you have POSIX threads, 
2008           and your system does not define that.])
2009       fi
2011       # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
2012       case  $ac_sys_system/$ac_sys_release in
2013   SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
2014                        Defined for Solaris 2.6 bug in pthread header.)
2015                        ;;
2016       SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2017                        Define if the Posix semaphores do not work on your system)
2018                        ;;
2019       AIX/5) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
2020                        Define if the Posix semaphores do not work on your system)
2021                        ;;
2022       esac
2024       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
2025       AC_CACHE_VAL(ac_cv_pthread_system_supported,
2026       [AC_TRY_RUN([#include <pthread.h>
2027       void *foo(void *parm) {
2028         return NULL;
2029       }
2030       main() {
2031         pthread_attr_t attr;
2032         pthread_t id;
2033         if (pthread_attr_init(&attr)) exit(-1);
2034         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
2035         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
2036         exit(0);
2037       }],
2038       ac_cv_pthread_system_supported=yes,
2039       ac_cv_pthread_system_supported=no,
2040       ac_cv_pthread_system_supported=no)
2041       ])
2042       AC_MSG_RESULT($ac_cv_pthread_system_supported)
2043       if test "$ac_cv_pthread_system_supported" = "yes"; then
2044         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
2045       fi
2046       AC_CHECK_FUNCS(pthread_sigmask,
2047         [case $ac_sys_system in
2048         CYGWIN*)
2049           AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
2050             [Define if pthread_sigmask() does not work on your system.])
2051             ;;
2052         esac])
2056 # Check for enable-ipv6
2057 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
2058 AC_MSG_CHECKING([if --enable-ipv6 is specified])
2059 AC_ARG_ENABLE(ipv6,
2060 [  --enable-ipv6           Enable ipv6 (with ipv4) support
2061   --disable-ipv6          Disable ipv6 support],
2062 [ case "$enableval" in
2063   no)
2064        AC_MSG_RESULT(no)
2065        ipv6=no
2066        ;;
2067   *)   AC_MSG_RESULT(yes)
2068        AC_DEFINE(ENABLE_IPV6)
2069        ipv6=yes
2070        ;;
2071   esac ],
2074 dnl the check does not work on cross compilation case...
2075   AC_TRY_RUN([ /* AF_INET6 available check */
2076 #include <sys/types.h>
2077 #include <sys/socket.h>
2078 main()
2080  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2081    exit(1);
2082  else
2083    exit(0);
2086   AC_MSG_RESULT(yes)
2087   ipv6=yes,
2088   AC_MSG_RESULT(no)
2089   ipv6=no,
2090   AC_MSG_RESULT(no)
2091   ipv6=no
2094 if test "$ipv6" = "yes"; then
2095         AC_MSG_CHECKING(if RFC2553 API is available)
2096         AC_TRY_COMPILE([#include <sys/types.h>
2097 #include <netinet/in.h>],
2098         [struct sockaddr_in6 x;
2099 x.sin6_scope_id;],
2100                 AC_MSG_RESULT(yes)
2101                 ipv6=yes,
2102                 AC_MSG_RESULT(no, IPv6 disabled)
2103                 ipv6=no)
2106 if test "$ipv6" = "yes"; then
2107         AC_DEFINE(ENABLE_IPV6)
2111 ipv6type=unknown
2112 ipv6lib=none
2113 ipv6trylibc=no
2115 if test "$ipv6" = "yes"; then
2116         AC_MSG_CHECKING([ipv6 stack type])
2117         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2118         do
2119                 case $i in
2120                 inria)
2121                         dnl http://www.kame.net/
2122                         AC_EGREP_CPP(yes, [
2123 #include <netinet/in.h>
2124 #ifdef IPV6_INRIA_VERSION
2126 #endif],
2127                                 [ipv6type=$i])
2128                         ;;
2129                 kame)
2130                         dnl http://www.kame.net/
2131                         AC_EGREP_CPP(yes, [
2132 #include <netinet/in.h>
2133 #ifdef __KAME__
2135 #endif],
2136                                 [ipv6type=$i;
2137                                 ipv6lib=inet6
2138                                 ipv6libdir=/usr/local/v6/lib
2139                                 ipv6trylibc=yes])
2140                         ;;
2141                 linux-glibc)
2142                         dnl http://www.v6.linux.or.jp/
2143                         AC_EGREP_CPP(yes, [
2144 #include <features.h>
2145 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2147 #endif],
2148                                 [ipv6type=$i;
2149                                 ipv6trylibc=yes])
2150                         ;;
2151                 linux-inet6)
2152                         dnl http://www.v6.linux.or.jp/
2153                         if test -d /usr/inet6; then
2154                                 ipv6type=$i
2155                                 ipv6lib=inet6
2156                                 ipv6libdir=/usr/inet6/lib
2157                                 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
2158                         fi
2159                         ;;
2160                 solaris)
2161                         if test -f /etc/netconfig; then
2162                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2163                                 ipv6type=$i
2164                                 ipv6trylibc=yes
2165                           fi
2166                         fi
2167                         ;;
2168                 toshiba)
2169                         AC_EGREP_CPP(yes, [
2170 #include <sys/param.h>
2171 #ifdef _TOSHIBA_INET6
2173 #endif],
2174                                 [ipv6type=$i;
2175                                 ipv6lib=inet6;
2176                                 ipv6libdir=/usr/local/v6/lib])
2177                         ;;
2178                 v6d)
2179                         AC_EGREP_CPP(yes, [
2180 #include </usr/local/v6/include/sys/v6config.h>
2181 #ifdef __V6D__
2183 #endif],
2184                                 [ipv6type=$i;
2185                                 ipv6lib=v6;
2186                                 ipv6libdir=/usr/local/v6/lib;
2187                                 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
2188                         ;;
2189                 zeta)
2190                         AC_EGREP_CPP(yes, [
2191 #include <sys/param.h>
2192 #ifdef _ZETA_MINAMI_INET6
2194 #endif],
2195                                 [ipv6type=$i;
2196                                 ipv6lib=inet6;
2197                                 ipv6libdir=/usr/local/v6/lib])
2198                         ;;
2199                 esac
2200                 if test "$ipv6type" != "unknown"; then
2201                         break
2202                 fi
2203         done
2204         AC_MSG_RESULT($ipv6type)
2207 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2208         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2209                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2210                 echo "using lib$ipv6lib"
2211         else
2212                 if test $ipv6trylibc = "yes"; then
2213                         echo "using libc"
2214                 else
2215                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
2216                         echo "You need to fetch lib$ipv6lib.a from appropriate"
2217                         echo 'ipv6 kit and compile beforehand.'
2218                         exit 1
2219                 fi
2220         fi
2223 # Check for --with-doc-strings
2224 AC_MSG_CHECKING(for --with-doc-strings)
2225 AC_ARG_WITH(doc-strings,
2226             AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
2228 if test -z "$with_doc_strings"
2229 then with_doc_strings="yes"
2231 if test "$with_doc_strings" != "no"
2232 then
2233     AC_DEFINE(WITH_DOC_STRINGS, 1,
2234       [Define if you want documentation strings in extension modules])
2236 AC_MSG_RESULT($with_doc_strings)
2238 # Check for Python-specific malloc support
2239 AC_MSG_CHECKING(for --with-tsc)
2240 AC_ARG_WITH(tsc,
2241 [  --with(out)-tsc         enable/disable timestamp counter profile], [
2242 if test "$withval" != no
2243 then 
2244   AC_DEFINE(WITH_TSC, 1, 
2245     [Define to profile with the Pentium timestamp counter]) 
2246     AC_MSG_RESULT(yes)
2247 else AC_MSG_RESULT(no)
2248 fi],
2249 [AC_MSG_RESULT(no)])
2251 # Check for Python-specific malloc support
2252 AC_MSG_CHECKING(for --with-pymalloc)
2253 AC_ARG_WITH(pymalloc,
2254             AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
2256 if test -z "$with_pymalloc"
2257 then with_pymalloc="yes"
2259 if test "$with_pymalloc" != "no"
2260 then
2261     AC_DEFINE(WITH_PYMALLOC, 1, 
2262      [Define if you want to compile in Python-specific mallocs])
2264 AC_MSG_RESULT($with_pymalloc)
2266 # Check for --with-wctype-functions
2267 AC_MSG_CHECKING(for --with-wctype-functions)
2268 AC_ARG_WITH(wctype-functions, 
2269             AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2271 if test "$withval" != no
2272 then 
2273   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2274   [Define if you want wctype.h functions to be used instead of the
2275    one supplied by Python itself. (see Include/unicodectype.h).]) 
2276   AC_MSG_RESULT(yes)
2277 else AC_MSG_RESULT(no)
2278 fi],
2279 [AC_MSG_RESULT(no)])
2281 # -I${DLINCLDIR} is added to the compile rule for importdl.o
2282 AC_SUBST(DLINCLDIR)
2283 DLINCLDIR=.
2285 # the dlopen() function means we might want to use dynload_shlib.o. some
2286 # platforms, such as AIX, have dlopen(), but don't want to use it.
2287 AC_CHECK_FUNCS(dlopen)
2289 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2290 # loading of modules.
2291 AC_SUBST(DYNLOADFILE)
2292 AC_MSG_CHECKING(DYNLOADFILE)
2293 if test -z "$DYNLOADFILE"
2294 then
2295         case $ac_sys_system/$ac_sys_release in
2296         AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2297         if test "$ac_cv_func_dlopen" = yes
2298         then DYNLOADFILE="dynload_shlib.o"
2299         else DYNLOADFILE="dynload_aix.o"
2300         fi
2301         ;;
2302         BeOS*) DYNLOADFILE="dynload_beos.o";;
2303         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2304         # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2305         Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
2306         atheos*) DYNLOADFILE="dynload_atheos.o";;
2307         *)
2308         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2309         # out any dynamic loading
2310         if test "$ac_cv_func_dlopen" = yes
2311         then DYNLOADFILE="dynload_shlib.o"
2312         else DYNLOADFILE="dynload_stub.o"
2313         fi
2314         ;;
2315         esac
2317 AC_MSG_RESULT($DYNLOADFILE)
2318 if test "$DYNLOADFILE" != "dynload_stub.o"
2319 then
2320         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2321         [Defined when any dynamic module loading is enabled.])
2324 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
2326 AC_SUBST(MACHDEP_OBJS)
2327 AC_MSG_CHECKING(MACHDEP_OBJS)
2328 if test -z "$MACHDEP_OBJS"
2329 then
2330         MACHDEP_OBJS=$extra_machdep_objs
2331 else
2332         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2334 AC_MSG_RESULT(MACHDEP_OBJS)
2336 # checks for library functions
2337 AC_CHECK_FUNCS(alarm setitimer getitimer bind_textdomain_codeset chown \
2338  clock confstr ctermid execv fchmod fchown fork fpathconf ftime ftruncate \
2339  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2340  getpriority getpwent getspnam getspent getsid getwd \
2341  kill killpg lchmod lchown lstat mkfifo mknod mktime \
2342  mremap nice pathconf pause plock poll pthread_init \
2343  putenv readlink realpath \
2344  select setegid seteuid setgid \
2345  setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2346  sigaction siginterrupt sigrelse strftime \
2347  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2348  truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
2350 # For some functions, having a definition is not sufficient, since
2351 # we want to take their address.
2352 AC_MSG_CHECKING(for chroot)
2353 AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2354   AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2355   AC_MSG_RESULT(yes),
2356   AC_MSG_RESULT(no)
2358 AC_MSG_CHECKING(for link)
2359 AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2360   AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2361   AC_MSG_RESULT(yes),
2362   AC_MSG_RESULT(no)
2364 AC_MSG_CHECKING(for symlink)
2365 AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2366   AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2367   AC_MSG_RESULT(yes),
2368   AC_MSG_RESULT(no)
2370 AC_MSG_CHECKING(for fchdir)
2371 AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2372   AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2373   AC_MSG_RESULT(yes),
2374   AC_MSG_RESULT(no)
2376 AC_MSG_CHECKING(for fsync)
2377 AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
2378   AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2379   AC_MSG_RESULT(yes),
2380   AC_MSG_RESULT(no)
2382 AC_MSG_CHECKING(for fdatasync)
2383 AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2384   AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2385   AC_MSG_RESULT(yes),
2386   AC_MSG_RESULT(no)
2388 AC_MSG_CHECKING(for epoll)
2389 AC_TRY_COMPILE([#include <sys/epoll.h>], void *x=epoll_create,
2390   AC_DEFINE(HAVE_EPOLL, 1, Define if you have the 'epoll' functions.)
2391   AC_MSG_RESULT(yes),
2392   AC_MSG_RESULT(no)
2394 AC_MSG_CHECKING(for kqueue)
2395 AC_TRY_COMPILE([
2396 #include <sys/types.h>
2397 #include <sys/event.h>
2398     ], int x=kqueue(),
2399   AC_DEFINE(HAVE_KQUEUE, 1, Define if you have the 'kqueue' functions.)
2400   AC_MSG_RESULT(yes),
2401   AC_MSG_RESULT(no)
2403 # On some systems (eg. FreeBSD 5), we would find a definition of the
2404 # functions ctermid_r, setgroups in the library, but no prototype
2405 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2406 # address to avoid compiler warnings and potential miscompilations
2407 # because of the missing prototypes.
2409 AC_MSG_CHECKING(for ctermid_r)
2410 AC_TRY_COMPILE([
2411 #include "confdefs.h" 
2412 #include <stdio.h>
2413 ], void* p = ctermid_r,
2414   AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2415   AC_MSG_RESULT(yes),
2416   AC_MSG_RESULT(no)
2419 AC_MSG_CHECKING(for flock)
2420 AC_TRY_COMPILE([
2421 #include "confdefs.h" 
2422 #include <sys/file.h>
2423 ], void* p = flock,
2424   AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2425   AC_MSG_RESULT(yes),
2426   AC_MSG_RESULT(no)
2429 AC_MSG_CHECKING(for getpagesize)
2430 AC_TRY_COMPILE([
2431 #include "confdefs.h" 
2432 #include <unistd.h>
2433 ], void* p = getpagesize,
2434   AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2435   AC_MSG_RESULT(yes),
2436   AC_MSG_RESULT(no)
2439 dnl check for true
2440 AC_CHECK_PROGS(TRUE, true, /bin/true)
2442 dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2443 dnl On others, they are in the C library, so we to take no action
2444 AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2445   AC_CHECK_LIB(resolv, inet_aton)
2448 # On Tru64, chflags seems to be present, but calling it will
2449 # exit Python
2450 AC_MSG_CHECKING(for chflags)
2451 AC_TRY_RUN([
2452 #include <sys/stat.h>
2453 #include <unistd.h>
2454 int main(int argc, char*argv[])
2456   if(chflags(argv[0], 0) != 0)
2457     return 1;
2458   return 0;
2460 ],AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.)
2461   AC_MSG_RESULT(yes),
2462   AC_MSG_RESULT(no)
2465 AC_MSG_CHECKING(for lchflags)
2466 AC_TRY_RUN([
2467 #include <sys/stat.h>
2468 #include <unistd.h>
2469 int main(int argc, char*argv[])
2471   if(lchflags(argv[0], 0) != 0)
2472     return 1;
2473   return 0;
2475 ],AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.)
2476   AC_MSG_RESULT(yes),
2477   AC_MSG_RESULT(no)
2480 dnl Check if system zlib has *Copy() functions
2482 dnl On MacOSX the linker will search for dylibs on the entire linker path
2483 dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2484 dnl to revert to a more traditional unix behaviour and make it possible to
2485 dnl override the system libz with a local static library of libz. Temporarily
2486 dnl add that flag to our CFLAGS as well to ensure that we check the version
2487 dnl of libz that will be used by setup.py. 
2488 dnl The -L/usr/local/lib is needed as wel to get the same compilation 
2489 dnl environment as setup.py (and leaving it out can cause configure to use the
2490 dnl wrong version of the library)
2491 case $ac_sys_system/$ac_sys_release in
2492 Darwin/*) 
2493         _CUR_CFLAGS="${CFLAGS}"
2494         _CUR_LDFLAGS="${LDFLAGS}"
2495         CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2496         LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2497         ;;
2498 esac
2500 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2502 case $ac_sys_system/$ac_sys_release in
2503 Darwin/*) 
2504         CFLAGS="${_CUR_CFLAGS}"
2505         LDFLAGS="${_CUR_LDFLAGS}"
2506         ;;
2507 esac
2509 AC_MSG_CHECKING(for hstrerror)
2510 AC_TRY_LINK([
2511 #include "confdefs.h" 
2512 #include <netdb.h>
2513 ], void* p = hstrerror; hstrerror(0),
2514   AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2515   AC_MSG_RESULT(yes),
2516   AC_MSG_RESULT(no)
2519 AC_MSG_CHECKING(for inet_aton)
2520 AC_TRY_LINK([
2521 #include "confdefs.h" 
2522 #include <sys/types.h>
2523 #include <sys/socket.h>
2524 #include <netinet/in.h>
2525 #include <arpa/inet.h>
2526 ], void* p = inet_aton;inet_aton(0,0),
2527   AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2528   AC_MSG_RESULT(yes),
2529   AC_MSG_RESULT(no)
2532 AC_MSG_CHECKING(for inet_pton)
2533 AC_TRY_COMPILE([
2534 #include "confdefs.h" 
2535 #include <sys/types.h>
2536 #include <sys/socket.h>
2537 #include <netinet/in.h>
2538 #include <arpa/inet.h>
2539 ], void* p = inet_pton,
2540   AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2541   AC_MSG_RESULT(yes),
2542   AC_MSG_RESULT(no)
2545 # On some systems, setgroups is in unistd.h, on others, in grp.h
2546 AC_MSG_CHECKING(for setgroups)
2547 AC_TRY_COMPILE([
2548 #include "confdefs.h" 
2549 #include <unistd.h>
2550 #ifdef HAVE_GRP_H
2551 #include <grp.h>
2552 #endif
2553 ], 
2554 void* p = setgroups,
2555   AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2556   AC_MSG_RESULT(yes),
2557   AC_MSG_RESULT(no)
2560 # check for openpty and forkpty
2562 AC_CHECK_FUNCS(openpty,, 
2563    AC_CHECK_LIB(util,openpty,
2564      [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2565      AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2566    )
2568 AC_CHECK_FUNCS(forkpty,, 
2569    AC_CHECK_LIB(util,forkpty, 
2570      [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2571      AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2572    )
2575 # Stuff for expat.
2576 AC_CHECK_FUNCS(memmove)
2578 # check for long file support functions
2579 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2581 AC_REPLACE_FUNCS(dup2 getcwd strdup)
2582 AC_CHECK_FUNCS(getpgrp, 
2583   AC_TRY_COMPILE([#include <unistd.h>], 
2584    [getpgrp(0);], 
2585    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2586    [Define if getpgrp() must be called as getpgrp(0).])
2589 AC_CHECK_FUNCS(setpgrp,
2590   AC_TRY_COMPILE([#include <unistd.h>],
2591     [setpgrp(0,0);],
2592     AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2593     [Define if setpgrp() must be called as setpgrp(0, 0).])
2594   )
2596 AC_CHECK_FUNCS(gettimeofday, 
2597   AC_TRY_COMPILE([#include <sys/time.h>], 
2598     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2599     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2600     [Define if gettimeofday() does not have second (timezone) argument
2601      This is the case on Motorola V4 (R40V4.2)])
2602   )
2605 AC_MSG_CHECKING(for major, minor, and makedev)
2606 AC_TRY_LINK([
2607 #if defined(MAJOR_IN_MKDEV)
2608 #include <sys/mkdev.h>
2609 #elif defined(MAJOR_IN_SYSMACROS)
2610 #include <sys/sysmacros.h>
2611 #else
2612 #include <sys/types.h>
2613 #endif
2615   makedev(major(0),minor(0));
2617   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2618             [Define to 1 if you have the device macros.])
2619   AC_MSG_RESULT(yes)
2621   AC_MSG_RESULT(no)
2624 # On OSF/1 V5.1, getaddrinfo is available, but a define
2625 # for [no]getaddrinfo in netdb.h. 
2626 AC_MSG_CHECKING(for getaddrinfo)
2627 AC_TRY_LINK([
2628 #include <sys/types.h>
2629 #include <sys/socket.h>
2630 #include <netdb.h>
2631 #include <stdio.h>
2633 getaddrinfo(NULL, NULL, NULL, NULL);
2634 ], [
2635 AC_MSG_RESULT(yes)
2636 AC_MSG_CHECKING(getaddrinfo bug)
2637 AC_TRY_RUN([
2638 #include <sys/types.h>
2639 #include <netdb.h>
2640 #include <string.h>
2641 #include <sys/socket.h>
2642 #include <netinet/in.h>
2644 main()
2646   int passive, gaierr, inet4 = 0, inet6 = 0;
2647   struct addrinfo hints, *ai, *aitop;
2648   char straddr[INET6_ADDRSTRLEN], strport[16];
2650   for (passive = 0; passive <= 1; passive++) {
2651     memset(&hints, 0, sizeof(hints));
2652     hints.ai_family = AF_UNSPEC;
2653     hints.ai_flags = passive ? AI_PASSIVE : 0;
2654     hints.ai_socktype = SOCK_STREAM;
2655     hints.ai_protocol = IPPROTO_TCP;
2656     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2657       (void)gai_strerror(gaierr);
2658       goto bad;
2659     }
2660     for (ai = aitop; ai; ai = ai->ai_next) {
2661       if (ai->ai_addr == NULL ||
2662           ai->ai_addrlen == 0 ||
2663           getnameinfo(ai->ai_addr, ai->ai_addrlen,
2664                       straddr, sizeof(straddr), strport, sizeof(strport),
2665                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2666         goto bad;
2667       }
2668       switch (ai->ai_family) {
2669       case AF_INET:
2670         if (strcmp(strport, "54321") != 0) {
2671           goto bad;
2672         }
2673         if (passive) {
2674           if (strcmp(straddr, "0.0.0.0") != 0) {
2675             goto bad;
2676           }
2677         } else {
2678           if (strcmp(straddr, "127.0.0.1") != 0) {
2679             goto bad;
2680           }
2681         }
2682         inet4++;
2683         break;
2684       case AF_INET6:
2685         if (strcmp(strport, "54321") != 0) {
2686           goto bad;
2687         }
2688         if (passive) {
2689           if (strcmp(straddr, "::") != 0) {
2690             goto bad;
2691           }
2692         } else {
2693           if (strcmp(straddr, "::1") != 0) {
2694             goto bad;
2695           }
2696         }
2697         inet6++;
2698         break;
2699       case AF_UNSPEC:
2700         goto bad;
2701         break;
2702       default:
2703         /* another family support? */
2704         break;
2705       }
2706     }
2707   }
2709   if (!(inet4 == 0 || inet4 == 2))
2710     goto bad;
2711   if (!(inet6 == 0 || inet6 == 2))
2712     goto bad;
2714   if (aitop)
2715     freeaddrinfo(aitop);
2716   exit(0);
2718  bad:
2719   if (aitop)
2720     freeaddrinfo(aitop);
2721   exit(1);
2724 AC_MSG_RESULT(good)
2725 buggygetaddrinfo=no,
2726 AC_MSG_RESULT(buggy)
2727 buggygetaddrinfo=yes,
2728 AC_MSG_RESULT(buggy)
2729 buggygetaddrinfo=yes)], [
2730 AC_MSG_RESULT(no)
2731 buggygetaddrinfo=yes
2734 if test "$buggygetaddrinfo" = "yes"; then
2735         if test "$ipv6" = "yes"; then
2736                 echo 'Fatal: You must get working getaddrinfo() function.'
2737                 echo '       or you can specify "--disable-ipv6"'.
2738                 exit 1
2739         fi
2740 else
2741         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2743 AC_CHECK_FUNCS(getnameinfo)
2745 # checks for structures
2746 AC_HEADER_TIME
2747 AC_STRUCT_TM
2748 AC_STRUCT_TIMEZONE
2749 AC_CHECK_MEMBERS([struct stat.st_rdev])
2750 AC_CHECK_MEMBERS([struct stat.st_blksize])
2751 AC_CHECK_MEMBERS([struct stat.st_flags])
2752 AC_CHECK_MEMBERS([struct stat.st_gen])
2753 AC_CHECK_MEMBERS([struct stat.st_birthtime])
2754 AC_STRUCT_ST_BLOCKS
2756 AC_MSG_CHECKING(for time.h that defines altzone)
2757 AC_CACHE_VAL(ac_cv_header_time_altzone,
2758 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2759   ac_cv_header_time_altzone=yes,
2760   ac_cv_header_time_altzone=no)])
2761 AC_MSG_RESULT($ac_cv_header_time_altzone)
2762 if test $ac_cv_header_time_altzone = yes; then
2763   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2766 was_it_defined=no
2767 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2768 AC_TRY_COMPILE([
2769 #include <sys/types.h>
2770 #include <sys/select.h>
2771 #include <sys/time.h>
2772 ], [;], [
2773   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2774   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
2775    (which you can't on SCO ODT 3.0).]) 
2776   was_it_defined=yes
2778 AC_MSG_RESULT($was_it_defined)
2780 AC_MSG_CHECKING(for addrinfo)
2781 AC_CACHE_VAL(ac_cv_struct_addrinfo,
2782 AC_TRY_COMPILE([
2783 #               include <netdb.h>],
2784         [struct addrinfo a],
2785         ac_cv_struct_addrinfo=yes,
2786         ac_cv_struct_addrinfo=no))
2787 AC_MSG_RESULT($ac_cv_struct_addrinfo)
2788 if test $ac_cv_struct_addrinfo = yes; then
2789         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
2792 AC_MSG_CHECKING(for sockaddr_storage)
2793 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2794 AC_TRY_COMPILE([
2795 #               include <sys/types.h>
2796 #               include <sys/socket.h>],
2797         [struct sockaddr_storage s],
2798         ac_cv_struct_sockaddr_storage=yes,
2799         ac_cv_struct_sockaddr_storage=no))
2800 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2801 if test $ac_cv_struct_sockaddr_storage = yes; then
2802         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
2805 # checks for compiler characteristics
2807 AC_C_CHAR_UNSIGNED
2808 AC_C_CONST
2810 works=no
2811 AC_MSG_CHECKING(for working volatile)
2812 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
2813   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2815 AC_MSG_RESULT($works)
2817 works=no
2818 AC_MSG_CHECKING(for working signed char)
2819 AC_TRY_COMPILE([], [signed char c;], works=yes, 
2820   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2822 AC_MSG_RESULT($works)
2824 have_prototypes=no
2825 AC_MSG_CHECKING(for prototypes)
2826 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2827   AC_DEFINE(HAVE_PROTOTYPES, 1, 
2828    [Define if your compiler supports function prototype]) 
2829   have_prototypes=yes
2831 AC_MSG_RESULT($have_prototypes)
2833 works=no
2834 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
2835 AC_TRY_COMPILE([
2836 #include <stdarg.h>
2837 int foo(int x, ...) {
2838         va_list va;
2839         va_start(va, x);
2840         va_arg(va, int);
2841         va_arg(va, char *);
2842         va_arg(va, double);
2843         return 0;
2845 ], [return foo(10, "", 3.14);], [
2846   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2847    [Define if your compiler supports variable length function prototypes
2848    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
2849   works=yes
2851 AC_MSG_RESULT($works)
2853 # check for socketpair
2854 AC_MSG_CHECKING(for socketpair)
2855 AC_TRY_COMPILE([
2856 #include <sys/types.h>
2857 #include <sys/socket.h>
2858 ], void *x=socketpair,
2859   AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
2860   AC_MSG_RESULT(yes),
2861   AC_MSG_RESULT(no)
2864 # check if sockaddr has sa_len member
2865 AC_MSG_CHECKING(if sockaddr has sa_len member)
2866 AC_TRY_COMPILE([#include <sys/types.h>
2867 #include <sys/socket.h>],
2868 [struct sockaddr x;
2869 x.sa_len = 0;],
2870         AC_MSG_RESULT(yes)
2871         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
2872         AC_MSG_RESULT(no))
2874 va_list_is_array=no
2875 AC_MSG_CHECKING(whether va_list is an array)
2876 AC_TRY_COMPILE([
2877 #ifdef HAVE_STDARG_PROTOTYPES
2878 #include <stdarg.h>
2879 #else
2880 #include <varargs.h>
2881 #endif
2882 ], [va_list list1, list2; list1 = list2;], , [
2883  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
2884  va_list_is_array=yes
2886 AC_MSG_RESULT($va_list_is_array)
2888 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
2889 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2890   [Define this if you have some version of gethostbyname_r()])
2892 AC_CHECK_FUNC(gethostbyname_r, [
2893   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2894   AC_MSG_CHECKING([gethostbyname_r with 6 args])
2895   OLD_CFLAGS=$CFLAGS
2896   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2897   AC_TRY_COMPILE([
2898 #   include <netdb.h>
2899   ], [
2900     char *name;
2901     struct hostent *he, *res;
2902     char buffer[2048];
2903     int buflen = 2048;
2904     int h_errnop;
2906     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2907   ], [
2908     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2909     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2910     [Define this if you have the 6-arg version of gethostbyname_r().])
2911     AC_MSG_RESULT(yes)
2912   ], [
2913     AC_MSG_RESULT(no)
2914     AC_MSG_CHECKING([gethostbyname_r with 5 args])
2915     AC_TRY_COMPILE([
2916 #     include <netdb.h>
2917     ], [
2918       char *name;
2919       struct hostent *he;
2920       char buffer[2048];
2921       int buflen = 2048;
2922       int h_errnop;
2924       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2925     ], [
2926       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2927       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2928       [Define this if you have the 5-arg version of gethostbyname_r().])
2929       AC_MSG_RESULT(yes)
2930     ], [
2931       AC_MSG_RESULT(no)
2932       AC_MSG_CHECKING([gethostbyname_r with 3 args])
2933       AC_TRY_COMPILE([
2934 #       include <netdb.h>
2935       ], [
2936         char *name;
2937         struct hostent *he;
2938         struct hostent_data data;
2940         (void) gethostbyname_r(name, he, &data);
2941       ], [
2942         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2943         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2944         [Define this if you have the 3-arg version of gethostbyname_r().])
2945         AC_MSG_RESULT(yes)
2946       ], [
2947         AC_MSG_RESULT(no)
2948       ])
2949     ])
2950   ])
2951   CFLAGS=$OLD_CFLAGS
2952 ], [
2953   AC_CHECK_FUNCS(gethostbyname)
2955 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2956 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2957 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
2958 AC_SUBST(HAVE_GETHOSTBYNAME_R)
2959 AC_SUBST(HAVE_GETHOSTBYNAME)
2961 # checks for system services
2962 # (none yet)
2964 # Linux requires this for correct f.p. operations
2965 AC_CHECK_FUNC(__fpu_control,
2966   [],
2967   [AC_CHECK_LIB(ieee, __fpu_control)
2970 # Check for --with-fpectl
2971 AC_MSG_CHECKING(for --with-fpectl)
2972 AC_ARG_WITH(fpectl,
2973             AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
2975 if test "$withval" != no
2976 then 
2977   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2978   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
2979   AC_MSG_RESULT(yes)
2980 else AC_MSG_RESULT(no)
2981 fi],
2982 [AC_MSG_RESULT(no)])
2984 # check for --with-libm=...
2985 AC_SUBST(LIBM)
2986 case $ac_sys_system in
2987 Darwin) ;;
2988 BeOS) ;;
2989 *) LIBM=-lm
2990 esac
2991 AC_MSG_CHECKING(for --with-libm=STRING)
2992 AC_ARG_WITH(libm,
2993             AC_HELP_STRING(--with-libm=STRING, math library),
2995 if test "$withval" = no
2996 then LIBM=
2997      AC_MSG_RESULT(force LIBM empty)
2998 elif test "$withval" != yes
2999 then LIBM=$withval
3000      AC_MSG_RESULT(set LIBM="$withval")
3001 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
3002 fi],
3003 [AC_MSG_RESULT(default LIBM="$LIBM")])
3005 # check for --with-libc=...
3006 AC_SUBST(LIBC)
3007 AC_MSG_CHECKING(for --with-libc=STRING)
3008 AC_ARG_WITH(libc,
3009             AC_HELP_STRING(--with-libc=STRING, C library),
3011 if test "$withval" = no
3012 then LIBC=
3013      AC_MSG_RESULT(force LIBC empty)
3014 elif test "$withval" != yes
3015 then LIBC=$withval
3016      AC_MSG_RESULT(set LIBC="$withval")
3017 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
3018 fi],
3019 [AC_MSG_RESULT(default LIBC="$LIBC")])
3021 # ************************************
3022 # * Check for mathematical functions *
3023 # ************************************
3025 LIBS_SAVE=$LIBS
3026 LIBS="$LIBS $LIBM"
3028 # On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
3029 # -0. on some architectures.
3030 AC_MSG_CHECKING(whether tanh preserves the sign of zero)
3031 AC_CACHE_VAL(ac_cv_tanh_preserves_zero_sign, [
3032 AC_TRY_RUN([
3033 #include <math.h>
3034 #include <stdlib.h>
3035 int main() {
3036     /* return 0 if either negative zeros don't exist
3037        on this platform or if negative zeros exist
3038        and tanh(-0.) == -0. */
3039   if (atan2(0., -1.) == atan2(-0., -1.) ||
3040       atan2(tanh(-0.), -1.) == atan2(-0., -1.)) exit(0);
3041   else exit(1);
3044 ac_cv_tanh_preserves_zero_sign=yes,
3045 ac_cv_tanh_preserves_zero_sign=no,
3046 ac_cv_tanh_preserves_zero_sign=no)])
3047 AC_MSG_RESULT($ac_cv_tanh_preserves_zero_sign)
3048 if test "$ac_cv_tanh_preserves_zero_sign" = yes
3049 then
3050   AC_DEFINE(TANH_PRESERVES_ZERO_SIGN, 1,
3051   [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros])
3054 AC_REPLACE_FUNCS(hypot)
3056 AC_CHECK_FUNCS(acosh asinh atanh copysign expm1 finite isinf isnan log1p)
3058 LIBS=$LIBS_SAVE
3060 # check for wchar.h
3061 AC_CHECK_HEADER(wchar.h, [
3062   AC_DEFINE(HAVE_WCHAR_H, 1, 
3063   [Define if the compiler provides a wchar.h header file.]) 
3064   wchar_h="yes"
3066 wchar_h="no"
3069 # determine wchar_t size
3070 if test "$wchar_h" = yes
3071 then
3072   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
3075 AC_MSG_CHECKING(for UCS-4 tcl)
3076 have_ucs4_tcl=no
3077 AC_TRY_COMPILE([
3078 #include <tcl.h>
3079 #if TCL_UTF_MAX != 6
3080 # error "NOT UCS4_TCL"
3081 #endif], [], [
3082   AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
3083   have_ucs4_tcl=yes
3085 AC_MSG_RESULT($have_ucs4_tcl)
3087 # check whether wchar_t is signed or not
3088 if test "$wchar_h" = yes
3089 then
3090   # check whether wchar_t is signed or not
3091   AC_MSG_CHECKING(whether wchar_t is signed)
3092   AC_CACHE_VAL(ac_cv_wchar_t_signed, [
3093   AC_TRY_RUN([
3094   #include <wchar.h>
3095   int main()
3096   {
3097         /* Success: exit code 0 */
3098         exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
3099   }
3100   ],
3101   ac_cv_wchar_t_signed=yes,
3102   ac_cv_wchar_t_signed=no,
3103   ac_cv_wchar_t_signed=yes)])
3104   AC_MSG_RESULT($ac_cv_wchar_t_signed)
3106   
3107 AC_MSG_CHECKING(what type to use for unicode)
3108 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
3109 AC_ARG_ENABLE(unicode, 
3110               AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
3111               [],
3112               [enable_unicode=yes])
3114 if test $enable_unicode = yes
3115 then
3116   # Without any arguments, Py_UNICODE defaults to two-byte mode
3117   case "$have_ucs4_tcl" in
3118   yes) enable_unicode="ucs4"
3119        ;;
3120   *)   enable_unicode="ucs2"
3121        ;;
3122   esac
3125 AH_TEMPLATE(Py_UNICODE_SIZE,
3126   [Define as the size of the unicode type.])
3127 case "$enable_unicode" in
3128 ucs2) unicode_size="2"
3129       AC_DEFINE(Py_UNICODE_SIZE,2)
3130       ;;
3131 ucs4) unicode_size="4"
3132       AC_DEFINE(Py_UNICODE_SIZE,4)
3133       ;;
3134 esac
3136 AH_TEMPLATE(PY_UNICODE_TYPE,
3137   [Define as the integral type used for Unicode representation.])
3139 AC_SUBST(UNICODE_OBJS)
3140 if test "$enable_unicode" = "no"
3141 then
3142   UNICODE_OBJS=""
3143   AC_MSG_RESULT(not used)
3144 else
3145   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
3146   AC_DEFINE(Py_USING_UNICODE, 1,
3147   [Define if you want to have a Unicode type.])
3149   # wchar_t is only usable if it maps to an unsigned type
3150   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
3151           -a "$ac_cv_wchar_t_signed" = "no"
3152   then
3153     PY_UNICODE_TYPE="wchar_t"
3154     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3155     [Define if you have a useable wchar_t type defined in wchar.h; useable
3156      means wchar_t must be an unsigned type with at least 16 bits. (see
3157      Include/unicodeobject.h).])
3158     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3159   elif test "$ac_cv_sizeof_short" = "$unicode_size"
3160   then
3161        PY_UNICODE_TYPE="unsigned short"
3162        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3163   elif test "$ac_cv_sizeof_long" = "$unicode_size"
3164   then
3165        PY_UNICODE_TYPE="unsigned long"
3166        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3167   else
3168        PY_UNICODE_TYPE="no type found"
3169   fi
3170   AC_MSG_RESULT($PY_UNICODE_TYPE)
3173 # check for endianness
3174 AC_C_BIGENDIAN
3175 AH_VERBATIM([WORDS_BIGENDIAN],
3177  /* Define to 1 if your processor stores words with the most significant byte
3178     first (like Motorola and SPARC, unlike Intel and VAX). 
3180     The block below does compile-time checking for endianness on platforms
3181     that use GCC and therefore allows compiling fat binaries on OSX by using 
3182     '-arch ppc -arch i386' as the compile flags. The phrasing was choosen
3183     such that the configure-result is used on systems that don't use GCC.
3184   */
3185 #ifdef __BIG_ENDIAN__
3186 #define WORDS_BIGENDIAN 1
3187 #else
3188 #ifndef __LITTLE_ENDIAN__
3189 #undef WORDS_BIGENDIAN
3190 #endif
3191 #endif])
3193 # Check whether right shifting a negative integer extends the sign bit
3194 # or fills with zeros (like the Cray J90, according to Tim Peters).
3195 AC_MSG_CHECKING(whether right shift extends the sign bit)
3196 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
3197 AC_TRY_RUN([
3198 int main()
3200         exit(((-1)>>3 == -1) ? 0 : 1);
3203 ac_cv_rshift_extends_sign=yes,
3204 ac_cv_rshift_extends_sign=no,
3205 ac_cv_rshift_extends_sign=yes)])
3206 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3207 if test "$ac_cv_rshift_extends_sign" = no
3208 then
3209   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3210   [Define if i>>j for signed int i does not extend the sign bit
3211    when i < 0])
3214 # check for getc_unlocked and related locking functions
3215 AC_MSG_CHECKING(for getc_unlocked() and friends)
3216 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3217 AC_TRY_LINK([#include <stdio.h>],[
3218         FILE *f = fopen("/dev/null", "r");
3219         flockfile(f);
3220         getc_unlocked(f);
3221         funlockfile(f);
3222 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3223 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3224 if test "$ac_cv_have_getc_unlocked" = yes
3225 then
3226   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3227   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
3230 # check where readline lives
3231 # save the value of LIBS so we don't actually link Python with readline
3232 LIBS_no_readline=$LIBS
3233 AC_CHECK_LIB(readline, readline)
3234 if test "$ac_cv_have_readline_readline" = no
3235 then
3236   AC_CHECK_LIB(termcap, readline)
3239 # check for readline 2.1
3240 AC_CHECK_LIB(readline, rl_callback_handler_install,
3241         AC_DEFINE(HAVE_RL_CALLBACK, 1,
3242         [Define if you have readline 2.1]), , )
3244 # check for readline 2.2
3245 AC_TRY_CPP([#include <readline/readline.h>],
3246 have_readline=yes, have_readline=no)
3247 if test $have_readline = yes
3248 then
3249   AC_EGREP_HEADER([extern int rl_completion_append_character;],
3250   [readline/readline.h],
3251   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3252   [Define if you have readline 2.2]), )
3255 # check for readline 4.0
3256 AC_CHECK_LIB(readline, rl_pre_input_hook,
3257         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
3258         [Define if you have readline 4.0]), , )
3260 # also in 4.0
3261 AC_CHECK_LIB(readline, rl_completion_display_matches_hook,
3262         AC_DEFINE(HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK, 1,
3263         [Define if you have readline 4.0]), , )
3265 # check for readline 4.2
3266 AC_CHECK_LIB(readline, rl_completion_matches,
3267         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
3268         [Define if you have readline 4.2]), , )
3270 # also in readline 4.2
3271 AC_TRY_CPP([#include <readline/readline.h>],
3272 have_readline=yes, have_readline=no)
3273 if test $have_readline = yes
3274 then
3275   AC_EGREP_HEADER([extern int rl_catch_signals;],
3276   [readline/readline.h],
3277   AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3278   [Define if you can turn off readline's signal handling.]), )
3281 # End of readline checks: restore LIBS
3282 LIBS=$LIBS_no_readline
3284 AC_MSG_CHECKING(for broken nice())
3285 AC_CACHE_VAL(ac_cv_broken_nice, [
3286 AC_TRY_RUN([
3287 int main()
3289         int val1 = nice(1);
3290         if (val1 != -1 && val1 == nice(2))
3291                 exit(0);
3292         exit(1);
3295 ac_cv_broken_nice=yes,
3296 ac_cv_broken_nice=no,
3297 ac_cv_broken_nice=no)])
3298 AC_MSG_RESULT($ac_cv_broken_nice)
3299 if test "$ac_cv_broken_nice" = yes
3300 then
3301   AC_DEFINE(HAVE_BROKEN_NICE, 1,
3302   [Define if nice() returns success/failure instead of the new priority.])
3305 AC_MSG_CHECKING(for broken poll())
3306 AC_TRY_RUN([
3307 #include <poll.h>
3309 int main (void)
3310     {
3311     struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3312     
3313     close (42);
3315     int poll_test = poll (&poll_struct, 1, 0);
3317     if (poll_test < 0)
3318         {
3319         exit(0);
3320         }
3321     else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3322         {
3323         exit(0);
3324         }
3325     else
3326         {
3327         exit(1);
3328         }
3329     }
3331 ac_cv_broken_poll=yes,
3332 ac_cv_broken_poll=no,
3333 ac_cv_broken_poll=no)
3334 AC_MSG_RESULT($ac_cv_broken_poll)
3335 if test "$ac_cv_broken_poll" = yes
3336 then
3337   AC_DEFINE(HAVE_BROKEN_POLL, 1,
3338       [Define if poll() sets errno on invalid file descriptors.])
3341 # Before we can test tzset, we need to check if struct tm has a tm_zone 
3342 # (which is not required by ISO C or UNIX spec) and/or if we support
3343 # tzname[]
3344 AC_STRUCT_TIMEZONE
3346 # check tzset(3) exists and works like we expect it to
3347 AC_MSG_CHECKING(for working tzset())
3348 AC_CACHE_VAL(ac_cv_working_tzset, [
3349 AC_TRY_RUN([
3350 #include <stdlib.h>
3351 #include <time.h>
3352 #include <string.h>
3354 #if HAVE_TZNAME
3355 extern char *tzname[];
3356 #endif
3358 int main()
3360         /* Note that we need to ensure that not only does tzset(3)
3361            do 'something' with localtime, but it works as documented
3362            in the library reference and as expected by the test suite.
3363            This includes making sure that tzname is set properly if
3364            tm->tm_zone does not exist since it is the alternative way
3365            of getting timezone info.
3367            Red Hat 6.2 doesn't understand the southern hemisphere 
3368            after New Year's Day.
3369         */
3371         time_t groundhogday = 1044144000; /* GMT-based */
3372         time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3374         putenv("TZ=UTC+0");
3375         tzset();
3376         if (localtime(&groundhogday)->tm_hour != 0)
3377             exit(1);
3378 #if HAVE_TZNAME
3379         /* For UTC, tzname[1] is sometimes "", sometimes "   " */
3380         if (strcmp(tzname[0], "UTC") || 
3381                 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3382             exit(1);
3383 #endif
3385         putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
3386         tzset();
3387         if (localtime(&groundhogday)->tm_hour != 19)
3388             exit(1);
3389 #if HAVE_TZNAME
3390         if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3391             exit(1);
3392 #endif
3394         putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3395         tzset();
3396         if (localtime(&groundhogday)->tm_hour != 11)
3397             exit(1);
3398 #if HAVE_TZNAME
3399         if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3400             exit(1);
3401 #endif
3403 #if HAVE_STRUCT_TM_TM_ZONE
3404         if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3405             exit(1);
3406         if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3407             exit(1);
3408 #endif
3410         exit(0);
3413 ac_cv_working_tzset=yes,
3414 ac_cv_working_tzset=no,
3415 ac_cv_working_tzset=no)])
3416 AC_MSG_RESULT($ac_cv_working_tzset)
3417 if test "$ac_cv_working_tzset" = yes
3418 then
3419   AC_DEFINE(HAVE_WORKING_TZSET, 1,
3420   [Define if tzset() actually switches the local timezone in a meaningful way.])
3423 # Look for subsecond timestamps in struct stat
3424 AC_MSG_CHECKING(for tv_nsec in struct stat)
3425 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3426 AC_TRY_COMPILE([#include <sys/stat.h>], [
3427 struct stat st;
3428 st.st_mtim.tv_nsec = 1;
3430 ac_cv_stat_tv_nsec=yes,
3431 ac_cv_stat_tv_nsec=no,
3432 ac_cv_stat_tv_nsec=no))
3433 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3434 if test "$ac_cv_stat_tv_nsec" = yes
3435 then
3436   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3437   [Define if you have struct stat.st_mtim.tv_nsec])
3440 # Look for BSD style subsecond timestamps in struct stat
3441 AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3442 AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3443 AC_TRY_COMPILE([#include <sys/stat.h>], [
3444 struct stat st;
3445 st.st_mtimespec.tv_nsec = 1;
3447 ac_cv_stat_tv_nsec2=yes,
3448 ac_cv_stat_tv_nsec2=no,
3449 ac_cv_stat_tv_nsec2=no))
3450 AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3451 if test "$ac_cv_stat_tv_nsec2" = yes
3452 then
3453   AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3454   [Define if you have struct stat.st_mtimensec])
3457 # On HP/UX 11.0, mvwdelch is a block with a return statement
3458 AC_MSG_CHECKING(whether mvwdelch is an expression)
3459 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3460 AC_TRY_COMPILE([#include <curses.h>], [
3461   int rtn;
3462   rtn = mvwdelch(0,0,0);
3463 ], ac_cv_mvwdelch_is_expression=yes,
3464    ac_cv_mvwdelch_is_expression=no,
3465    ac_cv_mvwdelch_is_expression=yes))
3466 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3468 if test "$ac_cv_mvwdelch_is_expression" = yes
3469 then
3470   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3471   [Define if mvwdelch in curses.h is an expression.])
3474 AC_MSG_CHECKING(whether WINDOW has _flags)
3475 AC_CACHE_VAL(ac_cv_window_has_flags,
3476 AC_TRY_COMPILE([#include <curses.h>], [
3477   WINDOW *w;
3478   w->_flags = 0;
3479 ], ac_cv_window_has_flags=yes,
3480    ac_cv_window_has_flags=no,
3481    ac_cv_window_has_flags=no))
3482 AC_MSG_RESULT($ac_cv_window_has_flags)
3485 if test "$ac_cv_window_has_flags" = yes
3486 then
3487   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
3488   [Define if WINDOW in curses.h offers a field _flags.])
3491 AC_MSG_CHECKING(for is_term_resized)
3492 AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3493   AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3494   AC_MSG_RESULT(yes),
3495   AC_MSG_RESULT(no)
3498 AC_MSG_CHECKING(for resize_term)
3499 AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3500   AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3501   AC_MSG_RESULT(yes),
3502   AC_MSG_RESULT(no)
3505 AC_MSG_CHECKING(for resizeterm)
3506 AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3507   AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3508   AC_MSG_RESULT(yes),
3509   AC_MSG_RESULT(no)
3512 AC_MSG_CHECKING(for /dev/ptmx)
3514 if test -r /dev/ptmx
3515 then
3516   AC_MSG_RESULT(yes)
3517   AC_DEFINE(HAVE_DEV_PTMX, 1,
3518   [Define if we have /dev/ptmx.])
3519 else
3520   AC_MSG_RESULT(no)
3523 AC_MSG_CHECKING(for /dev/ptc)
3525 if test -r /dev/ptc
3526 then
3527   AC_MSG_RESULT(yes)
3528   AC_DEFINE(HAVE_DEV_PTC, 1,
3529   [Define if we have /dev/ptc.])
3530 else
3531   AC_MSG_RESULT(no)
3534 AC_MSG_CHECKING(for %zd printf() format support)
3535 AC_TRY_RUN([#include <stdio.h>
3536 #include <stddef.h>
3537 #include <string.h>
3539 #ifdef HAVE_SYS_TYPES_H
3540 #include <sys/types.h>
3541 #endif
3543 #ifdef HAVE_SSIZE_T
3544 typedef ssize_t Py_ssize_t;
3545 #elif SIZEOF_VOID_P == SIZEOF_LONG
3546 typedef long Py_ssize_t;
3547 #else
3548 typedef int Py_ssize_t;
3549 #endif
3551 int main()
3553     char buffer[256];
3555     if(sprintf(buffer, "%zd", (size_t)123) < 0)
3556         return 1;
3558     if (strcmp(buffer, "123"))
3559         return 1;
3561     if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0)
3562         return 1;
3564     if (strcmp(buffer, "-123"))
3565         return 1;
3567     return 0;
3569 [AC_MSG_RESULT(yes)
3570  AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3571  AC_MSG_RESULT(no))
3573 AC_CHECK_TYPE(socklen_t,,
3574   AC_DEFINE(socklen_t,int,
3575             Define to `int' if <sys/socket.h> does not define.),[
3576 #ifdef HAVE_SYS_TYPES_H
3577 #include <sys/types.h>
3578 #endif
3579 #ifdef HAVE_SYS_SOCKET_H
3580 #include <sys/socket.h>
3581 #endif
3584 AC_SUBST(THREADHEADERS)
3586 for h in `(cd $srcdir;echo Python/thread_*.h)`
3588   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3589 done
3591 AC_SUBST(SRCDIRS)
3592 SRCDIRS="Parser Grammar Objects Python Modules Mac"
3593 AC_MSG_CHECKING(for build directories)
3594 for dir in $SRCDIRS; do
3595     if test ! -d $dir; then
3596         mkdir $dir
3597     fi
3598 done
3599 AC_MSG_RESULT(done)
3601 # generate output files
3602 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
3603 AC_OUTPUT
3605 echo "creating Modules/Setup"
3606 if test ! -f Modules/Setup
3607 then
3608         cp $srcdir/Modules/Setup.dist Modules/Setup
3611 echo "creating Modules/Setup.local"
3612 if test ! -f Modules/Setup.local
3613 then
3614         echo "# Edit this file for local setup changes" >Modules/Setup.local
3617 echo "creating Makefile"
3618 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3619                         -s Modules Modules/Setup.config \
3620                         Modules/Setup.local Modules/Setup
3622 case $ac_sys_system in
3623 BeOS)
3624         AC_MSG_WARN([
3626   Support for BeOS is deprecated as of Python 2.6.
3627   See PEP 11 for the gory details.
3628   ])
3629   ;;
3630 *) ;;
3631 esac
3633 mv config.c Modules