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