1 dnl Process this file with autoconf 2.0 or later to make a configure script.
2 AC_REVISION($Revision$)
4 AC_INIT(Include/object.h)
5 AC_CONFIG_HEADER(pyconfig.h)
7 # Set VERSION so we only need to edit in one place (i.e., here)
11 # Arguments passed to configure.
13 CONFIG_ARGS="$ac_configure_args"
16 AC_ARG_ENABLE(framework,
17 [ --enable-framework[=INSTALLDIR] Build (MacOSX|Darwin) framework],[
20 enableval=/Library/Frameworks
25 PYTHONFRAMEWORKDIR=no-framework
26 PYTHONFRAMEWORKPREFIX=
27 PYTHONFRAMEWORKINSTALLDIR=
31 PYTHONFRAMEWORK=Python
32 PYTHONFRAMEWORKDIR=Python.framework
33 PYTHONFRAMEWORKPREFIX=$enableval
34 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
35 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
39 PYTHONFRAMEWORKDIR=no-framework
40 PYTHONFRAMEWORKPREFIX=
41 PYTHONFRAMEWORKINSTALLDIR=
44 AC_SUBST(PYTHONFRAMEWORK)
45 AC_SUBST(PYTHONFRAMEWORKDIR)
46 AC_SUBST(PYTHONFRAMEWORKPREFIX)
47 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
50 ##[ --with-dyld Use (OpenStep|Rhapsody) dynamic linker],,)
52 # Set name for machine-dependent library files
54 AC_MSG_CHECKING(MACHDEP)
57 ac_sys_system=`uname -s`
58 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
59 ac_sys_release=`uname -v`
61 ac_sys_release=`uname -r`
63 ac_md_system=`echo $ac_sys_system |
64 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
65 ac_md_release=`echo $ac_sys_release |
66 tr -d '[/ ]' | sed 's/\..*//'`
67 MACHDEP="$ac_md_system$ac_md_release"
70 cygwin*) MACHDEP="cygwin";;
71 '') MACHDEP="unknown";;
76 # SGI compilers allow the specification of the both the ABI and the
77 # ISA on the command line. Depending on the values of these switches,
78 # different and often incompatable code will be generated.
80 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
81 # thus supply support for various ABI/ISA combinations. The MACHDEP
82 # variable is also adjusted.
85 if test ! -z "$SGI_ABI"
88 LDFLAGS="$SGI_ABI $LDFLAGS"
89 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
91 AC_MSG_RESULT($MACHDEP)
93 # checks for alternative programs
94 AC_MSG_CHECKING(for --without-gcc)
95 AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
102 without_gcc=$withval;;
104 case $ac_sys_system in
112 OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
113 CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
114 LDFLAGS="$LDFLAGS -nodup"
122 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
125 AR="\$(srcdir)/Modules/ar_beos"
133 AC_MSG_RESULT($without_gcc)
138 AC_MSG_CHECKING(for --with-cxx=<compiler>)
139 AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
151 AC_MSG_RESULT($with_cxx)
153 dnl The following fragment works similar to AC_PROG_CXX.
154 dnl It does not fail if CXX is not found, and it is not executed if
155 dnl --with-cxx was given.
156 dnl Finally, it does not test whether CXX is g++.
158 if test "$check_cxx" = "yes"
160 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
161 if test "$CXX" = "notfound"
169 # If the user switches compilers, we can't believe the cache
170 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
172 AC_ERROR(cached CC is different -- throw away $cache_file
173 (it is also a good idea to do 'make clean' before compiling))
178 # checks for UNIX variants that set C preprocessor variables
183 AC_MSG_CHECKING(for --with-suffix)
184 AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
190 AC_MSG_RESULT($EXEEXT)
191 # Test whether we're running on a non-case-sensitive system, in which
192 # case we give a warning if no ext is given
193 if test -d "python" -a -z "$EXEEXT"
195 AC_MSG_WARN(This filesystem is not case-sensitive so you should probably use --with-suffix)
201 gcc) CC="$CC -D_HAVE_BSDI";;
205 case $ac_sys_system in
208 cc|*/cc) CC="$CC -Ae";;
212 cc) CC="$CC -Wl,-Bexport";;
215 # Some functions have a prototype only with that define, e.g. confstr
216 AC_DEFINE(__EXTENSIONS__)
222 AC_MSG_CHECKING(LIBRARY)
223 if test -z "$LIBRARY"
225 LIBRARY='libpython$(VERSION).a'
227 AC_MSG_RESULT($LIBRARY)
229 # LDLIBRARY is the name of the library to link against (as opposed to the
230 # name of the library into which to insert object files). BLDLIBRARY is also
231 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
232 # is blank as the main program is not linked directly against LDLIBRARY.
233 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
234 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
235 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
236 # DLLLIBRARY is the shared (i.e., DLL) library.
241 AC_SUBST(LDLIBRARYDIR)
243 BLDLIBRARY='$(LDLIBRARY)'
247 # LINKCC is the command that links the python executable -- default is $(CC).
248 # This is altered for AIX in order to build the export list before
251 AC_MSG_CHECKING(LINKCC)
254 case $ac_sys_system in
256 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
258 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
260 LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
261 *) LINKCC="\$(PURIFY) \$(CC)";;
264 AC_MSG_RESULT($LINKCC)
266 AC_MSG_CHECKING(LDLIBRARY)
268 # DG/UX requires some fancy ld contortions to produce a .so from an .a
271 LDLIBRARY='libpython$(VERSION).so'
275 LDLIBRARY='libpython$(VERSION).so'
278 LDLIBRARY='libpython$(VERSION).dll.a'
279 DLLLIBRARY='libpython$(VERSION).dll'
283 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
284 # library that we build, but we do not want to link against it (we
285 # will find it with a -framework option). For this reason there is an
286 # extra variable BLDLIBRARY against which Python and the extension
287 # modules are linked, BLDLIBRARY. This is normally the same as
288 # LDLIBRARY, but empty for MacOSX framework builds.
289 if test "$enable_framework"
291 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
292 LDLIBRARYDIR='$(PYTHONFRAMEWORKDIR)'
295 BLDLIBRARY='$(LDLIBRARY)'
298 AC_MSG_RESULT($LDLIBRARY)
302 AC_CHECK_PROGS(AR, ar aal, ar)
306 # install -d does not work on BSDI
307 if test -z "$INSTALL"
309 INSTALL="${srcdir}/install-sh -c"
314 # Not every filesystem supports hard links
316 if test -z "$LN" ; then
317 case $ac_sys_system in
319 CYGWIN*) LN="ln -s";;
324 # Check for --with-pydebug
325 AC_MSG_CHECKING(for --with-pydebug)
327 [ --with-pydebug build with Py_DEBUG defined], [
328 if test "$withval" != no
329 then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes); Py_DEBUG='true'
330 else AC_MSG_RESULT(no); Py_DEBUG='false'
334 # Optimizer/debugger flags
340 case $ac_cv_prog_cc_g in
342 if test "$Py_DEBUG" = 'true' ; then
343 # Optimization messes up debuggers, so turn it off for
345 OPT="-g -Wall -Wstrict-prototypes"
347 OPT="-g -O3 -Wall -Wstrict-prototypes"
350 OPT="-O3 -Wall -Wstrict-prototypes";;
354 case $ac_sys_system in
356 OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
361 case $ac_sys_system in
363 OPT="$OPT -no-cpp-precomp";;
367 # The current (beta) Monterey compiler dies with optimizations
368 case $ac_sys_system in
372 if test "$ac_arch_flags"
374 OPT="$OPT $ac_arch_flags"
377 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
378 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
380 CC="$CC -OPT:Olimit=0"
381 AC_TRY_RUN([int main() { return 0; }],
382 ac_cv_opt_olimit_ok=yes,
383 ac_cv_opt_olimit_ok=no,
384 ac_cv_opt_olimit_ok=no)
386 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
387 if test $ac_cv_opt_olimit_ok = yes; then
388 case $ac_sys_system in
389 Darwin*) OPT="$OPT" ;;
390 *) OPT="$OPT -OPT:Olimit=0";;
393 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
394 AC_CACHE_VAL(ac_cv_olimit_ok,
396 CC="$CC -Olimit 1500"
397 AC_TRY_RUN([int main() { return 0; }],
402 AC_MSG_RESULT($ac_cv_olimit_ok)
403 if test $ac_cv_olimit_ok = yes; then
404 OPT="$OPT -Olimit 1500"
408 # -Kpthread, if available, provides the right #defines
409 # and linker options to make pthread_create available
410 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
411 AC_CACHE_VAL(ac_cv_kpthread,
414 AC_TRY_LINK([#include <pthread.h>],[pthread_create(0,0,0,0)],
419 # GCC does not reject -Kpthread as an illegal option, it merely complains that
421 if test "$GCC" = "yes"
422 then ac_cv_kpthread="no, we have gcc"
424 AC_MSG_RESULT($ac_cv_kpthread)
426 dnl # check for ANSI or K&R ("traditional") preprocessor
427 dnl AC_MSG_CHECKING(for C preprocessor type)
429 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
431 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
432 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
433 dnl AC_MSG_RESULT($cpp_type)
435 # checks for header files
437 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h langinfo.h locale.h \
438 ncurses.h poll.h pthread.h \
439 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
440 sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
441 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
442 sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
443 ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h)
446 # checks for typedefs
448 AC_MSG_CHECKING(for clock_t in time.h)
449 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
450 AC_MSG_RESULT($was_it_defined)
452 # Two defines needed to enable largefile support on various platforms
453 # These may affect some typedefs
454 AC_DEFINE(_LARGEFILE_SOURCE)
455 AC_DEFINE(_FILE_OFFSET_BITS, 64)
457 # Add some code to confdefs.h so that the test for off_t works on SCO
458 cat >> confdefs.h <<\EOF
464 # Type availability checks
472 # Sizes of various common basic types
473 AC_CHECK_SIZEOF(int, 4)
474 AC_CHECK_SIZEOF(long, 4)
475 AC_CHECK_SIZEOF(void *, 4)
476 AC_CHECK_SIZEOF(char, 1)
477 AC_CHECK_SIZEOF(short, 2)
478 AC_CHECK_SIZEOF(float, 4)
479 AC_CHECK_SIZEOF(double, 8)
480 AC_CHECK_SIZEOF(fpos_t, 4)
482 AC_MSG_CHECKING(for long long support)
484 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
485 AC_MSG_RESULT($have_long_long)
486 if test "$have_long_long" = yes ; then
487 AC_CHECK_SIZEOF(long long, 8)
490 AC_MSG_CHECKING(for uintptr_t support)
492 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
493 AC_MSG_RESULT($have_uintptr_t)
494 if test "$have_uintptr_t" = yes ; then
495 AC_CHECK_SIZEOF(uintptr_t, 4)
498 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
499 AC_MSG_CHECKING(size of off_t)
500 AC_CACHE_VAL(ac_cv_sizeof_off_t,
501 [AC_TRY_RUN([#include <stdio.h>
502 #include <sys/types.h>
505 FILE *f=fopen("conftestval", "w");
507 fprintf(f, "%d\n", sizeof(off_t));
510 ac_cv_sizeof_off_t=`cat conftestval`,
511 ac_cv_sizeof_off_t=0,
512 ac_cv_sizeof_off_t=4)
514 AC_MSG_RESULT($ac_cv_sizeof_off_t)
515 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
517 AC_MSG_CHECKING(whether to enable large file support)
518 if test "$have_long_long" = yes -a \
519 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
520 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
521 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
527 # AC_CHECK_SIZEOF() doesn't include <time.h>.
528 AC_MSG_CHECKING(size of time_t)
529 AC_CACHE_VAL(ac_cv_sizeof_time_t,
530 [AC_TRY_RUN([#include <stdio.h>
534 FILE *f=fopen("conftestval", "w");
536 fprintf(f, "%d\n", sizeof(time_t));
539 ac_cv_sizeof_time_t=`cat conftestval`,
540 ac_cv_sizeof_time_t=0,
541 ac_cv_sizeof_time_t=4)
543 AC_MSG_RESULT($ac_cv_sizeof_time_t)
544 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
547 # if have pthread_t then define SIZEOF_PTHREAD_T
549 if test "$ac_cv_kpthread" = "yes"
550 then CC="$CC -Kpthread"
552 AC_MSG_CHECKING(for pthread_t)
554 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
555 AC_MSG_RESULT($have_pthread_t)
556 if test "$have_pthread_t" = yes ; then
557 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
558 AC_MSG_CHECKING(size of pthread_t)
559 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
560 [AC_TRY_RUN([#include <stdio.h>
564 FILE *f=fopen("conftestval", "w");
566 fprintf(f, "%d\n", sizeof(pthread_t));
569 ac_cv_sizeof_pthread_t=`cat conftestval`,
570 ac_cv_sizeof_pthread_t=0,
571 ac_cv_sizeof_pthread_t=4)
573 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
574 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
578 AC_MSG_CHECKING(for --enable-toolbox-glue)
579 AC_ARG_ENABLE(toolbox-glue,
580 [ --enable-toolbox-glue disable/enable MacOSX glue code for extensions])
582 if test -z "$enable_toolbox_glue"
584 case $ac_sys_system/$ac_sys_release in
586 enable_toolbox_glue="yes";;
588 enable_toolbox_glue="no";;
591 case "$enable_toolbox_glue" in
593 extra_frameworks="-framework Carbon -framework Foundation"
594 extra_machdep_objs="Python/mactoolboxglue.o"
595 extra_undefs="-u __dummy -u _PyMac_Error"
596 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE)
600 extra_machdep_objs=""
604 AC_MSG_RESULT($enable_toolbox_glue)
606 AC_SUBST(LIBTOOL_CRUFT)
607 case $ac_sys_system/$ac_sys_release in
609 ns_undef_sym='_environ'
610 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -flat_namespace -U $ns_undef_sym"
611 LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
612 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
613 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
615 ns_undef_sym='_environ'
616 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym"
617 LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
618 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
619 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
622 AC_MSG_CHECKING(for --enable-framework)
623 if test "$enable_framework"
625 OPT="$OPT -fno-common -dynamic"
626 # -U __environ is needed since bundles don't have access
627 # to crt0 when built but will always be linked against it
628 # -F. is needed to allow linking to the framework while
629 # in the build location.
631 case $ac_sys_system/$ac_sys_release in
632 Darwin/1.4*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-flat_namespace,-U,$ns_undef_sym";;
633 Darwin/*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-U,$ns_undef_sym";;
635 AC_DEFINE(WITH_NEXT_FRAMEWORK)
641 AC_MSG_CHECKING(for dyld)
642 case $ac_sys_system/$ac_sys_release in
645 AC_MSG_RESULT(always on for Darwin)
652 # Set info about shared libraries.
657 AC_SUBST(LINKFORSHARED)
658 # SO is the extension of shared libraries `(including the dot!)
659 # -- usually .so, .sl on HP-UX, .dll on Cygwin
663 case $ac_sys_system in
670 # LDSHARED is the ld *command* used to create shared library
671 # -- "ld" on SunOS 4.x.x, "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
672 # (Shared libraries in this instance are shared modules to be loaded into
673 # Python, as opposed to building Python itself as a shared library.)
674 AC_MSG_CHECKING(LDSHARED)
675 if test -z "$LDSHARED"
677 case $ac_sys_system/$ac_sys_release in
679 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
680 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
683 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
684 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
686 IRIX/5*) LDSHARED="ld -shared";;
687 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
688 SunOS/4*) LDSHARED="ld";;
690 if test "$GCC" = "yes"
691 then LDSHARED='$(CC) -shared'
692 else LDSHARED="$(CC) -G";
694 hp*|HP*) LDSHARED="ld -b";;
695 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
696 DYNIX/ptx*) LDSHARED="ld -G";;
698 LDSHARED='$(CC) $(LDFLAGS) -bundle'
699 if test "$enable_framework" ; then
700 # Link against the framework. All externals should be defined.
701 LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
703 # No framework. Ignore undefined symbols, assuming they come from Python
704 LDSHARED="$LDSHARED -flat_namespace -undefined suppress"
707 LDSHARED='$(CC) $(LDFLAGS) -bundle'
708 if test "$enable_framework" ; then
709 # Link against the framework. All externals should be defined.
710 LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
712 # No framework. Ignore undefined symbols, assuming they come from Python
713 LDSHARED="$LDSHARED -undefined suppress"
715 Linux*) LDSHARED="gcc -shared";;
716 dgux*) LDSHARED="ld -G";;
717 BSD/OS*/4*) LDSHARED="gcc -shared";;
718 OpenBSD*|NetBSD*|FreeBSD*)
719 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
721 LDSHARED="cc -shared ${LDFLAGS}"
723 LDSHARED="ld -Bshareable ${LDFLAGS}"
726 if test "$GCC" = "yes"
727 then LDSHARED="$(CC) -shared"
728 else LDSHARED="$(CC) -G"
730 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
731 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
732 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
736 AC_MSG_RESULT($LDSHARED)
737 BLDSHARED=${BLDSHARED-$LDSHARED}
738 # CCSHARED are the C *flags* used to create objects to go into a shared
739 # library (module) -- this is only needed for a few systems
740 AC_MSG_CHECKING(CCSHARED)
741 if test -z "$CCSHARED"
743 case $ac_sys_system/$ac_sys_release in
744 SunOS*) if test "$GCC" = yes;
745 then CCSHARED="-fPIC";
747 hp*|HP*) if test "$GCC" = yes;
748 then CCSHARED="-fPIC";
751 Linux*) CCSHARED="-fPIC";;
752 BSD/OS*/4*) CCSHARED="-fpic";;
753 FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
755 if test "$GCC" = "yes"
756 then CCSHARED="-fPIC"
757 else CCSHARED="-KPIC"
759 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
760 Monterey*) CCSHARED="-G";;
761 IRIX*/6*) case $CC in
762 *gcc*) CCSHARED="-shared";;
765 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
768 AC_MSG_RESULT($CCSHARED)
769 # LINKFORSHARED are the flags passed to the $(CC) command that links
770 # the python executable -- this is only needed for a few systems
771 AC_MSG_CHECKING(LINKFORSHARED)
772 if test -z "$LINKFORSHARED"
774 case $ac_sys_system/$ac_sys_release in
775 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
777 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
778 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
779 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
780 # -u libsys_s pulls in all symbols in libsys
782 # -u __dummy makes the linker aware of the objc runtime
783 # in System.framework; otherwise, __objcInit (referenced in
784 # crt1.o) gets erroneously defined as common, which breaks dynamic
785 # loading of any modules which reference it in System.framework.
786 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
787 # not used by the core itself but which needs to be in the core so
788 # that dynamically loaded extension modules have access to it.
789 LINKFORSHARED="$extra_undefs -framework System"
790 if test "$enable_framework"
792 LINKFORSHARED="$LINKFORSHARED -framework Python"
794 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
795 UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
796 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
797 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
798 FreeBSD*|NetBSD*|OpenBSD*)
799 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
801 LINKFORSHARED="-Wl,--export-dynamic"
803 SunOS/5*) case $CC in
805 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
807 LINKFORSHARED="-Xlinker --export-dynamic"
812 AC_MSG_RESULT($LINKFORSHARED)
814 AC_SUBST(CFLAGSFORSHARED)
815 AC_MSG_CHECKING(CFLAGSFORSHARED)
816 if test ! "$LIBRARY" = "$LDLIBRARY"
818 case $ac_sys_system in
820 # Cygwin needs CCSHARED when building extension DLLs
821 # but not when building the interpreter DLL.
824 CFLAGSFORSHARED='$(CCSHARED)'
827 AC_MSG_RESULT($CFLAGSFORSHARED)
829 # checks for libraries
830 AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
831 AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
833 # checks for system dependent C++ extensions support
834 case "$ac_sys_system" in
835 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
836 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
837 [loadAndInit("", 0, "")],
838 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
840 [AC_MSG_RESULT(no)]);;
844 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
845 # However on SGI IRIX, these exist but are broken.
846 # BeOS' sockets are stashed in libnet.
847 case "$ac_sys_system" in
850 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
851 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
854 case "$ac_sys_system" in
856 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
860 AC_MSG_CHECKING(for --with-libs)
862 [ --with-libs='lib1 ...' link against additional libs], [
863 AC_MSG_RESULT($withval)
864 LIBS="$withval $LIBS"
865 ], AC_MSG_RESULT(no))
867 # Determine if signalmodule should be used.
868 AC_SUBST(USE_SIGNAL_MODULE)
869 AC_SUBST(SIGNAL_OBJS)
870 AC_MSG_CHECKING(for --with-signal-module)
871 AC_ARG_WITH(signal-module,
872 [ --with-signal-module disable/enable signal module])
874 if test -z "$with_signal_module"
875 then with_signal_module="yes"
877 AC_MSG_RESULT($with_signal_module)
879 if test "${with_signal_module}" = "yes"; then
883 USE_SIGNAL_MODULE="#"
884 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
887 # This is used to generate Setup.config
888 AC_SUBST(USE_THREAD_MODULE)
891 AC_MSG_CHECKING(for --with-dec-threads)
893 AC_ARG_WITH(dec-threads,
894 [ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
895 AC_MSG_RESULT($withval)
897 if test "${with_thread+set}" != set; then
898 with_thread="$withval";
902 AC_MSG_CHECKING(for --with-threads)
904 [ --with(out)-threads[=DIRECTORY] disable/enable thread support])
906 # --with-thread is deprecated, but check for it anyway
908 [ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
909 with_threads=$with_thread])
911 if test -z "$with_threads"
912 then with_threads="yes"
914 AC_MSG_RESULT($with_threads)
916 if test "$with_threads" = "no"
918 USE_THREAD_MODULE="#"
919 elif test "$ac_cv_kpthread" = "yes"
922 AC_DEFINE(WITH_THREAD)
923 AC_DEFINE(_POSIX_THREADS)
925 LIBOBJS="$LIBOBJS thread.o"
927 if test ! -z "$with_threads" -a -d "$with_threads"
928 then LDFLAGS="$LDFLAGS -L$with_threads"
930 if test ! -z "$withval" -a -d "$withval"
931 then LDFLAGS="$LDFLAGS -L$withval"
933 AC_DEFINE(_REENTRANT)
934 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
936 LIBOBJS="$LIBOBJS thread.o"],[
937 AC_MSG_CHECKING(for --with-pth)
939 [ --with-pth use GNU pth threading libraries], [
940 AC_MSG_RESULT($withval)
941 AC_DEFINE(WITH_THREAD)
944 LIBOBJS="$LIBOBJS thread.o"],[
946 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
947 case $ac_sys_system in
949 *) AC_DEFINE(_POSIX_THREADS)
953 LIBS="-lpthread $LIBS"
954 LIBOBJS="$LIBOBJS thread.o"],[
955 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
956 case $ac_sys_system in
958 *) AC_DEFINE(_POSIX_THREADS)
962 LIBOBJS="$LIBOBJS thread.o"],[
963 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
964 AC_DEFINE(BEOS_THREADS)
965 LIBOBJS="$LIBOBJS thread.o"],[
966 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
967 AC_DEFINE(_POSIX_THREADS)
969 LIBS="$LIBS -lpthreads"
970 LIBOBJS="$LIBOBJS thread.o"], [
971 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
972 AC_DEFINE(_POSIX_THREADS)
975 LIBOBJS="$LIBOBJS thread.o"], [
976 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
977 AC_DEFINE(_POSIX_THREADS)
979 LIBS="$LIBS -lthread"
980 LIBOBJS="$LIBOBJS thread.o"], [
981 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
982 AC_DEFINE(_POSIX_THREADS)
984 LIBS="$LIBS -lpthread"
985 LIBOBJS="$LIBOBJS thread.o"], [
986 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
987 AC_DEFINE(_POSIX_THREADS)
990 LIBOBJS="$LIBOBJS thread.o"],[
991 USE_THREAD_MODULE="#"])
994 if test "$posix_threads" = "yes"; then
995 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
996 AC_CACHE_VAL(ac_cv_pthread_system_supported,
997 [AC_TRY_RUN([#include <pthread.h>
998 void *foo(void *parm) {
1002 pthread_attr_t attr;
1003 if (pthread_attr_init(&attr)) exit(-1);
1004 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
1005 if (pthread_create(NULL, &attr, foo, NULL)) exit(-1);
1008 ac_cv_pthread_system_supported=yes,
1009 ac_cv_pthread_system_supported=no,
1010 ac_cv_pthread_system_supported=no)
1012 AC_MSG_RESULT($ac_cv_pthread_system_supported)
1013 if test "$ac_cv_pthread_system_supported" = "yes"; then
1014 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED)
1018 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1020 LIBOBJS="$LIBOBJS thread.o"
1021 USE_THREAD_MODULE=""])
1022 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1023 LIBS="$LIBS -lthread"
1024 LIBOBJS="$LIBOBJS thread.o"
1025 USE_THREAD_MODULE=""])
1027 if test "$USE_THREAD_MODULE" != "#"
1029 # If the above checks didn't disable threads, (at least) OSF1
1030 # needs this '-threads' argument during linking.
1031 case $ac_sys_system in
1032 OSF1) LDLAST=-threads;;
1037 # Check for enable-ipv6
1038 AC_MSG_CHECKING([if --enable-ipv6 is specified])
1040 [ --enable-ipv6 Enable ipv6 (with ipv4) support
1041 --disable-ipv6 Disable ipv6 support],
1042 [ case "$enableval" in
1047 *) AC_MSG_RESULT(yes)
1048 AC_DEFINE(ENABLE_IPV6)
1054 dnl the check does not work on cross compilation case...
1055 AC_TRY_RUN([ /* AF_INET6 available check */
1056 #include <sys/types.h>
1057 #include <sys/socket.h>
1060 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1074 if test "$ipv6" = "yes"; then
1075 AC_MSG_CHECKING(if RFC2553 API is available)
1076 AC_TRY_COMPILE([#include <sys/types.h>
1077 #include <netinet/in.h>],
1078 [struct sockaddr_in6 x;
1082 AC_MSG_RESULT(no, IPv6 disabled)
1086 if test "$ipv6" = "yes"; then
1087 AC_DEFINE(ENABLE_IPV6)
1095 if test "$ipv6" = "yes"; then
1096 AC_MSG_CHECKING([ipv6 stack type])
1097 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1101 dnl http://www.kame.net/
1102 AC_EGREP_CPP(yes, [dnl
1103 #include <netinet/in.h>
1104 #ifdef IPV6_INRIA_VERSION
1108 OPT="-DINET6 $OPT"])
1111 dnl http://www.kame.net/
1112 AC_EGREP_CPP(yes, [dnl
1113 #include <netinet/in.h>
1119 ipv6libdir=/usr/local/v6/lib
1121 OPT="-DINET6 $OPT"])
1124 dnl http://www.v6.linux.or.jp/
1125 AC_EGREP_CPP(yes, [dnl
1126 #include <features.h>
1127 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1132 OPT="-DINET6 $OPT"])
1135 dnl http://www.v6.linux.or.jp/
1136 if test -d /usr/inet6; then
1139 ipv6libdir=/usr/inet6/lib
1140 OPT="-DINET6 -I/usr/inet6/include $OPT"
1144 if test -f /etc/netconfig; then
1145 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1153 AC_EGREP_CPP(yes, [dnl
1154 #include <sys/param.h>
1155 #ifdef _TOSHIBA_INET6
1160 ipv6libdir=/usr/local/v6/lib;
1161 OPT="-DINET6 $OPT"])
1164 AC_EGREP_CPP(yes, [dnl
1165 #include </usr/local/v6/include/sys/v6config.h>
1171 ipv6libdir=/usr/local/v6/lib;
1172 OPT="-I/usr/local/v6/include $OPT"])
1175 AC_EGREP_CPP(yes, [dnl
1176 #include <sys/param.h>
1177 #ifdef _ZETA_MINAMI_INET6
1182 ipv6libdir=/usr/local/v6/lib;
1183 OPT="-DINET6 $OPT"])
1186 if test "$ipv6type" != "unknown"; then
1190 AC_MSG_RESULT($ipv6type)
1193 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1194 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1195 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1196 echo "using lib$ipv6lib"
1198 if test $ipv6trylibc = "yes"; then
1201 echo 'Fatal: no $ipv6lib library found. cannot continue.'
1202 echo "You need to fetch lib$ipv6lib.a from appropriate"
1203 echo 'ipv6 kit and compile beforehand.'
1209 # Check for GC support
1210 AC_MSG_CHECKING(for --with-cycle-gc)
1211 AC_ARG_WITH(cycle-gc,
1212 [ --with(out)-cycle-gc disable/enable garbage collection])
1214 if test -z "$with_cycle_gc"
1215 then with_cycle_gc="yes"
1217 if test "$with_cycle_gc" != "no"
1219 AC_DEFINE(WITH_CYCLE_GC)
1221 AC_MSG_RESULT($with_cycle_gc)
1223 # Check for Python-specific malloc support
1224 AC_MSG_CHECKING(for --with-pymalloc)
1225 AC_ARG_WITH(pymalloc,
1226 [ --with(out)-pymalloc disable/enable specialized mallocs], [
1227 if test "$withval" != no
1228 then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
1229 else AC_MSG_RESULT(no)
1231 [AC_MSG_RESULT(no)])
1233 # Check for --with-wctype-functions
1234 AC_MSG_CHECKING(for --with-wctype-functions)
1235 AC_ARG_WITH(wctype-functions,
1236 [ --with-wctype-functions use wctype.h functions], [
1237 if test "$withval" != no
1238 then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
1239 else AC_MSG_RESULT(no)
1241 [AC_MSG_RESULT(no)])
1243 # -I${DLINCLDIR} is added to the compile rule for importdl.o
1247 AC_MSG_CHECKING(for --with-sgi-dl)
1249 [ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
1250 AC_MSG_RESULT($withval)
1251 AC_DEFINE(WITH_SGI_DL)
1252 DYNLOADFILE="dynload_dl.o"
1254 if test ! -z "$dldir" -a -d "$dldir"
1255 then LDFLAGS="$LDFLAGS -L$dldir"
1256 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1259 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
1261 AC_MSG_CHECKING(for --with-dl-dld)
1262 AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
1263 AC_MSG_RESULT($withval)
1264 AC_DEFINE(WITH_DL_DLD)
1265 DYNLOADFILE="dynload_dl.o"
1266 dldir=`echo "$withval" | sed 's/,.*//'`
1267 dlddir=`echo "$withval" | sed 's/.*,//'`
1268 if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
1269 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
1270 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1273 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
1275 # the dlopen() function means we might want to use dynload_shlib.o. some
1276 # platforms, such as AIX, have dlopen(), but don't want to use it.
1277 AC_CHECK_FUNCS(dlopen)
1279 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1280 # loading of modules.
1281 AC_SUBST(DYNLOADFILE)
1282 AC_MSG_CHECKING(DYNLOADFILE)
1283 if test -z "$DYNLOADFILE"
1285 case $ac_sys_system/$ac_sys_release in
1286 AIX*) DYNLOADFILE="dynload_aix.o";;
1287 BeOS*) DYNLOADFILE="dynload_beos.o";;
1288 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
1289 Darwin/*) DYNLOADFILE="dynload_next.o";;
1291 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1292 # out any dynamic loading
1293 if test "$ac_cv_func_dlopen" = yes
1294 then DYNLOADFILE="dynload_shlib.o"
1295 else DYNLOADFILE="dynload_stub.o"
1300 AC_MSG_RESULT($DYNLOADFILE)
1301 if test "$DYNLOADFILE" != "dynload_stub.o"
1303 AC_DEFINE(HAVE_DYNAMIC_LOADING)
1306 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
1308 AC_SUBST(MACHDEP_OBJS)
1309 AC_MSG_CHECKING(MACHDEP_OBJS)
1310 if test -z "$MACHDEP_OBJS"
1312 MACHDEP_OBJS=$extra_machdep_objs
1314 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
1316 AC_MSG_RESULT(MACHDEP_OBJS)
1318 # checks for library functions
1319 AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
1320 flock fork fsync fdatasync fpathconf ftime ftruncate \
1321 gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
1322 hstrerror inet_pton kill link lstat mkfifo mktime mremap \
1323 nice pathconf pause plock poll pthread_init \
1325 select setegid seteuid setgid \
1326 setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
1327 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
1328 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
1329 truncate uname waitpid _getpty getpriority)
1331 # check for openpty and forkpty
1333 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1334 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1336 # check for long file support functions
1337 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1339 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
1340 AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1341 AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1342 AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
1344 AC_CHECK_FUNCS(getaddrinfo, [dnl
1345 AC_MSG_CHECKING(getaddrinfo bug)
1347 #include <sys/types.h>
1350 #include <sys/socket.h>
1351 #include <netinet/in.h>
1355 int passive, gaierr, inet4 = 0, inet6 = 0;
1356 struct addrinfo hints, *ai, *aitop;
1357 char straddr[INET6_ADDRSTRLEN], strport[16];
1359 for (passive = 0; passive <= 1; passive++) {
1360 memset(&hints, 0, sizeof(hints));
1361 hints.ai_family = AF_UNSPEC;
1362 hints.ai_flags = passive ? AI_PASSIVE : 0;
1363 hints.ai_socktype = SOCK_STREAM;
1364 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1365 (void)gai_strerror(gaierr);
1368 for (ai = aitop; ai; ai = ai->ai_next) {
1369 if (ai->ai_addr == NULL ||
1370 ai->ai_addrlen == 0 ||
1371 getnameinfo(ai->ai_addr, ai->ai_addrlen,
1372 straddr, sizeof(straddr), strport, sizeof(strport),
1373 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1376 switch (ai->ai_family) {
1378 if (strcmp(strport, "54321") != 0) {
1382 if (strcmp(straddr, "0.0.0.0") != 0) {
1386 if (strcmp(straddr, "127.0.0.1") != 0) {
1393 if (strcmp(strport, "54321") != 0) {
1397 if (strcmp(straddr, "::") != 0) {
1401 if (strcmp(straddr, "::1") != 0) {
1411 /* another family support? */
1417 if (!(inet4 == 0 || inet4 == 2))
1419 if (!(inet6 == 0 || inet6 == 2))
1423 freeaddrinfo(aitop);
1428 freeaddrinfo(aitop);
1433 buggygetaddrinfo=no,
1434 AC_MSG_RESULT(buggy)
1435 buggygetaddrinfo=yes,
1436 AC_MSG_RESULT(buggy)
1437 buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
1439 if test "$buggygetaddrinfo" = "yes"; then
1440 if test "$ipv6" = "yes"; then
1441 echo 'Fatal: You must get working getaddrinfo() function.'
1442 echo ' or you can specify "--disable-ipv6"'.
1446 AC_CHECK_FUNCS(getnameinfo)
1448 # checks for structures
1453 AC_MSG_CHECKING(for time.h that defines altzone)
1454 AC_CACHE_VAL(ac_cv_header_time_altzone,
1455 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1456 ac_cv_header_time_altzone=yes,
1457 ac_cv_header_time_altzone=no)])
1458 AC_MSG_RESULT($ac_cv_header_time_altzone)
1459 if test $ac_cv_header_time_altzone = yes; then
1460 AC_DEFINE(HAVE_ALTZONE)
1464 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
1466 #include <sys/types.h>
1467 #include <sys/select.h>
1468 #include <sys/time.h>
1469 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1470 AC_MSG_RESULT($was_it_defined)
1472 AC_MSG_CHECKING(for addrinfo)
1473 AC_CACHE_VAL(ac_cv_struct_addrinfo,
1475 # include <netdb.h>],
1476 [struct addrinfo a],
1477 ac_cv_struct_addrinfo=yes,
1478 ac_cv_struct_addrinfo=no))
1479 AC_MSG_RESULT($ac_cv_struct_addrinfo)
1480 if test $ac_cv_struct_addrinfo = yes; then
1481 AC_DEFINE(HAVE_ADDRINFO)
1484 AC_MSG_CHECKING(for sockaddr_storage)
1485 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1487 # include <sys/types.h>
1488 # include <sys/socket.h>],
1489 [struct sockaddr_storage s],
1490 ac_cv_struct_sockaddr_storage=yes,
1491 ac_cv_struct_sockaddr_storage=no))
1492 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1493 if test $ac_cv_struct_sockaddr_storage = yes; then
1494 AC_DEFINE(HAVE_SOCKADDR_STORAGE)
1497 # checks for compiler characteristics
1503 AC_MSG_CHECKING(for working volatile)
1504 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1505 AC_MSG_RESULT($works)
1508 AC_MSG_CHECKING(for working signed char)
1509 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1510 AC_MSG_RESULT($works)
1513 AC_MSG_CHECKING(for prototypes)
1514 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1515 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
1516 AC_MSG_RESULT($have_prototypes)
1519 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
1522 int foo(int x, ...) {
1530 ], [return foo(10, "", 3.14);],
1531 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1532 AC_MSG_RESULT($works)
1534 if test "$have_prototypes" = yes; then
1536 AC_MSG_CHECKING(for bad exec* prototypes)
1537 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1538 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1539 AC_MSG_RESULT($bad_prototypes)
1542 # check if sockaddr has sa_len member
1543 AC_MSG_CHECKING(if sockaddr has sa_len member)
1544 AC_TRY_COMPILE([#include <sys/types.h>
1545 #include <sys/socket.h>],
1549 AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
1552 AC_MSG_CHECKING(for bad static forward)
1553 AC_CACHE_VAL(ac_cv_bad_static_forward,
1555 struct s { int a; int b; };
1556 static struct s foo;
1559 random = (int) &foo;
1562 static struct s foo = { 1, 2 };
1564 exit(!((int)&foo == foobar()));
1566 ac_cv_bad_static_forward=no,
1567 ac_cv_bad_static_forward=yes,
1568 ac_cv_bad_static_forward=no)])
1569 AC_MSG_RESULT($ac_cv_bad_static_forward)
1570 if test "$ac_cv_bad_static_forward" = yes
1572 AC_DEFINE(BAD_STATIC_FORWARD)
1576 AC_MSG_CHECKING(whether va_list is an array)
1578 #ifdef HAVE_STDARG_PROTOTYPES
1581 #include <varargs.h>
1583 ], [va_list list1, list2; list1 = list2;], ,
1584 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1585 AC_MSG_RESULT($va_list_is_array)
1587 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1588 AC_CHECK_FUNC(gethostbyname_r, [
1589 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1590 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1592 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1597 struct hostent *he, *res;
1602 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1604 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1605 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1609 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1619 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1621 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1622 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1626 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1632 struct hostent_data data;
1634 (void) gethostbyname_r(name, he, &data);
1636 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1637 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1646 AC_CHECK_FUNCS(gethostbyname)
1648 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1649 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1650 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
1651 AC_SUBST(HAVE_GETHOSTBYNAME_R)
1652 AC_SUBST(HAVE_GETHOSTBYNAME)
1654 # checks for system services
1657 # Linux requires this for correct f.p. operations
1658 AC_CHECK_FUNC(__fpu_control,
1660 [AC_CHECK_LIB(ieee, __fpu_control)
1663 # Check for --with-fpectl
1664 AC_MSG_CHECKING(for --with-fpectl)
1666 [ --with-fpectl enable SIGFPE catching], [
1667 if test "$withval" != no
1668 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1669 else AC_MSG_RESULT(no)
1671 [AC_MSG_RESULT(no)])
1673 # check for --with-libm=...
1675 case $ac_sys_system in
1680 AC_MSG_CHECKING(for --with-libm=STRING)
1681 AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
1682 if test "$withval" = no
1684 AC_MSG_RESULT(force LIBM empty)
1685 elif test "$withval" != yes
1687 AC_MSG_RESULT(set LIBM=\"$withval\")
1688 else AC_ERROR(proper usage is --with-libm=STRING)
1690 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
1692 # check for --with-libc=...
1694 AC_MSG_CHECKING(for --with-libc=STRING)
1695 AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
1696 if test "$withval" = no
1698 AC_MSG_RESULT(force LIBC empty)
1699 elif test "$withval" != yes
1701 AC_MSG_RESULT(set LIBC=\"$withval\")
1702 else AC_ERROR(proper usage is --with-libc=STRING)
1704 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
1706 # check for hypot() in math library
1709 AC_REPLACE_FUNCS(hypot)
1712 # check whether malloc(0) returns NULL or not
1713 AC_MSG_CHECKING(what malloc(0) returns)
1714 AC_CACHE_VAL(ac_cv_malloc_zero,
1715 [AC_TRY_RUN([#include <stdio.h>
1719 char *malloc(), *realloc();
1725 if (p == NULL) exit(1);
1727 if (p == NULL) exit(1);
1731 ac_cv_malloc_zero=nonnull,
1732 ac_cv_malloc_zero=null,
1733 ac_cv_malloc_zero=nonnull)]) # XXX arm cross-compile?
1734 AC_MSG_RESULT($ac_cv_malloc_zero)
1735 if test "$ac_cv_malloc_zero" = null
1737 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1741 AC_CHECK_HEADER(wchar.h,
1742 AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1746 # determine wchar_t size
1747 if test "$wchar_h" = yes
1749 AC_CHECK_SIZEOF(wchar_t, 4)
1752 AC_MSG_CHECKING(what type to use for unicode)
1753 AC_ARG_ENABLE(unicode,
1754 [ --enable-unicode[=ucs2,ucs4] Enable Unicode strings (default is yes)],,enable_unicode=yes)
1756 if test $enable_unicode = yes
1758 # Without any arguments, Py_UNICODE defaults to two-byte mode
1759 enable_unicode="ucs2"
1762 case "$enable_unicode" in
1763 ucs2) unicode_size="2"
1764 AC_DEFINE(Py_UNICODE_SIZE,2)
1766 ucs4) unicode_size="4"
1767 AC_DEFINE(Py_UNICODE_SIZE,4)
1771 AC_SUBST(UNICODE_OBJS)
1772 if test "$enable_unicode" = "no"
1775 AC_MSG_RESULT(not used)
1777 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
1778 AC_DEFINE(Py_USING_UNICODE)
1779 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
1781 PY_UNICODE_TYPE="wchar_t"
1782 AC_DEFINE(HAVE_USABLE_WCHAR_T)
1783 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
1784 elif test "$ac_cv_sizeof_short" = "$unicode_size"
1786 PY_UNICODE_TYPE="unsigned short"
1787 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
1788 elif test "$ac_cv_sizeof_long" = "$unicode_size"
1790 PY_UNICODE_TYPE="unsigned long"
1791 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
1793 PY_UNICODE_TYPE="no type found"
1795 AC_MSG_RESULT($PY_UNICODE_TYPE)
1798 # check for endianness
1801 # Check whether right shifting a negative integer extends the sign bit
1802 # or fills with zeros (like the Cray J90, according to Tim Peters).
1803 AC_MSG_CHECKING(whether right shift extends the sign bit)
1804 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
1808 exit(((-1)>>3 == -1) ? 0 : 1);
1811 ac_cv_rshift_extends_sign=yes,
1812 ac_cv_rshift_extends_sign=no,
1813 ac_cv_rshift_extends_sign=yes)])
1814 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1815 if test "$ac_cv_rshift_extends_sign" = no
1817 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1820 # check for getc_unlocked and related locking functions
1821 AC_MSG_CHECKING(for getc_unlocked() and friends)
1822 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1823 AC_TRY_LINK([#include <stdio.h>],[
1824 FILE *f = fopen("/dev/null", "r");
1828 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1829 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1830 if test "$ac_cv_have_getc_unlocked" = yes
1832 AC_DEFINE(HAVE_GETC_UNLOCKED)
1835 # check for readline 4.2
1836 AC_CHECK_LIB(readline, rl_completion_matches,
1837 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
1839 AC_MSG_CHECKING(for broken nice())
1840 AC_CACHE_VAL(ac_cv_broken_nice, [
1845 if (val1 != -1 && val1 == nice(2))
1850 ac_cv_broken_nice=yes,
1851 ac_cv_broken_nice=no,
1852 ac_cv_broken_nice=no)])
1853 AC_MSG_RESULT($ac_cv_broken_nice)
1854 if test "$ac_cv_broken_nice" = yes
1856 AC_DEFINE(HAVE_BROKEN_NICE)
1859 # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1860 # Add sys/socket.h to confdefs.h
1861 cat >> confdefs.h <<\EOF
1862 #ifdef HAVE_SYS_SOCKET_H
1863 #include <sys/socket.h>
1866 AC_CHECK_TYPE(socklen_t, int)
1868 # Add Python/ prefix to LIBOBJS
1871 for obj in $libobjs; do
1872 LIBOBJS="$LIBOBJS Python/$obj"
1875 #AC_MSG_CHECKING(for Modules/Setup)
1876 #if test ! -f Modules/Setup ; then
1877 # if test ! -d Modules ; then
1880 # cp "$srcdir/Modules/Setup.dist" Modules/Setup
1881 # AC_MSG_RESULT(creating)
1883 # AC_MSG_RESULT(already exists)
1887 SRCDIRS="Parser Grammar Objects Python Modules"
1888 AC_MSG_CHECKING(for build directories)
1889 for dir in $SRCDIRS; do
1890 if test ! -d $dir; then
1896 # generate output files
1897 AC_OUTPUT(Makefile.pre Modules/Setup.config)
1899 echo "creating Setup"
1900 if test ! -f Modules/Setup
1902 cp $srcdir/Modules/Setup.dist Modules/Setup
1905 echo "creating Setup.local"
1906 if test ! -f Modules/Setup.local
1908 echo "# Edit this file for local setup changes" >Modules/Setup.local
1911 echo "creating Makefile"
1912 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1913 -s Modules Modules/Setup.config \
1914 Modules/Setup.local Modules/Setup