Updated for 2.1b2 distribution.
[python/dscho.git] / configure.in
blob75b9d32bd4b1e90c60482aa9385c1b2852cceb68
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(config.h)
7 # Set VERSION so we only need to edit in one place (i.e., here)
8 AC_SUBST(VERSION)
9 VERSION=2.1
11 # Arguments passed to configure.
12 AC_SUBST(CONFIG_ARGS)
13 CONFIG_ARGS="$ac_configure_args"
15 # NEXTSTEP|MacOSX|Darwin stuff
16 if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
18         AC_MSG_CHECKING(for --with-next-archs)
19         AC_ARG_WITH(next-archs,
20          [  --with-next-archs='arch1 arch2 ..'   build MAB binary], [
21                 if test -n "$withval"; then
22                     ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval`
23                     # GCC does not currently support multi archs on the NeXT
24                     with_gcc=no
25                 fi
26                 AC_MSG_RESULT($with_next_archs)
27         ], [AC_MSG_RESULT(none: using `arch`)])
28         
29         if test -z "$MACHDEP"
30         then
31             ac_sys_system=`uname -s`
32             if test "$ac_sys_system" = "Darwin" ; then
33                 ac_sys_release=`uname -r`
34             else
35                 set X `hostinfo | egrep '(NeXT Mach|Kernel Release).*:' | \
36                         sed -e 's/://' -e 's/\./_/'` && \
37                 ac_sys_system=next && ac_sys_release=$4
38             fi
40             MACHDEP="$ac_sys_system$ac_sys_release"
41         fi
44 AC_ARG_WITH(next-framework,
45 [  --with-next-framework           Build (OpenStep|Rhapsody|MacOSX|Darwin) framework],,)
46 AC_ARG_WITH(dyld,
47 [  --with-dyld                     Use (OpenStep|Rhapsody|MacOSX|Darwin) dynamic linker],,)
49 # Set name for machine-dependent library files
50 AC_SUBST(MACHDEP)
51 AC_MSG_CHECKING(MACHDEP)
52 if test -z "$MACHDEP"
53 then
54         ac_sys_system=`uname -s`
55         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
56                 ac_sys_release=`uname -v`
57         else
58                 ac_sys_release=`uname -r`
59         fi
60         ac_md_system=`echo $ac_sys_system |
61                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
62         ac_md_release=`echo $ac_sys_release |
63                            tr -d '[/ ]' | sed 's/\..*//'`
64         MACHDEP="$ac_md_system$ac_md_release"
66         case $MACHDEP in
67         '')     MACHDEP="unknown";;
68         esac
72 # SGI compilers allow the specification of the both the ABI and the
73 # ISA on the command line.  Depending on the values of these switches,
74 # different and often incompatable code will be generated.
76 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
77 # thus supply support for various ABI/ISA combinations.  The MACHDEP
78 # variable is also adjusted.
80 AC_SUBST(SGI_ABI)
81 if test ! -z "$SGI_ABI"
82 then
83         CC="cc $SGI_ABI"
84         LDFLAGS="$SGI_ABI $LDFLAGS"
85         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
87 AC_MSG_RESULT($MACHDEP)
89 # checks for alternative programs
90 AC_MSG_CHECKING(for --without-gcc)
91 AC_ARG_WITH(gcc, [  --without-gcc                   never use gcc], [
92         case $withval in
93         no)     CC=cc
94                 without_gcc=yes;;
95         yes)    CC=gcc
96                 without_gcc=no;;
97         *)      CC=$withval
98                 without_gcc=$withval;;
99         esac], [
100         case $ac_sys_system in
101         OSF1)   CC=cc
102                 without_gcc=;;
103         AIX*)   CC=cc_r
104                 without_gcc=;;
105         BeOS*)
106                 case $BE_HOST_CPU in
107                 ppc)
108                         CC=mwcc
109                         without_gcc=yes
110                         OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
111                         CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
112                         LDFLAGS="$LDFLAGS -nodup"
113                         ;;
114                 x86)
115                         CC=gcc
116                         without_gcc=no
117                         OPT=-O
118                         ;;
119                 *)
120                         AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
121                         ;;
122                 esac
123                 AR="\$(srcdir)/Modules/ar_beos"
124                 RANLIB=:
125                 ;;
126     Monterey*)
127         RANLIB=:
128         without_gcc=;;
129         *)      without_gcc=no;;
130         esac])
131 AC_MSG_RESULT($without_gcc)
133 AC_SUBST(CXX)
134 AC_SUBST(MAINOBJ)
135 MAINOBJ=python.o
136 AC_MSG_CHECKING(for --with-cxx=<compiler>)
137 AC_ARG_WITH(cxx, [  --with-cxx=<compiler>           enable C++ support],[
138         check_cxx=no
139         case $withval in
140         no)     CXX=
141                 with_cxx=no;;
142         *)      CXX=$withval
143                 MAINOBJ=ccpython.o
144                 with_cxx=$withval;;
145         esac], [
146         with_cxx=no
147         check_cxx=yes
149 AC_MSG_RESULT($with_cxx)
151 dnl The following fragment works similar to AC_PROG_CXX.
152 dnl It does not fail if CXX is not found, and it is not executed if 
153 dnl --with-cxx was given.
154 dnl Finally, it does not test whether CXX is g++.
156 if test "$check_cxx" = "yes" 
157 then
158         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
159         if test "$CXX" = "notfound"
160         then
161                 CXX=
162         else
163                 AC_PROG_CXX_WORKS
164         fi
167 # If the user switches compilers, we can't believe the cache
168 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
169 then
170   AC_ERROR(cached CC is different -- throw away $cache_file
171 (it is also a good idea to do 'make clean' before compiling))
174 AC_PROG_CC
175 AC_EXEEXT
176 AC_MSG_CHECKING(for --with-suffix)
177 AC_ARG_WITH(suffix, [  --with-suffix=.exe              set executable suffix],[
178         case $withval in
179         no)     EXEEXT=;;
180         yes)    EXEEXT=.exe;;
181         *)      EXEEXT=$withval;;
182         esac])
183 AC_MSG_RESULT($EXEEXT)
185 case $MACHDEP in
186 bsdos*)
187     case $CC in
188     gcc) CC="$CC -D_HAVE_BSDI";;
189     esac;;
190 esac
192 case $ac_sys_system in
193 hp*|HP*)
194     case $CC in
195     cc|*/cc) CC="$CC -Ae";;
196     esac;;
197 Monterey*)
198     case $CC in
199     cc) CC="$CC -Wl,-Bexport";;
200     esac;;
201 SunOS*)
202     # Some functions have a prototype only with that define, e.g. confstr
203     AC_DEFINE(__EXTENSIONS__)
204     ;;
205 esac
208 AC_SUBST(LIBRARY)
209 AC_MSG_CHECKING(LIBRARY)
210 if test -z "$LIBRARY"
211 then
212         LIBRARY='libpython$(VERSION).a'
214 AC_MSG_RESULT($LIBRARY)
216 # LDLIBRARY is the name of the library to link against (as opposed to the
217 # name of the library into which to insert object files). On systems
218 # without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
219 # the Makefiles). On Cygwin LDLIBRARY is the import library, DLLLIBRARY is the
220 # shared (i.e., DLL) library.
221 AC_SUBST(LDLIBRARY)
222 AC_SUBST(DLLLIBRARY)
223 LDLIBRARY="$LIBRARY"
224 DLLLIBRARY=''
226 # LINKCC is the command that links the python executable -- default is $(CC).
227 # This is altered for AIX in order to build the export list before 
228 # linking.
229 AC_SUBST(LINKCC)
230 AC_MSG_CHECKING(LINKCC)
231 if test -z "$LINKCC"
232 then
233         case $ac_sys_system in
234         AIX*)
235            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
236         dgux*)
237            LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
238         Monterey64*)
239            LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
240         *) LINKCC="\$(PURIFY) \$(CC)";;
241         esac
243 AC_MSG_RESULT($LINKCC)
245 AC_MSG_CHECKING(LDLIBRARY)
247 # NeXT framework builds require that the 'ar' library be converted into
248 # a bundle using libtool.
249 if test "$with_next_framework"
250 then
251   LDLIBRARY='libpython$(VERSION).dylib'
252 fi  
254 # DG/UX requires some fancy ld contortions to produce a .so from an .a
255 case $MACHDEP in
256 dguxR4)
257       LDLIBRARY='libpython$(VERSION).so'
258       OPT="$OPT -pic"
259       ;;
260 beos*)
261       LDLIBRARY='libpython$(VERSION).so'
262       ;;
263 cygwin*)
264       LDLIBRARY='libpython$(VERSION).dll.a'
265       DLLLIBRARY='libpython$(VERSION).dll'
266       ;;
267 esac
268 AC_MSG_RESULT($LDLIBRARY)
270 AC_PROG_RANLIB
271 AC_SUBST(AR)
272 AC_CHECK_PROGS(AR, ar aal, ar)
273 AC_PROG_INSTALL
275 # Not every filesystem supports hard links
276 AC_SUBST(LN)
277 if test -z "$LN" ; then
278         case $ac_sys_system in
279                 BeOS*) LN="ln -s";;
280                 CYGWIN*) LN="ln -s";;
281                 *) LN=ln;;
282         esac
285 # Optimizer/debugger flags
286 AC_SUBST(OPT)
287 if test -z "$OPT"
288 then
289         case $GCC in
290         yes)
291                 case $ac_cv_prog_cc_g in
292                 yes)    OPT="-g -O2 -Wall -Wstrict-prototypes";;
293                 *)      OPT="-O2 -Wall -Wstrict-prototypes";;
294                 esac
295                 ;;
296         *)      OPT="-O";;
297         esac
300 # The current (beta) Monterey compiler dies with optimizations
301 case $ac_sys_system in
302 Monterey*) OPT="";;
303 esac
305 if test "$ac_arch_flags"
306 then
307         OPT="$OPT $ac_arch_flags"
309 # checks for UNIX variants that set C preprocessor variables
310 AC_AIX
311 AC_MINIX
313 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
314 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
315 [ac_save_cc="$CC"
316 CC="$CC -OPT:Olimit=0"
317 AC_TRY_RUN([int main() { return 0; }],
318   ac_cv_opt_olimit_ok=yes,
319   ac_cv_opt_olimit_ok=no)
320 CC="$ac_save_cc"])
321 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
322 if test $ac_cv_opt_olimit_ok = yes; then
323     case $ac_sys_system in
324       Darwin*) OPT="$OPT" ;;
325       *) OPT="$OPT -OPT:Olimit=0";;
326     esac
327 else
328   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
329   AC_CACHE_VAL(ac_cv_olimit_ok,
330   [ac_save_cc="$CC"
331   CC="$CC -Olimit 1500"
332   AC_TRY_RUN([int main() { return 0; }],
333     ac_cv_olimit_ok=yes,
334     ac_cv_olimit_ok=no)
335   CC="$ac_save_cc"])
336   AC_MSG_RESULT($ac_cv_olimit_ok)
337   if test $ac_cv_olimit_ok = yes; then
338     OPT="$OPT -Olimit 1500"
339   fi
342 dnl # check for ANSI or K&R ("traditional") preprocessor
343 dnl AC_MSG_CHECKING(for C preprocessor type)
344 dnl AC_TRY_COMPILE([
345 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
346 dnl int foo;
347 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
348 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
349 dnl AC_MSG_RESULT($cpp_type)
351 # checks for header files
352 AC_HEADER_STDC
353 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
354 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
355 sys/audioio.h sys/file.h sys/lock.h db_185.h db.h \
356 sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \
357 sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
358 ndbm.h db1/ndbm.h gdbm/ndbm.h)
359 AC_HEADER_DIRENT
361 # checks for typedefs
362 was_it_defined=no
363 AC_MSG_CHECKING(for clock_t in time.h)
364 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
365 AC_MSG_RESULT($was_it_defined)
367 # Add some code to confdefs.h so that the test for off_t works on SCO
368 cat >> confdefs.h <<\EOF
369 #if defined(SCO_DS)
370 #undef _OFF_T
371 #endif
374 # Type availability checks
375 AC_TYPE_MODE_T
376 AC_TYPE_OFF_T
377 AC_TYPE_PID_T
378 AC_TYPE_SIGNAL
379 AC_TYPE_SIZE_T
380 AC_TYPE_UID_T
382 # Sizes of various common basic types
383 AC_CHECK_SIZEOF(int)
384 AC_CHECK_SIZEOF(long)
385 AC_CHECK_SIZEOF(void *)
386 AC_CHECK_SIZEOF(char)
387 AC_CHECK_SIZEOF(short)
388 AC_CHECK_SIZEOF(float)
389 AC_CHECK_SIZEOF(double)
390 AC_CHECK_SIZEOF(fpos_t)
392 AC_MSG_CHECKING(for long long support)
393 have_long_long=no
394 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
395 AC_MSG_RESULT($have_long_long)
396 if test "$have_long_long" = yes ; then
397 AC_CHECK_SIZEOF(long long)
400 AC_MSG_CHECKING(for uintptr_t support)
401 have_uintptr_t=no
402 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
403 AC_MSG_RESULT($have_uintptr_t)
404 if test "$have_uintptr_t" = yes ; then
405 AC_CHECK_SIZEOF(uintptr_t)
408 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
409 AC_MSG_CHECKING(size of off_t)
410 AC_CACHE_VAL(ac_cv_sizeof_off_t,
411 [AC_TRY_RUN([#include <stdio.h>
412 #include <sys/types.h>
413 main()
415   FILE *f=fopen("conftestval", "w");
416   if (!f) exit(1);
417   fprintf(f, "%d\n", sizeof(off_t));
418   exit(0);
419 }], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
421 AC_MSG_RESULT($ac_cv_sizeof_off_t)
422 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
424 AC_MSG_CHECKING(whether to enable large file support)
425 if test "$have_long_long" = yes -a \
426         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
427         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
428   AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
429   AC_MSG_RESULT(yes)
430 else
431   AC_MSG_RESULT(no)
434 # AC_CHECK_SIZEOF() doesn't include <time.h>.
435 AC_MSG_CHECKING(size of time_t)
436 AC_CACHE_VAL(ac_cv_sizeof_time_t,
437 [AC_TRY_RUN([#include <stdio.h>
438 #include <time.h>
439 main()
441   FILE *f=fopen("conftestval", "w");
442   if (!f) exit(1);
443   fprintf(f, "%d\n", sizeof(time_t));
444   exit(0);
445 }], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
447 AC_MSG_RESULT($ac_cv_sizeof_time_t)
448 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
451 # if have pthread_t then define SIZEOF_PTHREAD_T
452 AC_MSG_CHECKING(for pthread_t)
453 have_pthread_t=no
454 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
455 AC_MSG_RESULT($have_pthread_t)
456 if test "$have_pthread_t" = yes ; then
457   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
458   AC_MSG_CHECKING(size of pthread_t)
459   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
460   [AC_TRY_RUN([#include <stdio.h>
461   #include <pthread.h>
462   main()
463   {
464     FILE *f=fopen("conftestval", "w");
465     if (!f) exit(1);
466     fprintf(f, "%d\n", sizeof(pthread_t));
467     exit(0);
468   }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
469   ])
470   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
471   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
475 # Minor variations in building a framework between NextStep versions 4 and 5
476 AC_SUBST(LIBTOOL_CRUFT)
477 case $ac_sys_system/$ac_sys_release in
478   Darwin/*)
479     ns_undef_sym='_environ'
480     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym" ;;
481   next/4*)
482     ns_undef_sym='__environ'
483     LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
484   next/5*)
485     ns_undef_sym='_environ'
486     LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
487 esac
489 AC_MSG_CHECKING(for --with-next-framework)
490 if test "$with_next_framework"
491 then
492         OPT="$OPT -fno-common"
493         # -U __environ is needed since bundles don't have access
494         # to crt0 when built but will always be linked against it
495         LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
496         AC_DEFINE(WITH_NEXT_FRAMEWORK)
497         AC_MSG_RESULT(yes)
498 else
499         AC_MSG_RESULT(no)
502 AC_MSG_CHECKING(for --with-dyld)
503 if test "$with_next_framework" -o "$with_dyld"
504 then
505         if test "$with_dyld"
506         then
507                 AC_MSG_RESULT(yes)
508         else
509                 AC_MSG_RESULT(required for framework build)
510         fi
511         AC_DEFINE(WITH_DYLD)
512         ns_dyld='set'
513 else
514         AC_MSG_RESULT(no)
517 # Set info about shared libraries.
518 AC_SUBST(SO)
519 AC_SUBST(LDSHARED)
520 AC_SUBST(BLDSHARED)
521 AC_SUBST(CCSHARED)
522 AC_SUBST(LINKFORSHARED)
523 # SO is the extension of shared libraries `(including the dot!)
524 # -- usually .so, .sl on HP-UX, .dll on Cygwin
525 AC_MSG_CHECKING(SO)
526 if test -z "$SO"
527 then
528         case $ac_sys_system in
529         hp*|HP*)   SO=.sl;;
530         CYGWIN*)   SO=.dll;;
531         *)         SO=.so;;
532         esac
534 AC_MSG_RESULT($SO)
535 # LDSHARED is the ld *command* used to create shared library
536 # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
537 # (Shared libraries in this instance are shared modules to be loaded into
538 # Python, as opposed to building Python itself as a shared library.)
539 AC_MSG_CHECKING(LDSHARED)
540 if test -z "$LDSHARED"
541 then
542         case $ac_sys_system/$ac_sys_release in
543         AIX*)
544                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
545                 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
546                 ;;
547         BeOS*)
548                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
549                 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
550                 ;;
551         IRIX/5*) LDSHARED="ld -shared";;
552         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
553         SunOS/4*) LDSHARED="ld";;
554         SunOS/5*) 
555                 if test "$GCC" = "yes"
556                 then LDSHARED='$(CC) -shared'
557                 else LDSHARED="ld -G";
558                 fi ;;
559         hp*|HP*) LDSHARED="ld -b";;
560         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
561         DYNIX/ptx*) LDSHARED="ld -G";;
562         Darwin/*|next/*) 
563                 if test "$ns_dyld"
564                 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined suppress'
565                 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
566                 fi
567         if test "$with_next_framework" ; then
568                     LDSHARED="$LDSHARED \$(LDLIBRARY)"
569                 fi ;;
570         Linux*) LDSHARED="gcc -shared";;
571         dgux*) LDSHARED="ld -G";;
572         BSD/OS*/4*) LDSHARED="gcc -shared";;
573         OpenBSD*) LDSHARED="ld -Bshareable";;
574         NetBSD*)
575                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
576                 then
577                         LDSHARED="cc -shared"
578                 else
579                         LDSHARED="ld -Bshareable"
580                 fi;;
581         FreeBSD*)
582                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
583                 then
584                         LDSHARED="cc -shared ${LDFLAGS}"
585                 else
586                         LDSHARED="ld -Bshareable ${LDFLAGS}"
587                 fi;;
588         UnixWare*)
589                 if test "$GCC" = "yes"
590                 then LDSHARED="$(CC) -shared"
591                 else LDSHARED="$(CC) -G"
592                 fi;;
593         SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
594         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
595         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
596         *)      LDSHARED="ld";;
597         esac
599 AC_MSG_RESULT($LDSHARED)
600 BLDSHARED=${BLDSHARED-$LDSHARED}
601 # CCSHARED are the C *flags* used to create objects to go into a shared
602 # library (module) -- this is only needed for a few systems
603 AC_MSG_CHECKING(CCSHARED)
604 if test -z "$CCSHARED"
605 then
606         case $ac_sys_system/$ac_sys_release in
607         SunOS*) if test "$GCC" = yes;
608                 then CCSHARED="-fPIC";
609                 fi;;
610         hp*|HP*) if test "$GCC" = yes;
611                  then CCSHARED="-fpic";
612                  else CCSHARED="+z";
613                  fi;;
614         Linux*) CCSHARED="-fPIC";;
615         BSD/OS*/4*) CCSHARED="-fpic";;
616         OpenBSD*) CCSHARED="-fpic";;
617         FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
618         UnixWare*)
619                 if test "$GCC" = "yes"
620                 then CCSHARED="-fPIC"
621                 else CCSHARED="-KPIC"
622                 fi;;
623         SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
624         Monterey*) CCSHARED="-G";;
625         IRIX*/6*)  case $CC in
626                    *gcc*) CCSHARED="-shared";;
627                    *) CCSHARED="";;
628                    esac;;
629         CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
630         esac
632 AC_MSG_RESULT($CCSHARED)
633 # LINKFORSHARED are the flags passed to the $(CC) command that links
634 # the python executable -- this is only needed for a few systems
635 AC_MSG_CHECKING(LINKFORSHARED)
636 if test -z "$LINKFORSHARED"
637 then
638         case $ac_sys_system/$ac_sys_release in
639         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
640         hp*|HP*)
641             LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
642         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
643         Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
644         # -u libsys_s pulls in all symbols in libsys
645         next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
646         # -u __dummy makes the linker aware of the objc runtime
647         # in System.framework; otherwise, __objcInit (referenced in
648         # crt1.o) gets erroneously defined as common, which breaks dynamic
649         # loading of any modules which reference it in System.framework
650         next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
651         Darwin/*) LINKFORSHARED="-u __dummy -framework System -framework Foundation" ;;
652         UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
653         SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
654         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
655         FreeBSD*|NetBSD*) 
656                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
657                 then
658                         LINKFORSHARED="-Wl,--export-dynamic"
659                 fi;;
660         SunOS/5*) case $CC in
661                   *gcc*)
662                     if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
663                     then
664                         LINKFORSHARED="-Xlinker --export-dynamic"
665                     fi;;
666                   esac;;
667         esac
669 AC_MSG_RESULT($LINKFORSHARED)
671 AC_SUBST(CFLAGSFORSHARED)
672 AC_MSG_CHECKING(CFLAGSFORSHARED)
673 if test ! "$LIBRARY" = "$LDLIBRARY"
674 then
675         case $ac_sys_system in
676         CYGWIN*)
677                 # Cygwin needs CCSHARED when building extension DLLs
678                 # but not when building the interpreter DLL.
679                 CFLAGSFORSHARED='';;
680         *)
681                 CFLAGSFORSHARED='$(CCSHARED)'
682         esac
684 AC_MSG_RESULT($CFLAGSFORSHARED)
686 # checks for libraries
687 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
688 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
690 # Check for --with-pydebug
691 AC_MSG_CHECKING(for --with-pydebug)
692 AC_ARG_WITH(pydebug, 
693 [  --with-pydebug                  build with Py_DEBUG defined], [
694 if test "$withval" != no
695 then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes)
696 else AC_MSG_RESULT(no)
697 fi],
698 [AC_MSG_RESULT(no)])
700 # checks for system dependent C++ extensions support
701 case "$ac_sys_system" in
702         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
703                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
704                             [loadAndInit("", 0, "")],
705                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
706                              AC_MSG_RESULT(yes)],
707                             [AC_MSG_RESULT(no)]);;
708         *) ;;
709 esac
711 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
712 # However on SGI IRIX, these exist but are broken.
713 # BeOS' sockets are stashed in libnet.
714 case "$ac_sys_system" in
715 IRIX*) ;;
717 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
718 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
720 esac
721 case "$ac_sys_system" in
722 BeOS*)
723 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
725 esac
727 AC_MSG_CHECKING(for --with-libs)
728 AC_ARG_WITH(libs,
729 [  --with-libs='lib1 ...'          link against additional libs], [
730 AC_MSG_RESULT($withval)
731 LIBS="$withval $LIBS"
732 ], AC_MSG_RESULT(no))
734 # Determine if signalmodule should be used.
735 AC_SUBST(USE_SIGNAL_MODULE)
736 AC_SUBST(SIGNAL_OBJS)
737 AC_MSG_CHECKING(for --with-signal-module)
738 AC_ARG_WITH(signal-module,
739 [  --with-signal-module            disable/enable signal module])
741 if test -z "$with_signal_module"
742 then with_signal_module="yes"
744 AC_MSG_RESULT($with_signal_module)
746 if test "${with_signal_module}" = "yes"; then
747         USE_SIGNAL_MODULE=""
748         SIGNAL_OBJS=""
749 else
750         USE_SIGNAL_MODULE="#"
751         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
754 # This is used to generate Setup.config
755 AC_SUBST(USE_THREAD_MODULE)
756 USE_THREAD_MODULE=""
758 AC_MSG_CHECKING(for --with-dec-threads)
759 AC_SUBST(LDLAST)
760 AC_ARG_WITH(dec-threads,
761 [  --with-dec-threads              use DEC Alpha/OSF1 thread-safe libraries], [
762 AC_MSG_RESULT($withval)
763 LDLAST=-threads
764 if test "${with_thread+set}" != set; then
765    with_thread="$withval";
766 fi],
767 AC_MSG_RESULT(no))
769 AC_MSG_CHECKING(for --with-threads)
770 AC_ARG_WITH(threads,
771 [  --with(out)-threads[=DIRECTORY] disable/enable thread support])
773 # --with-thread is deprecated, but check for it anyway
774 AC_ARG_WITH(thread,
775 [  --with(out)-thread[=DIRECTORY]  deprecated; use --with(out)-threads],[
776 with_threads=$with_thread])
778 if test -z "$with_threads"
779 then with_threads="yes"
781 AC_MSG_RESULT($with_threads)
783 if test "$with_threads" = "no"
784 then
785     USE_THREAD_MODULE="#"
786 else
787     if test ! -z "$with_threads" -a -d "$with_threads"
788     then LDFLAGS="$LDFLAGS -L$with_threads"
789     fi
790     if test ! -z "$withval" -a -d "$withval"
791     then LDFLAGS="$LDFLAGS -L$withval"
792     fi
793     AC_DEFINE(_REENTRANT)
794     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
795     AC_DEFINE(C_THREADS)
796     LIBOBJS="$LIBOBJS thread.o"],[
797     AC_MSG_CHECKING(for --with-pth)
798     AC_ARG_WITH(pth,
799     [  --with-pth                      use GNU pth threading libraries], [
800     AC_MSG_RESULT($withval)
801     AC_DEFINE(WITH_THREAD)
802     AC_DEFINE(HAVE_PTH)
803     LIBS="-lpth $LIBS"
804     LIBOBJS="$LIBOBJS thread.o"],[
805     AC_MSG_RESULT(no)
806     AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
807     AC_DEFINE(_POSIX_THREADS)
808     LIBS="-lpthread $LIBS"
809     LIBOBJS="$LIBOBJS thread.o"],[
810     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
811     case $ac_sys_system in
812       Darwin*) ;;
813       *) AC_DEFINE(_POSIX_THREADS);;
814     esac
815     LIBOBJS="$LIBOBJS thread.o"],[
816     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
817     AC_DEFINE(BEOS_THREADS)
818     LIBOBJS="$LIBOBJS thread.o"],[
819     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
820     AC_DEFINE(_POSIX_THREADS)
821     LIBS="$LIBS -lpthreads"
822     LIBOBJS="$LIBOBJS thread.o"], [
823     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
824     AC_DEFINE(_POSIX_THREADS)
825     LIBS="$LIBS -lc_r"
826     LIBOBJS="$LIBOBJS thread.o"], [
827     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
828     AC_DEFINE(_POSIX_THREADS)
829     LIBS="$LIBS -lthread"
830     LIBOBJS="$LIBOBJS thread.o"], [
831     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
832     AC_DEFINE(_POSIX_THREADS)
833     LIBS="$LIBS -lpthread"
834     LIBOBJS="$LIBOBJS thread.o"], [
835     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
836     AC_DEFINE(_POSIX_THREADS)
837     LIBS="$LIBS -lcma"
838     LIBOBJS="$LIBOBJS thread.o"],[
839     USE_THREAD_MODULE="#"])
840     ])])])])])])])])])
842     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
843     LIBS="$LIBS -lmpc"
844     LIBOBJS="$LIBOBJS thread.o"
845     USE_THREAD_MODULE=""])
846     AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
847     LIBS="$LIBS -lthread"
848     LIBOBJS="$LIBOBJS thread.o"
849     USE_THREAD_MODULE=""])
851     if test "$USE_THREAD_MODULE" != "#"
852     then
853         # If the above checks didn't disable threads, (at least) OSF1
854         # needs this '-threads' argument during linking.
855         case $ac_sys_system in
856         OSF1) LDLAST=-threads;;
857         esac
858     fi
861 # Check for GC support
862 AC_SUBST(USE_GC_MODULE)
863 USE_GC_MODULE=""
864 AC_MSG_CHECKING(for --with-cycle-gc)
865 AC_ARG_WITH(cycle-gc,
866 [  --with(out)-cycle-gc            disable/enable garbage collection])
868 if test -z "$with_cycle_gc"
869 then with_cycle_gc="yes"
871 if test "$with_cycle_gc" = "no"
872 then
873     USE_GC_MODULE="#"
874 else
875     AC_DEFINE(WITH_CYCLE_GC)
877 AC_MSG_RESULT($with_cycle_gc)
879 # Check for Python-specific malloc support
880 AC_MSG_CHECKING(for --with-pymalloc)
881 AC_ARG_WITH(pymalloc,
882 [  --with(out)-pymalloc            disable/enable specialized mallocs], [
883 if test "$withval" != no
884 then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
885 else AC_MSG_RESULT(no)
886 fi],
887 [AC_MSG_RESULT(no)])
889 # Check for --with-wctype-functions
890 AC_MSG_CHECKING(for --with-wctype-functions)
891 AC_ARG_WITH(wctype-functions, 
892 [  --with-wctype-functions         use wctype.h functions], [
893 if test "$withval" != no
894 then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
895 else AC_MSG_RESULT(no)
896 fi],
897 [AC_MSG_RESULT(no)])
899 # -I${DLINCLDIR} is added to the compile rule for importdl.o
900 AC_SUBST(DLINCLDIR)
901 DLINCLDIR=/
903 AC_MSG_CHECKING(for --with-sgi-dl)
904 AC_ARG_WITH(sgi-dl,
905 [  --with-sgi-dl=DIRECTORY         IRIX 4 dynamic linking], [
906 AC_MSG_RESULT($withval)
907 AC_DEFINE(WITH_SGI_DL)
908 DYNLOADFILE="dynload_dl.o"
909 dldir=$withval
910 if test ! -z "$dldir" -a -d "$dldir"
911 then LDFLAGS="$LDFLAGS -L$dldir"
912 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
914 DLINCLDIR=${dldir}
915 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
917 AC_MSG_CHECKING(for --with-dl-dld)
918 AC_ARG_WITH(dl-dld, [  --with-dl-dld=DL_DIR,DLD_DIR    GNU dynamic linking], [
919 AC_MSG_RESULT($withval)
920 AC_DEFINE(WITH_DL_DLD)
921 DYNLOADFILE="dynload_dl.o"
922 dldir=`echo "$withval" | sed 's/,.*//'`
923 dlddir=`echo "$withval" | sed 's/.*,//'`
924 if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
925 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
926 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
928 DLINCLDIR=${dldir}
929 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
931 # the dlopen() function means we might want to use dynload_shlib.o. some
932 # platforms, such as AIX, have dlopen(), but don't want to use it.
933 AC_CHECK_FUNCS(dlopen)
935 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
936 # loading of modules.
937 AC_SUBST(DYNLOADFILE)
938 AC_MSG_CHECKING(DYNLOADFILE)
939 if test -z "$DYNLOADFILE"
940 then
941         case $ac_sys_system/$ac_sys_release in
942         AIX*) DYNLOADFILE="dynload_aix.o";;
943         BeOS*) DYNLOADFILE="dynload_beos.o";;
944         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
945         Darwin/*|next/*) DYNLOADFILE="dynload_next.o";;
946         *)
947         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
948         # out any dynamic loading
949         if test "$ac_cv_func_dlopen" = yes
950         then DYNLOADFILE="dynload_shlib.o"
951         else DYNLOADFILE="dynload_stub.o"
952         fi
953         ;;
954         esac
956 AC_MSG_RESULT($DYNLOADFILE)
957 if test "$DYNLOADFILE" != "dynload_stub.o"
958 then
959         AC_DEFINE(HAVE_DYNAMIC_LOADING)
962 # checks for library functions
963 AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
964  flock fork fsync fdatasync fpathconf ftime ftruncate \
965  getgroups getlogin getpeername getpid getpwent getwd \
966  kill link lstat mkfifo mktime mremap \
967  nice pathconf pause plock poll pthread_init \
968  putenv readlink \
969  select setegid seteuid setgid \
970  setlocale setregid setreuid setsid setpgid setuid setvbuf \
971  sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
972  tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
973  truncate uname waitpid _getpty)
975 # check for openpty and forkpty
977 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
978 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
980 # check for long file support functions
981 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
983 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
984 AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
985 AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
986 AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
988 # checks for structures
989 AC_HEADER_TIME
990 AC_STRUCT_TM
991 AC_STRUCT_TIMEZONE
993 AC_MSG_CHECKING(for time.h that defines altzone)
994 AC_CACHE_VAL(ac_cv_header_time_altzone,
995 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
996   ac_cv_header_time_altzone=yes,
997   ac_cv_header_time_altzone=no)])
998 AC_MSG_RESULT($ac_cv_header_time_altzone)
999 if test $ac_cv_header_time_altzone = yes; then
1000   AC_DEFINE(HAVE_ALTZONE)
1003 was_it_defined=no
1004 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
1005 AC_TRY_COMPILE([
1006 #include <sys/types.h>
1007 #include <sys/select.h>
1008 #include <sys/time.h>
1009 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1010 AC_MSG_RESULT($was_it_defined)
1012 # checks for compiler characteristics
1014 AC_C_CHAR_UNSIGNED
1015 AC_C_CONST
1017 works=no
1018 AC_MSG_CHECKING(for working volatile)
1019 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1020 AC_MSG_RESULT($works)
1022 works=no
1023 AC_MSG_CHECKING(for working signed char)
1024 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1025 AC_MSG_RESULT($works)
1027 have_prototypes=no
1028 AC_MSG_CHECKING(for prototypes)
1029 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1030 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
1031 AC_MSG_RESULT($have_prototypes)
1033 works=no
1034 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
1035 AC_TRY_COMPILE([
1036 #include <stdarg.h>
1037 int foo(int x, ...) {
1038         va_list va;
1039         va_start(va, x);
1040         va_arg(va, int);
1041         va_arg(va, char *);
1042         va_arg(va, double);
1043         return 0;
1045 ], [return foo(10, "", 3.14);],
1046 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1047 AC_MSG_RESULT($works)
1049 if test "$have_prototypes" = yes; then
1050 bad_prototypes=no
1051 AC_MSG_CHECKING(for bad exec* prototypes)
1052 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1053         AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1054 AC_MSG_RESULT($bad_prototypes)
1057 bad_forward=no
1058 AC_MSG_CHECKING(for bad static forward)
1059 AC_TRY_RUN([
1060 struct s { int a; int b; };
1061 static struct s foo;
1062 int foobar() {
1063  static int random;
1064  random = (int) &foo;
1065  return random;
1067 static struct s foo = { 1, 2 };
1068 main() {
1069  exit(!((int)&foo == foobar()));
1071 ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
1072 AC_MSG_RESULT($bad_forward)
1074 va_list_is_array=no
1075 AC_MSG_CHECKING(whether va_list is an array)
1076 AC_TRY_COMPILE([
1077 #ifdef HAVE_STDARG_PROTOTYPES
1078 #include <stdarg.h>
1079 #else
1080 #include <varargs.h>
1081 #endif
1082 ], [va_list list1, list2; list1 = list2;], , 
1083 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1084 AC_MSG_RESULT($va_list_is_array)
1086 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1087 AC_CHECK_FUNC(gethostbyname_r, [
1088   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1089   AC_MSG_CHECKING([gethostbyname_r with 6 args])
1090   OLD_CFLAGS=$CFLAGS
1091   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1092   AC_TRY_COMPILE([
1093 #   include <netdb.h>
1094   ], [
1095     char *name;
1096     struct hostent *he, *res;
1097     char buffer[2048];
1098     int buflen = 2048;
1099     int h_errnop;
1101     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1102   ], [
1103     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1104     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1105     AC_MSG_RESULT(yes)
1106   ], [
1107     AC_MSG_RESULT(no)
1108     AC_MSG_CHECKING([gethostbyname_r with 5 args])
1109     AC_TRY_COMPILE([
1110 #     include <netdb.h>
1111     ], [
1112       char *name;
1113       struct hostent *he;
1114       char buffer[2048];
1115       int buflen = 2048;
1116       int h_errnop;
1118       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1119     ], [
1120       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1121       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1122       AC_MSG_RESULT(yes)
1123     ], [
1124       AC_MSG_RESULT(no)
1125       AC_MSG_CHECKING([gethostbyname_r with 3 args])
1126       AC_TRY_COMPILE([
1127 #       include <netdb.h>
1128       ], [
1129         char *name;
1130         struct hostent *he;
1131         struct hostent_data data;
1133         (void) gethostbyname_r(name, he, &data);
1134       ], [
1135         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1136         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1137         AC_MSG_RESULT(yes)
1138       ], [
1139         AC_MSG_RESULT(no)
1140       ])
1141     ])
1142   ])
1143   CFLAGS=$OLD_CFLAGS
1144 ], [
1145   AC_CHECK_FUNCS(gethostbyname)
1147 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1148 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1149 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
1150 AC_SUBST(HAVE_GETHOSTBYNAME_R)
1151 AC_SUBST(HAVE_GETHOSTBYNAME)
1153 # checks for system services
1154 # (none yet)
1156 # Linux requires this for correct f.p. operations
1157 AC_CHECK_FUNC(__fpu_control,
1158   [],
1159   [AC_CHECK_LIB(ieee, __fpu_control)
1162 # Check for --with-fpectl
1163 AC_MSG_CHECKING(for --with-fpectl)
1164 AC_ARG_WITH(fpectl,
1165 [  --with-fpectl                   enable SIGFPE catching], [
1166 if test "$withval" != no
1167 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1168 else AC_MSG_RESULT(no)
1169 fi],
1170 [AC_MSG_RESULT(no)])
1172 # check for --with-libm=...
1173 AC_SUBST(LIBM)
1174 case $ac_sys_system in
1175 Darwin) ;;
1176 next) ;;
1177 BeOS) ;;
1178 *) LIBM=-lm
1179 esac
1180 AC_MSG_CHECKING(for --with-libm=STRING)
1181 AC_ARG_WITH(libm, [  --with-libm=STRING              math library], [
1182 if test "$withval" = no
1183 then LIBM=
1184      AC_MSG_RESULT(force LIBM empty)
1185 elif test "$withval" != yes
1186 then LIBM=$withval
1187      AC_MSG_RESULT(set LIBM=\"$withval\")
1188 else AC_ERROR(proper usage is --with-libm=STRING)
1189 fi],
1190 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
1192 # check for --with-libc=...
1193 AC_SUBST(LIBC)
1194 AC_MSG_CHECKING(for --with-libc=STRING)
1195 AC_ARG_WITH(libc, [  --with-libc=STRING              C library], [
1196 if test "$withval" = no
1197 then LIBC=
1198      AC_MSG_RESULT(force LIBC empty)
1199 elif test "$withval" != yes
1200 then LIBC=$withval
1201      AC_MSG_RESULT(set LIBC=\"$withval\")
1202 else AC_ERROR(proper usage is --with-libc=STRING)
1203 fi],
1204 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
1206 # check for hypot() in math library
1207 LIBS_SAVE=$LIBS
1208 LIBS="$LIBS $LIBM"
1209 AC_REPLACE_FUNCS(hypot)
1210 LIBS=$LIBS_SAVE
1212 # check whether malloc(0) returns NULL or not
1213 AC_MSG_CHECKING(what malloc(0) returns)
1214 AC_CACHE_VAL(ac_cv_malloc_zero,
1215 [AC_TRY_RUN([#include <stdio.h>
1216 #ifdef HAVE_STDLIB
1217 #include <stdlib.h>
1218 #else
1219 char *malloc(), *realloc();
1220 int *free();
1221 #endif
1222 main() {
1223         char *p;
1224         p = malloc(0);
1225         if (p == NULL) exit(1);
1226         p = realloc(p, 0);
1227         if (p == NULL) exit(1);
1228         free(p);
1229         exit(0);
1230 }], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1231 AC_MSG_RESULT($ac_cv_malloc_zero)
1232 if test "$ac_cv_malloc_zero" = null
1233 then
1234   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1237 # check for wchar.h
1238 AC_CHECK_HEADER(wchar.h,
1239 AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1240 wchar_h="no"
1243 # check for usable wchar_t
1244 usable_wchar_t="unkown"
1245 AC_MSG_CHECKING(for usable wchar_t)
1246 AC_TRY_RUN([
1247 #include "wchar.h"
1248 #include "wctype.h"
1249 main() {
1250  wchar_t s;
1251  if (sizeof(s) == 2)
1252   exit(0);
1253  else
1254   exit(1);
1256 ], 
1257 AC_DEFINE(HAVE_USABLE_WCHAR_T) usable_wchar_t="yes",
1258 usable_wchar_t="no")
1259 AC_MSG_RESULT($usable_wchar_t)
1261 # check for endianness
1262 AC_C_BIGENDIAN
1264 # Check whether right shifting a negative integer extends the sign bit
1265 # or fills with zeros (like the Cray J90, according to Tim Peters).
1266 AC_MSG_CHECKING(whether right shift extends the sign bit)
1267 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
1268 AC_TRY_RUN([
1269 int main()
1271         exit(((-1)>>3 == -1) ? 0 : 1);
1273 ], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1274 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1275 if test "$ac_cv_rshift_extends_sign" = no
1276 then
1277   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1280 # check for getc_unlocked and related locking functions
1281 AC_MSG_CHECKING(for getc_unlocked() and friends)
1282 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1283 AC_TRY_LINK([#include <stdio.h>],[
1284         FILE *f = fopen("/dev/null", "r");
1285         flockfile(f);
1286         getc_unlocked(f);
1287         funlockfile(f);
1288 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1289 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1290 if test "$ac_cv_have_getc_unlocked" = yes
1291 then
1292   AC_DEFINE(HAVE_GETC_UNLOCKED)
1295 # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1296 # Add sys/socket.h to confdefs.h
1297 cat >> confdefs.h <<\EOF
1298 #ifdef HAVE_SYS_SOCKET_H
1299 #include <sys/socket.h>
1300 #endif
1302 AC_CHECK_TYPE(socklen_t, int)
1304 # Add Python/ prefix to LIBOBJS
1305 libobjs=$LIBOBJS
1306 LIBOBJS=
1307 for obj in $libobjs; do
1308     LIBOBJS="$LIBOBJS Python/$obj"
1309 done
1311 #AC_MSG_CHECKING(for Modules/Setup)
1312 #if test ! -f Modules/Setup ; then
1313 #    if test ! -d Modules ; then
1314 #        mkdir Modules
1315 #    fi
1316 #    cp "$srcdir/Modules/Setup.dist" Modules/Setup
1317 #    AC_MSG_RESULT(creating)
1318 #else
1319 #    AC_MSG_RESULT(already exists)
1322 AC_SUBST(SRCDIRS)
1323 SRCDIRS="Parser Grammar Objects Python Modules"
1324 AC_MSG_CHECKING(for build directories)
1325 for dir in $SRCDIRS; do
1326     if test ! -d $dir; then
1327         mkdir $dir
1328     fi
1329 done
1330 AC_MSG_RESULT(done)
1332 # generate output files
1333 AC_OUTPUT(Makefile.pre Modules/Setup.config)
1335 echo "creating Setup"
1336 if test ! -f Modules/Setup
1337 then
1338         cp $srcdir/Modules/Setup.dist Modules/Setup
1341 echo "creating Setup.local"
1342 if test ! -f Modules/Setup.local
1343 then
1344         echo "# Edit this file for local setup changes" >Modules/Setup.local
1347 echo "creating Makefile"
1348 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1349                         -s Modules Modules/Setup.config \
1350                         Modules/Setup Modules/Setup.local
1351 mv config.c Modules