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