More installation info. Bump alpha version.
[python/dscho.git] / configure.in
blob48fa694bd44d46267c58f53c1e5bb8532e248cfe
1 dnl Process this file with autoconf 2.0 or later to make a configure script.
3 # Set VERSION so we only need to edit in one place (i.e., here)
4 m4_define(PYTHON_VERSION, 2.3)
6 AC_REVISION($Revision$)
7 AC_PREREQ(2.53)
8 AC_INIT(python, PYTHON_VERSION)
9 AC_CONFIG_SRCDIR([Include/object.h])
10 AC_CONFIG_HEADER(pyconfig.h)
12 # This is for stuff that absolutely must end up in pyconfig.h.
13 # Please use pyport.h instead, if possible.
14 AH_TOP([
15 #ifndef Py_PYCONFIG_H
16 #define Py_PYCONFIG_H
18 AH_BOTTOM([
19 /* Define the macros needed if on a UnixWare 7.x system. */
20 #if defined(__USLC__) && defined(__SCO_VERSION__)
21 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
22 #endif
24 #endif /*Py_PYCONFIG_H*/
27 AC_SUBST(VERSION)
28 VERSION=PYTHON_VERSION
30 AC_SUBST(SOVERSION)
31 SOVERSION=1.0
33 # The later defininition of _XOPEN_SOURCE disables certain features
34 # on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
35 AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
37 define_xopen_source=yes
39 # Arguments passed to configure.
40 AC_SUBST(CONFIG_ARGS)
41 CONFIG_ARGS="$ac_configure_args"
43 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
44 AC_ARG_ENABLE(framework,
45               AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
47         case $enableval in
48         yes) 
49                 enableval=/Library/Frameworks
50         esac
51         case $enableval in
52         no)
53                 PYTHONFRAMEWORK=
54                 PYTHONFRAMEWORKDIR=no-framework
55                 PYTHONFRAMEWORKPREFIX=
56                 PYTHONFRAMEWORKINSTALLDIR=
57                 enable_framework=
58                 ;;
59         *)
60                 PYTHONFRAMEWORK=Python
61                 PYTHONFRAMEWORKDIR=Python.framework
62                 PYTHONFRAMEWORKPREFIX=$enableval
63                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
64                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
65         esac
66         ],[
67         PYTHONFRAMEWORK=
68         PYTHONFRAMEWORKDIR=no-framework
69         PYTHONFRAMEWORKPREFIX=
70         PYTHONFRAMEWORKINSTALLDIR=
71         enable_framework=
73 AC_SUBST(PYTHONFRAMEWORK)
74 AC_SUBST(PYTHONFRAMEWORKDIR)
75 AC_SUBST(PYTHONFRAMEWORKPREFIX)
76 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
78 ##AC_ARG_WITH(dyld,
79 ##            AC_HELP_STRING(--with-dyld,
80 ##                           Use (OpenStep|Rhapsody) dynamic linker))
82 # Set name for machine-dependent library files
83 AC_SUBST(MACHDEP)
84 AC_MSG_CHECKING(MACHDEP)
85 if test -z "$MACHDEP"
86 then
87         ac_sys_system=`uname -s`
88         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
89         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
90                 ac_sys_release=`uname -v`
91         else
92                 ac_sys_release=`uname -r`
93         fi
94         ac_md_system=`echo $ac_sys_system |
95                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
96         ac_md_release=`echo $ac_sys_release |
97                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
98         MACHDEP="$ac_md_system$ac_md_release"
100         case $MACHDEP in
101         cygwin*) MACHDEP="cygwin";;
102         darwin*) MACHDEP="darwin";;
103         atheos*) MACHDEP="atheos";;
104         '')     MACHDEP="unknown";;
105         esac
107         
108 # Some systems cannot stand _XOPEN_SOURCE being defined at all; they
109 # disable features if it is defined, without any means to access these
110 # features as extensions. For these systems, we skip the definition of
111 # _XOPEN_SOURCE. Before adding a system to the list to gain access to
112 # some feature, make sure there is no alternative way to access this
113 # feature. Also, when using wildcards, make sure you have verified the
114 # need for not defining _XOPEN_SOURCE on all systems matching the
115 # wildcard, and that the wildcard does not include future systems
116 # (which may remove their limitations).
117 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
118 case $ac_sys_system/$ac_sys_release in
119   # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
120   # even though select is a POSIX function. Reported by J. Ribbens.
121   OpenBSD/2.* | OpenBSD/3.@<:@012@:>@) 
122     define_xopen_source=no;;
123 esac
125 if test $define_xopen_source = yes
126 then
127   AC_DEFINE(_XOPEN_SOURCE, 600, 
128             Define to the level of X/Open that your system supports)
130   # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
131   # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
132   # several APIs are not declared. Since this is also needed in some
133   # cases for HP-UX, we define it globally.
134   
135   AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Define to activate Unix95-and-earlier features)
136   AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
141 # SGI compilers allow the specification of the both the ABI and the
142 # ISA on the command line.  Depending on the values of these switches,
143 # different and often incompatable code will be generated.
145 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
146 # thus supply support for various ABI/ISA combinations.  The MACHDEP
147 # variable is also adjusted.
149 AC_SUBST(SGI_ABI)
150 if test ! -z "$SGI_ABI"
151 then
152         CC="cc $SGI_ABI"
153         LDFLAGS="$SGI_ABI $LDFLAGS"
154         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
156 AC_MSG_RESULT($MACHDEP)
158 # And add extra plat-mac for darwin
159 AC_SUBST(EXTRAPLATDIR)
160 AC_MSG_CHECKING(EXTRAPLATDIR)
161 if test -z "$EXTRAPLATDIR"
162 then
163         case $MACHDEP in
164         darwin) EXTRAPLATDIR="\$(PLATMACDIRS)";;
165         *) EXTRAPLATDIR="";;
166         esac
168 AC_MSG_RESULT($EXTRAPLATDIR)
170 # checks for alternative programs
171 AC_MSG_CHECKING(for --without-gcc)
172 AC_ARG_WITH(gcc,
173             AC_HELP_STRING(--without-gcc,never use gcc),
175         case $withval in
176         no)     CC=cc
177                 without_gcc=yes;;
178         yes)    CC=gcc
179                 without_gcc=no;;
180         *)      CC=$withval
181                 without_gcc=$withval;;
182         esac], [
183         case $ac_sys_system in
184         AIX*)   CC=cc_r
185                 without_gcc=;;
186         BeOS*)
187                 case $BE_HOST_CPU in
188                 ppc)
189                         CC=mwcc
190                         without_gcc=yes
191                         OPT="-O -export pragma"
192                         LDFLAGS="$LDFLAGS -nodup"
193                         ;;
194                 x86)
195                         CC=gcc
196                         without_gcc=no
197                         OPT=-O
198                         ;;
199                 *)
200                         AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
201                         ;;
202                 esac
203                 AR="\$(srcdir)/Modules/ar_beos"
204                 RANLIB=:
205                 ;;
206     Monterey*)
207         RANLIB=:
208         without_gcc=;;
209         *)      without_gcc=no;;
210         esac])
211 AC_MSG_RESULT($without_gcc)
213 AC_SUBST(CXX)
214 AC_SUBST(MAINOBJ)
215 MAINOBJ=python.o
216 AC_MSG_CHECKING(for --with-cxx=<compiler>)
217 AC_ARG_WITH(cxx,
218             AC_HELP_STRING(--with-cxx=<compiler>, enable C++ support),
220         check_cxx=no
221         case $withval in
222         no)     CXX=
223                 with_cxx=no;;
224         *)      CXX=$withval
225                 MAINOBJ=ccpython.o
226                 with_cxx=$withval;;
227         esac], [
228         with_cxx=no
229         check_cxx=yes
231 AC_MSG_RESULT($with_cxx)
233 if test "$with_cxx" = "yes"
234 then
235         AC_MSG_ERROR([must supply a compiler when using --with-cxx])
238 dnl The following fragment works similar to AC_PROG_CXX.
239 dnl It does not fail if CXX is not found, and it is not executed if 
240 dnl --without-cxx was given.
241 dnl Finally, it does not test whether CXX is g++.
243 dnl Autoconf 2.5x does not have AC_PROG_CXX_WORKS anymore
244 ifdef([AC_PROG_CXX_WORKS],[],
245       [AC_DEFUN([AC_PROG_CXX_WORKS],
246       [AC_LANG_PUSH(C++)dnl
247        _AC_COMPILER_EXEEXT
248        AC_LANG_POP()
249       ]
252 if test "$check_cxx" = "yes" 
253 then
254         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
255         if test "$CXX" = "notfound"
256         then
257                 CXX=
258         else
259                 AC_PROG_CXX_WORKS
260         fi
263 # If the user switches compilers, we can't believe the cache
264 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
265 then
266   AC_MSG_ERROR([cached CC is different -- throw away $cache_file
267 (it is also a good idea to do 'make clean' before compiling)])
270 AC_PROG_CC
272 # checks for UNIX variants that set C preprocessor variables
273 AC_AIX
274 AC_MINIX
276 # Check for unsupported systems
277 case $ac_sys_system/$ac_sys_release in
278 SunOS/4*|DYNIX/*|dgux*/*|IRIX/4*|Linux*/1*)
279    echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
280    echo See README for details.
281    exit 1;;
282 esac
284 if test "$MINIX" = yes; then
285    echo This system \(MINIX\) is no longer supported.
286    echo Read README for details.
287    exit 1
290 AC_EXEEXT
291 AC_MSG_CHECKING(for --with-suffix)
292 AC_ARG_WITH(suffix,
293             AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
295         case $withval in
296         no)     EXEEXT=;;
297         yes)    EXEEXT=.exe;;
298         *)      EXEEXT=$withval;;
299         esac])
300 AC_MSG_RESULT($EXEEXT)
302 # Test whether we're running on a non-case-sensitive system, in which
303 # case we give a warning if no ext is given
304 AC_SUBST(BUILDEXEEXT)
305 AC_MSG_CHECKING(for case-insensitive build directory)
306 if test ! -d CaseSensitiveTestDir; then
307 mkdir CaseSensitiveTestDir
310 if test -d casesensitivetestdir
311 then
312     AC_MSG_RESULT(yes)
313     BUILDEXEEXT=.exe
314 else
315         AC_MSG_RESULT(no)
316         BUILDEXEEXT=$EXEEXT
318 rmdir CaseSensitiveTestDir
320 case $MACHDEP in
321 bsdos*)
322     case $CC in
323     gcc) CC="$CC -D_HAVE_BSDI";;
324     esac;;
325 esac
327 case $ac_sys_system in
328 hp*|HP*)
329     case $CC in
330     cc|*/cc) CC="$CC -Ae";;
331     esac;;
332 Monterey*)
333     case $CC in
334     cc) CC="$CC -Wl,-Bexport";;
335     esac;;
336 SunOS*)
337     # Some functions have a prototype only with that define, e.g. confstr
338     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
339     ;;
340 esac
343 AC_SUBST(LIBRARY)
344 AC_MSG_CHECKING(LIBRARY)
345 if test -z "$LIBRARY"
346 then
347         LIBRARY='libpython$(VERSION).a'
349 AC_MSG_RESULT($LIBRARY)
351 # LDLIBRARY is the name of the library to link against (as opposed to the
352 # name of the library into which to insert object files). BLDLIBRARY is also
353 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
354 # is blank as the main program is not linked directly against LDLIBRARY.
355 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
356 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
357 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
358 # DLLLIBRARY is the shared (i.e., DLL) library.
360 # RUNSHARED is used to run shared python without installed libraries
362 # INSTSONAME is the name of the shared library that will be use to install
363 # on the system - some systems like version suffix, others don't
364 AC_SUBST(LDLIBRARY)
365 AC_SUBST(DLLLIBRARY)
366 AC_SUBST(BLDLIBRARY)
367 AC_SUBST(LDLIBRARYDIR)
368 AC_SUBST(INSTSONAME)
369 AC_SUBST(RUNSHARED)
370 LDLIBRARY="$LIBRARY"
371 BLDLIBRARY='$(LDLIBRARY)'
372 INSTSONAME='$(LDLIBRARY)'
373 DLLLIBRARY=''
374 LDLIBRARYDIR=''
375 RUNSHARED=''
377 # LINKCC is the command that links the python executable -- default is $(CC).
378 # If CXX is set, and if it is needed to link a main function that was
379 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
380 # python might then depend on the C++ runtime
381 # This is altered for AIX in order to build the export list before 
382 # linking.
383 AC_SUBST(LINKCC)
384 AC_MSG_CHECKING(LINKCC)
385 if test -z "$LINKCC"
386 then
387         if test -z "$CXX"; then
388               LINKCC="\$(PURIFY) \$(CC)"
389         else
390               echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
391               $CXX -c conftest.$ac_ext 2>&5
392               if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
393                  && test -s conftest$ac_exeext && ./conftest$ac_exeext
394               then
395                  LINKCC="\$(PURIFY) \$(CC)"
396               else
397                  LINKCC="\$(PURIFY) \$(CXX)"
398               fi
399               rm -fr conftest*
400         fi
401         case $ac_sys_system in
402         AIX*)
403            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";;
404         dgux*)
405            LINKCC="LD_RUN_PATH=$libdir $LINKCC";;
406         Monterey64*)
407            LINKCC="$LINKCC -L/usr/lib/ia64l64";;
408         esac
410 AC_MSG_RESULT($LINKCC)
412 AC_MSG_CHECKING(for --enable-shared)
413 AC_ARG_ENABLE(shared,
414               AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
416 if test -z "$enable_shared"
417 then 
418   case $ac_sys_system in
419   CYGWIN* | atheos*)
420     enable_shared="yes";;
421   *)
422     enable_shared="no";;
423   esac
425 AC_MSG_RESULT($enable_shared)
428 AC_MSG_CHECKING(LDLIBRARY)
430 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
431 # library that we build, but we do not want to link against it (we
432 # will find it with a -framework option). For this reason there is an
433 # extra variable BLDLIBRARY against which Python and the extension
434 # modules are linked, BLDLIBRARY. This is normally the same as
435 # LDLIBRARY, but empty for MacOSX framework builds.
436 if test "$enable_framework"
437 then
438   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
439   LDLIBRARYDIR='$(PYTHONFRAMEWORKDIR)'
440   BLDLIBRARY=''
441 else
442   BLDLIBRARY='$(LDLIBRARY)'
443 fi  
445 # Other platforms follow
446 if test $enable_shared = "yes"; then
447   AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
448   case $ac_sys_system in
449     BeOS*)
450           LDLIBRARY='libpython$(VERSION).so'
451           ;;
452     CYGWIN*)
453           LDLIBRARY='libpython$(VERSION).dll.a'
454           DLLLIBRARY='libpython$(VERSION).dll'
455           ;;
456     SunOS*)
457           LDLIBRARY='libpython$(VERSION).so'
458           BLDLIBRARY='-Wl,-rpath,$(LIBDIR) -L. -lpython$(VERSION)'
459           RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
460           ;;
461     Linux*|GNU*)
462           LDLIBRARY='libpython$(VERSION).so'
463           BLDLIBRARY='-L. -lpython$(VERSION)'
464           RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
465           INSTSONAME="$LDLIBRARY".$SOVERSION
466           ;;
467     hp*|HP*)
468           LDLIBRARY='libpython$(VERSION).sl'
469           BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
470           RUNSHARED=SHLIB_PATH=`pwd`:$SHLIB_PATH
471           ;;
472     OSF*)
473           LDLIBRARY='libpython$(VERSION).so'
474          BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
475           RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
476           ;;
477     atheos*)
478           LDLIBRARY='libpython$(VERSION).so'
479           BLDLIBRARY='-L. -lpython$(VERSION)'
480           RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
481           ;;
482   esac
483   # DG/UX requires some fancy ld contortions to produce a .so from an .a
484   case $MACHDEP in
485   dguxR4)
486         LDLIBRARY='libpython$(VERSION).so'
487         OPT="$OPT -pic"
488         ;;
489   esac
492 AC_MSG_RESULT($LDLIBRARY)
494 AC_PROG_RANLIB
495 AC_SUBST(AR)
496 AC_CHECK_PROGS(AR, ar aal, ar)
498 case $MACHDEP in
499 bsdos*|hp*|HP*)
500         # install -d does not work on BSDI or HP-UX
501         if test -z "$INSTALL"
502         then
503                 INSTALL="${srcdir}/install-sh -c"
504         fi
505 esac
506 AC_PROG_INSTALL
508 # Not every filesystem supports hard links
509 AC_SUBST(LN)
510 if test -z "$LN" ; then
511         case $ac_sys_system in
512                 BeOS*) LN="ln -s";;
513                 CYGWIN*) LN="ln -s";;
514                 atheos*) LN="ln -s";;
515                 *) LN=ln;;
516         esac
519 # Check for --with-pydebug
520 AC_MSG_CHECKING(for --with-pydebug)
521 AC_ARG_WITH(pydebug, 
522             AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
524 if test "$withval" != no
525 then 
526   AC_DEFINE(Py_DEBUG, 1, 
527   [Define if you want to build an interpreter with many run-time checks.]) 
528   AC_MSG_RESULT(yes); 
529   Py_DEBUG='true'
530 else AC_MSG_RESULT(no); Py_DEBUG='false'
531 fi],
532 [AC_MSG_RESULT(no)])
534 # Optimizer/debugger flags
535 AC_SUBST(OPT)
536 if test -z "$OPT"
537 then
538         case $GCC in
539         yes)
540                 case $ac_cv_prog_cc_g in
541         yes)
542             if test "$Py_DEBUG" = 'true' ; then
543                 # Optimization messes up debuggers, so turn it off for
544                 # debug builds.
545                 OPT="-g -Wall -Wstrict-prototypes"
546             else
547                 OPT="-g -O3 -Wall -Wstrict-prototypes"
548             fi;;
549         *)
550             OPT="-O3 -Wall -Wstrict-prototypes";;
551         esac
552         case $ac_sys_system in
553             SCO_SV*) OPT="$OPT -m486 -DSCO5";;
554         esac
555         ;;
556     *)
557         case $ac_sys_system in
558         OpenUNIX*|UnixWare*)
559             OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
560         SCO_SV*)
561             CFLAGS="$CFLAGS -belf"
562             OPT="-belf -O -Ki486 -DSCO5";;
563         *)
564             OPT="-O";;
565         esac
566     esac
567     case $ac_sys_system in
568     Darwin*)
569         OPT="$OPT -Wno-long-double -no-cpp-precomp";;
570     esac
573 if test "$Py_DEBUG" = 'true'; then
574   :
575 else
576   OPT="-DNDEBUG $OPT"
579 # The current (beta) Monterey compiler dies with optimizations
580 case $ac_sys_system in
581 Monterey*) OPT="";;
582 esac
584 if test "$ac_arch_flags"
585 then
586         OPT="$OPT $ac_arch_flags"
589 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
590 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
591 [ac_save_cc="$CC"
592 CC="$CC -OPT:Olimit=0"
593 AC_TRY_RUN([int main() { return 0; }],
594   ac_cv_opt_olimit_ok=yes,
595   ac_cv_opt_olimit_ok=no,
596   ac_cv_opt_olimit_ok=no)
597 CC="$ac_save_cc"])
598 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
599 if test $ac_cv_opt_olimit_ok = yes; then
600     case $ac_sys_system in
601       Darwin*) OPT="$OPT" ;;
602       *) OPT="$OPT -OPT:Olimit=0";;
603     esac
604 else
605   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
606   AC_CACHE_VAL(ac_cv_olimit_ok,
607   [ac_save_cc="$CC"
608   CC="$CC -Olimit 1500"
609   AC_TRY_RUN([int main() { return 0; }],
610     ac_cv_olimit_ok=yes,
611     ac_cv_olimit_ok=no,
612     ac_cv_olimit_ok=no)
613   CC="$ac_save_cc"])
614   AC_MSG_RESULT($ac_cv_olimit_ok)
615   if test $ac_cv_olimit_ok = yes; then
616     OPT="$OPT -Olimit 1500"
617   fi
620 # On some compilers, pthreads are available without further options
621 # (e.g. MacOS X). On some of these systems, the compiler will not
622 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
623 # So we have to see first whether pthreads are available without
624 # options before we can check whether -Kpthread improves anything.
625 AC_MSG_CHECKING(whether pthreads are available without options)
626 AC_CACHE_VAL(ac_cv_pthread_is_default,
627 [AC_TRY_RUN([
628 #include <pthread.h>
630 void* routine(void* p){return NULL;}
632 int main(){
633   pthread_t p;
634   if(pthread_create(&p,NULL,routine,NULL)!=0)
635     return 1;
636   (void)pthread_detach(p);
637   return 0;
640   ac_cv_pthread_is_default=yes,
641   ac_cv_pthread_is_default=no,
642   ac_cv_pthread_is_default=no)
644 AC_MSG_RESULT($ac_cv_pthread_is_default)
647 if test $ac_cv_pthread_is_default = yes 
648 then
649   ac_cv_kpthread=no
650 else
651 # -Kpthread, if available, provides the right #defines
652 # and linker options to make pthread_create available
653 # Some compilers won't report that they do not support -Kpthread,
654 # so we need to run a program to see whether it really made the
655 # function available.
656 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
657 AC_CACHE_VAL(ac_cv_kpthread,
658 [ac_save_cc="$CC"
659 CC="$CC -Kpthread"
660 AC_TRY_RUN([
661 #include <pthread.h>
663 void* routine(void* p){return NULL;}
665 int main(){
666   pthread_t p;
667   if(pthread_create(&p,NULL,routine,NULL)!=0)
668     return 1;
669   (void)pthread_detach(p);
670   return 0;
673   ac_cv_kpthread=yes,
674   ac_cv_kpthread=no,
675   ac_cv_kpthread=no)
676 CC="$ac_save_cc"])
677 AC_MSG_RESULT($ac_cv_kpthread)
680 dnl # check for ANSI or K&R ("traditional") preprocessor
681 dnl AC_MSG_CHECKING(for C preprocessor type)
682 dnl AC_TRY_COMPILE([
683 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
684 dnl int foo;
685 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
686 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
687 dnl AC_MSG_RESULT($cpp_type)
689 # checks for header files
690 AC_HEADER_STDC
691 AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h \
692 libintl.h locale.h ncurses.h poll.h pthread.h \
693 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
694 sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
695 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
696 sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
697 sys/resource.h netpacket/packet.h)
698 AC_HEADER_DIRENT
699 AC_HEADER_MAJOR
701 # checks for typedefs
702 was_it_defined=no
703 AC_MSG_CHECKING(for clock_t in time.h)
704 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
705     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
707 AC_MSG_RESULT($was_it_defined)
709 # Check whether using makedev requires defining _OSF_SOURCE
710 AC_MSG_CHECKING(for makedev)
711 AC_TRY_LINK([ #include <sys/types.h> ],
712             [ makedev(0, 0) ],
713             ac_cv_has_makedev=yes,
714             ac_cv_has_makedev=no)
715 if test "$ac_cv_has_makedev" = "no"; then
716     # we didn't link, try if _OSF_SOURCE will allow us to link
717     AC_TRY_LINK([
718     #define _OSF_SOURCE 1
719     #include <sys/types.h>
720     ],
721     [ makedev(0, 0) ],
722     ac_cv_has_makedev=yes,
723     ac_cv_has_makedev=no)
724     if test "$ac_cv_has_makedev" = "yes"; then
725         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
726     fi
728 AC_MSG_RESULT($ac_cv_has_makedev)
729 if test "$ac_cv_has_makedev" = "yes"; then
730     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
733 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
734 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
735 # defined, but the compiler does not support pragma redefine_extname,
736 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
737 # structures (such as rlimit64) without declaring them. As a
738 # work-around, disable LFS on such configurations
740 use_lfs=yes
741 AC_MSG_CHECKING(Solaris LFS bug)
742 AC_TRY_COMPILE([
743 #define _LARGEFILE_SOURCE 1
744 #define _FILE_OFFSET_BITS 64
745 #include <sys/resource.h>
746 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
747 AC_MSG_RESULT($sol_lfs_bug)
748 if test "$sol_lfs_bug" = "yes"; then
749   use_lfs=no
752 if test "$use_lfs" = "yes"; then
753 # Two defines needed to enable largefile support on various platforms
754 # These may affect some typedefs
755 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
756 [This must be defined on some systems to enable large file support.])
757 AC_DEFINE(_FILE_OFFSET_BITS, 64,
758 [This must be set to 64 on some systems to enable large file support.])
761 # Add some code to confdefs.h so that the test for off_t works on SCO
762 cat >> confdefs.h <<\EOF
763 #if defined(SCO_DS)
764 #undef _OFF_T
765 #endif
768 # Type availability checks
769 AC_TYPE_MODE_T
770 AC_TYPE_OFF_T
771 AC_TYPE_PID_T
772 AC_TYPE_SIGNAL
773 AC_TYPE_SIZE_T
774 AC_TYPE_UID_T
776 # Sizes of various common basic types
777 AC_CHECK_SIZEOF(int, 4)
778 AC_CHECK_SIZEOF(long, 4)
779 AC_CHECK_SIZEOF(void *, 4)
780 AC_CHECK_SIZEOF(char, 1)
781 AC_CHECK_SIZEOF(short, 2)
782 AC_CHECK_SIZEOF(float, 4)
783 AC_CHECK_SIZEOF(double, 8)
784 AC_CHECK_SIZEOF(fpos_t, 4)
786 AC_MSG_CHECKING(for long long support)
787 have_long_long=no
788 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
789   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
790   have_long_long=yes
792 AC_MSG_RESULT($have_long_long)
793 if test "$have_long_long" = yes ; then
794 AC_CHECK_SIZEOF(long long, 8)
797 AC_MSG_CHECKING(for uintptr_t support)
798 have_uintptr_t=no
799 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], [
800   AC_DEFINE(HAVE_UINTPTR_T, 1, [Define this if you have the type uintptr_t.]) 
801   have_uintptr_t=yes
803 AC_MSG_RESULT($have_uintptr_t)
804 if test "$have_uintptr_t" = yes ; then
805 AC_CHECK_SIZEOF(uintptr_t, 4)
808 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
809 AC_MSG_CHECKING(size of off_t)
810 AC_CACHE_VAL(ac_cv_sizeof_off_t,
811 [AC_TRY_RUN([#include <stdio.h>
812 #include <sys/types.h>
813 main()
815   FILE *f=fopen("conftestval", "w");
816   if (!f) exit(1);
817   fprintf(f, "%d\n", sizeof(off_t));
818   exit(0);
820 ac_cv_sizeof_off_t=`cat conftestval`,
821 ac_cv_sizeof_off_t=0,
822 ac_cv_sizeof_off_t=4)
824 AC_MSG_RESULT($ac_cv_sizeof_off_t)
825 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
826 [The number of bytes in an off_t.])
828 AC_MSG_CHECKING(whether to enable large file support)
829 if test "$have_long_long" = yes -a \
830         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
831         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
832   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
833   [Defined to enable large file support when an off_t is bigger than a long
834    and long long is available and at least as big as an off_t. You may need
835    to add some flags for configuration and compilation to enable this mode.
836    (For Solaris and Linux, the necessary defines are already defined.)])
837   AC_MSG_RESULT(yes)
838 else
839   AC_MSG_RESULT(no)
842 # AC_CHECK_SIZEOF() doesn't include <time.h>.
843 AC_MSG_CHECKING(size of time_t)
844 AC_CACHE_VAL(ac_cv_sizeof_time_t,
845 [AC_TRY_RUN([#include <stdio.h>
846 #include <time.h>
847 main()
849   FILE *f=fopen("conftestval", "w");
850   if (!f) exit(1);
851   fprintf(f, "%d\n", sizeof(time_t));
852   exit(0);
854 ac_cv_sizeof_time_t=`cat conftestval`,
855 ac_cv_sizeof_time_t=0,
856 ac_cv_sizeof_time_t=4)
858 AC_MSG_RESULT($ac_cv_sizeof_time_t)
859 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
860 [The number of bytes in a time_t.])
863 # if have pthread_t then define SIZEOF_PTHREAD_T
864 ac_save_cc="$CC"
865 if test "$ac_cv_kpthread" = "yes"
866 then CC="$CC -Kpthread"
868 AC_MSG_CHECKING(for pthread_t)
869 have_pthread_t=no
870 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
871 AC_MSG_RESULT($have_pthread_t)
872 if test "$have_pthread_t" = yes ; then
873   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
874   AC_MSG_CHECKING(size of pthread_t)
875   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
876   [AC_TRY_RUN([#include <stdio.h>
877   #include <pthread.h>
878   main()
879   {
880     FILE *f=fopen("conftestval", "w");
881     if (!f) exit(1);
882     fprintf(f, "%d\n", sizeof(pthread_t));
883     exit(0);
884   }],
885   ac_cv_sizeof_pthread_t=`cat conftestval`,
886   ac_cv_sizeof_pthread_t=0,
887   ac_cv_sizeof_pthread_t=4)
888   ])
889   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
890   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
891    [The number of bytes in a pthread_t.])
893 CC="$ac_save_cc"
895 AC_MSG_CHECKING(for --enable-toolbox-glue)
896 AC_ARG_ENABLE(toolbox-glue,
897               AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
899 if test -z "$enable_toolbox_glue"
900 then 
901         case $ac_sys_system/$ac_sys_release in
902         Darwin/*)
903                 enable_toolbox_glue="yes";;
904         *)
905                 enable_toolbox_glue="no";;
906         esac
908 case "$enable_toolbox_glue" in
909 yes)
910         extra_frameworks="-framework CoreServices -framework Foundation"
911         extra_machdep_objs="Python/mactoolboxglue.o"
912         extra_undefs="-u __dummy -u _PyMac_Error"
913         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
914          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
915         ;;
917         extra_frameworks=""
918         extra_machdep_objs=""
919         extra_undefs=""
920         ;;
921 esac
922 AC_MSG_RESULT($enable_toolbox_glue)
924 AC_SUBST(LIBTOOL_CRUFT)
925 case $ac_sys_system/$ac_sys_release in
926   Darwin/1.3*)
927     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
928         LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
929     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
930     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
931   Darwin/*)
932     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
933       LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
934     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
935     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
936 esac
938 AC_MSG_CHECKING(for --enable-framework)
939 if test "$enable_framework"
940 then
941         OPT="$OPT -fno-common -dynamic"
942         # -F. is needed to allow linking to the framework while 
943         # in the build location.
944         LDFLAGS="$LDFLAGS -Wl,-F."
945         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
946          [Define if you want to produce an OpenStep/Rhapsody framework
947          (shared library plus accessory files).])
948         AC_MSG_RESULT(yes)
949 else
950         AC_MSG_RESULT(no)
953 AC_MSG_CHECKING(for dyld)
954 case $ac_sys_system/$ac_sys_release in
955   Darwin/*)
956         AC_DEFINE(WITH_DYLD, 1, 
957         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
958          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
959          linker (rld). Dyld is necessary to support frameworks.])
960         AC_MSG_RESULT(always on for Darwin)
961         ;;
962   *)
963         AC_MSG_RESULT(no)
964         ;;
965 esac
967 # Set info about shared libraries.
968 AC_SUBST(SO)
969 AC_SUBST(LDSHARED)
970 AC_SUBST(BLDSHARED)
971 AC_SUBST(CCSHARED)
972 AC_SUBST(LINKFORSHARED)
973 # SO is the extension of shared libraries `(including the dot!)
974 # -- usually .so, .sl on HP-UX, .dll on Cygwin
975 AC_MSG_CHECKING(SO)
976 if test -z "$SO"
977 then
978         case $ac_sys_system in
979         hp*|HP*)   SO=.sl;;
980         CYGWIN*)   SO=.dll;;
981         *)         SO=.so;;
982         esac
984 AC_MSG_RESULT($SO)
985 # LDSHARED is the ld *command* used to create shared library
986 # -- "ld" on SunOS 4.x.x, "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
987 # (Shared libraries in this instance are shared modules to be loaded into
988 # Python, as opposed to building Python itself as a shared library.)
989 AC_MSG_CHECKING(LDSHARED)
990 if test -z "$LDSHARED"
991 then
992         case $ac_sys_system/$ac_sys_release in
993         AIX*)
994                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
995                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
996                 ;;
997         BeOS*)
998                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
999                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1000                 ;;
1001         IRIX/5*) LDSHARED="ld -shared";;
1002         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1003         SunOS/4*) LDSHARED="ld";;
1004         SunOS/5*) 
1005                 if test "$GCC" = "yes"
1006                 then LDSHARED='$(CC) -shared'
1007                 else LDSHARED='$(CC) -G';
1008                 fi ;;
1009         hp*|HP*) LDSHARED="ld -b";;
1010         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1011         DYNIX/ptx*) LDSHARED="ld -G";;
1012         Darwin/1.3*)
1013                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1014                 if test "$enable_framework" ; then
1015                         # Link against the framework. All externals should be defined.
1016                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
1017                 else
1018                         # No framework. Ignore undefined symbols, assuming they come from Python
1019                         LDSHARED="$LDSHARED -undefined suppress"
1020                 fi ;;
1021         Darwin/*)
1022                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1023                 if test "$enable_framework" ; then
1024                         # Link against the framework. All externals should be defined.
1025                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
1026                 else
1027                         # No framework, use the Python app as bundle-loader
1028                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1029                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/$(PYTHON)'
1030                 fi ;;
1031         Linux*|GNU*) LDSHARED='$(CC) -shared';;
1032         dgux*) LDSHARED="ld -G";;
1033         BSD/OS*/4*) LDSHARED="gcc -shared";;
1034         OpenBSD*|FreeBSD*)
1035                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1036                 then
1037                         LDSHARED="cc -shared ${LDFLAGS}"
1038                 else
1039                         LDSHARED="ld -Bshareable ${LDFLAGS}"
1040                 fi;;
1041         NetBSD*) LDSHARED="cc -shared ${LDFLAGS}";;
1042         OpenUNIX*|UnixWare*)
1043                 if test "$GCC" = "yes"
1044                 then LDSHARED='$(CC) -shared'
1045                 else LDSHARED='$(CC) -G'
1046                 fi;;
1047         SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1048         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
1049         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1050         atheos*) LDSHARED="gcc -shared";;
1051         *)      LDSHARED="ld";;
1052         esac
1054 AC_MSG_RESULT($LDSHARED)
1055 BLDSHARED=${BLDSHARED-$LDSHARED}
1056 # CCSHARED are the C *flags* used to create objects to go into a shared
1057 # library (module) -- this is only needed for a few systems
1058 AC_MSG_CHECKING(CCSHARED)
1059 if test -z "$CCSHARED"
1060 then
1061         case $ac_sys_system/$ac_sys_release in
1062         SunOS*) if test "$GCC" = yes;
1063                 then CCSHARED="-fPIC";
1064                 fi;;
1065         hp*|HP*) if test "$GCC" = yes;
1066                  then CCSHARED="-fPIC";
1067                  else CCSHARED="+z";
1068                  fi;;
1069         Linux*|GNU*) CCSHARED="-fPIC";;
1070         BSD/OS*/4*) CCSHARED="-fpic";;
1071         FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
1072         OpenUNIX*|UnixWare*)
1073                 if test "$GCC" = "yes"
1074                 then CCSHARED="-fPIC"
1075                 else CCSHARED="-KPIC"
1076                 fi;;
1077         SCO_SV*)
1078                 if test "$GCC" = "yes"
1079                 then CCSHARED="-fPIC"
1080                 else CCSHARED="-Kpic -belf"
1081                 fi;;
1082         Monterey*) CCSHARED="-G";;
1083         IRIX*/6*)  case $CC in
1084                    *gcc*) CCSHARED="-shared";;
1085                    *) CCSHARED="";;
1086                    esac;;
1087         atheos*) CCSHARED="-fPIC";;
1088         esac
1090 AC_MSG_RESULT($CCSHARED)
1091 # LINKFORSHARED are the flags passed to the $(CC) command that links
1092 # the python executable -- this is only needed for a few systems
1093 AC_MSG_CHECKING(LINKFORSHARED)
1094 if test -z "$LINKFORSHARED"
1095 then
1096         case $ac_sys_system/$ac_sys_release in
1097         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1098         hp*|HP*)
1099             LINKFORSHARED="-Wl,-E -Wl,+s";;
1100 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1101         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1102         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1103         # -u libsys_s pulls in all symbols in libsys
1104         Darwin/*) 
1105                 # -u __dummy makes the linker aware of the objc runtime
1106                 # in System.framework; otherwise, __objcInit (referenced in
1107                 # crt1.o) gets erroneously defined as common, which breaks dynamic
1108                 # loading of any modules which reference it in System.framework.
1109                 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
1110                 # not used by the core itself but which needs to be in the core so
1111                 # that dynamically loaded extension modules have access to it.
1112                 LINKFORSHARED="$extra_undefs -framework System"
1113                 if test "$enable_framework"
1114                 then
1115                         LINKFORSHARED="$LINKFORSHARED -framework Python"
1116                 fi
1117                 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
1118         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1119         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1120         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1121         FreeBSD*|NetBSD*|OpenBSD*) 
1122                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1123                 then
1124                         LINKFORSHARED="-Wl,--export-dynamic"
1125                 fi;;
1126         SunOS/5*) case $CC in
1127                   *gcc*)
1128                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1129                     then
1130                         LINKFORSHARED="-Xlinker --export-dynamic"
1131                     fi;;
1132                   esac;;
1133         esac
1135 AC_MSG_RESULT($LINKFORSHARED)
1137 AC_SUBST(CFLAGSFORSHARED)
1138 AC_MSG_CHECKING(CFLAGSFORSHARED)
1139 if test ! "$LIBRARY" = "$LDLIBRARY"
1140 then
1141         case $ac_sys_system in
1142         CYGWIN*)
1143                 # Cygwin needs CCSHARED when building extension DLLs
1144                 # but not when building the interpreter DLL.
1145                 CFLAGSFORSHARED='';;
1146         *)
1147                 CFLAGSFORSHARED='$(CCSHARED)'
1148         esac
1150 AC_MSG_RESULT($CFLAGSFORSHARED)
1152 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1153 # library (with --enable-shared).
1154 # For platforms on which shared libraries are not allowed to have unresolved
1155 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1156 # if it is not required, since it creates a dependency of the shared library
1157 # to LIBS. This, in turn, means that applications linking the shared libpython
1158 # don't need to link LIBS explicitly. The default should be only changed
1159 # on systems where this approach causes problems.
1160 AC_SUBST(SHLIBS)
1161 AC_MSG_CHECKING(SHLIBS)
1162 case "$ac_sys_system" in
1163         *)
1164                 SHLIBS='$(LIBS)';;
1165 esac
1166 AC_MSG_RESULT($SHLIBS)
1169 # checks for libraries
1170 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1171 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1172 AC_SEARCH_LIBS(sem_init, rt posix4)     # 'Real Time' functions on Solaris,
1173                                         # posix4 on Solaris 2.6
1175 # checks for system dependent C++ extensions support
1176 case "$ac_sys_system" in
1177         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1178                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1179                             [loadAndInit("", 0, "")],
1180                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1181                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1182                        and you want support for AIX C++ shared extension modules.])
1183                              AC_MSG_RESULT(yes)],
1184                             [AC_MSG_RESULT(no)]);;
1185         *) ;;
1186 esac
1188 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1189 # However on SGI IRIX 4, these exist but are broken.
1190 # BeOS' sockets are stashed in libnet.
1191 case "$ac_sys_system" in
1192 IRIX*) ;;
1194 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1195 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1197 esac
1198 case "$ac_sys_system" in
1199 BeOS*)
1200 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1202 esac
1204 AC_MSG_CHECKING(for --with-libs)
1205 AC_ARG_WITH(libs,
1206             AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1208 AC_MSG_RESULT($withval)
1209 LIBS="$withval $LIBS"
1211 [AC_MSG_RESULT(no)])
1213 # Determine if signalmodule should be used.
1214 AC_SUBST(USE_SIGNAL_MODULE)
1215 AC_SUBST(SIGNAL_OBJS)
1216 AC_MSG_CHECKING(for --with-signal-module)
1217 AC_ARG_WITH(signal-module,
1218             AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1220 if test -z "$with_signal_module"
1221 then with_signal_module="yes"
1223 AC_MSG_RESULT($with_signal_module)
1225 if test "${with_signal_module}" = "yes"; then
1226         USE_SIGNAL_MODULE=""
1227         SIGNAL_OBJS=""
1228 else
1229         USE_SIGNAL_MODULE="#"
1230         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1233 # This is used to generate Setup.config
1234 AC_SUBST(USE_THREAD_MODULE)
1235 USE_THREAD_MODULE=""
1237 AC_MSG_CHECKING(for --with-dec-threads)
1238 AC_SUBST(LDLAST)
1239 AC_ARG_WITH(dec-threads,
1240             AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1242 AC_MSG_RESULT($withval)
1243 LDLAST=-threads
1244 if test "${with_thread+set}" != set; then
1245    with_thread="$withval";
1246 fi],
1247 [AC_MSG_RESULT(no)])
1249 # Templates for things AC_DEFINEd more than once.
1250 # For a single AC_DEFINE, no template is needed.
1251 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1252 AH_TEMPLATE(_REENTRANT,
1253   [Define to force use of thread-safe errno, h_errno, and other functions])
1254 AH_TEMPLATE(WITH_THREAD,
1255   [Define if you want to compile in rudimentary thread support])
1257 AC_MSG_CHECKING(for --with-threads)
1258 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1259 AC_ARG_WITH(threads,
1260             AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
1262 # --with-thread is deprecated, but check for it anyway
1263 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1264 AC_ARG_WITH(thread,
1265             AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1266             [with_threads=$with_thread])
1268 if test -z "$with_threads"
1269 then with_threads="yes"
1271 AC_MSG_RESULT($with_threads)
1273 AC_SUBST(THREADOBJ)
1274 if test "$with_threads" = "no"
1275 then
1276     USE_THREAD_MODULE="#"
1277 elif test "$ac_cv_pthread_is_default" = yes
1278 then
1279     AC_DEFINE(WITH_THREAD)
1280     # Defining _REENTRANT on system with POSIX threads should not hurt.
1281     AC_DEFINE(_REENTRANT)
1282     posix_threads=yes
1283     THREADOBJ="Python/thread.o"    
1284 elif test "$ac_cv_kpthread" = "yes"
1285 then
1286     CC="$CC -Kpthread"
1287     AC_DEFINE(WITH_THREAD)
1288     posix_threads=yes
1289     THREADOBJ="Python/thread.o"
1290 else
1291     if test ! -z "$with_threads" -a -d "$with_threads"
1292     then LDFLAGS="$LDFLAGS -L$with_threads"
1293     fi
1294     if test ! -z "$withval" -a -d "$withval"
1295     then LDFLAGS="$LDFLAGS -L$withval"
1296     fi
1298     # According to the POSIX spec, a pthreads implementation must
1299     # define _POSIX_THREADS in unistd.h. Some apparently don't (which ones?)
1300     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1301     AC_EGREP_CPP(yes,
1302     [#include <unistd.h>
1303      #ifdef _POSIX_THREADS
1304      yes
1305      #endif
1306     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1307     AC_MSG_RESULT($unistd_defines_pthreads)
1309     AC_DEFINE(_REENTRANT)
1310     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1311     AC_DEFINE(C_THREADS)
1312     AC_DEFINE(HURD_C_THREADS, 1,
1313     [Define if you are using Mach cthreads directly under /include])
1314     LIBS="$LIBS -lthreads"
1315     THREADOBJ="Python/thread.o"],[
1316     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1317     AC_DEFINE(C_THREADS)
1318     AC_DEFINE(MACH_C_THREADS, 1,
1319     [Define if you are using Mach cthreads under mach /])
1320     THREADOBJ="Python/thread.o"],[
1321     AC_MSG_CHECKING(for --with-pth)
1322     AC_ARG_WITH([pth],
1323                 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
1324                 [AC_MSG_RESULT($withval)
1325                   AC_DEFINE([WITH_THREAD])
1326                   AC_DEFINE([HAVE_PTH], 1,
1327                             [Define if you have GNU PTH threads.])
1328                   LIBS="-lpth $LIBS"
1329                   THREADOBJ="Python/thread.o"],
1330                 [AC_MSG_RESULT(no)
1332     # Just looking for pthread_create in libpthread is not enough:
1333     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1334     # So we really have to include pthread.h, and then link.
1335     _libs=$LIBS
1336     LIBS="$LIBS -lpthread"
1337     AC_MSG_CHECKING([for pthread_create in -lpthread])
1338     AC_TRY_LINK([#include <pthread.h>
1340 void * start_routine (void *arg) { exit (0); }], [
1341 pthread_create (NULL, NULL, start_routine, NULL)], [
1342     AC_MSG_RESULT(yes)
1343     AC_DEFINE(WITH_THREAD)
1344     posix_threads=yes
1345     THREADOBJ="Python/thread.o"],[
1346     LIBS=$_libs
1347     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
1348     posix_threads=yes
1349     THREADOBJ="Python/thread.o"],[
1350     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1351     AC_DEFINE(ATHEOS_THREADS, 1,
1352     [Define this if you have AtheOS threads.])
1353     THREADOBJ="Python/thread.o"],[
1354     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1355     AC_DEFINE(BEOS_THREADS, 1,
1356     [Define this if you have BeOS threads.])
1357     THREADOBJ="Python/thread.o"],[
1358     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
1359     posix_threads=yes
1360     LIBS="$LIBS -lpthreads"
1361     THREADOBJ="Python/thread.o"], [
1362     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
1363     posix_threads=yes
1364     LIBS="$LIBS -lc_r"
1365     THREADOBJ="Python/thread.o"], [
1366     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
1367     echo Systems with __d6_pthread_create are not supported anymore.
1368     echo See README
1369     exit 1
1370     posix_threads=yes
1371     LIBS="$LIBS -lthread"
1372     THREADOBJ="Python/thread.o"], [
1373     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
1374     posix_threads=yes
1375     LIBS="$LIBS -lpthread"
1376     THREADOBJ="Python/thread.o"], [
1377     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
1378     posix_threads=yes
1379     LIBS="$LIBS -lcma"
1380     THREADOBJ="Python/thread.o"],[
1381     USE_THREAD_MODULE="#"])
1382     ])])])])])])])])])])])
1384     if test "$posix_threads" = "yes"; then
1385       if test "$unistd_defines_pthreads" = "no"; then
1386          AC_DEFINE(_POSIX_THREADS, 1,
1387          [Define if you have POSIX threads, 
1388           and your system does not define that.])
1389       fi
1391       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
1392       AC_CACHE_VAL(ac_cv_pthread_system_supported,
1393       [AC_TRY_RUN([#include <pthread.h>
1394       void *foo(void *parm) {
1395         return NULL;
1396       }
1397       main() {
1398         pthread_attr_t attr;
1399         pthread_t id;
1400         if (pthread_attr_init(&attr)) exit(-1);
1401         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
1402         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
1403         exit(0);
1404       }],
1405       ac_cv_pthread_system_supported=yes,
1406       ac_cv_pthread_system_supported=no,
1407       ac_cv_pthread_system_supported=no)
1408       ])
1409       AC_MSG_RESULT($ac_cv_pthread_system_supported)
1410       if test "$ac_cv_pthread_system_supported" = "yes"; then
1411         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
1412       fi
1413       AC_CHECK_FUNCS(pthread_sigmask)
1414     fi
1416     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1417     LIBS="$LIBS -lmpc"
1418     THREADOBJ="Python/thread.o"
1419     USE_THREAD_MODULE=""])
1421     if test "$posix_threads" != "yes"; then     
1422       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1423       LIBS="$LIBS -lthread"
1424       THREADOBJ="Python/thread.o"
1425       USE_THREAD_MODULE=""])
1426     fi
1428     if test "$USE_THREAD_MODULE" != "#"
1429     then
1430         # If the above checks didn't disable threads, (at least) OSF1
1431         # needs this '-threads' argument during linking.
1432         case $ac_sys_system in
1433         OSF1) LDLAST=-threads;;
1434         esac
1435     fi
1437     if test "$posix_threads" = yes -a \
1438                 "$ac_sys_system" = "SunOS" -a \
1439                 "$ac_sys_release" = "5.6"; then
1440                 AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
1441                 [Defined for Solaris 2.6 bug in pthread header.])
1442         fi
1446 # Check for enable-ipv6
1447 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
1448 AC_MSG_CHECKING([if --enable-ipv6 is specified])
1449 AC_ARG_ENABLE(ipv6,
1450 [  --enable-ipv6           Enable ipv6 (with ipv4) support
1451   --disable-ipv6          Disable ipv6 support],
1452 [ case "$enableval" in
1453   no)
1454        AC_MSG_RESULT(no)
1455        ipv6=no
1456        ;;
1457   *)   AC_MSG_RESULT(yes)
1458        AC_DEFINE(ENABLE_IPV6)
1459        ipv6=yes
1460        ;;
1461   esac ],
1464 dnl the check does not work on cross compilation case...
1465   AC_TRY_RUN([ /* AF_INET6 available check */
1466 #include <sys/types.h>
1467 #include <sys/socket.h>
1468 main()
1470  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1471    exit(1);
1472  else
1473    exit(0);
1476   AC_MSG_RESULT(yes)
1477   ipv6=yes,
1478   AC_MSG_RESULT(no)
1479   ipv6=no,
1480   AC_MSG_RESULT(no)
1481   ipv6=no
1484 if test "$ipv6" = "yes"; then
1485         AC_MSG_CHECKING(if RFC2553 API is available)
1486         AC_TRY_COMPILE([#include <sys/types.h>
1487 #include <netinet/in.h>],
1488         [struct sockaddr_in6 x;
1489 x.sin6_scope_id;],
1490                 AC_MSG_RESULT(yes)
1491                 ipv6=yes,
1492                 AC_MSG_RESULT(no, IPv6 disabled)
1493                 ipv6=no)
1496 if test "$ipv6" = "yes"; then
1497         AC_DEFINE(ENABLE_IPV6)
1501 ipv6type=unknown
1502 ipv6lib=none
1503 ipv6trylibc=no
1505 if test "$ipv6" = "yes"; then
1506         AC_MSG_CHECKING([ipv6 stack type])
1507         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1508         do
1509                 case $i in
1510                 inria)
1511                         dnl http://www.kame.net/
1512                         AC_EGREP_CPP(yes, [
1513 #include <netinet/in.h>
1514 #ifdef IPV6_INRIA_VERSION
1516 #endif],
1517                                 [ipv6type=$i])
1518                         ;;
1519                 kame)
1520                         dnl http://www.kame.net/
1521                         AC_EGREP_CPP(yes, [
1522 #include <netinet/in.h>
1523 #ifdef __KAME__
1525 #endif],
1526                                 [ipv6type=$i;
1527                                 ipv6lib=inet6
1528                                 ipv6libdir=/usr/local/v6/lib
1529                                 ipv6trylibc=yes])
1530                         ;;
1531                 linux-glibc)
1532                         dnl http://www.v6.linux.or.jp/
1533                         AC_EGREP_CPP(yes, [
1534 #include <features.h>
1535 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1537 #endif],
1538                                 [ipv6type=$i;
1539                                 ipv6trylibc=yes])
1540                         ;;
1541                 linux-inet6)
1542                         dnl http://www.v6.linux.or.jp/
1543                         if test -d /usr/inet6; then
1544                                 ipv6type=$i
1545                                 ipv6lib=inet6
1546                                 ipv6libdir=/usr/inet6/lib
1547                                 OPT="-I/usr/inet6/include $OPT"
1548                         fi
1549                         ;;
1550                 solaris)
1551                         if test -f /etc/netconfig; then
1552                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1553                                 ipv6type=$i
1554                                 ipv6trylibc=yes
1555                           fi
1556                         fi
1557                         ;;
1558                 toshiba)
1559                         AC_EGREP_CPP(yes, [
1560 #include <sys/param.h>
1561 #ifdef _TOSHIBA_INET6
1563 #endif],
1564                                 [ipv6type=$i;
1565                                 ipv6lib=inet6;
1566                                 ipv6libdir=/usr/local/v6/lib])
1567                         ;;
1568                 v6d)
1569                         AC_EGREP_CPP(yes, [
1570 #include </usr/local/v6/include/sys/v6config.h>
1571 #ifdef __V6D__
1573 #endif],
1574                                 [ipv6type=$i;
1575                                 ipv6lib=v6;
1576                                 ipv6libdir=/usr/local/v6/lib;
1577                                 OPT="-I/usr/local/v6/include $OPT"])
1578                         ;;
1579                 zeta)
1580                         AC_EGREP_CPP(yes, [
1581 #include <sys/param.h>
1582 #ifdef _ZETA_MINAMI_INET6
1584 #endif],
1585                                 [ipv6type=$i;
1586                                 ipv6lib=inet6;
1587                                 ipv6libdir=/usr/local/v6/lib])
1588                         ;;
1589                 esac
1590                 if test "$ipv6type" != "unknown"; then
1591                         break
1592                 fi
1593         done
1594         AC_MSG_RESULT($ipv6type)
1597 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1598         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1599                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1600                 echo "using lib$ipv6lib"
1601         else
1602                 if test $ipv6trylibc = "yes"; then
1603                         echo "using libc"
1604                 else
1605                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
1606                         echo "You need to fetch lib$ipv6lib.a from appropriate"
1607                         echo 'ipv6 kit and compile beforehand.'
1608                         exit 1
1609                 fi
1610         fi
1613 # Check for universal newline support
1614 AC_MSG_CHECKING(for --with-universal-newlines)
1615 AC_ARG_WITH(universal-newlines,
1616             AC_HELP_STRING(--with(out)-universal-newlines, disable/enable foreign newlines))
1618 if test -z "$with_universal_newlines"
1619 then with_universal_newlines="yes"
1621 if test "$with_universal_newlines" = "no"
1622 then
1623     echo --without-universal-newlines is unsupported, see README
1624     exit 1
1625 else
1626     AC_DEFINE(WITH_UNIVERSAL_NEWLINES, 1,
1627       [Define if you want to read files with foreign newlines.])
1629 AC_MSG_RESULT($with_universal_newlines)
1631 # Check for --with-doc-strings
1632 AC_MSG_CHECKING(for --with-doc-strings)
1633 AC_ARG_WITH(doc-strings,
1634             AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
1636 if test -z "$with_doc_strings"
1637 then with_doc_strings="yes"
1639 if test "$with_doc_strings" != "no"
1640 then
1641     AC_DEFINE(WITH_DOC_STRINGS, 1,
1642       [Define if you want documentation strings in extension modules])
1644 AC_MSG_RESULT($with_doc_strings)
1646 # Check for Python-specific malloc support
1647 AC_MSG_CHECKING(for --with-pymalloc)
1648 AC_ARG_WITH(pymalloc,
1649             AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
1651 if test -z "$with_pymalloc"
1652 then with_pymalloc="yes"
1654 if test "$with_pymalloc" != "no"
1655 then
1656     AC_DEFINE(WITH_PYMALLOC, 1, 
1657      [Define if you want to compile in Python-specific mallocs])
1659 AC_MSG_RESULT($with_pymalloc)
1661 # Check for --with-wctype-functions
1662 AC_MSG_CHECKING(for --with-wctype-functions)
1663 AC_ARG_WITH(wctype-functions, 
1664             AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
1666 if test "$withval" != no
1667 then 
1668   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
1669   [Define if you want wctype.h functions to be used instead of the
1670    one supplied by Python itself. (see Include/unicodectype.h).]) 
1671   AC_MSG_RESULT(yes)
1672 else AC_MSG_RESULT(no)
1673 fi],
1674 [AC_MSG_RESULT(no)])
1676 # -I${DLINCLDIR} is added to the compile rule for importdl.o
1677 AC_SUBST(DLINCLDIR)
1678 DLINCLDIR=.
1680 AC_MSG_CHECKING(for --with-sgi-dl)
1681 AC_ARG_WITH(sgi-dl,
1682             AC_HELP_STRING(--with-sgi-dl=DIRECTORY, IRIX 4 dynamic linking),
1684 AC_MSG_RESULT($withval)
1685 echo --with-sgi-dl is unsupported, see README
1686 exit 1
1687 AC_DEFINE(WITH_SGI_DL, 1,
1688   [Define if you want to use SGI (IRIX 4) dynamic linking.
1689    This requires the "dl" library by Jack Jansen,
1690    ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z.
1691    Do not bother on IRIX 5, it already has dynamic linking using SunOS
1692    style shared libraries])
1693 DYNLOADFILE="dynload_dl.o"
1694 dldir=$withval
1695 if test ! -z "$dldir" -a -d "$dldir"
1696 then LDFLAGS="$LDFLAGS -L$dldir"
1697 else AC_MSG_ERROR([proper usage is --with-sgi-dl=DIRECTORY])
1699 DLINCLDIR=${dldir}
1700 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
1702 AC_MSG_CHECKING(for --with-dl-dld)
1703 AC_ARG_WITH(dl-dld,
1704             AC_HELP_STRING(--with-dl-dld=DL_DIR, GNU dynamic linking),
1706 AC_MSG_RESULT($withval)
1707 echo --with-dl-dld is unsupported, see README
1708 exit 1
1709 AC_DEFINE(WITH_DL_DLD, 1, 
1710   [Define if you want to emulate SGI (IRIX 4) dynamic linking.
1711    This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4),
1712    Sequent Symmetry (Dynix), and Atari ST.
1713    This requires the 'dl-dld' library,
1714    ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z,
1715    as well as the 'GNU dld' library,
1716    ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z.
1717    Do not bother on SunOS 4 or 5, they already have dynamic linking using
1718    shared libraries.])
1719 DYNLOADFILE="dynload_dl.o"
1720 dldir=`echo "$withval" | sed 's/,.*//'`
1721 dlddir=`echo "$withval" | sed 's/.*,//'`
1722 if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
1723 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
1724 else AC_MSG_ERROR([proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY])
1726 DLINCLDIR=${dldir}
1727 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
1729 # the dlopen() function means we might want to use dynload_shlib.o. some
1730 # platforms, such as AIX, have dlopen(), but don't want to use it.
1731 AC_CHECK_FUNCS(dlopen)
1733 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1734 # loading of modules.
1735 AC_SUBST(DYNLOADFILE)
1736 AC_MSG_CHECKING(DYNLOADFILE)
1737 if test -z "$DYNLOADFILE"
1738 then
1739         case $ac_sys_system/$ac_sys_release in
1740         AIX*) DYNLOADFILE="dynload_aix.o";;
1741         BeOS*) DYNLOADFILE="dynload_beos.o";;
1742         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
1743         Darwin/*) DYNLOADFILE="dynload_next.o";;
1744         atheos*) DYNLOADFILE="dynload_atheos.o";;
1745         *)
1746         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1747         # out any dynamic loading
1748         if test "$ac_cv_func_dlopen" = yes
1749         then DYNLOADFILE="dynload_shlib.o"
1750         else DYNLOADFILE="dynload_stub.o"
1751         fi
1752         ;;
1753         esac
1755 AC_MSG_RESULT($DYNLOADFILE)
1756 if test "$DYNLOADFILE" != "dynload_stub.o"
1757 then
1758         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
1759         [Defined when any dynamic module loading is enabled.])
1762 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
1764 AC_SUBST(MACHDEP_OBJS)
1765 AC_MSG_CHECKING(MACHDEP_OBJS)
1766 if test -z "$MACHDEP_OBJS"
1767 then
1768         MACHDEP_OBJS=$extra_machdep_objs
1769 else
1770         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
1772 AC_MSG_RESULT(MACHDEP_OBJS)
1774 # checks for library functions
1775 AC_CHECK_FUNCS(alarm chown clock confstr ctermid execv \
1776  fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
1777  gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
1778  getpriority getpwent getwd \
1779  hstrerror inet_pton kill killpg lchown lstat mkfifo mknod mktime \
1780  mremap nice pathconf pause plock poll pthread_init \
1781  putenv readlink \
1782  select setegid seteuid setgid \
1783  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
1784  sigaction siginterrupt sigrelse strftime strptime \
1785  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
1786  truncate uname unsetenv utimes waitpid wcscoll _getpty)
1788 # For some functions, having a definition is not sufficient, since
1789 # we want to take their address.
1790 AC_MSG_CHECKING(for chroot)
1791 AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
1792   AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
1793   AC_MSG_RESULT(yes),
1794   AC_MSG_RESULT(no)
1796 AC_MSG_CHECKING(for link)
1797 AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
1798   AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
1799   AC_MSG_RESULT(yes),
1800   AC_MSG_RESULT(no)
1802 AC_MSG_CHECKING(for symlink)
1803 AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
1804   AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
1805   AC_MSG_RESULT(yes),
1806   AC_MSG_RESULT(no)
1809 # On some systems (eg. FreeBSD 5), we would find a definition of the
1810 # functions ctermid_r, setgroups in the library, but no prototype
1811 # (e.g. because we use _XOPEN_SOURCE). See whether we can take their
1812 # address to avoid compiler warnings and potential miscompilations
1813 # because of the missing prototypes.
1815 AC_MSG_CHECKING(for ctermid_r)
1816 AC_TRY_COMPILE([
1817 #include "confdefs.h" 
1818 #include <stdio.h>
1819 ], void* p = ctermid_r,
1820   AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
1821   AC_MSG_RESULT(yes),
1822   AC_MSG_RESULT(no)
1825 AC_MSG_CHECKING(for setgroups)
1826 AC_TRY_COMPILE([
1827 #include "confdefs.h" 
1828 #include <unistd.h.h>
1829 ], 
1830 void* p = setgroups,
1831   AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
1832   AC_MSG_RESULT(yes),
1833   AC_MSG_RESULT(no)
1836 # check for openpty and forkpty
1838 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"]))
1839 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"]))
1841 # check for long file support functions
1842 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1844 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
1845 AC_CHECK_FUNCS(getpgrp, 
1846   AC_TRY_COMPILE([#include <unistd.h>], 
1847    [getpgrp(0);], 
1848    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
1849    [Define if getpgrp() must be called as getpgrp(0).])
1852 AC_FUNC_SETPGRP(AC_DEFINE(SETPGRP_HAVE_ARG, 1,
1853            [Define if setpgrp() must be called as setpgrp(0, 0).])
1855 AC_CHECK_FUNCS(gettimeofday, 
1856   AC_TRY_COMPILE([#include <sys/time.h>], 
1857     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
1858     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
1859     [Define if gettimeofday() does not have second (timezone) argument
1860      This is the case on Motorola V4 (R40V4.2)])
1861   )
1864 AC_MSG_CHECKING(for major, minor, and makedev)
1865 AC_TRY_LINK([
1866   #if defined(MAJOR_IN_MKDEV)
1867   #include <sys/mkdev.h>
1868   #elif defined(MAJOR_IN_SYSMACROS)
1869   #include <sys/sysmacros.h>
1870   #else
1871   #include <sys/types.h>
1872   #endif
1874   makedev(major(0),minor(0));
1876   AC_DEFINE(HAVE_DEVICE_MACROS, 1,
1877             [Define to 1 if you have the device macros.])
1878   AC_MSG_RESULT(yes)
1880   AC_MSG_RESULT(no)
1883 # On OSF/1 V5.1, getaddrinfo is available, but a define
1884 # for [no]getaddrinfo in netdb.h. 
1885 AC_MSG_CHECKING(for getaddrinfo)
1886 AC_TRY_LINK([
1887 #include <sys/types.h>
1888 #include <sys/socket.h>
1889 #include <netdb.h>
1890 #include <stdio.h>
1892 getaddrinfo(NULL, NULL, NULL, NULL);
1893 ], [
1894 AC_MSG_RESULT(yes)
1895 AC_MSG_CHECKING(getaddrinfo bug)
1896 AC_TRY_RUN([
1897 #include <sys/types.h>
1898 #include <netdb.h>
1899 #include <string.h>
1900 #include <sys/socket.h>
1901 #include <netinet/in.h>
1903 main()
1905   int passive, gaierr, inet4 = 0, inet6 = 0;
1906   struct addrinfo hints, *ai, *aitop;
1907   char straddr[INET6_ADDRSTRLEN], strport[16];
1909   for (passive = 0; passive <= 1; passive++) {
1910     memset(&hints, 0, sizeof(hints));
1911     hints.ai_family = AF_UNSPEC;
1912     hints.ai_flags = passive ? AI_PASSIVE : 0;
1913     hints.ai_socktype = SOCK_STREAM;
1914     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1915       (void)gai_strerror(gaierr);
1916       goto bad;
1917     }
1918     for (ai = aitop; ai; ai = ai->ai_next) {
1919       if (ai->ai_addr == NULL ||
1920           ai->ai_addrlen == 0 ||
1921           getnameinfo(ai->ai_addr, ai->ai_addrlen,
1922                       straddr, sizeof(straddr), strport, sizeof(strport),
1923                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1924         goto bad;
1925       }
1926       switch (ai->ai_family) {
1927       case AF_INET:
1928         if (strcmp(strport, "54321") != 0) {
1929           goto bad;
1930         }
1931         if (passive) {
1932           if (strcmp(straddr, "0.0.0.0") != 0) {
1933             goto bad;
1934           }
1935         } else {
1936           if (strcmp(straddr, "127.0.0.1") != 0) {
1937             goto bad;
1938           }
1939         }
1940         inet4++;
1941         break;
1942       case AF_INET6:
1943         if (strcmp(strport, "54321") != 0) {
1944           goto bad;
1945         }
1946         if (passive) {
1947           if (strcmp(straddr, "::") != 0) {
1948             goto bad;
1949           }
1950         } else {
1951           if (strcmp(straddr, "::1") != 0) {
1952             goto bad;
1953           }
1954         }
1955         inet6++;
1956         break;
1957       case AF_UNSPEC:
1958         goto bad;
1959         break;
1960       default:
1961         /* another family support? */
1962         break;
1963       }
1964     }
1965   }
1967   if (!(inet4 == 0 || inet4 == 2))
1968     goto bad;
1969   if (!(inet6 == 0 || inet6 == 2))
1970     goto bad;
1972   if (aitop)
1973     freeaddrinfo(aitop);
1974   exit(0);
1976  bad:
1977   if (aitop)
1978     freeaddrinfo(aitop);
1979   exit(1);
1982 AC_MSG_RESULT(good)
1983 buggygetaddrinfo=no,
1984 AC_MSG_RESULT(buggy)
1985 buggygetaddrinfo=yes,
1986 AC_MSG_RESULT(buggy)
1987 buggygetaddrinfo=yes)], [
1988 AC_MSG_RESULT(no)
1989 buggygetaddrinfo=yes
1992 if test "$buggygetaddrinfo" = "yes"; then
1993         if test "$ipv6" = "yes"; then
1994                 echo 'Fatal: You must get working getaddrinfo() function.'
1995                 echo '       or you can specify "--disable-ipv6"'.
1996                 exit 1
1997         fi
1998 else
1999         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2001 AC_CHECK_FUNCS(getnameinfo)
2003 # checks for structures
2004 AC_HEADER_TIME
2005 AC_STRUCT_TM
2006 AC_STRUCT_TIMEZONE
2007 AC_CHECK_MEMBERS([struct stat.st_rdev])
2008 AC_CHECK_MEMBERS([struct stat.st_blksize])
2009 AC_STRUCT_ST_BLOCKS
2011 AC_MSG_CHECKING(for time.h that defines altzone)
2012 AC_CACHE_VAL(ac_cv_header_time_altzone,
2013 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2014   ac_cv_header_time_altzone=yes,
2015   ac_cv_header_time_altzone=no)])
2016 AC_MSG_RESULT($ac_cv_header_time_altzone)
2017 if test $ac_cv_header_time_altzone = yes; then
2018   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2021 was_it_defined=no
2022 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2023 AC_TRY_COMPILE([
2024 #include <sys/types.h>
2025 #include <sys/select.h>
2026 #include <sys/time.h>
2027 ], [;], [
2028   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2029   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
2030    (which you can't on SCO ODT 3.0).]) 
2031   was_it_defined=yes
2033 AC_MSG_RESULT($was_it_defined)
2035 AC_MSG_CHECKING(for addrinfo)
2036 AC_CACHE_VAL(ac_cv_struct_addrinfo,
2037 AC_TRY_COMPILE([
2038 #               include <netdb.h>],
2039         [struct addrinfo a],
2040         ac_cv_struct_addrinfo=yes,
2041         ac_cv_struct_addrinfo=no))
2042 AC_MSG_RESULT($ac_cv_struct_addrinfo)
2043 if test $ac_cv_struct_addrinfo = yes; then
2044         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
2047 AC_MSG_CHECKING(for sockaddr_storage)
2048 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2049 AC_TRY_COMPILE([
2050 #               include <sys/types.h>
2051 #               include <sys/socket.h>],
2052         [struct sockaddr_storage s],
2053         ac_cv_struct_sockaddr_storage=yes,
2054         ac_cv_struct_sockaddr_storage=no))
2055 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2056 if test $ac_cv_struct_sockaddr_storage = yes; then
2057         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
2060 # checks for compiler characteristics
2062 AC_C_CHAR_UNSIGNED
2063 AC_C_CONST
2065 works=no
2066 AC_MSG_CHECKING(for working volatile)
2067 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
2068   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2070 AC_MSG_RESULT($works)
2072 works=no
2073 AC_MSG_CHECKING(for working signed char)
2074 AC_TRY_COMPILE([], [signed char c;], works=yes, 
2075   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2077 AC_MSG_RESULT($works)
2079 have_prototypes=no
2080 AC_MSG_CHECKING(for prototypes)
2081 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2082   AC_DEFINE(HAVE_PROTOTYPES, 1, 
2083    [Define if your compiler supports function prototype]) 
2084   have_prototypes=yes
2086 AC_MSG_RESULT($have_prototypes)
2088 works=no
2089 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
2090 AC_TRY_COMPILE([
2091 #include <stdarg.h>
2092 int foo(int x, ...) {
2093         va_list va;
2094         va_start(va, x);
2095         va_arg(va, int);
2096         va_arg(va, char *);
2097         va_arg(va, double);
2098         return 0;
2100 ], [return foo(10, "", 3.14);], [
2101   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2102    [Define if your compiler supports variable length function prototypes
2103    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
2104   works=yes
2106 AC_MSG_RESULT($works)
2108 if test "$have_prototypes" = yes; then
2109 bad_prototypes=no
2110 AC_MSG_CHECKING(for bad exec* prototypes)
2111 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
2112     AC_DEFINE(BAD_EXEC_PROTOTYPES, 1,
2113     [Define if your <unistd.h> contains bad prototypes for exec*()
2114     (as it does on SGI IRIX 4.x)]) 
2115     bad_prototypes=yes
2117 AC_MSG_RESULT($bad_prototypes)
2120 # check if sockaddr has sa_len member
2121 AC_MSG_CHECKING(if sockaddr has sa_len member)
2122 AC_TRY_COMPILE([#include <sys/types.h>
2123 #include <sys/socket.h>],
2124 [struct sockaddr x;
2125 x.sa_len = 0;],
2126         AC_MSG_RESULT(yes)
2127         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
2128         AC_MSG_RESULT(no))
2130 va_list_is_array=no
2131 AC_MSG_CHECKING(whether va_list is an array)
2132 AC_TRY_COMPILE([
2133 #ifdef HAVE_STDARG_PROTOTYPES
2134 #include <stdarg.h>
2135 #else
2136 #include <varargs.h>
2137 #endif
2138 ], [va_list list1, list2; list1 = list2;], , [
2139  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
2140  va_list_is_array=yes
2142 AC_MSG_RESULT($va_list_is_array)
2144 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
2145 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2146   [Define this if you have some version of gethostbyname_r()])
2148 AC_CHECK_FUNC(gethostbyname_r, [
2149   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2150   AC_MSG_CHECKING([gethostbyname_r with 6 args])
2151   OLD_CFLAGS=$CFLAGS
2152   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2153   AC_TRY_COMPILE([
2154 #   include <netdb.h>
2155   ], [
2156     char *name;
2157     struct hostent *he, *res;
2158     char buffer[2048];
2159     int buflen = 2048;
2160     int h_errnop;
2162     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2163   ], [
2164     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2165     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2166     [Define this if you have the 6-arg version of gethostbyname_r().])
2167     AC_MSG_RESULT(yes)
2168   ], [
2169     AC_MSG_RESULT(no)
2170     AC_MSG_CHECKING([gethostbyname_r with 5 args])
2171     AC_TRY_COMPILE([
2172 #     include <netdb.h>
2173     ], [
2174       char *name;
2175       struct hostent *he;
2176       char buffer[2048];
2177       int buflen = 2048;
2178       int h_errnop;
2180       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2181     ], [
2182       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2183       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2184       [Define this if you have the 5-arg version of gethostbyname_r().])
2185       AC_MSG_RESULT(yes)
2186     ], [
2187       AC_MSG_RESULT(no)
2188       AC_MSG_CHECKING([gethostbyname_r with 3 args])
2189       AC_TRY_COMPILE([
2190 #       include <netdb.h>
2191       ], [
2192         char *name;
2193         struct hostent *he;
2194         struct hostent_data data;
2196         (void) gethostbyname_r(name, he, &data);
2197       ], [
2198         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2199         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2200         [Define this if you have the 3-arg version of gethostbyname_r().])
2201         AC_MSG_RESULT(yes)
2202       ], [
2203         AC_MSG_RESULT(no)
2204       ])
2205     ])
2206   ])
2207   CFLAGS=$OLD_CFLAGS
2208 ], [
2209   AC_CHECK_FUNCS(gethostbyname)
2211 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2212 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2213 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
2214 AC_SUBST(HAVE_GETHOSTBYNAME_R)
2215 AC_SUBST(HAVE_GETHOSTBYNAME)
2217 # checks for system services
2218 # (none yet)
2220 # Linux requires this for correct f.p. operations
2221 AC_CHECK_FUNC(__fpu_control,
2222   [],
2223   [AC_CHECK_LIB(ieee, __fpu_control)
2226 # Check for --with-fpectl
2227 AC_MSG_CHECKING(for --with-fpectl)
2228 AC_ARG_WITH(fpectl,
2229             AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
2231 if test "$withval" != no
2232 then 
2233   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2234   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
2235   AC_MSG_RESULT(yes)
2236 else AC_MSG_RESULT(no)
2237 fi],
2238 [AC_MSG_RESULT(no)])
2240 # check for --with-libm=...
2241 AC_SUBST(LIBM)
2242 case $ac_sys_system in
2243 Darwin) ;;
2244 BeOS) ;;
2245 *) LIBM=-lm
2246 esac
2247 AC_MSG_CHECKING(for --with-libm=STRING)
2248 AC_ARG_WITH(libm,
2249             AC_HELP_STRING(--with-libm=STRING, math library),
2251 if test "$withval" = no
2252 then LIBM=
2253      AC_MSG_RESULT(force LIBM empty)
2254 elif test "$withval" != yes
2255 then LIBM=$withval
2256      AC_MSG_RESULT(set LIBM="$withval")
2257 else AC_MSG_ERROR([proper usage is --with-libm=STRING])
2258 fi],
2259 [AC_MSG_RESULT(default LIBM="$LIBM")])
2261 # check for --with-libc=...
2262 AC_SUBST(LIBC)
2263 AC_MSG_CHECKING(for --with-libc=STRING)
2264 AC_ARG_WITH(libc,
2265             AC_HELP_STRING(--with-libc=STRING, C library),
2267 if test "$withval" = no
2268 then LIBC=
2269      AC_MSG_RESULT(force LIBC empty)
2270 elif test "$withval" != yes
2271 then LIBC=$withval
2272      AC_MSG_RESULT(set LIBC="$withval")
2273 else AC_MSG_ERROR([proper usage is --with-libc=STRING])
2274 fi],
2275 [AC_MSG_RESULT(default LIBC="$LIBC")])
2277 # check for hypot() in math library
2278 LIBS_SAVE=$LIBS
2279 LIBS="$LIBS $LIBM"
2280 AC_REPLACE_FUNCS(hypot)
2281 LIBS=$LIBS_SAVE
2283 # check for wchar.h
2284 AC_CHECK_HEADER(wchar.h, [
2285   AC_DEFINE(HAVE_WCHAR_H, 1, 
2286   [Define if the compiler provides a wchar.h header file.]) 
2287   wchar_h="yes"
2289 wchar_h="no"
2292 # determine wchar_t size
2293 if test "$wchar_h" = yes
2294 then
2295   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
2298 AC_MSG_CHECKING(what type to use for unicode)
2299 dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2300 AC_ARG_ENABLE(unicode, 
2301               AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
2302               [],
2303               [enable_unicode=yes])
2305 if test $enable_unicode = yes
2306 then
2307   # Without any arguments, Py_UNICODE defaults to two-byte mode
2308   enable_unicode="ucs2"
2311 AH_TEMPLATE(Py_UNICODE_SIZE,
2312   [Define as the size of the unicode type.])
2313 case "$enable_unicode" in
2314 ucs2) unicode_size="2"
2315       AC_DEFINE(Py_UNICODE_SIZE,2)
2316       ;;
2317 ucs4) unicode_size="4"
2318       AC_DEFINE(Py_UNICODE_SIZE,4)
2319       ;;
2320 esac
2322 AH_TEMPLATE(PY_UNICODE_TYPE,
2323   [Define as the integral type used for Unicode representation.])
2325 AC_SUBST(UNICODE_OBJS)
2326 if test "$enable_unicode" = "no"
2327 then
2328   UNICODE_OBJS=""
2329   AC_MSG_RESULT(not used)
2330 else
2331   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
2332   AC_DEFINE(Py_USING_UNICODE, 1,
2333   [Define if you want to have a Unicode type.])
2334   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
2335   then
2336     PY_UNICODE_TYPE="wchar_t"
2337     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
2338     [Define if you have a useable wchar_t type defined in wchar.h; useable
2339      means wchar_t must be 16-bit unsigned type. (see
2340      Include/unicodeobject.h).])
2341     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
2342   elif test "$ac_cv_sizeof_short" = "$unicode_size"
2343   then
2344        PY_UNICODE_TYPE="unsigned short"
2345        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
2346   elif test "$ac_cv_sizeof_long" = "$unicode_size"
2347   then
2348        PY_UNICODE_TYPE="unsigned long"
2349        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
2350   else
2351        PY_UNICODE_TYPE="no type found"
2352   fi
2353   AC_MSG_RESULT($PY_UNICODE_TYPE)
2356 # check for endianness
2357 AC_C_BIGENDIAN
2359 # Check whether right shifting a negative integer extends the sign bit
2360 # or fills with zeros (like the Cray J90, according to Tim Peters).
2361 AC_MSG_CHECKING(whether right shift extends the sign bit)
2362 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
2363 AC_TRY_RUN([
2364 int main()
2366         exit(((-1)>>3 == -1) ? 0 : 1);
2369 ac_cv_rshift_extends_sign=yes,
2370 ac_cv_rshift_extends_sign=no,
2371 ac_cv_rshift_extends_sign=yes)])
2372 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
2373 if test "$ac_cv_rshift_extends_sign" = no
2374 then
2375   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
2376   [Define if i>>j for signed int i does not extend the sign bit
2377    when i < 0])
2380 # check for getc_unlocked and related locking functions
2381 AC_MSG_CHECKING(for getc_unlocked() and friends)
2382 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
2383 AC_TRY_LINK([#include <stdio.h>],[
2384         FILE *f = fopen("/dev/null", "r");
2385         flockfile(f);
2386         getc_unlocked(f);
2387         funlockfile(f);
2388 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
2389 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
2390 if test "$ac_cv_have_getc_unlocked" = yes
2391 then
2392   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
2393   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
2396 # check for readline 2.2
2397 AC_TRY_CPP([#include <readline/readline.h>],
2398 have_readline=yes, have_readline=no)
2399 if test $have_readline = yes
2400 then
2401   AC_EGREP_HEADER([extern int rl_completion_append_character;],
2402   [readline/readline.h],
2403   AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
2404   [Define if you have readline 2.2]), )
2407 # check for readline 4.0
2408 AC_CHECK_LIB(readline, rl_pre_input_hook,
2409         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
2410         [Define if you have readline 4.0]), , -ltermcap)
2412 # check for readline 4.2
2413 AC_CHECK_LIB(readline, rl_completion_matches,
2414         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
2415         [Define if you have readline 4.2]), , -ltermcap)
2417 AC_MSG_CHECKING(for broken nice())
2418 AC_CACHE_VAL(ac_cv_broken_nice, [
2419 AC_TRY_RUN([
2420 int main()
2422         int val1 = nice(1);
2423         if (val1 != -1 && val1 == nice(2))
2424                 exit(0);
2425         exit(1);
2428 ac_cv_broken_nice=yes,
2429 ac_cv_broken_nice=no,
2430 ac_cv_broken_nice=no)])
2431 AC_MSG_RESULT($ac_cv_broken_nice)
2432 if test "$ac_cv_broken_nice" = yes
2433 then
2434   AC_DEFINE(HAVE_BROKEN_NICE, 1,
2435   [Define if nice() returns success/failure instead of the new priority.])
2438 # Look for subsecond timestamps in struct stat
2439 AC_MSG_CHECKING(for tv_nsec in struct stat)
2440 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
2441 AC_TRY_COMPILE([#include <sys/stat.h>], [
2442 struct stat st;
2443 st.st_mtim.tv_nsec = 1;
2445 ac_cv_stat_tv_nsec=yes,
2446 ac_cv_stat_tv_nsec=no,
2447 ac_cv_stat_tv_nsec=no))
2448 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
2449 if test "$ac_cv_stat_tv_nsec" = yes
2450 then
2451   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
2452   [Define if you have struct stat.st_mtim.tv_nsec])
2455 # On HP/UX 11.0, mvwdelch is a block with a return statement
2456 AC_MSG_CHECKING(whether mvwdelch is an expression)
2457 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
2458 AC_TRY_COMPILE([#include <curses.h>], [
2459   int rtn;
2460   rtn = mvwdelch(0,0,0);
2461 ], ac_cv_mvwdelch_is_expression=yes,
2462    ac_cv_mvwdelch_is_expression=no,
2463    ac_cv_mvwdelch_is_expression=yes))
2464 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
2466 if test "$ac_cv_mvwdelch_is_expression" = yes
2467 then
2468   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
2469   [Define if mvwdelch in curses.h is an expression.])
2472 AC_MSG_CHECKING(whether WINDOW has _flags)
2473 AC_CACHE_VAL(ac_cv_window_has_flags,
2474 AC_TRY_COMPILE([#include <curses.h>], [
2475   WINDOW *w;
2476   w->_flags = 0;
2477 ], ac_cv_window_has_flags=yes,
2478    ac_cv_window_has_flags=no,
2479    ac_cv_window_has_flags=no))
2480 AC_MSG_RESULT($ac_cv_window_has_flags)
2483 if test "$ac_cv_window_has_flags" = yes
2484 then
2485   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
2486   [Define if WINDOW in curses.h offers a field _flags.])
2489 AC_MSG_CHECKING(for /dev/ptmx)
2491 if test -e /dev/ptmx
2492 then
2493   AC_MSG_RESULT(yes)
2494   AC_DEFINE(HAVE_DEV_PTMX, 1,
2495   [Define if we have /dev/ptmx.])
2496 else
2497   AC_MSG_RESULT(no)
2500 AC_CHECK_TYPE(socklen_t,,
2501   AC_DEFINE(socklen_t,int,
2502             Define to `int' if <sys/socket.h> does not define.),[
2503 #ifdef HAVE_SYS_TYPES_H
2504 #include <sys/types.h>
2505 #endif
2506 #ifdef HAVE_SYS_SOCKET_H
2507 #include <sys/socket.h>
2508 #endif
2511 AC_SUBST(THREADHEADERS)
2513 for h in `(cd $srcdir;echo Python/thread_*.h)`
2515   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
2516 done
2518 AC_SUBST(SRCDIRS)
2519 SRCDIRS="Parser Grammar Objects Python Modules Mac Mac/Python"
2520 AC_MSG_CHECKING(for build directories)
2521 for dir in $SRCDIRS; do
2522     if test ! -d $dir; then
2523         mkdir $dir
2524     fi
2525 done
2526 AC_MSG_RESULT(done)
2528 # generate output files
2529 AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
2530 AC_OUTPUT
2532 echo "creating Setup"
2533 if test ! -f Modules/Setup
2534 then
2535         cp $srcdir/Modules/Setup.dist Modules/Setup
2538 echo "creating Setup.local"
2539 if test ! -f Modules/Setup.local
2540 then
2541         echo "# Edit this file for local setup changes" >Modules/Setup.local
2544 echo "creating Makefile"
2545 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
2546                         -s Modules Modules/Setup.config \
2547                         Modules/Setup.local Modules/Setup
2548 mv config.c Modules