Bump version to 1.0.
[python/dscho.git] / configure.in
blobb7352da996d03cff40914ee05436092e494839ed
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.0
11 # NEXTSTEP 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                 set X `hostinfo | egrep '(NeXT Mach|Kernel Release).*:' | \
28                         sed -e 's/://' -e 's/\./_/'` && \
29                         ac_sys_system=next && ac_sys_release=$4
31                 MACHDEP="$ac_sys_system$ac_sys_release"
32         fi
35 AC_ARG_WITH(next-framework,
36 [  --with-next-framework           Build (OpenStep|Rhapsody|MacOSX) framework],,)
37 AC_ARG_WITH(dyld,
38 [  --with-dyld                     Use (OpenStep|Rhapsody|MacOSX) dynamic linker],,)
40 # Set name for machine-dependent library files
41 AC_SUBST(MACHDEP)
42 AC_MSG_CHECKING(MACHDEP)
43 if test -z "$MACHDEP"
44 then
45         ac_sys_system=`uname -s`
46         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
47                 ac_sys_release=`uname -v`
48         else
49                 ac_sys_release=`uname -r`
50         fi
51         ac_md_system=`echo $ac_sys_system |
52                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
53         ac_md_release=`echo $ac_sys_release |
54                            tr -d '[/ ]' | sed 's/\..*//'`
55         MACHDEP="$ac_md_system$ac_md_release"
57         case $MACHDEP in
58         '')     MACHDEP="unknown";;
59         esac
63 # SGI compilers allow the specification of the both the ABI and the
64 # ISA on the command line.  Depending on the values of these switches,
65 # different and often incompatable code will be generated.
67 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
68 # thus supply support for various ABI/ISA combinations.  The MACHDEP
69 # variable is also adjusted.
71 AC_SUBST(SGI_ABI)
72 if test ! -z "$SGI_ABI"
73 then
74         CC="cc $SGI_ABI"
75         LDFLAGS="$SGI_ABI $LDFLAGS"
76         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
78 AC_MSG_RESULT($MACHDEP)
81 # CCC is the command that compiles C++ programs
83 # Not all make programs have this predefined.
85 #AC_SUBST(SET_CCC)
86 #AC_MSG_CHECKING(CCC)
87 #if test -z "$CCC"
88 #then
89 #       case $ac_sys_system in
90 #       IRIX*)  SET_CCC="CCC= CC ${SGI_ABI}";;
91 #       Linux*) SET_CCC="CCC= g++";;
92 #       *)      SET_CCC=""
93 #       esac
94 #else
95 #        SET_CCC="CCC= ${CCC}"
96 #fi
97 #AC_MSG_RESULT($SET_CCC)
100 # checks for alternative programs
101 AC_MSG_CHECKING(for --without-gcc)
102 AC_ARG_WITH(gcc, [  --without-gcc                   never use gcc], [
103         case $withval in
104         no)     CC=cc
105                 without_gcc=yes;;
106         yes)    CC=gcc
107                 without_gcc=no;;
108         *)      CC=$withval
109                 without_gcc=$withval;;
110         esac], [
111         case $ac_sys_system in
112         OSF1)   CC=cc
113                 without_gcc=;;
114         BeOS*)
115                 # Dunno if it's a good idea to get this over with all at once, or
116                 # to handle it in with the other goodies.
117                 MACHDEP=beos
119                 case $BE_HOST_CPU in
120                 ppc)
121                         CC="mwcc -I$PWD/BeOS -nodup"
122                         without_gcc=yes
123                         case `uname -r` in
124                                 4.0*) OPT="-DUSE_DL_EXPORT -O7 -opt schedule604 -export pragma" ;;
125                                 *) OPT="-DUSE_DL_EXPORT -O2 -proc 604e -export pragma" ;;
126                         esac
127                         CCSHARED=-UUSE_DL_EXPORT
128                         LDFLAGS="$LDFLAGS -nodup"
130                         AR="$PWD/BeOS/ar-fake"
131                         RANLIB=:
132                         
133                         AC_DEFINE(DL_EXPORT_HEADER,"dl_export.h")
134                         ;;
135                 x86)
136                         CC="gcc -I$PWD/BeOS"
137                         without_gcc=no
138                         OPT="-DUSE_DL_EXPORT -O"
139                         CCSHARED=-UUSE_DL_EXPORT
141                         AR="$PWD/BeOS/ar-fake"
142                         RANLIB=:
143                         
144                         AC_DEFINE(DL_EXPORT_HEADER,"dl_export.h")
145                         ;;
146                 *)
147                         AC_ERROR(Your BeOS system isn't PowerPC or x86... neat, but this won't work...)
148                         ;;
149                 esac
150                 ;;
151     Monterey*)
152         RANLIB=:
153         without_gcc=;;
154         *)      without_gcc=no;;
155         esac])
156 AC_MSG_RESULT($without_gcc)
158 AC_SUBST(SET_CXX)
159 AC_SUBST(MAINOBJ)
160 MAINOBJ=python.o
161 AC_MSG_CHECKING(for --with-cxx=<compiler>)
162 AC_ARG_WITH(cxx, [  --with-cxx=<compiler>           enable C++ support],[
163         case $withval in
164         no)     CXX=
165                 with_cxx=no;;
166         *)      CXX=$withval
167                 MAINOBJ=ccpython.o
168                 with_cxx=$withval;;
169         esac], [
170         with_cxx=no
172 AC_MSG_RESULT($with_cxx)
173 SET_CXX="CXX=$CXX"
175 #AC_MSG_CHECKING(CCC)
176 #if test -z "$CCC"
177 #then
178 #       case $ac_sys_system in
179 #       IRIX*)  SET_CCC="CCC= CC ${SGI_ABI}";;
180 #       Linux*) SET_CCC="CCC= g++";;
181 #       *)      SET_CCC=""
182 #       esac
183 #else
184 #        SET_CCC="CCC= ${CCC}"
186 #AC_MSG_RESULT($SET_CCC)
188 # If the user switches compilers, we can't believe the cache
189 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
190 then
191   AC_ERROR(cached CC is different -- throw away $cache_file
192 (it is also a good idea to do 'make clean' before compiling))
195 AC_PROG_CC
196 AC_SUBST(EXE)
197 AC_MSG_CHECKING(for --with-suffix)
198 AC_ARG_WITH(suffix, [  --with-suffix=.exe              set executable suffix],[
199         case $withval in
200         no)     EXE=;;
201         yes)    EXE=.exe;;
202         *)      EXE=$withval;;
203         esac])
204 AC_MSG_RESULT($EXE)
206 case $MACHDEP in
207 bsdos*)
208     case $CC in
209     gcc) CC="$CC -D_HAVE_BSDI";;
210     esac;;
211 esac
213 case $ac_sys_system in
214 hp*|HP*)
215     case $CC in
216     cc|*/cc) CC="$CC -Ae";;
217     esac;;
218 BeOS*)
219     case $CC in
220     cc) CC=cc;;
221     esac;;
222 Monterey*)
223     case $CC in
224     cc) CC="$CC -Wl,-Bexport";;
225     esac;;
226 esac
228 # LDLIBRARY is the name of the library to link against (as opposed to the
229 # name of the library into which to insert object files). On systems
230 # without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
231 # the Makefiles). 
232 AC_SUBST(MAKE_LDLIBRARY)
233 AC_SUBST(LDLIBRARY)
234 LDLIBRARY=''
236 # LINKCC is the command that links the python executable -- default is $(CC).
237 # This is altered for AIX and BeOS in order to build the export list before 
238 # linking.
239 AC_SUBST(LINKCC)
240 AC_MSG_CHECKING(LINKCC)
241 if test -z "$LINKCC" -a ! -z "$CXX"
242 then
243     LINKCC="$CXX"
245 if test -z "$LINKCC"
246 then
247         case $ac_sys_system in
248         AIX*)
249            LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
250         BeOS*)
251            LINKCC="\$(srcdir)/../BeOS/linkcc \$(LIBRARY) \$(PURIFY) \$(CC) \$(OPT)"
252            LDLIBRARY='libpython$(VERSION).so';;
253         dgux*)
254            LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
255         Monterey64*)
256            LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
257         *) LINKCC="\$(PURIFY) \$(CC)";;
258         esac
260 AC_MSG_RESULT($LINKCC)
262 AC_MSG_CHECKING(LDLIBRARY)
264 # NeXT framework builds require that the 'ar' library be converted into
265 # a bundle using libtool.
266 if test "$with_next_framework"
267 then
268   LDLIBRARY='libpython$(VERSION).dylib'
269 fi  
271 # DG/UX requires some fancy ld contortions to produce a .so from an .a
272 if test "$MACHDEP" = "dguxR4"
273 then
274   LDLIBRARY='libpython$(VERSION).so'
275   OPT="$OPT -pic"
277 AC_MSG_RESULT($LDLIBRARY)
279 # If LDLIBRARY is different from LIBRARY, emit a rule to build it.
280 if test -z "$LDLIBRARY"
281 then
282   LDLIBRARY='libpython$(VERSION).a'
283   MAKE_LDLIBRARY="true"
284 else
285   MAKE_LDLIBRARY='$(MAKE) $(LDLIBRARY)'
288 AC_PROG_RANLIB
289 AC_SUBST(AR)
290 AC_CHECK_PROGS(AR, ar aal, ar)
291 AC_SUBST(INSTALL)
292 AC_SUBST(INSTALL_PROGRAM)
293 AC_SUBST(INSTALL_DATA)
294 # Install just never works :-(
295 if test -z "$INSTALL"
296 then
297         INSTALL=cp
298         INSTALL_PROGRAM=cp
299         INSTALL_DATA=cp
300 else
301         INSTALL_PROGRAM="$INSTALL"
302         INSTALL_DATA="$INSTALL -m 644"
305 # Not every filesystem supports hard links
306 AC_SUBST(LN)
307 if test -z "$LN" ; then
308         case $ac_sys_system in
309                 BeOS*) LN="ln -s";;
310                 *) LN=ln;;
311         esac
314 # Optimizer/debugger flags passed between Makefiles
315 AC_SUBST(OPT)
316 if test -z "$OPT"
317 then
318         case $GCC in
319         yes)
320                 case $ac_cv_prog_cc_g in
321                 yes)    OPT="-g -O2";;
322                 *)      OPT="-O2";;
323                 esac
324                 ;;
325         *)      OPT="-O";;
326         esac
329 # The current (beta) Monterey compiler dies with optimizations
330 case $ac_sys_system in
331 Monterey*) OPT="";;
332 esac
334 if test "$ac_arch_flags"
335 then
336         OPT="$OPT $ac_arch_flags"
338 # checks for UNIX variants that set C preprocessor variables
339 AC_AIX
340 AC_MINIX
342 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
343 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
344 [ac_save_cc="$CC"
345 CC="$CC -OPT:Olimit=0"
346 AC_TRY_RUN([int main() { return 0; }],
347   ac_cv_opt_olimit_ok=yes,
348   ac_cv_opt_olimit_ok=no)
349 CC="$ac_save_cc"])
350 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
351 if test $ac_cv_opt_olimit_ok = yes; then
352   OPT="$OPT -OPT:Olimit=0"
353 else
354   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
355   AC_CACHE_VAL(ac_cv_olimit_ok,
356   [ac_save_cc="$CC"
357   CC="$CC -Olimit 1500"
358   AC_TRY_RUN([int main() { return 0; }],
359     ac_cv_olimit_ok=yes,
360     ac_cv_olimit_ok=no)
361   CC="$ac_save_cc"])
362   AC_MSG_RESULT($ac_cv_olimit_ok)
363   if test $ac_cv_olimit_ok = yes; then
364     OPT="$OPT -Olimit 1500"
365   fi
368 dnl # check for ANSI or K&R ("traditional") preprocessor
369 dnl AC_MSG_CHECKING(for C preprocessor type)
370 dnl AC_TRY_COMPILE([
371 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
372 dnl int foo;
373 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
374 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
375 dnl AC_MSG_RESULT($cpp_type)
377 # checks for header files
378 AC_HEADER_STDC
379 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
380 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
381 sys/audioio.h sys/file.h sys/lock.h db_185.h db.h \
382 sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \
383 sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
384 ndbm.h db1/ndbm.h gdbm/ndbm.h)
385 AC_HEADER_DIRENT
387 # checks for typedefs
388 was_it_defined=no
389 AC_MSG_CHECKING(for clock_t in time.h)
390 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
391 AC_MSG_RESULT($was_it_defined)
393 # Add some code to confdefs.h so that the test for off_t works on SCO
394 cat >> confdefs.h <<\EOF
395 #if defined(SCO_DS)
396 #undef _OFF_T
397 #endif
400 # Type availability checks
401 AC_TYPE_MODE_T
402 AC_TYPE_OFF_T
403 AC_TYPE_PID_T
404 AC_TYPE_SIGNAL
405 AC_TYPE_SIZE_T
406 AC_TYPE_UID_T
408 # Sizes of various common basic types
409 AC_CHECK_SIZEOF(int)
410 AC_CHECK_SIZEOF(long)
411 AC_CHECK_SIZEOF(void *)
412 AC_CHECK_SIZEOF(char)
413 AC_CHECK_SIZEOF(short)
414 AC_CHECK_SIZEOF(float)
415 AC_CHECK_SIZEOF(double)
416 AC_CHECK_SIZEOF(fpos_t)
418 AC_MSG_CHECKING(for long long support)
419 have_long_long=no
420 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
421 AC_MSG_RESULT($have_long_long)
422 if test "$have_long_long" = yes ; then
423 AC_CHECK_SIZEOF(long long)
426 AC_MSG_CHECKING(for uintptr_t support)
427 have_uintptr_t=no
428 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
429 AC_MSG_RESULT($have_uintptr_t)
430 if test "$have_uintptr_t" = yes ; then
431 AC_CHECK_SIZEOF(uintptr_t)
434 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
435 AC_MSG_CHECKING(size of off_t)
436 AC_CACHE_VAL(ac_cv_sizeof_off_t,
437 [AC_TRY_RUN([#include <stdio.h>
438 #include <sys/types.h>
439 main()
441   FILE *f=fopen("conftestval", "w");
442   if (!f) exit(1);
443   fprintf(f, "%d\n", sizeof(off_t));
444   exit(0);
445 }], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
447 AC_MSG_RESULT($ac_cv_sizeof_off_t)
448 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
450 AC_MSG_CHECKING(whether to enable large file support)
451 if test "$have_long_long" = yes -a \
452         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
453         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
454   AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
455   AC_MSG_RESULT(yes)
456 else
457   AC_MSG_RESULT(no)
460 # AC_CHECK_SIZEOF() doesn't include <time.h>.
461 AC_MSG_CHECKING(size of time_t)
462 AC_CACHE_VAL(ac_cv_sizeof_time_t,
463 [AC_TRY_RUN([#include <stdio.h>
464 #include <time.h>
465 main()
467   FILE *f=fopen("conftestval", "w");
468   if (!f) exit(1);
469   fprintf(f, "%d\n", sizeof(time_t));
470   exit(0);
471 }], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
473 AC_MSG_RESULT($ac_cv_sizeof_time_t)
474 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
477 # if have pthread_t then define SIZEOF_PTHREAD_T
478 AC_MSG_CHECKING(for pthread_t)
479 have_pthread_t=no
480 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
481 AC_MSG_RESULT($have_pthread_t)
482 if test "$have_pthread_t" = yes ; then
483   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
484   AC_MSG_CHECKING(size of pthread_t)
485   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
486   [AC_TRY_RUN([#include <stdio.h>
487   #include <pthread.h>
488   main()
489   {
490     FILE *f=fopen("conftestval", "w");
491     if (!f) exit(1);
492     fprintf(f, "%d\n", sizeof(pthread_t));
493     exit(0);
494   }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
495   ])
496   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
497   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
501 # Minor variations in building a framework between NextStep versions 4 and 5
502 AC_SUBST(LIBTOOL_CRUFT)
503 case $ac_sys_system/$ac_sys_release in
504   next/4*)
505     ns_undef_sym='__environ'
506     LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
507   next/5*)
508     ns_undef_sym='_environ'
509     LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
510 esac
512 AC_MSG_CHECKING(for --with-next-framework)
513 if test "$with_next_framework"
514 then
515         OPT="$OPT -fno-common"
516         # -U __environ is needed since bundles don't have access
517         # to crt0 when built but will always be linked against it
518         LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
519         AC_DEFINE(WITH_NEXT_FRAMEWORK)
520         AC_MSG_RESULT(yes)
521 else
522         AC_MSG_RESULT(no)
525 AC_MSG_CHECKING(for --with-dyld)
526 if test "$with_next_framework" -o "$with_dyld"
527 then
528         if test "$with_dyld"
529         then
530                 AC_MSG_RESULT(yes)
531         else
532                 AC_MSG_RESULT(required for framework build)
533         fi
534         AC_DEFINE(WITH_DYLD)
535         ns_dyld='set'
536 else
537         AC_MSG_RESULT(no)
540 # Set info about shared libraries.
541 AC_SUBST(SO)
542 AC_SUBST(LDSHARED)
543 AC_SUBST(CCSHARED)
544 AC_SUBST(LINKFORSHARED)
545 # SO is the extension of shared libraries `(including the dot!)
546 # -- usually .so, .sl on HP-UX
547 AC_MSG_CHECKING(SO)
548 if test -z "$SO"
549 then
550         case $ac_sys_system in
551         hp*|HP*)   SO=.sl;;
552         *)         SO=.so;;
553         esac
555 AC_MSG_RESULT($SO)
556 # LDSHARED is the ld *command* used to create shared library
557 # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
558 # (Shared libraries in this instance are shared modules to be loaded into
559 # Python, as opposed to building Python itself as a shared library.)
560 AC_MSG_CHECKING(LDSHARED)
561 if test -z "$LDSHARED"
562 then
563         case $ac_sys_system/$ac_sys_release in
564         AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
565         BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
566         IRIX/5*) LDSHARED="ld -shared";;
567         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
568         SunOS/4*) LDSHARED="ld";;
569         SunOS/5*) 
570                 if test "$GCC" = "yes"
571                 then LDSHARED='$(CC) -G'
572                 else LDSHARED="ld -G";
573                 fi ;;
574         hp*|HP*) LDSHARED="ld -b";;
575         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
576         DYNIX/ptx*) LDSHARED="ld -G";;
577         next/*) 
578                 if test "$ns_dyld"
579                 then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
580                 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
581                 fi
582                 if test "$with_next_framework" ; then
583                     LDSHARED="$LDSHARED \$(LDLIBRARY)"
584                 fi ;;
585         Linux*) LDSHARED="gcc -shared";;
586         dgux*) LDSHARED="ld -G";;
587         BSD/OS*/4*) LDSHARED="gcc -shared";;
588         OpenBSD*) LDSHARED="ld -Bshareable";;
589         NetBSD*)
590                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
591                 then
592                         LDSHARED="cc -shared"
593                 else
594                         LDSHARED="ld -Bshareable"
595                 fi;;
596         FreeBSD*)
597                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
598                 then
599                         LDSHARED="cc -shared ${LDFLAGS}"
600                 else
601                         LDSHARED="ld -Bshareable ${LDFLAGS}"
602                 fi;;
603         SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
604         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
605         *)      LDSHARED="ld";;
606         esac
608 AC_MSG_RESULT($LDSHARED)
609 # CCSHARED are the C *flags* used to create objects to go into a shared
610 # library (module) -- this is only needed for a few systems
611 AC_MSG_CHECKING(CCSHARED)
612 if test -z "$CCSHARED"
613 then
614         case $ac_sys_system/$ac_sys_release in
615         hp*|HP*) if test "$GCC" = yes;
616                  then CCSHARED="-fpic";
617                  else CCSHARED="+z";
618                  fi;;
619         Linux*) CCSHARED="-fpic";;
620         BSD/OS*/4*) CCSHARED="-fpic";;
621         OpenBSD*) CCSHARED="-fpic";;
622         FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
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         esac
631 AC_MSG_RESULT($CCSHARED)
632 # LINKFORSHARED are the flags passed to the $(CC) command that links
633 # the python executable -- this is only needed for a few systems
634 AC_MSG_CHECKING(LINKFORSHARED)
635 if test -z "$LINKFORSHARED"
636 then
637         case $ac_sys_system/$ac_sys_release in
638         AIX*)   LINKFORSHARED='-Wl,-bE:python.exp -lld';;
639         hp*|HP*)
640             LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
641         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
642         Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
643         # -u libsys_s pulls in all symbols in libsys
644         next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
645         # -u __dummy makes the linker aware of the objc runtime
646         # in System.framework; otherwise, __objcInit (referenced in
647         # crt1.o) gets erroneously defined as common, which breaks dynamic
648         # loading of any modules which reference it in System.framework
649         next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
650         SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
651         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
652         FreeBSD*|NetBSD*) 
653                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
654                 then
655                         LINKFORSHARED="-Wl,--export-dynamic"
656                 fi;;
657         SunOS/5*) case $CC in
658                   *gcc*)
659                     if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
660                     then
661                         LINKFORSHARED="-Xlinker --export-dynamic"
662                     fi;;
663                   esac;;
664         esac
666 AC_MSG_RESULT($LINKFORSHARED)
668 # checks for libraries
669 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
670 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
672 # Check for --with-pydebug
673 AC_MSG_CHECKING(for --with-pydebug)
674 AC_ARG_WITH(pydebug, 
675 [  --with-pydebug                  build with Py_DEBUG defined], [
676 if test "$withval" != no
677 then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes)
678 else AC_MSG_RESULT(no)
679 fi],
680 [AC_MSG_RESULT(no)])
682 # checks for system dependent C++ extensions support
683 case "$ac_sys_system" in
684         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
685                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
686                             [loadAndInit("", 0, "")],
687                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
688                              AC_MSG_RESULT(yes)],
689                             [AC_MSG_RESULT(no)]);;
690         *) ;;
691 esac
693 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
694 # However on SGI IRIX, these exist but are broken.
695 # BeOS' sockets are stashed in libnet.
696 case "$ac_sys_system" in
697 IRIX*) ;;
699 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
700 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
702 esac
703 case "$ac_sys_system" in
704 BeOS*)
705 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
707 esac
709 AC_MSG_CHECKING(for --with-libs)
710 AC_ARG_WITH(libs,
711 [  --with-libs='lib1 ...'          link against additional libs], [
712 AC_MSG_RESULT($withval)
713 LIBS="$withval $LIBS"
714 ], AC_MSG_RESULT(no))
716 AC_SUBST(USE_THREAD_MODULE)
717 USE_THREAD_MODULE=""
719 AC_MSG_CHECKING(for --with-dec-threads)
720 AC_SUBST(LDLAST)
721 AC_ARG_WITH(dec-threads,
722 [  --with-dec-threads              use DEC Alpha/OSF1 thread-safe libraries], [
723 AC_MSG_RESULT($withval)
724 LDLAST=-threads
725 if test "${with_thread+set}" != set; then
726    with_thread="$withval";
727 fi],
728 AC_MSG_RESULT(no))
730 AC_MSG_CHECKING(for --with-threads)
731 AC_ARG_WITH(threads,
732 [  --with(out)-threads[=DIRECTORY] disable/enable thread support])
734 # --with-thread is deprecated, but check for it anyway
735 AC_ARG_WITH(thread,
736 [  --with(out)-thread[=DIRECTORY]  deprecated; use --with(out)-threads],[
737 with_threads=$with_thread])
739 if test -z "$with_threads"
740 then with_threads="yes"
742 AC_MSG_RESULT($with_threads)
744 if test "$with_threads" = "no"
745 then
746     USE_THREAD_MODULE="#"
747 else
748     if test -d "$with_threads"
749     then LDFLAGS="$LDFLAGS -L$with_threads"
750     fi
751     if test -d "$withval"
752     then LDFLAGS="$LDFLAGS -L$withval"
753     fi
754     AC_DEFINE(_REENTRANT)
755     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
756     AC_DEFINE(C_THREADS)
757     LIBOBJS="$LIBOBJS thread.o"],[
758     AC_MSG_CHECKING(for --with-pth)
759     AC_ARG_WITH(pth,
760     [  --with-pth                      use GNU pth threading libraries], [
761     AC_MSG_RESULT($withval)
762     AC_DEFINE(WITH_THREAD)
763     AC_DEFINE(HAVE_PTH)
764     LIBS="-lpth $LIBS"
765     LIBOBJS="$LIBOBJS thread.o"],[
766     AC_MSG_RESULT(no)
767     AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
768     AC_DEFINE(_POSIX_THREADS)
769     LIBS="-lpthread $LIBS"
770     LIBOBJS="$LIBOBJS thread.o"],[
771     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
772     AC_DEFINE(_POSIX_THREADS)
773     LIBOBJS="$LIBOBJS thread.o"],[
774     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
775     AC_DEFINE(BEOS_THREADS)
776     LIBOBJS="$LIBOBJS thread.o"],[
777     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
778     AC_DEFINE(_POSIX_THREADS)
779     LIBS="$LIBS -lpthreads"
780     LIBOBJS="$LIBOBJS thread.o"], [
781     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
782     AC_DEFINE(_POSIX_THREADS)
783     LIBS="$LIBS -lc_r"
784     LIBOBJS="$LIBOBJS thread.o"], [
785     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
786     AC_DEFINE(_POSIX_THREADS)
787     LIBS="$LIBS -lthread"
788     LIBOBJS="$LIBOBJS thread.o"], [
789     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
790     AC_DEFINE(_POSIX_THREADS)
791     LIBS="$LIBS -lcma"
792     LIBOBJS="$LIBOBJS thread.o"],[
793     USE_THREAD_MODULE="#"])
794     ])])])])])])])])
796     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
797     LIBS="$LIBS -lmpc"
798     LIBOBJS="$LIBOBJS thread.o"
799     USE_THREAD_MODULE=""])
800     AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
801     LIBS="$LIBS -lthread"
802     LIBOBJS="$LIBOBJS thread.o"
803     USE_THREAD_MODULE=""])
806 # Check for GC support
807 AC_SUBST(USE_GC_MODULE)
808 USE_GC_MODULE=""
809 AC_MSG_CHECKING(for --with-cycle-gc)
810 AC_ARG_WITH(cycle-gc,
811 [  --with(out)-cycle-gc            disable/enable garbage collection])
813 if test -z "$with_cycle_gc"
814 then with_cycle_gc="yes"
816 if test "$with_cycle_gc" = "no"
817 then
818     USE_GC_MODULE="#"
819 else
820     AC_DEFINE(WITH_CYCLE_GC)
822 AC_MSG_RESULT($with_cycle_gc)
824 # Check for LIBDB support
825 # either --with-libdb or, in its absence, the presence of db.h
826 AC_SUBST(USE_BSDDB_MODULE)
827 USE_BSDDB_MODULE=""
828 AC_MSG_CHECKING(for --with-libdb)
829 AC_ARG_WITH(libdb,
830 [  --with(out)-libdb               disable/enable bsddb module])
832 # enabled by default, but db.h must be found
833 if test "$ac_cv_header_db_h" = "yes"
834 then
835     if test "$with_libdb" != "no"
836     then with_libdb="yes"
837     fi
838 else
839     # make sure user knows why bsddb support wasn't enabled event
840     # though s/he requested it
841     if test "$with_libdb" = "yes"
842     then echo $ac_n "(requested, but db.h was not found) $ac_c"
843     fi
844     with_libdb="no"
847 if test "$with_libdb" = "no"
848 then
849     USE_BSDDB_MODULE="#"
850 else
851     AC_DEFINE(WITH_LIBDB)
853 AC_MSG_RESULT($with_libdb)
855 if test "$with_libdb" = "yes"
856 then
857     # check for libdb; BSD systems have the DB routines in libc  --tg
858     AC_SUBST(HAVE_LIBDB)
859     # If dbopen is not in libc, then checking whether it is in libdb
860     # is difficult: db_185.h may #define it as __db185_open
861     # Instead, we just trust it is in libdb; linking will fail if it
862     # is not.
863     AC_CHECK_FUNC(dbopen, [HAVE_LIBDB=], [HAVE_LIBDB=-ldb])
866 # Check for --with-wctype-functions
867 AC_MSG_CHECKING(for --with-wctype-functions)
868 AC_ARG_WITH(wctype-functions, 
869 [  --with-wctype-functions         use wctype.h functions], [
870 if test "$withval" != no
871 then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
872 else AC_MSG_RESULT(no)
873 fi],
874 [AC_MSG_RESULT(no)])
876 # -I${DLINCLDIR} is added to the compile rule for importdl.o
877 AC_SUBST(DLINCLDIR)
878 DLINCLDIR=/
880 AC_MSG_CHECKING(for --with-sgi-dl)
881 AC_ARG_WITH(sgi-dl,
882 [  --with-sgi-dl=DIRECTORY         IRIX 4 dynamic linking], [
883 AC_MSG_RESULT($withval)
884 AC_DEFINE(WITH_SGI_DL)
885 DYNLOADFILE="dynload_dl.o"
886 dldir=$withval
887 if test -d "$dldir"
888 then LDFLAGS="$LDFLAGS -L$dldir"
889 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
891 DLINCLDIR=${dldir}
892 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
894 AC_MSG_CHECKING(for --with-dl-dld)
895 AC_ARG_WITH(dl-dld, [  --with-dl-dld=DL_DIR,DLD_DIR    GNU dynamic linking], [
896 AC_MSG_RESULT($withval)
897 AC_DEFINE(WITH_DL_DLD)
898 DYNLOADFILE="dynload_dl.o"
899 dldir=`echo "$withval" | sed 's/,.*//'`
900 dlddir=`echo "$withval" | sed 's/.*,//'`
901 if test -d "$dldir" -a -d "$dlddir"
902 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
903 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
905 DLINCLDIR=${dldir}
906 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
908 # the dlopen() function means we might want to use dynload_shlib.o. some
909 # platforms, such as AIX, have dlopen(), but don't want to use it.
910 AC_CHECK_FUNCS(dlopen)
912 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
913 # loading of modules.
914 AC_SUBST(DYNLOADFILE)
915 AC_MSG_CHECKING(DYNLOADFILE)
916 if test -z "$DYNLOADFILE"
917 then
918         case $ac_sys_system/$ac_sys_release in
919         AIX*) DYNLOADFILE="dynload_aix.o";;
920         BeOS*) DYNLOADFILE="dynload_beos.o";;
921         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
922         next/*) DYNLOADFILE="dynload_next.o";;
923         *)
924         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
925         # out any dynamic loading
926         if test "$ac_cv_func_dlopen" = yes
927         then DYNLOADFILE="dynload_shlib.o"
928         else DYNLOADFILE="dynload_stub.o"
929         fi
930         ;;
931         esac
933 AC_MSG_RESULT($DYNLOADFILE)
934 if test "$DYNLOADFILE" != "dynload_stub.o"
935 then
936         AC_DEFINE(HAVE_DYNAMIC_LOADING)
939 # checks for library functions
940 AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
941  flock fork fsync fdatasync fpathconf ftime ftruncate \
942  getgroups getlogin getpeername getpid getpwent getwd \
943  kill link lstat mkfifo mktime mremap \
944  nice pathconf pause plock poll pthread_init \
945  putenv readlink \
946  select setegid seteuid setgid \
947  setlocale setregid setreuid setsid setpgid setuid setvbuf \
948  sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
949  tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
950  truncate uname waitpid _getpty)
952 # check for openpty and forkpty
954 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
955 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
957 # check for long file support functions
958 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
960 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
961 AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
962 AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
963 AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
965 # checks for structures
966 AC_HEADER_TIME
967 AC_STRUCT_TM
968 AC_STRUCT_TIMEZONE
970 AC_MSG_CHECKING(for time.h that defines altzone)
971 AC_CACHE_VAL(ac_cv_header_time_altzone,
972 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
973   ac_cv_header_time_altzone=yes,
974   ac_cv_header_time_altzone=no)])
975 AC_MSG_RESULT($ac_cv_header_time_altzone)
976 if test $ac_cv_header_time_altzone = yes; then
977   AC_DEFINE(HAVE_ALTZONE)
980 was_it_defined=no
981 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
982 AC_TRY_COMPILE([
983 #include <sys/types.h>
984 #include <sys/select.h>
985 #include <sys/time.h>
986 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
987 AC_MSG_RESULT($was_it_defined)
989 # checks for compiler characteristics
991 AC_C_CHAR_UNSIGNED
992 AC_C_CONST
993 AC_C_INLINE
995 works=no
996 AC_MSG_CHECKING(for working volatile)
997 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
998 AC_MSG_RESULT($works)
1000 works=no
1001 AC_MSG_CHECKING(for working signed char)
1002 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1003 AC_MSG_RESULT($works)
1005 have_prototypes=no
1006 AC_MSG_CHECKING(for prototypes)
1007 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1008 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
1009 AC_MSG_RESULT($have_prototypes)
1011 works=no
1012 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
1013 AC_TRY_COMPILE([
1014 #include <stdarg.h>
1015 int foo(int x, ...) {
1016         va_list va;
1017         va_start(va, x);
1018         va_arg(va, int);
1019         va_arg(va, char *);
1020         va_arg(va, double);
1021         return 0;
1023 ], [return foo(10, "", 3.14);],
1024 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1025 AC_MSG_RESULT($works)
1027 if test "$have_prototypes" = yes; then
1028 bad_prototypes=no
1029 AC_MSG_CHECKING(for bad exec* prototypes)
1030 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1031         AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1032 AC_MSG_RESULT($bad_prototypes)
1035 bad_forward=no
1036 AC_MSG_CHECKING(for bad static forward)
1037 AC_TRY_RUN([
1038 struct s { int a; int b; };
1039 static struct s foo;
1040 int foobar() {
1041  static int random;
1042  random = (int) &foo;
1043  return random;
1045 static struct s foo = { 1, 2 };
1046 main() {
1047  exit(!((int)&foo == foobar()));
1049 ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
1050 AC_MSG_RESULT($bad_forward)
1052 va_list_is_array=no
1053 AC_MSG_CHECKING(whether va_list is an array)
1054 AC_TRY_COMPILE([
1055 #ifdef HAVE_STDARG_PROTOTYPES
1056 #include <stdarg.h>
1057 #else
1058 #include <varargs.h>
1059 #endif
1060 ], [va_list list1, list2; list1 = list2;], , 
1061 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1062 AC_MSG_RESULT($va_list_is_array)
1064 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1065 AC_CHECK_FUNC(gethostbyname_r, [
1066   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1067   AC_MSG_CHECKING([gethostbyname_r with 6 args])
1068   OLD_CFLAGS=$CFLAGS
1069   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1070   AC_TRY_COMPILE([
1071 #   include <netdb.h>
1072   ], [
1073     char *name;
1074     struct hostent *he, *res;
1075     char buffer[2048];
1076     int buflen = 2048;
1077     int h_errnop;
1079     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1080   ], [
1081     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1082     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1083     AC_MSG_RESULT(yes)
1084   ], [
1085     AC_MSG_RESULT(no)
1086     AC_MSG_CHECKING([gethostbyname_r with 5 args])
1087     AC_TRY_COMPILE([
1088 #     include <netdb.h>
1089     ], [
1090       char *name;
1091       struct hostent *he;
1092       char buffer[2048];
1093       int buflen = 2048;
1094       int h_errnop;
1096       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1097     ], [
1098       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1099       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1100       AC_MSG_RESULT(yes)
1101     ], [
1102       AC_MSG_RESULT(no)
1103       AC_MSG_CHECKING([gethostbyname_r with 3 args])
1104       AC_TRY_COMPILE([
1105 #       include <netdb.h>
1106       ], [
1107         char *name;
1108         struct hostent *he;
1109         struct hostent_data data;
1111         (void) gethostbyname_r(name, he, &data);
1112       ], [
1113         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1114         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1115         AC_MSG_RESULT(yes)
1116       ], [
1117         AC_MSG_RESULT(no)
1118       ])
1119     ])
1120   ])
1121   CFLAGS=$OLD_CFLAGS
1122 ], [
1123   AC_CHECK_FUNCS(gethostbyname)
1125 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1126 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1127 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
1128 AC_SUBST(HAVE_GETHOSTBYNAME_R)
1129 AC_SUBST(HAVE_GETHOSTBYNAME)
1131 # checks for system services
1132 # (none yet)
1134 # Linux requires this for correct f.p. operations
1135 AC_CHECK_FUNC(__fpu_control,
1136   [],
1137   [AC_CHECK_LIB(ieee, __fpu_control)
1140 # Check for --with-fpectl
1141 AC_MSG_CHECKING(for --with-fpectl)
1142 AC_ARG_WITH(fpectl,
1143 [  --with-fpectl                   enable SIGFPE catching], [
1144 if test "$withval" != no
1145 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1146 else AC_MSG_RESULT(no)
1147 fi],
1148 [AC_MSG_RESULT(no)])
1150 # check for --with-libm=...
1151 AC_SUBST(LIBM)
1152 case $ac_sys_system in
1153 next) ;;
1154 BeOS) ;;
1155 *) LIBM=-lm
1156 esac
1157 AC_MSG_CHECKING(for --with-libm=STRING)
1158 AC_ARG_WITH(libm, [  --with-libm=STRING              math library], [
1159 if test "$withval" = no
1160 then LIBM=
1161      AC_MSG_RESULT(force LIBM empty)
1162 elif test "$withval" != yes
1163 then LIBM=$withval
1164      AC_MSG_RESULT(set LIBM=\"$withval\")
1165 else AC_ERROR(proper usage is --with-libm=STRING)
1166 fi],
1167 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
1169 # check for --with-libc=...
1170 AC_SUBST(LIBC)
1171 AC_MSG_CHECKING(for --with-libc=STRING)
1172 AC_ARG_WITH(libc, [  --with-libc=STRING              C library], [
1173 if test "$withval" = no
1174 then LIBC=
1175      AC_MSG_RESULT(force LIBC empty)
1176 elif test "$withval" != yes
1177 then LIBC=$withval
1178      AC_MSG_RESULT(set LIBC=\"$withval\")
1179 else AC_ERROR(proper usage is --with-libc=STRING)
1180 fi],
1181 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
1183 # check for hypot() in math library
1184 LIBS_SAVE=$LIBS
1185 LIBS="$LIBS $LIBM"
1186 AC_REPLACE_FUNCS(hypot)
1187 LIBS=$LIBS_SAVE
1189 # check for getopt
1190 AC_MSG_CHECKING(for genuine getopt)
1191 AC_CACHE_VAL(ac_cv_func_getopt,
1192 [AC_TRY_RUN([#include <stdio.h>
1193 extern int optind, opterr, getopt();
1194 extern char* optarg;
1195 int main() {
1196         char* av[] = { "testprog", "parameter", "-fFlag", NULL };
1197         opterr = 0;
1198         if (getopt(3, av, "f:") == 'f') { exit(1); }
1199         exit(0);
1200 }], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
1201 AC_MSG_RESULT($ac_cv_func_getopt)
1202 test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
1203 AC_SUBST(LIBOBJS)dnl
1205 # check whether malloc(0) returns NULL or not
1206 AC_MSG_CHECKING(what malloc(0) returns)
1207 AC_CACHE_VAL(ac_cv_malloc_zero,
1208 [AC_TRY_RUN([#include <stdio.h>
1209 #ifdef HAVE_STDLIB
1210 #include <stdlib.h>
1211 #else
1212 char *malloc(), *realloc();
1213 int *free();
1214 #endif
1215 main() {
1216         char *p;
1217         p = malloc(0);
1218         if (p == NULL) exit(1);
1219         p = realloc(p, 0);
1220         if (p == NULL) exit(1);
1221         free(p);
1222         exit(0);
1223 }], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1224 AC_MSG_RESULT($ac_cv_malloc_zero)
1225 if test "$ac_cv_malloc_zero" = null
1226 then
1227   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1230 # check for wchar.h
1231 AC_CHECK_HEADER(wchar.h,
1232 AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1233 wchar_h="no"
1236 # check for usable wchar_t
1237 usable_wchar_t="unkown"
1238 AC_MSG_CHECKING(for usable wchar_t)
1239 AC_TRY_RUN([
1240 #include "wchar.h"
1241 #include "wctype.h"
1242 main() {
1243  wchar_t s;
1244  if (sizeof(s) == 2)
1245   exit(0);
1246  else
1247   exit(1);
1249 ], 
1250 AC_DEFINE(HAVE_USABLE_WCHAR_T) usable_wchar_t="yes",
1251 usable_wchar_t="no")
1252 AC_MSG_RESULT($usable_wchar_t)
1254 # check for endianness
1255 AC_C_BIGENDIAN
1257 # Check whether right shifting a negative integer extends the sign bit
1258 # or fills with zeros (like the Cray J90, according to Tim Peters).
1259 AC_MSG_CHECKING(whether right shift extends the sign bit)
1260 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
1261 AC_TRY_RUN([
1262 int main()
1264         exit(((-1)>>3 == -1) ? 0 : 1);
1266 ], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1267 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1268 if test "$ac_cv_rshift_extends_sign" = no
1269 then
1270   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1274 # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1275 # Add sys/socket.h to confdefs.h
1276 cat >> confdefs.h <<\EOF
1277 #ifdef HAVE_SYS_SOCKET_H
1278 #include <sys/socket.h>
1279 #endif
1281 AC_CHECK_TYPE(socklen_t, int)
1283 # generate output files
1284 AC_OUTPUT(Makefile \
1285  Objects/Makefile \
1286  Parser/Makefile \
1287  Grammar/Makefile \
1288  Python/Makefile \
1289  Modules/Makefile.pre \
1290  Modules/Setup.config)