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(config.h)
7 # Set VERSION so we only need to edit in one place (i.e., here)
11 # NEXTSTEP|MacOSX|Darwin stuff
12 if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
14 AC_MSG_CHECKING(for --with-next-archs)
15 AC_ARG_WITH(next-archs,
16 [ --with-next-archs='arch1 arch2 ..' build MAB binary], [
17 if test -n "$withval"; then
18 ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval`
19 # GCC does not currently support multi archs on the NeXT
22 AC_MSG_RESULT($with_next_archs)
23 ], [AC_MSG_RESULT(none: using `arch`)])
27 ac_sys_system=`uname -s`
28 if test "$ac_sys_system" = "Darwin" ; then
29 ac_sys_release=`uname -r`
31 set X `hostinfo | egrep '(NeXT Mach|Kernel Release).*:' | \
32 sed -e 's/://' -e 's/\./_/'` && \
33 ac_sys_system=next && ac_sys_release=$4
36 MACHDEP="$ac_sys_system$ac_sys_release"
40 AC_ARG_WITH(next-framework,
41 [ --with-next-framework Build (OpenStep|Rhapsody|MacOSX|Darwin) framework],,)
43 [ --with-dyld Use (OpenStep|Rhapsody|MacOSX|Darwin) dynamic linker],,)
45 # Set name for machine-dependent library files
47 AC_MSG_CHECKING(MACHDEP)
50 ac_sys_system=`uname -s`
51 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
52 ac_sys_release=`uname -v`
54 ac_sys_release=`uname -r`
56 ac_md_system=`echo $ac_sys_system |
57 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
58 ac_md_release=`echo $ac_sys_release |
59 tr -d '[/ ]' | sed 's/\..*//'`
60 MACHDEP="$ac_md_system$ac_md_release"
63 '') MACHDEP="unknown";;
68 # SGI compilers allow the specification of the both the ABI and the
69 # ISA on the command line. Depending on the values of these switches,
70 # different and often incompatable code will be generated.
72 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
73 # thus supply support for various ABI/ISA combinations. The MACHDEP
74 # variable is also adjusted.
77 if test ! -z "$SGI_ABI"
80 LDFLAGS="$SGI_ABI $LDFLAGS"
81 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
83 AC_MSG_RESULT($MACHDEP)
85 # checks for alternative programs
86 AC_MSG_CHECKING(for --without-gcc)
87 AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
94 without_gcc=$withval;;
96 case $ac_sys_system in
106 OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
107 CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
108 LDFLAGS="$LDFLAGS -nodup"
116 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
119 AR="\$(srcdir)/Modules/ar_beos"
127 AC_MSG_RESULT($without_gcc)
132 AC_MSG_CHECKING(for --with-cxx=<compiler>)
133 AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
145 AC_MSG_RESULT($with_cxx)
147 dnl The following fragment works similar to AC_PROG_CXX.
148 dnl It does not fail if CXX is not found, and it is not executed if
149 dnl --with-cxx was given.
150 dnl Finally, it does not test whether CXX is g++.
152 if test "$check_cxx" = "yes"
154 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
155 if test "$CXX" = "notfound"
163 # If the user switches compilers, we can't believe the cache
164 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
166 AC_ERROR(cached CC is different -- throw away $cache_file
167 (it is also a good idea to do 'make clean' before compiling))
172 AC_MSG_CHECKING(for --with-suffix)
173 AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
179 AC_MSG_RESULT($EXEEXT)
184 gcc) CC="$CC -D_HAVE_BSDI";;
188 case $ac_sys_system in
191 cc|*/cc) CC="$CC -Ae";;
195 cc) CC="$CC -Wl,-Bexport";;
198 # Some functions have a prototype only with that define, e.g. confstr
199 AC_DEFINE(__EXTENSIONS__)
205 AC_MSG_CHECKING(LIBRARY)
206 if test -z "$LIBRARY"
208 LIBRARY='libpython$(VERSION).a'
210 AC_MSG_RESULT($LIBRARY)
212 # LDLIBRARY is the name of the library to link against (as opposed to the
213 # name of the library into which to insert object files). On systems
214 # without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
215 # the Makefiles). On Cygwin LDLIBRARY is the import library, DLLLIBRARY is the
216 # shared (i.e., DLL) library.
222 # LINKCC is the command that links the python executable -- default is $(CC).
223 # This is altered for AIX in order to build the export list before
226 AC_MSG_CHECKING(LINKCC)
229 case $ac_sys_system in
231 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
233 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
235 LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
236 *) LINKCC="\$(PURIFY) \$(CC)";;
239 AC_MSG_RESULT($LINKCC)
241 AC_MSG_CHECKING(LDLIBRARY)
243 # NeXT framework builds require that the 'ar' library be converted into
244 # a bundle using libtool.
245 if test "$with_next_framework"
247 LDLIBRARY='libpython$(VERSION).dylib'
250 # DG/UX requires some fancy ld contortions to produce a .so from an .a
253 LDLIBRARY='libpython$(VERSION).so'
257 LDLIBRARY='libpython$(VERSION).so'
260 LDLIBRARY='libpython$(VERSION).dll.a'
261 DLLLIBRARY='libpython$(VERSION).dll'
264 AC_MSG_RESULT($LDLIBRARY)
268 AC_CHECK_PROGS(AR, ar aal, ar)
271 # Not every filesystem supports hard links
273 if test -z "$LN" ; then
274 case $ac_sys_system in
276 CYGWIN*) LN="ln -s";;
281 # Optimizer/debugger flags
287 case $ac_cv_prog_cc_g in
288 yes) OPT="-g -O2 -Wall -Wstrict-prototypes";;
289 *) OPT="-O2 -Wall -Wstrict-prototypes";;
296 # The current (beta) Monterey compiler dies with optimizations
297 case $ac_sys_system in
301 if test "$ac_arch_flags"
303 OPT="$OPT $ac_arch_flags"
305 # checks for UNIX variants that set C preprocessor variables
309 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
310 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
312 CC="$CC -OPT:Olimit=0"
313 AC_TRY_RUN([int main() { return 0; }],
314 ac_cv_opt_olimit_ok=yes,
315 ac_cv_opt_olimit_ok=no)
317 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
318 if test $ac_cv_opt_olimit_ok = yes; then
319 case $ac_sys_system in
320 Darwin*) OPT="$OPT" ;;
321 *) OPT="$OPT -OPT:Olimit=0";;
324 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
325 AC_CACHE_VAL(ac_cv_olimit_ok,
327 CC="$CC -Olimit 1500"
328 AC_TRY_RUN([int main() { return 0; }],
332 AC_MSG_RESULT($ac_cv_olimit_ok)
333 if test $ac_cv_olimit_ok = yes; then
334 OPT="$OPT -Olimit 1500"
338 dnl # check for ANSI or K&R ("traditional") preprocessor
339 dnl AC_MSG_CHECKING(for C preprocessor type)
341 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
343 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
344 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
345 dnl AC_MSG_RESULT($cpp_type)
347 # checks for header files
349 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
350 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
351 sys/audioio.h sys/file.h sys/lock.h db_185.h db.h \
352 sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \
353 sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
354 ndbm.h db1/ndbm.h gdbm/ndbm.h)
357 # checks for typedefs
359 AC_MSG_CHECKING(for clock_t in time.h)
360 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
361 AC_MSG_RESULT($was_it_defined)
363 # Add some code to confdefs.h so that the test for off_t works on SCO
364 cat >> confdefs.h <<\EOF
370 # Type availability checks
378 # Sizes of various common basic types
380 AC_CHECK_SIZEOF(long)
381 AC_CHECK_SIZEOF(void *)
382 AC_CHECK_SIZEOF(char)
383 AC_CHECK_SIZEOF(short)
384 AC_CHECK_SIZEOF(float)
385 AC_CHECK_SIZEOF(double)
386 AC_CHECK_SIZEOF(fpos_t)
388 AC_MSG_CHECKING(for long long support)
390 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
391 AC_MSG_RESULT($have_long_long)
392 if test "$have_long_long" = yes ; then
393 AC_CHECK_SIZEOF(long long)
396 AC_MSG_CHECKING(for uintptr_t support)
398 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
399 AC_MSG_RESULT($have_uintptr_t)
400 if test "$have_uintptr_t" = yes ; then
401 AC_CHECK_SIZEOF(uintptr_t)
404 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
405 AC_MSG_CHECKING(size of off_t)
406 AC_CACHE_VAL(ac_cv_sizeof_off_t,
407 [AC_TRY_RUN([#include <stdio.h>
408 #include <sys/types.h>
411 FILE *f=fopen("conftestval", "w");
413 fprintf(f, "%d\n", sizeof(off_t));
415 }], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
417 AC_MSG_RESULT($ac_cv_sizeof_off_t)
418 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
420 AC_MSG_CHECKING(whether to enable large file support)
421 if test "$have_long_long" = yes -a \
422 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
423 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
424 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
430 # AC_CHECK_SIZEOF() doesn't include <time.h>.
431 AC_MSG_CHECKING(size of time_t)
432 AC_CACHE_VAL(ac_cv_sizeof_time_t,
433 [AC_TRY_RUN([#include <stdio.h>
437 FILE *f=fopen("conftestval", "w");
439 fprintf(f, "%d\n", sizeof(time_t));
441 }], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
443 AC_MSG_RESULT($ac_cv_sizeof_time_t)
444 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
447 # if have pthread_t then define SIZEOF_PTHREAD_T
448 AC_MSG_CHECKING(for pthread_t)
450 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
451 AC_MSG_RESULT($have_pthread_t)
452 if test "$have_pthread_t" = yes ; then
453 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
454 AC_MSG_CHECKING(size of pthread_t)
455 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
456 [AC_TRY_RUN([#include <stdio.h>
460 FILE *f=fopen("conftestval", "w");
462 fprintf(f, "%d\n", sizeof(pthread_t));
464 }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
466 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
467 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
471 # Minor variations in building a framework between NextStep versions 4 and 5
472 AC_SUBST(LIBTOOL_CRUFT)
473 case $ac_sys_system/$ac_sys_release in
475 ns_undef_sym='_environ'
476 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym" ;;
478 ns_undef_sym='__environ'
479 LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
481 ns_undef_sym='_environ'
482 LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
485 AC_MSG_CHECKING(for --with-next-framework)
486 if test "$with_next_framework"
488 OPT="$OPT -fno-common"
489 # -U __environ is needed since bundles don't have access
490 # to crt0 when built but will always be linked against it
491 LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
492 AC_DEFINE(WITH_NEXT_FRAMEWORK)
498 AC_MSG_CHECKING(for --with-dyld)
499 if test "$with_next_framework" -o "$with_dyld"
505 AC_MSG_RESULT(required for framework build)
513 # Set info about shared libraries.
518 AC_SUBST(LINKFORSHARED)
519 # SO is the extension of shared libraries `(including the dot!)
520 # -- usually .so, .sl on HP-UX, .dll on Cygwin
524 case $ac_sys_system in
531 # LDSHARED is the ld *command* used to create shared library
532 # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
533 # (Shared libraries in this instance are shared modules to be loaded into
534 # Python, as opposed to building Python itself as a shared library.)
535 AC_MSG_CHECKING(LDSHARED)
536 if test -z "$LDSHARED"
538 case $ac_sys_system/$ac_sys_release in
540 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
541 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
544 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
545 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
547 IRIX/5*) LDSHARED="ld -shared";;
548 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
549 SunOS/4*) LDSHARED="ld";;
551 if test "$GCC" = "yes"
552 then LDSHARED='$(CC) -shared'
553 else LDSHARED="ld -G";
555 hp*|HP*) LDSHARED="ld -b";;
556 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
557 DYNIX/ptx*) LDSHARED="ld -G";;
560 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined suppress'
561 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
563 if test "$with_next_framework" ; then
564 LDSHARED="$LDSHARED \$(LDLIBRARY)"
566 Linux*) LDSHARED="gcc -shared";;
567 dgux*) LDSHARED="ld -G";;
568 BSD/OS*/4*) LDSHARED="gcc -shared";;
569 OpenBSD*) LDSHARED="ld -Bshareable";;
571 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
573 LDSHARED="cc -shared"
575 LDSHARED="ld -Bshareable"
578 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
580 LDSHARED="cc -shared ${LDFLAGS}"
582 LDSHARED="ld -Bshareable ${LDFLAGS}"
584 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
585 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
586 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
590 AC_MSG_RESULT($LDSHARED)
591 BLDSHARED=${BLDSHARED-$LDSHARED}
592 # CCSHARED are the C *flags* used to create objects to go into a shared
593 # library (module) -- this is only needed for a few systems
594 AC_MSG_CHECKING(CCSHARED)
595 if test -z "$CCSHARED"
597 case $ac_sys_system/$ac_sys_release in
598 SunOS*) if test "$GCC" = yes;
599 then CCSHARED="-fPIC";
601 hp*|HP*) if test "$GCC" = yes;
602 then CCSHARED="-fpic";
605 Linux*) CCSHARED="-fPIC";;
606 BSD/OS*/4*) CCSHARED="-fpic";;
607 OpenBSD*) CCSHARED="-fpic";;
608 FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
609 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
610 Monterey*) CCSHARED="-G";;
611 IRIX*/6*) case $CC in
612 *gcc*) CCSHARED="-shared";;
615 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
618 AC_MSG_RESULT($CCSHARED)
619 # LINKFORSHARED are the flags passed to the $(CC) command that links
620 # the python executable -- this is only needed for a few systems
621 AC_MSG_CHECKING(LINKFORSHARED)
622 if test -z "$LINKFORSHARED"
624 case $ac_sys_system/$ac_sys_release in
625 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
627 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
628 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
629 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
630 # -u libsys_s pulls in all symbols in libsys
631 next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
632 # -u __dummy makes the linker aware of the objc runtime
633 # in System.framework; otherwise, __objcInit (referenced in
634 # crt1.o) gets erroneously defined as common, which breaks dynamic
635 # loading of any modules which reference it in System.framework
636 next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
637 Darwin/*) LINKFORSHARED="-u __dummy -framework System -framework Foundation" ;;
638 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
639 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
641 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
643 LINKFORSHARED="-Wl,--export-dynamic"
645 SunOS/5*) case $CC in
647 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
649 LINKFORSHARED="-Xlinker --export-dynamic"
654 AC_MSG_RESULT($LINKFORSHARED)
656 AC_SUBST(CFLAGSFORSHARED)
657 AC_MSG_CHECKING(CFLAGSFORSHARED)
658 if test ! "$LIBRARY" = "$LDLIBRARY"
660 case $ac_sys_system in
662 # Cygwin needs CCSHARED when building extension DLLs
663 # but not when building the interpreter DLL.
666 CFLAGSFORSHARED='$(CCSHARED)'
669 AC_MSG_RESULT($CFLAGSFORSHARED)
671 # checks for libraries
672 AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
673 AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
675 # Check for --with-pydebug
676 AC_MSG_CHECKING(for --with-pydebug)
678 [ --with-pydebug build with Py_DEBUG defined], [
679 if test "$withval" != no
680 then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes)
681 else AC_MSG_RESULT(no)
685 # checks for system dependent C++ extensions support
686 case "$ac_sys_system" in
687 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
688 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
689 [loadAndInit("", 0, "")],
690 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
692 [AC_MSG_RESULT(no)]);;
696 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
697 # However on SGI IRIX, these exist but are broken.
698 # BeOS' sockets are stashed in libnet.
699 case "$ac_sys_system" in
702 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
703 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
706 case "$ac_sys_system" in
708 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
712 AC_MSG_CHECKING(for --with-libs)
714 [ --with-libs='lib1 ...' link against additional libs], [
715 AC_MSG_RESULT($withval)
716 LIBS="$withval $LIBS"
717 ], AC_MSG_RESULT(no))
719 # Determine if signalmodule should be used.
720 AC_SUBST(USE_SIGNAL_MODULE)
721 AC_SUBST(SIGNAL_OBJS)
722 AC_MSG_CHECKING(for --with-signal-module)
723 AC_ARG_WITH(signal-module,
724 [ --with-signal-module disable/enable signal module])
726 if test -z "$with_signal_module"
727 then with_signal_module="yes"
729 AC_MSG_RESULT($with_signal_module)
731 if test "${with_signal_module}" = "yes"; then
735 USE_SIGNAL_MODULE="#"
736 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
739 # This is used to generate Setup.config
740 AC_SUBST(USE_THREAD_MODULE)
743 AC_MSG_CHECKING(for --with-dec-threads)
745 AC_ARG_WITH(dec-threads,
746 [ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
747 AC_MSG_RESULT($withval)
749 if test "${with_thread+set}" != set; then
750 with_thread="$withval";
754 AC_MSG_CHECKING(for --with-threads)
756 [ --with(out)-threads[=DIRECTORY] disable/enable thread support])
758 # --with-thread is deprecated, but check for it anyway
760 [ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
761 with_threads=$with_thread])
763 if test -z "$with_threads"
764 then with_threads="yes"
766 AC_MSG_RESULT($with_threads)
768 if test "$with_threads" = "no"
770 USE_THREAD_MODULE="#"
772 if test ! -z "$with_threads" -a -d "$with_threads"
773 then LDFLAGS="$LDFLAGS -L$with_threads"
775 if test ! -z "$withval" -a -d "$withval"
776 then LDFLAGS="$LDFLAGS -L$withval"
778 AC_DEFINE(_REENTRANT)
779 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
781 LIBOBJS="$LIBOBJS thread.o"],[
782 AC_MSG_CHECKING(for --with-pth)
784 [ --with-pth use GNU pth threading libraries], [
785 AC_MSG_RESULT($withval)
786 AC_DEFINE(WITH_THREAD)
789 LIBOBJS="$LIBOBJS thread.o"],[
791 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
792 AC_DEFINE(_POSIX_THREADS)
793 LIBS="-lpthread $LIBS"
794 LIBOBJS="$LIBOBJS thread.o"],[
795 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
796 case $ac_sys_system in
798 *) AC_DEFINE(_POSIX_THREADS);;
800 LIBOBJS="$LIBOBJS thread.o"],[
801 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
802 AC_DEFINE(BEOS_THREADS)
803 LIBOBJS="$LIBOBJS thread.o"],[
804 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
805 AC_DEFINE(_POSIX_THREADS)
806 LIBS="$LIBS -lpthreads"
807 LIBOBJS="$LIBOBJS thread.o"], [
808 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
809 AC_DEFINE(_POSIX_THREADS)
811 LIBOBJS="$LIBOBJS thread.o"], [
812 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
813 AC_DEFINE(_POSIX_THREADS)
814 LIBS="$LIBS -lthread"
815 LIBOBJS="$LIBOBJS thread.o"], [
816 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
817 AC_DEFINE(_POSIX_THREADS)
818 LIBS="$LIBS -lpthread"
819 LIBOBJS="$LIBOBJS thread.o"], [
820 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
821 AC_DEFINE(_POSIX_THREADS)
823 LIBOBJS="$LIBOBJS thread.o"],[
824 USE_THREAD_MODULE="#"])
827 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
829 LIBOBJS="$LIBOBJS thread.o"
830 USE_THREAD_MODULE=""])
831 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
832 LIBS="$LIBS -lthread"
833 LIBOBJS="$LIBOBJS thread.o"
834 USE_THREAD_MODULE=""])
836 if test "$USE_THREAD_MODULE" != "#"
838 # If the above checks didn't disable threads, (at least) OSF1
839 # needs this '-threads' argument during linking.
840 case $ac_sys_system in
841 OSF1) LDLAST=-threads;;
846 # Check for GC support
847 AC_SUBST(USE_GC_MODULE)
849 AC_MSG_CHECKING(for --with-cycle-gc)
850 AC_ARG_WITH(cycle-gc,
851 [ --with(out)-cycle-gc disable/enable garbage collection])
853 if test -z "$with_cycle_gc"
854 then with_cycle_gc="yes"
856 if test "$with_cycle_gc" = "no"
860 AC_DEFINE(WITH_CYCLE_GC)
862 AC_MSG_RESULT($with_cycle_gc)
864 # Check for Python-specific malloc support
865 AC_MSG_CHECKING(for --with-pymalloc)
866 AC_ARG_WITH(pymalloc,
867 [ --with(out)-pymalloc disable/enable specialized mallocs], [
868 if test "$withval" != no
869 then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
870 else AC_MSG_RESULT(no)
874 # Check for --with-wctype-functions
875 AC_MSG_CHECKING(for --with-wctype-functions)
876 AC_ARG_WITH(wctype-functions,
877 [ --with-wctype-functions use wctype.h functions], [
878 if test "$withval" != no
879 then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
880 else AC_MSG_RESULT(no)
884 # -I${DLINCLDIR} is added to the compile rule for importdl.o
888 AC_MSG_CHECKING(for --with-sgi-dl)
890 [ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
891 AC_MSG_RESULT($withval)
892 AC_DEFINE(WITH_SGI_DL)
893 DYNLOADFILE="dynload_dl.o"
895 if test ! -z "$dldir" -a -d "$dldir"
896 then LDFLAGS="$LDFLAGS -L$dldir"
897 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
900 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
902 AC_MSG_CHECKING(for --with-dl-dld)
903 AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
904 AC_MSG_RESULT($withval)
905 AC_DEFINE(WITH_DL_DLD)
906 DYNLOADFILE="dynload_dl.o"
907 dldir=`echo "$withval" | sed 's/,.*//'`
908 dlddir=`echo "$withval" | sed 's/.*,//'`
909 if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
910 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
911 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
914 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
916 # the dlopen() function means we might want to use dynload_shlib.o. some
917 # platforms, such as AIX, have dlopen(), but don't want to use it.
918 AC_CHECK_FUNCS(dlopen)
920 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
921 # loading of modules.
922 AC_SUBST(DYNLOADFILE)
923 AC_MSG_CHECKING(DYNLOADFILE)
924 if test -z "$DYNLOADFILE"
926 case $ac_sys_system/$ac_sys_release in
927 AIX*) DYNLOADFILE="dynload_aix.o";;
928 BeOS*) DYNLOADFILE="dynload_beos.o";;
929 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
930 Darwin/*|next/*) DYNLOADFILE="dynload_next.o";;
932 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
933 # out any dynamic loading
934 if test "$ac_cv_func_dlopen" = yes
935 then DYNLOADFILE="dynload_shlib.o"
936 else DYNLOADFILE="dynload_stub.o"
941 AC_MSG_RESULT($DYNLOADFILE)
942 if test "$DYNLOADFILE" != "dynload_stub.o"
944 AC_DEFINE(HAVE_DYNAMIC_LOADING)
947 # checks for library functions
948 AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
949 flock fork fsync fdatasync fpathconf ftime ftruncate \
950 getgroups getlogin getpeername getpid getpwent getwd \
951 kill link lstat mkfifo mktime mremap \
952 nice pathconf pause plock poll pthread_init \
954 select setegid seteuid setgid \
955 setlocale setregid setreuid setsid setpgid setuid setvbuf \
956 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
957 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
958 truncate uname waitpid _getpty)
960 # check for openpty and forkpty
962 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
963 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
965 # check for long file support functions
966 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
968 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
969 AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
970 AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
971 AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
973 # checks for structures
978 AC_MSG_CHECKING(for time.h that defines altzone)
979 AC_CACHE_VAL(ac_cv_header_time_altzone,
980 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
981 ac_cv_header_time_altzone=yes,
982 ac_cv_header_time_altzone=no)])
983 AC_MSG_RESULT($ac_cv_header_time_altzone)
984 if test $ac_cv_header_time_altzone = yes; then
985 AC_DEFINE(HAVE_ALTZONE)
989 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
991 #include <sys/types.h>
992 #include <sys/select.h>
993 #include <sys/time.h>
994 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
995 AC_MSG_RESULT($was_it_defined)
997 # checks for compiler characteristics
1003 AC_MSG_CHECKING(for working volatile)
1004 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1005 AC_MSG_RESULT($works)
1008 AC_MSG_CHECKING(for working signed char)
1009 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1010 AC_MSG_RESULT($works)
1013 AC_MSG_CHECKING(for prototypes)
1014 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1015 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
1016 AC_MSG_RESULT($have_prototypes)
1019 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
1022 int foo(int x, ...) {
1030 ], [return foo(10, "", 3.14);],
1031 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1032 AC_MSG_RESULT($works)
1034 if test "$have_prototypes" = yes; then
1036 AC_MSG_CHECKING(for bad exec* prototypes)
1037 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1038 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1039 AC_MSG_RESULT($bad_prototypes)
1043 AC_MSG_CHECKING(for bad static forward)
1045 struct s { int a; int b; };
1046 static struct s foo;
1049 random = (int) &foo;
1052 static struct s foo = { 1, 2 };
1054 exit(!((int)&foo == foobar()));
1056 ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
1057 AC_MSG_RESULT($bad_forward)
1060 AC_MSG_CHECKING(whether va_list is an array)
1062 #ifdef HAVE_STDARG_PROTOTYPES
1065 #include <varargs.h>
1067 ], [va_list list1, list2; list1 = list2;], ,
1068 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1069 AC_MSG_RESULT($va_list_is_array)
1071 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1072 AC_CHECK_FUNC(gethostbyname_r, [
1073 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1074 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1076 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1081 struct hostent *he, *res;
1086 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1088 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1089 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1093 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1103 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1105 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1106 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1110 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1116 struct hostent_data data;
1118 (void) gethostbyname_r(name, he, &data);
1120 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1121 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1130 AC_CHECK_FUNCS(gethostbyname)
1132 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1133 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1134 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
1135 AC_SUBST(HAVE_GETHOSTBYNAME_R)
1136 AC_SUBST(HAVE_GETHOSTBYNAME)
1138 # checks for system services
1141 # Linux requires this for correct f.p. operations
1142 AC_CHECK_FUNC(__fpu_control,
1144 [AC_CHECK_LIB(ieee, __fpu_control)
1147 # Check for --with-fpectl
1148 AC_MSG_CHECKING(for --with-fpectl)
1150 [ --with-fpectl enable SIGFPE catching], [
1151 if test "$withval" != no
1152 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1153 else AC_MSG_RESULT(no)
1155 [AC_MSG_RESULT(no)])
1157 # check for --with-libm=...
1159 case $ac_sys_system in
1165 AC_MSG_CHECKING(for --with-libm=STRING)
1166 AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
1167 if test "$withval" = no
1169 AC_MSG_RESULT(force LIBM empty)
1170 elif test "$withval" != yes
1172 AC_MSG_RESULT(set LIBM=\"$withval\")
1173 else AC_ERROR(proper usage is --with-libm=STRING)
1175 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
1177 # check for --with-libc=...
1179 AC_MSG_CHECKING(for --with-libc=STRING)
1180 AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
1181 if test "$withval" = no
1183 AC_MSG_RESULT(force LIBC empty)
1184 elif test "$withval" != yes
1186 AC_MSG_RESULT(set LIBC=\"$withval\")
1187 else AC_ERROR(proper usage is --with-libc=STRING)
1189 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
1191 # check for --with-check-import-case
1192 AC_ARG_WITH(check-import-case,
1193 [ --with-check-import-case enable imported module name case checking],,)
1194 AC_MSG_CHECKING(for --with-check-import-case)
1195 if test "$with_check_import_case"
1197 AC_DEFINE(CHECK_IMPORT_CASE)
1203 # check for hypot() in math library
1206 AC_REPLACE_FUNCS(hypot)
1209 # check whether malloc(0) returns NULL or not
1210 AC_MSG_CHECKING(what malloc(0) returns)
1211 AC_CACHE_VAL(ac_cv_malloc_zero,
1212 [AC_TRY_RUN([#include <stdio.h>
1216 char *malloc(), *realloc();
1222 if (p == NULL) exit(1);
1224 if (p == NULL) exit(1);
1227 }], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1228 AC_MSG_RESULT($ac_cv_malloc_zero)
1229 if test "$ac_cv_malloc_zero" = null
1231 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1235 AC_CHECK_HEADER(wchar.h,
1236 AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1240 # check for usable wchar_t
1241 usable_wchar_t="unkown"
1242 AC_MSG_CHECKING(for usable wchar_t)
1254 AC_DEFINE(HAVE_USABLE_WCHAR_T) usable_wchar_t="yes",
1255 usable_wchar_t="no")
1256 AC_MSG_RESULT($usable_wchar_t)
1258 # check for endianness
1261 # Check whether right shifting a negative integer extends the sign bit
1262 # or fills with zeros (like the Cray J90, according to Tim Peters).
1263 AC_MSG_CHECKING(whether right shift extends the sign bit)
1264 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
1268 exit(((-1)>>3 == -1) ? 0 : 1);
1270 ], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1271 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1272 if test "$ac_cv_rshift_extends_sign" = no
1274 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1277 # check for getc_unlocked and related locking functions
1278 AC_MSG_CHECKING(for getc_unlocked() and friends)
1279 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1280 AC_TRY_LINK([#include <stdio.h>],[
1281 FILE *f = fopen("/dev/null", "r");
1285 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1286 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1287 if test "$ac_cv_have_getc_unlocked" = yes
1289 AC_DEFINE(HAVE_GETC_UNLOCKED)
1292 # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1293 # Add sys/socket.h to confdefs.h
1294 cat >> confdefs.h <<\EOF
1295 #ifdef HAVE_SYS_SOCKET_H
1296 #include <sys/socket.h>
1299 AC_CHECK_TYPE(socklen_t, int)
1301 # Add Python/ prefix to LIBOBJS
1304 for obj in $libobjs; do
1305 LIBOBJS="$LIBOBJS Python/$obj"
1308 #AC_MSG_CHECKING(for Modules/Setup)
1309 #if test ! -f Modules/Setup ; then
1310 # if test ! -d Modules ; then
1313 # cp "$srcdir/Modules/Setup.dist" Modules/Setup
1314 # AC_MSG_RESULT(creating)
1316 # AC_MSG_RESULT(already exists)
1320 SRCDIRS="Parser Grammar Objects Python Modules"
1321 AC_MSG_CHECKING(for build directories)
1322 for dir in $SRCDIRS; do
1323 if test ! -d $dir; then
1329 # generate output files
1330 AC_OUTPUT(Makefile.pre Modules/Setup.config)
1332 echo "creating Setup"
1333 if test ! -f Modules/Setup
1335 cp $srcdir/Modules/Setup.dist Modules/Setup
1338 echo "creating Setup.local"
1339 if test ! -f Modules/Setup.local
1341 echo "# Edit this file for local setup changes" >Modules/Setup.local
1344 echo "creating Makefile"
1345 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1346 -s Modules Modules/Setup.config \
1347 Modules/Setup Modules/Setup.local