This commit was manufactured by cvs2svn to create tag 'r22a4-fork'.
[python/dscho.git] / configure.in
blob32147bf5f5010d14cd8b0f9b25ae8d4baed40bc3
1 dnl Process this file with autoconf 2.0 or later to make a configure script.
2 AC_REVISION($Revision$)
3 AC_PREREQ(2.0)
4 AC_INIT(Include/object.h)
5 AC_CONFIG_HEADER(pyconfig.h)
7 # Set VERSION so we only need to edit in one place (i.e., here)
8 AC_SUBST(VERSION)
9 VERSION=2.2
11 # Arguments passed to configure.
12 AC_SUBST(CONFIG_ARGS)
13 CONFIG_ARGS="$ac_configure_args"
16 AC_ARG_ENABLE(framework,
17 [  --enable-framework[=INSTALLDIR] Build (MacOSX|Darwin) framework],[
18         case $enableval in
19         yes) 
20                 enableval=/Library/Frameworks
21         esac
22         case $enableval in
23         no)
24                 PYTHONFRAMEWORK=
25                 PYTHONFRAMEWORKDIR=no-framework
26                 PYTHONFRAMEWORKPREFIX=
27                 PYTHONFRAMEWORKINSTALLDIR=
28                 enable_framework=
29                 ;;
30         *)
31                 PYTHONFRAMEWORK=Python
32                 PYTHONFRAMEWORKDIR=Python.framework
33                 PYTHONFRAMEWORKPREFIX=$enableval
34                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
35                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
36         esac
37         ],[
38         PYTHONFRAMEWORK=
39         PYTHONFRAMEWORKDIR=no-framework
40         PYTHONFRAMEWORKPREFIX=
41         PYTHONFRAMEWORKINSTALLDIR=
42         enable_framework=
44 AC_SUBST(PYTHONFRAMEWORK)
45 AC_SUBST(PYTHONFRAMEWORKDIR)
46 AC_SUBST(PYTHONFRAMEWORKPREFIX)
47 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
49 ##AC_ARG_WITH(dyld,
50 ##[  --with-dyld                     Use (OpenStep|Rhapsody) dynamic linker],,)
52 # Set name for machine-dependent library files
53 AC_SUBST(MACHDEP)
54 AC_MSG_CHECKING(MACHDEP)
55 if test -z "$MACHDEP"
56 then
57         ac_sys_system=`uname -s`
58         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
59                 ac_sys_release=`uname -v`
60         else
61                 ac_sys_release=`uname -r`
62         fi
63         ac_md_system=`echo $ac_sys_system |
64                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
65         ac_md_release=`echo $ac_sys_release |
66                            tr -d '[/ ]' | sed 's/\..*//'`
67         MACHDEP="$ac_md_system$ac_md_release"
69         case $MACHDEP in
70         cygwin*) MACHDEP="cygwin";;
71         '')     MACHDEP="unknown";;
72         esac
76 # SGI compilers allow the specification of the both the ABI and the
77 # ISA on the command line.  Depending on the values of these switches,
78 # different and often incompatable code will be generated.
80 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
81 # thus supply support for various ABI/ISA combinations.  The MACHDEP
82 # variable is also adjusted.
84 AC_SUBST(SGI_ABI)
85 if test ! -z "$SGI_ABI"
86 then
87         CC="cc $SGI_ABI"
88         LDFLAGS="$SGI_ABI $LDFLAGS"
89         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
91 AC_MSG_RESULT($MACHDEP)
93 # checks for alternative programs
94 AC_MSG_CHECKING(for --without-gcc)
95 AC_ARG_WITH(gcc, [  --without-gcc                   never use gcc], [
96         case $withval in
97         no)     CC=cc
98                 without_gcc=yes;;
99         yes)    CC=gcc
100                 without_gcc=no;;
101         *)      CC=$withval
102                 without_gcc=$withval;;
103         esac], [
104         case $ac_sys_system in
105         AIX*)   CC=cc_r
106                 without_gcc=;;
107         BeOS*)
108                 case $BE_HOST_CPU in
109                 ppc)
110                         CC=mwcc
111                         without_gcc=yes
112                         OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
113                         CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
114                         LDFLAGS="$LDFLAGS -nodup"
115                         ;;
116                 x86)
117                         CC=gcc
118                         without_gcc=no
119                         OPT=-O
120                         ;;
121                 *)
122                         AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
123                         ;;
124                 esac
125                 AR="\$(srcdir)/Modules/ar_beos"
126                 RANLIB=:
127                 ;;
128     Monterey*)
129         RANLIB=:
130         without_gcc=;;
131         *)      without_gcc=no;;
132         esac])
133 AC_MSG_RESULT($without_gcc)
135 AC_SUBST(CXX)
136 AC_SUBST(MAINOBJ)
137 MAINOBJ=python.o
138 AC_MSG_CHECKING(for --with-cxx=<compiler>)
139 AC_ARG_WITH(cxx, [  --with-cxx=<compiler>           enable C++ support],[
140         check_cxx=no
141         case $withval in
142         no)     CXX=
143                 with_cxx=no;;
144         *)      CXX=$withval
145                 MAINOBJ=ccpython.o
146                 with_cxx=$withval;;
147         esac], [
148         with_cxx=no
149         check_cxx=yes
151 AC_MSG_RESULT($with_cxx)
153 dnl The following fragment works similar to AC_PROG_CXX.
154 dnl It does not fail if CXX is not found, and it is not executed if 
155 dnl --with-cxx was given.
156 dnl Finally, it does not test whether CXX is g++.
158 if test "$check_cxx" = "yes" 
159 then
160         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
161         if test "$CXX" = "notfound"
162         then
163                 CXX=
164         else
165                 AC_PROG_CXX_WORKS
166         fi
169 # If the user switches compilers, we can't believe the cache
170 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
171 then
172   AC_ERROR(cached CC is different -- throw away $cache_file
173 (it is also a good idea to do 'make clean' before compiling))
176 AC_PROG_CC
178 # checks for UNIX variants that set C preprocessor variables
179 AC_AIX
180 AC_MINIX
182 AC_EXEEXT
183 AC_MSG_CHECKING(for --with-suffix)
184 AC_ARG_WITH(suffix, [  --with-suffix=.exe              set executable suffix],[
185         case $withval in
186         no)     EXEEXT=;;
187         yes)    EXEEXT=.exe;;
188         *)      EXEEXT=$withval;;
189         esac])
190 AC_MSG_RESULT($EXEEXT)
191 # Test whether we're running on a non-case-sensitive system, in which
192 # case we give a warning if no ext is given
193 if test -d "python" -a -z "$EXEEXT"
194 then
195     AC_MSG_WARN(This filesystem is not case-sensitive so you should probably use --with-suffix)
198 case $MACHDEP in
199 bsdos*)
200     case $CC in
201     gcc) CC="$CC -D_HAVE_BSDI";;
202     esac;;
203 esac
205 case $ac_sys_system in
206 hp*|HP*)
207     case $CC in
208     cc|*/cc) CC="$CC -Ae";;
209     esac;;
210 Monterey*)
211     case $CC in
212     cc) CC="$CC -Wl,-Bexport";;
213     esac;;
214 SunOS*)
215     # Some functions have a prototype only with that define, e.g. confstr
216     AC_DEFINE(__EXTENSIONS__)
217     ;;
218 esac
221 AC_SUBST(LIBRARY)
222 AC_MSG_CHECKING(LIBRARY)
223 if test -z "$LIBRARY"
224 then
225         LIBRARY='libpython$(VERSION).a'
227 AC_MSG_RESULT($LIBRARY)
229 # LDLIBRARY is the name of the library to link against (as opposed to the
230 # name of the library into which to insert object files). BLDLIBRARY is also
231 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
232 # is blank as the main program is not linked directly against LDLIBRARY.
233 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
234 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
235 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
236 # DLLLIBRARY is the shared (i.e., DLL) library.
238 AC_SUBST(LDLIBRARY)
239 AC_SUBST(DLLLIBRARY)
240 AC_SUBST(BLDLIBRARY)
241 AC_SUBST(LDLIBRARYDIR)
242 LDLIBRARY="$LIBRARY"
243 BLDLIBRARY='$(LDLIBRARY)'
244 DLLLIBRARY=''
245 LDLIBRARYDIR=''
247 # LINKCC is the command that links the python executable -- default is $(CC).
248 # This is altered for AIX in order to build the export list before 
249 # linking.
250 AC_SUBST(LINKCC)
251 AC_MSG_CHECKING(LINKCC)
252 if test -z "$LINKCC"
253 then
254         case $ac_sys_system in
255         AIX*)
256            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
257         dgux*)
258            LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
259         Monterey64*)
260            LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
261         *) LINKCC="\$(PURIFY) \$(CC)";;
262         esac
264 AC_MSG_RESULT($LINKCC)
266 AC_MSG_CHECKING(LDLIBRARY)
268 # DG/UX requires some fancy ld contortions to produce a .so from an .a
269 case $MACHDEP in
270 dguxR4)
271       LDLIBRARY='libpython$(VERSION).so'
272       OPT="$OPT -pic"
273       ;;
274 beos*)
275       LDLIBRARY='libpython$(VERSION).so'
276       ;;
277 cygwin*)
278       LDLIBRARY='libpython$(VERSION).dll.a'
279       DLLLIBRARY='libpython$(VERSION).dll'
280       ;;
281 esac
283 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
284 # library that we build, but we do not want to link against it (we
285 # will find it with a -framework option). For this reason there is an
286 # extra variable BLDLIBRARY against which Python and the extension
287 # modules are linked, BLDLIBRARY. This is normally the same as
288 # LDLIBRARY, but empty for MacOSX framework builds.
289 if test "$enable_framework"
290 then
291   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
292   LDLIBRARYDIR='$(PYTHONFRAMEWORKDIR)'
293   BLDLIBRARY=''
294 else
295   BLDLIBRARY='$(LDLIBRARY)'
296 fi  
298 AC_MSG_RESULT($LDLIBRARY)
300 AC_PROG_RANLIB
301 AC_SUBST(AR)
302 AC_CHECK_PROGS(AR, ar aal, ar)
304 case $MACHDEP in
305 bsdos*)
306         # install -d does not work on BSDI
307         if test -z "$INSTALL"
308         then
309                 INSTALL="${srcdir}/install-sh -c"
310         fi
311 esac
312 AC_PROG_INSTALL
314 # Not every filesystem supports hard links
315 AC_SUBST(LN)
316 if test -z "$LN" ; then
317         case $ac_sys_system in
318                 BeOS*) LN="ln -s";;
319                 CYGWIN*) LN="ln -s";;
320                 *) LN=ln;;
321         esac
324 # Check for --with-pydebug
325 AC_MSG_CHECKING(for --with-pydebug)
326 AC_ARG_WITH(pydebug, 
327 [  --with-pydebug                  build with Py_DEBUG defined], [
328 if test "$withval" != no
329 then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes); Py_DEBUG='true'
330 else AC_MSG_RESULT(no); Py_DEBUG='false'
331 fi],
332 [AC_MSG_RESULT(no)])
334 # Optimizer/debugger flags
335 AC_SUBST(OPT)
336 if test -z "$OPT"
337 then
338         case $GCC in
339         yes)
340                 case $ac_cv_prog_cc_g in
341         yes)
342             if test "$Py_DEBUG" = 'true' ; then
343                 # Optimization messes up debuggers, so turn it off for
344                 # debug builds.
345                 OPT="-g -Wall -Wstrict-prototypes"
346             else
347                 OPT="-g -O3 -Wall -Wstrict-prototypes"
348             fi;;
349         *)
350             OPT="-O3 -Wall -Wstrict-prototypes";;
351         esac
352         ;;
353     *)
354         case $ac_sys_system in
355         UnixWare*)
356             OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
357         *)
358             OPT="-O";;
359         esac
360     esac
361     case $ac_sys_system in
362     Darwin*)
363         OPT="$OPT -no-cpp-precomp";;
364     esac
367 # The current (beta) Monterey compiler dies with optimizations
368 case $ac_sys_system in
369 Monterey*) OPT="";;
370 esac
372 if test "$ac_arch_flags"
373 then
374         OPT="$OPT $ac_arch_flags"
377 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
378 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
379 [ac_save_cc="$CC"
380 CC="$CC -OPT:Olimit=0"
381 AC_TRY_RUN([int main() { return 0; }],
382   ac_cv_opt_olimit_ok=yes,
383   ac_cv_opt_olimit_ok=no,
384   ac_cv_opt_olimit_ok=no)
385 CC="$ac_save_cc"])
386 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
387 if test $ac_cv_opt_olimit_ok = yes; then
388     case $ac_sys_system in
389       Darwin*) OPT="$OPT" ;;
390       *) OPT="$OPT -OPT:Olimit=0";;
391     esac
392 else
393   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
394   AC_CACHE_VAL(ac_cv_olimit_ok,
395   [ac_save_cc="$CC"
396   CC="$CC -Olimit 1500"
397   AC_TRY_RUN([int main() { return 0; }],
398     ac_cv_olimit_ok=yes,
399     ac_cv_olimit_ok=no,
400     ac_cv_olimit_ok=no)
401   CC="$ac_save_cc"])
402   AC_MSG_RESULT($ac_cv_olimit_ok)
403   if test $ac_cv_olimit_ok = yes; then
404     OPT="$OPT -Olimit 1500"
405   fi
408 # -Kpthread, if available, provides the right #defines
409 # and linker options to make pthread_create available
410 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
411 AC_CACHE_VAL(ac_cv_kpthread,
412 [ac_save_cc="$CC"
413 CC="$CC -Kpthread"
414 AC_TRY_LINK([#include <pthread.h>],[pthread_create(0,0,0,0)],
415   ac_cv_kpthread=yes,
416   ac_cv_kpthread=no)
417 CC="$ac_save_cc"])
419 # GCC does not reject -Kpthread as an illegal option, it merely complains that
420 # it is unrecognized
421 if test "$GCC" = "yes"
422 then ac_cv_kpthread="no, we have gcc"
424 AC_MSG_RESULT($ac_cv_kpthread)
426 dnl # check for ANSI or K&R ("traditional") preprocessor
427 dnl AC_MSG_CHECKING(for C preprocessor type)
428 dnl AC_TRY_COMPILE([
429 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
430 dnl int foo;
431 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
432 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
433 dnl AC_MSG_RESULT($cpp_type)
435 # checks for header files
436 AC_HEADER_STDC
437 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h langinfo.h locale.h \
438 ncurses.h poll.h pthread.h \
439 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
440 sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
441 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
442 sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
443 ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h)
444 AC_HEADER_DIRENT
446 # checks for typedefs
447 was_it_defined=no
448 AC_MSG_CHECKING(for clock_t in time.h)
449 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
450 AC_MSG_RESULT($was_it_defined)
452 # Two defines needed to enable largefile support on various platforms
453 # These may affect some typedefs
454 AC_DEFINE(_LARGEFILE_SOURCE)
455 AC_DEFINE(_FILE_OFFSET_BITS, 64)
457 # Add some code to confdefs.h so that the test for off_t works on SCO
458 cat >> confdefs.h <<\EOF
459 #if defined(SCO_DS)
460 #undef _OFF_T
461 #endif
464 # Type availability checks
465 AC_TYPE_MODE_T
466 AC_TYPE_OFF_T
467 AC_TYPE_PID_T
468 AC_TYPE_SIGNAL
469 AC_TYPE_SIZE_T
470 AC_TYPE_UID_T
472 # Sizes of various common basic types
473 AC_CHECK_SIZEOF(int, 4)
474 AC_CHECK_SIZEOF(long, 4)
475 AC_CHECK_SIZEOF(void *, 4)
476 AC_CHECK_SIZEOF(char, 1)
477 AC_CHECK_SIZEOF(short, 2)
478 AC_CHECK_SIZEOF(float, 4)
479 AC_CHECK_SIZEOF(double, 8)
480 AC_CHECK_SIZEOF(fpos_t, 4)
482 AC_MSG_CHECKING(for long long support)
483 have_long_long=no
484 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
485 AC_MSG_RESULT($have_long_long)
486 if test "$have_long_long" = yes ; then
487 AC_CHECK_SIZEOF(long long, 8)
490 AC_MSG_CHECKING(for uintptr_t support)
491 have_uintptr_t=no
492 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
493 AC_MSG_RESULT($have_uintptr_t)
494 if test "$have_uintptr_t" = yes ; then
495 AC_CHECK_SIZEOF(uintptr_t, 4)
498 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
499 AC_MSG_CHECKING(size of off_t)
500 AC_CACHE_VAL(ac_cv_sizeof_off_t,
501 [AC_TRY_RUN([#include <stdio.h>
502 #include <sys/types.h>
503 main()
505   FILE *f=fopen("conftestval", "w");
506   if (!f) exit(1);
507   fprintf(f, "%d\n", sizeof(off_t));
508   exit(0);
510 ac_cv_sizeof_off_t=`cat conftestval`,
511 ac_cv_sizeof_off_t=0,
512 ac_cv_sizeof_off_t=4)
514 AC_MSG_RESULT($ac_cv_sizeof_off_t)
515 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
517 AC_MSG_CHECKING(whether to enable large file support)
518 if test "$have_long_long" = yes -a \
519         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
520         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
521   AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
522   AC_MSG_RESULT(yes)
523 else
524   AC_MSG_RESULT(no)
527 # AC_CHECK_SIZEOF() doesn't include <time.h>.
528 AC_MSG_CHECKING(size of time_t)
529 AC_CACHE_VAL(ac_cv_sizeof_time_t,
530 [AC_TRY_RUN([#include <stdio.h>
531 #include <time.h>
532 main()
534   FILE *f=fopen("conftestval", "w");
535   if (!f) exit(1);
536   fprintf(f, "%d\n", sizeof(time_t));
537   exit(0);
539 ac_cv_sizeof_time_t=`cat conftestval`,
540 ac_cv_sizeof_time_t=0,
541 ac_cv_sizeof_time_t=4)
543 AC_MSG_RESULT($ac_cv_sizeof_time_t)
544 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
547 # if have pthread_t then define SIZEOF_PTHREAD_T
548 ac_save_cc="$CC"
549 if test "$ac_cv_kpthread" = "yes"
550 then CC="$CC -Kpthread"
552 AC_MSG_CHECKING(for pthread_t)
553 have_pthread_t=no
554 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
555 AC_MSG_RESULT($have_pthread_t)
556 if test "$have_pthread_t" = yes ; then
557   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
558   AC_MSG_CHECKING(size of pthread_t)
559   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
560   [AC_TRY_RUN([#include <stdio.h>
561   #include <pthread.h>
562   main()
563   {
564     FILE *f=fopen("conftestval", "w");
565     if (!f) exit(1);
566     fprintf(f, "%d\n", sizeof(pthread_t));
567     exit(0);
568   }],
569   ac_cv_sizeof_pthread_t=`cat conftestval`,
570   ac_cv_sizeof_pthread_t=0,
571   ac_cv_sizeof_pthread_t=4)
572   ])
573   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
574   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
576 CC="$ac_save_cc"
578 AC_MSG_CHECKING(for --enable-toolbox-glue)
579 AC_ARG_ENABLE(toolbox-glue,
580 [  --enable-toolbox-glue            disable/enable MacOSX glue code for extensions])
582 if test -z "$enable_toolbox_glue"
583 then 
584         case $ac_sys_system/$ac_sys_release in
585         Darwin/*)
586                 enable_toolbox_glue="yes";;
587         *)
588                 enable_toolbox_glue="no";;
589         esac
591 case "$enable_toolbox_glue" in
592 yes)
593         extra_frameworks="-framework Carbon -framework Foundation"
594         extra_machdep_objs="Python/mactoolboxglue.o"
595         extra_undefs="-u __dummy -u _PyMac_Error"
596         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE)
597         ;;
599         extra_frameworks=""
600         extra_machdep_objs=""
601         extra_undefs=""
602         ;;
603 esac
604 AC_MSG_RESULT($enable_toolbox_glue)
606 AC_SUBST(LIBTOOL_CRUFT)
607 case $ac_sys_system/$ac_sys_release in
608   Darwin/1.4*)
609     ns_undef_sym='_environ'
610     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -flat_namespace -U $ns_undef_sym"
611       LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
612     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
613     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
614   Darwin/*)
615     ns_undef_sym='_environ'
616     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym"
617         LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
618     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
619     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
620 esac
622 AC_MSG_CHECKING(for --enable-framework)
623 if test "$enable_framework"
624 then
625         OPT="$OPT -fno-common -dynamic"
626         # -U __environ is needed since bundles don't have access
627         # to crt0 when built but will always be linked against it
628         # -F. is needed to allow linking to the framework while 
629         # in the build location.
630         
631         case $ac_sys_system/$ac_sys_release in
632             Darwin/1.4*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-flat_namespace,-U,$ns_undef_sym";;
633             Darwin/*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-U,$ns_undef_sym";;
634         esac
635         AC_DEFINE(WITH_NEXT_FRAMEWORK)
636         AC_MSG_RESULT(yes)
637 else
638         AC_MSG_RESULT(no)
641 AC_MSG_CHECKING(for dyld)
642 case $ac_sys_system/$ac_sys_release in
643   Darwin/*)
644         AC_DEFINE(WITH_DYLD)
645         AC_MSG_RESULT(always on for Darwin)
646         ;;
647   *)
648         AC_MSG_RESULT(no)
649         ;;
650 esac
652 # Set info about shared libraries.
653 AC_SUBST(SO)
654 AC_SUBST(LDSHARED)
655 AC_SUBST(BLDSHARED)
656 AC_SUBST(CCSHARED)
657 AC_SUBST(LINKFORSHARED)
658 # SO is the extension of shared libraries `(including the dot!)
659 # -- usually .so, .sl on HP-UX, .dll on Cygwin
660 AC_MSG_CHECKING(SO)
661 if test -z "$SO"
662 then
663         case $ac_sys_system in
664         hp*|HP*)   SO=.sl;;
665         CYGWIN*)   SO=.dll;;
666         *)         SO=.so;;
667         esac
669 AC_MSG_RESULT($SO)
670 # LDSHARED is the ld *command* used to create shared library
671 # -- "ld" on SunOS 4.x.x, "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
672 # (Shared libraries in this instance are shared modules to be loaded into
673 # Python, as opposed to building Python itself as a shared library.)
674 AC_MSG_CHECKING(LDSHARED)
675 if test -z "$LDSHARED"
676 then
677         case $ac_sys_system/$ac_sys_release in
678         AIX*)
679                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
680                 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
681                 ;;
682         BeOS*)
683                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
684                 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
685                 ;;
686         IRIX/5*) LDSHARED="ld -shared";;
687         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
688         SunOS/4*) LDSHARED="ld";;
689         SunOS/5*) 
690                 if test "$GCC" = "yes"
691                 then LDSHARED='$(CC) -shared'
692                 else LDSHARED="$(CC) -G";
693                 fi ;;
694         hp*|HP*) LDSHARED="ld -b";;
695         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
696         DYNIX/ptx*) LDSHARED="ld -G";;
697         Darwin/1.4*)
698                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
699                 if test "$enable_framework" ; then
700                         # Link against the framework. All externals should be defined.
701                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
702                 else
703                         # No framework. Ignore undefined symbols, assuming they come from Python
704                         LDSHARED="$LDSHARED -flat_namespace -undefined suppress"
705                 fi ;;
706         Darwin/*)
707                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
708                 if test "$enable_framework" ; then
709                         # Link against the framework. All externals should be defined.
710                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
711                 else
712                         # No framework. Ignore undefined symbols, assuming they come from Python
713                         LDSHARED="$LDSHARED -undefined suppress"
714                 fi ;;
715         Linux*) LDSHARED="gcc -shared";;
716         dgux*) LDSHARED="ld -G";;
717         BSD/OS*/4*) LDSHARED="gcc -shared";;
718         OpenBSD*|NetBSD*|FreeBSD*)
719                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
720                 then
721                         LDSHARED="cc -shared ${LDFLAGS}"
722                 else
723                         LDSHARED="ld -Bshareable ${LDFLAGS}"
724                 fi;;
725         UnixWare*)
726                 if test "$GCC" = "yes"
727                 then LDSHARED="$(CC) -shared"
728                 else LDSHARED="$(CC) -G"
729                 fi;;
730         SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
731         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
732         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
733         *)      LDSHARED="ld";;
734         esac
736 AC_MSG_RESULT($LDSHARED)
737 BLDSHARED=${BLDSHARED-$LDSHARED}
738 # CCSHARED are the C *flags* used to create objects to go into a shared
739 # library (module) -- this is only needed for a few systems
740 AC_MSG_CHECKING(CCSHARED)
741 if test -z "$CCSHARED"
742 then
743         case $ac_sys_system/$ac_sys_release in
744         SunOS*) if test "$GCC" = yes;
745                 then CCSHARED="-fPIC";
746                 fi;;
747         hp*|HP*) if test "$GCC" = yes;
748                  then CCSHARED="-fPIC";
749                  else CCSHARED="+z";
750                  fi;;
751         Linux*) CCSHARED="-fPIC";;
752         BSD/OS*/4*) CCSHARED="-fpic";;
753         FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
754         UnixWare*)
755                 if test "$GCC" = "yes"
756                 then CCSHARED="-fPIC"
757                 else CCSHARED="-KPIC"
758                 fi;;
759         SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
760         Monterey*) CCSHARED="-G";;
761         IRIX*/6*)  case $CC in
762                    *gcc*) CCSHARED="-shared";;
763                    *) CCSHARED="";;
764                    esac;;
765         CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
766         esac
768 AC_MSG_RESULT($CCSHARED)
769 # LINKFORSHARED are the flags passed to the $(CC) command that links
770 # the python executable -- this is only needed for a few systems
771 AC_MSG_CHECKING(LINKFORSHARED)
772 if test -z "$LINKFORSHARED"
773 then
774         case $ac_sys_system/$ac_sys_release in
775         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
776         hp*|HP*)
777             LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
778         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
779         Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
780         # -u libsys_s pulls in all symbols in libsys
781         Darwin/*) 
782                 # -u __dummy makes the linker aware of the objc runtime
783                 # in System.framework; otherwise, __objcInit (referenced in
784                 # crt1.o) gets erroneously defined as common, which breaks dynamic
785                 # loading of any modules which reference it in System.framework.
786                 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
787                 # not used by the core itself but which needs to be in the core so
788                 # that dynamically loaded extension modules have access to it.
789                 LINKFORSHARED="$extra_undefs -framework System"
790                 if test "$enable_framework"
791                 then
792                         LINKFORSHARED="$LINKFORSHARED -framework Python"
793                 fi
794                 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
795         UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
796         SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
797         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
798         FreeBSD*|NetBSD*|OpenBSD*) 
799                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
800                 then
801                         LINKFORSHARED="-Wl,--export-dynamic"
802                 fi;;
803         SunOS/5*) case $CC in
804                   *gcc*)
805                     if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
806                     then
807                         LINKFORSHARED="-Xlinker --export-dynamic"
808                     fi;;
809                   esac;;
810         esac
812 AC_MSG_RESULT($LINKFORSHARED)
814 AC_SUBST(CFLAGSFORSHARED)
815 AC_MSG_CHECKING(CFLAGSFORSHARED)
816 if test ! "$LIBRARY" = "$LDLIBRARY"
817 then
818         case $ac_sys_system in
819         CYGWIN*)
820                 # Cygwin needs CCSHARED when building extension DLLs
821                 # but not when building the interpreter DLL.
822                 CFLAGSFORSHARED='';;
823         *)
824                 CFLAGSFORSHARED='$(CCSHARED)'
825         esac
827 AC_MSG_RESULT($CFLAGSFORSHARED)
829 # checks for libraries
830 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
831 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
833 # checks for system dependent C++ extensions support
834 case "$ac_sys_system" in
835         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
836                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
837                             [loadAndInit("", 0, "")],
838                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
839                              AC_MSG_RESULT(yes)],
840                             [AC_MSG_RESULT(no)]);;
841         *) ;;
842 esac
844 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
845 # However on SGI IRIX, these exist but are broken.
846 # BeOS' sockets are stashed in libnet.
847 case "$ac_sys_system" in
848 IRIX*) ;;
850 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
851 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
853 esac
854 case "$ac_sys_system" in
855 BeOS*)
856 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
858 esac
860 AC_MSG_CHECKING(for --with-libs)
861 AC_ARG_WITH(libs,
862 [  --with-libs='lib1 ...'          link against additional libs], [
863 AC_MSG_RESULT($withval)
864 LIBS="$withval $LIBS"
865 ], AC_MSG_RESULT(no))
867 # Determine if signalmodule should be used.
868 AC_SUBST(USE_SIGNAL_MODULE)
869 AC_SUBST(SIGNAL_OBJS)
870 AC_MSG_CHECKING(for --with-signal-module)
871 AC_ARG_WITH(signal-module,
872 [  --with-signal-module            disable/enable signal module])
874 if test -z "$with_signal_module"
875 then with_signal_module="yes"
877 AC_MSG_RESULT($with_signal_module)
879 if test "${with_signal_module}" = "yes"; then
880         USE_SIGNAL_MODULE=""
881         SIGNAL_OBJS=""
882 else
883         USE_SIGNAL_MODULE="#"
884         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
887 # This is used to generate Setup.config
888 AC_SUBST(USE_THREAD_MODULE)
889 USE_THREAD_MODULE=""
891 AC_MSG_CHECKING(for --with-dec-threads)
892 AC_SUBST(LDLAST)
893 AC_ARG_WITH(dec-threads,
894 [  --with-dec-threads              use DEC Alpha/OSF1 thread-safe libraries], [
895 AC_MSG_RESULT($withval)
896 LDLAST=-threads
897 if test "${with_thread+set}" != set; then
898    with_thread="$withval";
899 fi],
900 AC_MSG_RESULT(no))
902 AC_MSG_CHECKING(for --with-threads)
903 AC_ARG_WITH(threads,
904 [  --with(out)-threads[=DIRECTORY] disable/enable thread support])
906 # --with-thread is deprecated, but check for it anyway
907 AC_ARG_WITH(thread,
908 [  --with(out)-thread[=DIRECTORY]  deprecated; use --with(out)-threads],[
909 with_threads=$with_thread])
911 if test -z "$with_threads"
912 then with_threads="yes"
914 AC_MSG_RESULT($with_threads)
916 if test "$with_threads" = "no"
917 then
918     USE_THREAD_MODULE="#"
919 elif test "$ac_cv_kpthread" = "yes"
920 then
921     CC="$CC -Kpthread"
922     AC_DEFINE(WITH_THREAD)
923     AC_DEFINE(_POSIX_THREADS)
924     posix_threads=yes
925     LIBOBJS="$LIBOBJS thread.o"
926 else
927     if test ! -z "$with_threads" -a -d "$with_threads"
928     then LDFLAGS="$LDFLAGS -L$with_threads"
929     fi
930     if test ! -z "$withval" -a -d "$withval"
931     then LDFLAGS="$LDFLAGS -L$withval"
932     fi
933     AC_DEFINE(_REENTRANT)
934     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
935     AC_DEFINE(C_THREADS)
936     LIBOBJS="$LIBOBJS thread.o"],[
937     AC_MSG_CHECKING(for --with-pth)
938     AC_ARG_WITH(pth,
939     [  --with-pth                      use GNU pth threading libraries], [
940     AC_MSG_RESULT($withval)
941     AC_DEFINE(WITH_THREAD)
942     AC_DEFINE(HAVE_PTH)
943     LIBS="-lpth $LIBS"
944     LIBOBJS="$LIBOBJS thread.o"],[
945     AC_MSG_RESULT(no)
946     AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
947     case $ac_sys_system in
948       Darwin*) ;;
949       *) AC_DEFINE(_POSIX_THREADS)
950          posix_threads=yes
951          ;;
952     esac
953     LIBS="-lpthread $LIBS"
954     LIBOBJS="$LIBOBJS thread.o"],[
955     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
956     case $ac_sys_system in
957       Darwin*) ;;
958       *) AC_DEFINE(_POSIX_THREADS)
959          posix_threads=yes
960          ;;
961     esac
962     LIBOBJS="$LIBOBJS thread.o"],[
963     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
964     AC_DEFINE(BEOS_THREADS)
965     LIBOBJS="$LIBOBJS thread.o"],[
966     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
967     AC_DEFINE(_POSIX_THREADS)
968     posix_threads=yes
969     LIBS="$LIBS -lpthreads"
970     LIBOBJS="$LIBOBJS thread.o"], [
971     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
972     AC_DEFINE(_POSIX_THREADS)
973     posix_threads=yes
974     LIBS="$LIBS -lc_r"
975     LIBOBJS="$LIBOBJS thread.o"], [
976     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
977     AC_DEFINE(_POSIX_THREADS)
978     posix_threads=yes
979     LIBS="$LIBS -lthread"
980     LIBOBJS="$LIBOBJS thread.o"], [
981     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
982     AC_DEFINE(_POSIX_THREADS)
983     posix_threads=yes
984     LIBS="$LIBS -lpthread"
985     LIBOBJS="$LIBOBJS thread.o"], [
986     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
987     AC_DEFINE(_POSIX_THREADS)
988     posix_threads=yes
989     LIBS="$LIBS -lcma"
990     LIBOBJS="$LIBOBJS thread.o"],[
991     USE_THREAD_MODULE="#"])
992     ])])])])])])])])])
994     if test "$posix_threads" = "yes"; then
995       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
996       AC_CACHE_VAL(ac_cv_pthread_system_supported,
997       [AC_TRY_RUN([#include <pthread.h>
998       void *foo(void *parm) {
999         return NULL;
1000       }
1001       main() {
1002         pthread_attr_t attr;
1003         if (pthread_attr_init(&attr)) exit(-1);
1004         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
1005         if (pthread_create(NULL, &attr, foo, NULL)) exit(-1);
1006         exit(0);
1007       }],
1008       ac_cv_pthread_system_supported=yes,
1009       ac_cv_pthread_system_supported=no,
1010       ac_cv_pthread_system_supported=no)
1011       ])
1012       AC_MSG_RESULT($ac_cv_pthread_system_supported)
1013       if test "$ac_cv_pthread_system_supported" = "yes"; then
1014         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED)
1015       fi
1016     fi
1018     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1019     LIBS="$LIBS -lmpc"
1020     LIBOBJS="$LIBOBJS thread.o"
1021     USE_THREAD_MODULE=""])
1022     AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1023     LIBS="$LIBS -lthread"
1024     LIBOBJS="$LIBOBJS thread.o"
1025     USE_THREAD_MODULE=""])
1027     if test "$USE_THREAD_MODULE" != "#"
1028     then
1029         # If the above checks didn't disable threads, (at least) OSF1
1030         # needs this '-threads' argument during linking.
1031         case $ac_sys_system in
1032         OSF1) LDLAST=-threads;;
1033         esac
1034     fi
1037 # Check for enable-ipv6
1038 AC_MSG_CHECKING([if --enable-ipv6 is specified])
1039 AC_ARG_ENABLE(ipv6,
1040 [  --enable-ipv6                   Enable ipv6 (with ipv4) support
1041   --disable-ipv6                  Disable ipv6 support],
1042 [ case "$enableval" in
1043   no)
1044        AC_MSG_RESULT(no)
1045        ipv6=no
1046        ;;
1047   *)   AC_MSG_RESULT(yes)
1048        AC_DEFINE(ENABLE_IPV6)
1049        ipv6=yes
1050        ;;
1051   esac ],
1054 dnl the check does not work on cross compilation case...
1055   AC_TRY_RUN([ /* AF_INET6 available check */
1056 #include <sys/types.h>
1057 #include <sys/socket.h>
1058 main()
1060  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1061    exit(1);
1062  else
1063    exit(0);
1066   AC_MSG_RESULT(yes)
1067   ipv6=yes,
1068   AC_MSG_RESULT(no)
1069   ipv6=no,
1070   AC_MSG_RESULT(no)
1071   ipv6=no
1074 if test "$ipv6" = "yes"; then
1075         AC_MSG_CHECKING(if RFC2553 API is available)
1076         AC_TRY_COMPILE([#include <sys/types.h>
1077 #include <netinet/in.h>],
1078         [struct sockaddr_in6 x;
1079 x.sin6_scope_id;],
1080                 AC_MSG_RESULT(yes)
1081                 ipv6=yes,
1082                 AC_MSG_RESULT(no, IPv6 disabled)
1083                 ipv6=no)
1086 if test "$ipv6" = "yes"; then
1087         AC_DEFINE(ENABLE_IPV6)
1091 ipv6type=unknown
1092 ipv6lib=none
1093 ipv6trylibc=no
1095 if test "$ipv6" = "yes"; then
1096         AC_MSG_CHECKING([ipv6 stack type])
1097         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1098         do
1099                 case $i in
1100                 inria)
1101                         dnl http://www.kame.net/
1102                         AC_EGREP_CPP(yes, [dnl
1103 #include <netinet/in.h>
1104 #ifdef IPV6_INRIA_VERSION
1106 #endif],
1107                                 [ipv6type=$i;
1108                                 OPT="-DINET6 $OPT"])
1109                         ;;
1110                 kame)
1111                         dnl http://www.kame.net/
1112                         AC_EGREP_CPP(yes, [dnl
1113 #include <netinet/in.h>
1114 #ifdef __KAME__
1116 #endif],
1117                                 [ipv6type=$i;
1118                                 ipv6lib=inet6
1119                                 ipv6libdir=/usr/local/v6/lib
1120                                 ipv6trylibc=yes
1121                                 OPT="-DINET6 $OPT"])
1122                         ;;
1123                 linux-glibc)
1124                         dnl http://www.v6.linux.or.jp/
1125                         AC_EGREP_CPP(yes, [dnl
1126 #include <features.h>
1127 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1129 #endif],
1130                                 [ipv6type=$i;
1131                                 ipv6trylibc=yes
1132                                 OPT="-DINET6 $OPT"])
1133                         ;;
1134                 linux-inet6)
1135                         dnl http://www.v6.linux.or.jp/
1136                         if test -d /usr/inet6; then
1137                                 ipv6type=$i
1138                                 ipv6lib=inet6
1139                                 ipv6libdir=/usr/inet6/lib
1140                                 OPT="-DINET6 -I/usr/inet6/include $OPT"
1141                         fi
1142                         ;;
1143                 solaris)
1144                         if test -f /etc/netconfig; then
1145                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1146                                 ipv6type=$i
1147                                 ipv6trylibc=yes
1148                                 OPT="-DINET6 $OPT"
1149                           fi
1150                         fi
1151                         ;;
1152                 toshiba)
1153                         AC_EGREP_CPP(yes, [dnl
1154 #include <sys/param.h>
1155 #ifdef _TOSHIBA_INET6
1157 #endif],
1158                                 [ipv6type=$i;
1159                                 ipv6lib=inet6;
1160                                 ipv6libdir=/usr/local/v6/lib;
1161                                 OPT="-DINET6 $OPT"])
1162                         ;;
1163                 v6d)
1164                         AC_EGREP_CPP(yes, [dnl
1165 #include </usr/local/v6/include/sys/v6config.h>
1166 #ifdef __V6D__
1168 #endif],
1169                                 [ipv6type=$i;
1170                                 ipv6lib=v6;
1171                                 ipv6libdir=/usr/local/v6/lib;
1172                                 OPT="-I/usr/local/v6/include $OPT"])
1173                         ;;
1174                 zeta)
1175                         AC_EGREP_CPP(yes, [dnl
1176 #include <sys/param.h>
1177 #ifdef _ZETA_MINAMI_INET6
1179 #endif],
1180                                 [ipv6type=$i;
1181                                 ipv6lib=inet6;
1182                                 ipv6libdir=/usr/local/v6/lib;
1183                                 OPT="-DINET6 $OPT"])
1184                         ;;
1185                 esac
1186                 if test "$ipv6type" != "unknown"; then
1187                         break
1188                 fi
1189         done
1190         AC_MSG_RESULT($ipv6type)
1193 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1194         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1195                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1196                 echo "using lib$ipv6lib"
1197         else
1198                 if test $ipv6trylibc = "yes"; then
1199                         echo "using libc"
1200                 else
1201                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
1202                         echo "You need to fetch lib$ipv6lib.a from appropriate"
1203                         echo 'ipv6 kit and compile beforehand.'
1204                         exit 1
1205                 fi
1206         fi
1209 # Check for GC support
1210 AC_MSG_CHECKING(for --with-cycle-gc)
1211 AC_ARG_WITH(cycle-gc,
1212 [  --with(out)-cycle-gc            disable/enable garbage collection])
1214 if test -z "$with_cycle_gc"
1215 then with_cycle_gc="yes"
1217 if test "$with_cycle_gc" != "no"
1218 then
1219     AC_DEFINE(WITH_CYCLE_GC)
1221 AC_MSG_RESULT($with_cycle_gc)
1223 # Check for Python-specific malloc support
1224 AC_MSG_CHECKING(for --with-pymalloc)
1225 AC_ARG_WITH(pymalloc,
1226 [  --with(out)-pymalloc            disable/enable specialized mallocs], [
1227 if test "$withval" != no
1228 then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
1229 else AC_MSG_RESULT(no)
1230 fi],
1231 [AC_MSG_RESULT(no)])
1233 # Check for --with-wctype-functions
1234 AC_MSG_CHECKING(for --with-wctype-functions)
1235 AC_ARG_WITH(wctype-functions, 
1236 [  --with-wctype-functions         use wctype.h functions], [
1237 if test "$withval" != no
1238 then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
1239 else AC_MSG_RESULT(no)
1240 fi],
1241 [AC_MSG_RESULT(no)])
1243 # -I${DLINCLDIR} is added to the compile rule for importdl.o
1244 AC_SUBST(DLINCLDIR)
1245 DLINCLDIR=.
1247 AC_MSG_CHECKING(for --with-sgi-dl)
1248 AC_ARG_WITH(sgi-dl,
1249 [  --with-sgi-dl=DIRECTORY         IRIX 4 dynamic linking], [
1250 AC_MSG_RESULT($withval)
1251 AC_DEFINE(WITH_SGI_DL)
1252 DYNLOADFILE="dynload_dl.o"
1253 dldir=$withval
1254 if test ! -z "$dldir" -a -d "$dldir"
1255 then LDFLAGS="$LDFLAGS -L$dldir"
1256 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1258 DLINCLDIR=${dldir}
1259 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
1261 AC_MSG_CHECKING(for --with-dl-dld)
1262 AC_ARG_WITH(dl-dld, [  --with-dl-dld=DL_DIR,DLD_DIR    GNU dynamic linking], [
1263 AC_MSG_RESULT($withval)
1264 AC_DEFINE(WITH_DL_DLD)
1265 DYNLOADFILE="dynload_dl.o"
1266 dldir=`echo "$withval" | sed 's/,.*//'`
1267 dlddir=`echo "$withval" | sed 's/.*,//'`
1268 if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
1269 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
1270 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1272 DLINCLDIR=${dldir}
1273 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
1275 # the dlopen() function means we might want to use dynload_shlib.o. some
1276 # platforms, such as AIX, have dlopen(), but don't want to use it.
1277 AC_CHECK_FUNCS(dlopen)
1279 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1280 # loading of modules.
1281 AC_SUBST(DYNLOADFILE)
1282 AC_MSG_CHECKING(DYNLOADFILE)
1283 if test -z "$DYNLOADFILE"
1284 then
1285         case $ac_sys_system/$ac_sys_release in
1286         AIX*) DYNLOADFILE="dynload_aix.o";;
1287         BeOS*) DYNLOADFILE="dynload_beos.o";;
1288         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
1289         Darwin/*) DYNLOADFILE="dynload_next.o";;
1290         *)
1291         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1292         # out any dynamic loading
1293         if test "$ac_cv_func_dlopen" = yes
1294         then DYNLOADFILE="dynload_shlib.o"
1295         else DYNLOADFILE="dynload_stub.o"
1296         fi
1297         ;;
1298         esac
1300 AC_MSG_RESULT($DYNLOADFILE)
1301 if test "$DYNLOADFILE" != "dynload_stub.o"
1302 then
1303         AC_DEFINE(HAVE_DYNAMIC_LOADING)
1306 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
1308 AC_SUBST(MACHDEP_OBJS)
1309 AC_MSG_CHECKING(MACHDEP_OBJS)
1310 if test -z "$MACHDEP_OBJS"
1311 then
1312         MACHDEP_OBJS=$extra_machdep_objs
1313 else
1314         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
1316 AC_MSG_RESULT(MACHDEP_OBJS)
1318 # checks for library functions
1319 AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
1320  flock fork fsync fdatasync fpathconf ftime ftruncate \
1321  gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
1322  hstrerror inet_pton kill link lstat mkfifo mktime mremap \
1323  nice pathconf pause plock poll pthread_init \
1324  putenv readlink \
1325  select setegid seteuid setgid \
1326  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
1327  sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
1328  tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
1329  truncate uname waitpid _getpty getpriority)
1331 # check for openpty and forkpty
1333 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1334 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1336 # check for long file support functions
1337 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1339 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
1340 AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1341 AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1342 AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
1344 AC_CHECK_FUNCS(getaddrinfo, [dnl
1345 AC_MSG_CHECKING(getaddrinfo bug)
1346 AC_TRY_RUN([
1347 #include <sys/types.h>
1348 #include <netdb.h>
1349 #include <string.h>
1350 #include <sys/socket.h>
1351 #include <netinet/in.h>
1353 main()
1355   int passive, gaierr, inet4 = 0, inet6 = 0;
1356   struct addrinfo hints, *ai, *aitop;
1357   char straddr[INET6_ADDRSTRLEN], strport[16];
1359   for (passive = 0; passive <= 1; passive++) {
1360     memset(&hints, 0, sizeof(hints));
1361     hints.ai_family = AF_UNSPEC;
1362     hints.ai_flags = passive ? AI_PASSIVE : 0;
1363     hints.ai_socktype = SOCK_STREAM;
1364     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1365       (void)gai_strerror(gaierr);
1366       goto bad;
1367     }
1368     for (ai = aitop; ai; ai = ai->ai_next) {
1369       if (ai->ai_addr == NULL ||
1370           ai->ai_addrlen == 0 ||
1371           getnameinfo(ai->ai_addr, ai->ai_addrlen,
1372                       straddr, sizeof(straddr), strport, sizeof(strport),
1373                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1374         goto bad;
1375       }
1376       switch (ai->ai_family) {
1377       case AF_INET:
1378         if (strcmp(strport, "54321") != 0) {
1379           goto bad;
1380         }
1381         if (passive) {
1382           if (strcmp(straddr, "0.0.0.0") != 0) {
1383             goto bad;
1384           }
1385         } else {
1386           if (strcmp(straddr, "127.0.0.1") != 0) {
1387             goto bad;
1388           }
1389         }
1390         inet4++;
1391         break;
1392       case AF_INET6:
1393         if (strcmp(strport, "54321") != 0) {
1394           goto bad;
1395         }
1396         if (passive) {
1397           if (strcmp(straddr, "::") != 0) {
1398             goto bad;
1399           }
1400         } else {
1401           if (strcmp(straddr, "::1") != 0) {
1402             goto bad;
1403           }
1404         }
1405         inet6++;
1406         break;
1407       case AF_UNSPEC:
1408         goto bad;
1409         break;
1410       default:
1411         /* another family support? */
1412         break;
1413       }
1414     }
1415   }
1417   if (!(inet4 == 0 || inet4 == 2))
1418     goto bad;
1419   if (!(inet6 == 0 || inet6 == 2))
1420     goto bad;
1422   if (aitop)
1423     freeaddrinfo(aitop);
1424   exit(0);
1426  bad:
1427   if (aitop)
1428     freeaddrinfo(aitop);
1429   exit(1);
1432 AC_MSG_RESULT(good)
1433 buggygetaddrinfo=no,
1434 AC_MSG_RESULT(buggy)
1435 buggygetaddrinfo=yes,
1436 AC_MSG_RESULT(buggy)
1437 buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
1439 if test "$buggygetaddrinfo" = "yes"; then
1440         if test "$ipv6" = "yes"; then
1441                 echo 'Fatal: You must get working getaddrinfo() function.'
1442                 echo '       or you can specify "--disable-ipv6"'.
1443                 exit 1
1444         fi
1446 AC_CHECK_FUNCS(getnameinfo)
1448 # checks for structures
1449 AC_HEADER_TIME
1450 AC_STRUCT_TM
1451 AC_STRUCT_TIMEZONE
1453 AC_MSG_CHECKING(for time.h that defines altzone)
1454 AC_CACHE_VAL(ac_cv_header_time_altzone,
1455 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1456   ac_cv_header_time_altzone=yes,
1457   ac_cv_header_time_altzone=no)])
1458 AC_MSG_RESULT($ac_cv_header_time_altzone)
1459 if test $ac_cv_header_time_altzone = yes; then
1460   AC_DEFINE(HAVE_ALTZONE)
1463 was_it_defined=no
1464 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
1465 AC_TRY_COMPILE([
1466 #include <sys/types.h>
1467 #include <sys/select.h>
1468 #include <sys/time.h>
1469 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1470 AC_MSG_RESULT($was_it_defined)
1472 AC_MSG_CHECKING(for addrinfo)
1473 AC_CACHE_VAL(ac_cv_struct_addrinfo,
1474 AC_TRY_COMPILE([
1475 #               include <netdb.h>],
1476         [struct addrinfo a],
1477         ac_cv_struct_addrinfo=yes,
1478         ac_cv_struct_addrinfo=no))
1479 AC_MSG_RESULT($ac_cv_struct_addrinfo)
1480 if test $ac_cv_struct_addrinfo = yes; then
1481         AC_DEFINE(HAVE_ADDRINFO)
1484 AC_MSG_CHECKING(for sockaddr_storage)
1485 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1486 AC_TRY_COMPILE([
1487 #               include <sys/types.h>
1488 #               include <sys/socket.h>],
1489         [struct sockaddr_storage s],
1490         ac_cv_struct_sockaddr_storage=yes,
1491         ac_cv_struct_sockaddr_storage=no))
1492 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1493 if test $ac_cv_struct_sockaddr_storage = yes; then
1494         AC_DEFINE(HAVE_SOCKADDR_STORAGE)
1497 # checks for compiler characteristics
1499 AC_C_CHAR_UNSIGNED
1500 AC_C_CONST
1502 works=no
1503 AC_MSG_CHECKING(for working volatile)
1504 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1505 AC_MSG_RESULT($works)
1507 works=no
1508 AC_MSG_CHECKING(for working signed char)
1509 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1510 AC_MSG_RESULT($works)
1512 have_prototypes=no
1513 AC_MSG_CHECKING(for prototypes)
1514 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1515 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
1516 AC_MSG_RESULT($have_prototypes)
1518 works=no
1519 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
1520 AC_TRY_COMPILE([
1521 #include <stdarg.h>
1522 int foo(int x, ...) {
1523         va_list va;
1524         va_start(va, x);
1525         va_arg(va, int);
1526         va_arg(va, char *);
1527         va_arg(va, double);
1528         return 0;
1530 ], [return foo(10, "", 3.14);],
1531 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1532 AC_MSG_RESULT($works)
1534 if test "$have_prototypes" = yes; then
1535 bad_prototypes=no
1536 AC_MSG_CHECKING(for bad exec* prototypes)
1537 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1538         AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1539 AC_MSG_RESULT($bad_prototypes)
1542 # check if sockaddr has sa_len member
1543 AC_MSG_CHECKING(if sockaddr has sa_len member)
1544 AC_TRY_COMPILE([#include <sys/types.h>
1545 #include <sys/socket.h>],
1546 [struct sockaddr x;
1547 x.sa_len = 0;],
1548         AC_MSG_RESULT(yes)
1549         AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
1550         AC_MSG_RESULT(no))
1552 AC_MSG_CHECKING(for bad static forward)
1553 AC_CACHE_VAL(ac_cv_bad_static_forward,
1554 [AC_TRY_RUN([
1555 struct s { int a; int b; };
1556 static struct s foo;
1557 int foobar() {
1558  static int random;
1559  random = (int) &foo;
1560  return random;
1562 static struct s foo = { 1, 2 };
1563 main() {
1564  exit(!((int)&foo == foobar()));
1566 ac_cv_bad_static_forward=no,
1567 ac_cv_bad_static_forward=yes,
1568 ac_cv_bad_static_forward=no)])
1569 AC_MSG_RESULT($ac_cv_bad_static_forward)
1570 if test "$ac_cv_bad_static_forward" = yes
1571 then
1572     AC_DEFINE(BAD_STATIC_FORWARD)
1575 va_list_is_array=no
1576 AC_MSG_CHECKING(whether va_list is an array)
1577 AC_TRY_COMPILE([
1578 #ifdef HAVE_STDARG_PROTOTYPES
1579 #include <stdarg.h>
1580 #else
1581 #include <varargs.h>
1582 #endif
1583 ], [va_list list1, list2; list1 = list2;], , 
1584 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1585 AC_MSG_RESULT($va_list_is_array)
1587 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1588 AC_CHECK_FUNC(gethostbyname_r, [
1589   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1590   AC_MSG_CHECKING([gethostbyname_r with 6 args])
1591   OLD_CFLAGS=$CFLAGS
1592   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1593   AC_TRY_COMPILE([
1594 #   include <netdb.h>
1595   ], [
1596     char *name;
1597     struct hostent *he, *res;
1598     char buffer[2048];
1599     int buflen = 2048;
1600     int h_errnop;
1602     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1603   ], [
1604     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1605     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1606     AC_MSG_RESULT(yes)
1607   ], [
1608     AC_MSG_RESULT(no)
1609     AC_MSG_CHECKING([gethostbyname_r with 5 args])
1610     AC_TRY_COMPILE([
1611 #     include <netdb.h>
1612     ], [
1613       char *name;
1614       struct hostent *he;
1615       char buffer[2048];
1616       int buflen = 2048;
1617       int h_errnop;
1619       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1620     ], [
1621       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1622       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1623       AC_MSG_RESULT(yes)
1624     ], [
1625       AC_MSG_RESULT(no)
1626       AC_MSG_CHECKING([gethostbyname_r with 3 args])
1627       AC_TRY_COMPILE([
1628 #       include <netdb.h>
1629       ], [
1630         char *name;
1631         struct hostent *he;
1632         struct hostent_data data;
1634         (void) gethostbyname_r(name, he, &data);
1635       ], [
1636         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1637         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1638         AC_MSG_RESULT(yes)
1639       ], [
1640         AC_MSG_RESULT(no)
1641       ])
1642     ])
1643   ])
1644   CFLAGS=$OLD_CFLAGS
1645 ], [
1646   AC_CHECK_FUNCS(gethostbyname)
1648 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1649 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1650 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
1651 AC_SUBST(HAVE_GETHOSTBYNAME_R)
1652 AC_SUBST(HAVE_GETHOSTBYNAME)
1654 # checks for system services
1655 # (none yet)
1657 # Linux requires this for correct f.p. operations
1658 AC_CHECK_FUNC(__fpu_control,
1659   [],
1660   [AC_CHECK_LIB(ieee, __fpu_control)
1663 # Check for --with-fpectl
1664 AC_MSG_CHECKING(for --with-fpectl)
1665 AC_ARG_WITH(fpectl,
1666 [  --with-fpectl                   enable SIGFPE catching], [
1667 if test "$withval" != no
1668 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1669 else AC_MSG_RESULT(no)
1670 fi],
1671 [AC_MSG_RESULT(no)])
1673 # check for --with-libm=...
1674 AC_SUBST(LIBM)
1675 case $ac_sys_system in
1676 Darwin) ;;
1677 BeOS) ;;
1678 *) LIBM=-lm
1679 esac
1680 AC_MSG_CHECKING(for --with-libm=STRING)
1681 AC_ARG_WITH(libm, [  --with-libm=STRING              math library], [
1682 if test "$withval" = no
1683 then LIBM=
1684      AC_MSG_RESULT(force LIBM empty)
1685 elif test "$withval" != yes
1686 then LIBM=$withval
1687      AC_MSG_RESULT(set LIBM=\"$withval\")
1688 else AC_ERROR(proper usage is --with-libm=STRING)
1689 fi],
1690 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
1692 # check for --with-libc=...
1693 AC_SUBST(LIBC)
1694 AC_MSG_CHECKING(for --with-libc=STRING)
1695 AC_ARG_WITH(libc, [  --with-libc=STRING              C library], [
1696 if test "$withval" = no
1697 then LIBC=
1698      AC_MSG_RESULT(force LIBC empty)
1699 elif test "$withval" != yes
1700 then LIBC=$withval
1701      AC_MSG_RESULT(set LIBC=\"$withval\")
1702 else AC_ERROR(proper usage is --with-libc=STRING)
1703 fi],
1704 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
1706 # check for hypot() in math library
1707 LIBS_SAVE=$LIBS
1708 LIBS="$LIBS $LIBM"
1709 AC_REPLACE_FUNCS(hypot)
1710 LIBS=$LIBS_SAVE
1712 # check whether malloc(0) returns NULL or not
1713 AC_MSG_CHECKING(what malloc(0) returns)
1714 AC_CACHE_VAL(ac_cv_malloc_zero,
1715 [AC_TRY_RUN([#include <stdio.h>
1716 #ifdef HAVE_STDLIB
1717 #include <stdlib.h>
1718 #else
1719 char *malloc(), *realloc();
1720 int *free();
1721 #endif
1722 main() {
1723         char *p;
1724         p = malloc(0);
1725         if (p == NULL) exit(1);
1726         p = realloc(p, 0);
1727         if (p == NULL) exit(1);
1728         free(p);
1729         exit(0);
1731 ac_cv_malloc_zero=nonnull,
1732 ac_cv_malloc_zero=null,
1733 ac_cv_malloc_zero=nonnull)]) # XXX arm cross-compile?
1734 AC_MSG_RESULT($ac_cv_malloc_zero)
1735 if test "$ac_cv_malloc_zero" = null
1736 then
1737   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1740 # check for wchar.h
1741 AC_CHECK_HEADER(wchar.h,
1742 AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1743 wchar_h="no"
1746 # determine wchar_t size
1747 if test "$wchar_h" = yes
1748 then
1749   AC_CHECK_SIZEOF(wchar_t, 4)
1752 AC_MSG_CHECKING(what type to use for unicode)
1753 AC_ARG_ENABLE(unicode, 
1754 [  --enable-unicode[=ucs2,ucs4]    Enable Unicode strings (default is yes)],,enable_unicode=yes)
1756 if test $enable_unicode = yes
1757 then
1758   # Without any arguments, Py_UNICODE defaults to two-byte mode
1759   enable_unicode="ucs2"
1762 case "$enable_unicode" in
1763 ucs2) unicode_size="2"
1764       AC_DEFINE(Py_UNICODE_SIZE,2)
1765       ;;
1766 ucs4) unicode_size="4"
1767       AC_DEFINE(Py_UNICODE_SIZE,4)
1768       ;;
1769 esac
1771 AC_SUBST(UNICODE_OBJS)
1772 if test "$enable_unicode" = "no"
1773 then
1774   UNICODE_OBJS=""
1775   AC_MSG_RESULT(not used)
1776 else
1777   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
1778   AC_DEFINE(Py_USING_UNICODE)
1779   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
1780   then
1781     PY_UNICODE_TYPE="wchar_t"
1782     AC_DEFINE(HAVE_USABLE_WCHAR_T)
1783     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
1784   elif test "$ac_cv_sizeof_short" = "$unicode_size"
1785   then
1786        PY_UNICODE_TYPE="unsigned short"
1787        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
1788   elif test "$ac_cv_sizeof_long" = "$unicode_size"
1789   then
1790        PY_UNICODE_TYPE="unsigned long"
1791        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
1792   else
1793        PY_UNICODE_TYPE="no type found"
1794   fi
1795   AC_MSG_RESULT($PY_UNICODE_TYPE)
1798 # check for endianness
1799 AC_C_BIGENDIAN
1801 # Check whether right shifting a negative integer extends the sign bit
1802 # or fills with zeros (like the Cray J90, according to Tim Peters).
1803 AC_MSG_CHECKING(whether right shift extends the sign bit)
1804 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
1805 AC_TRY_RUN([
1806 int main()
1808         exit(((-1)>>3 == -1) ? 0 : 1);
1811 ac_cv_rshift_extends_sign=yes,
1812 ac_cv_rshift_extends_sign=no,
1813 ac_cv_rshift_extends_sign=yes)])
1814 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1815 if test "$ac_cv_rshift_extends_sign" = no
1816 then
1817   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1820 # check for getc_unlocked and related locking functions
1821 AC_MSG_CHECKING(for getc_unlocked() and friends)
1822 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1823 AC_TRY_LINK([#include <stdio.h>],[
1824         FILE *f = fopen("/dev/null", "r");
1825         flockfile(f);
1826         getc_unlocked(f);
1827         funlockfile(f);
1828 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1829 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1830 if test "$ac_cv_have_getc_unlocked" = yes
1831 then
1832   AC_DEFINE(HAVE_GETC_UNLOCKED)
1835 # check for readline 4.2
1836 AC_CHECK_LIB(readline, rl_completion_matches,
1837         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
1839 AC_MSG_CHECKING(for broken nice())
1840 AC_CACHE_VAL(ac_cv_broken_nice, [
1841 AC_TRY_RUN([
1842 int main()
1844         int val1 = nice(1);
1845         if (val1 != -1 && val1 == nice(2))
1846                 exit(0);
1847         exit(1);
1850 ac_cv_broken_nice=yes,
1851 ac_cv_broken_nice=no,
1852 ac_cv_broken_nice=no)])
1853 AC_MSG_RESULT($ac_cv_broken_nice)
1854 if test "$ac_cv_broken_nice" = yes
1855 then
1856   AC_DEFINE(HAVE_BROKEN_NICE)
1859 # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1860 # Add sys/socket.h to confdefs.h
1861 cat >> confdefs.h <<\EOF
1862 #ifdef HAVE_SYS_SOCKET_H
1863 #include <sys/socket.h>
1864 #endif
1866 AC_CHECK_TYPE(socklen_t, int)
1868 # Add Python/ prefix to LIBOBJS
1869 libobjs=$LIBOBJS
1870 LIBOBJS=
1871 for obj in $libobjs; do
1872     LIBOBJS="$LIBOBJS Python/$obj"
1873 done
1875 #AC_MSG_CHECKING(for Modules/Setup)
1876 #if test ! -f Modules/Setup ; then
1877 #    if test ! -d Modules ; then
1878 #        mkdir Modules
1879 #    fi
1880 #    cp "$srcdir/Modules/Setup.dist" Modules/Setup
1881 #    AC_MSG_RESULT(creating)
1882 #else
1883 #    AC_MSG_RESULT(already exists)
1886 AC_SUBST(SRCDIRS)
1887 SRCDIRS="Parser Grammar Objects Python Modules"
1888 AC_MSG_CHECKING(for build directories)
1889 for dir in $SRCDIRS; do
1890     if test ! -d $dir; then
1891         mkdir $dir
1892     fi
1893 done
1894 AC_MSG_RESULT(done)
1896 # generate output files
1897 AC_OUTPUT(Makefile.pre Modules/Setup.config)
1899 echo "creating Setup"
1900 if test ! -f Modules/Setup
1901 then
1902         cp $srcdir/Modules/Setup.dist Modules/Setup
1905 echo "creating Setup.local"
1906 if test ! -f Modules/Setup.local
1907 then
1908         echo "# Edit this file for local setup changes" >Modules/Setup.local
1911 echo "creating Makefile"
1912 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1913                         -s Modules Modules/Setup.config \
1914                         Modules/Setup.local Modules/Setup
1915 mv config.c Modules