Last set of CW Pro 5 projects (probably)
[python/dscho.git] / configure.in
blobbb341c6e5ed8fc5fd34b61ee66fe2ffac06a9bb0
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
197 case $MACHDEP in
198 bsdos*)
199     case $CC in
200     gcc) CC="$CC -D_HAVE_BSDI";;
201     esac;;
202 esac
204 case $ac_sys_system in
205 hp*|HP*)
206     case $CC in
207     cc|*/cc) CC="$CC -Aa -D_HPUX_SOURCE";;
208     esac;;
209 BeOS*)
210         case $CC in
211         cc) CC=cc;;
212         esac;;
213 Monterey*)
214     case $CC in
215     cc) CC="$CC -Wl,-Bexport";;
216     esac;;
217 esac
219 # LDLIBRARY is the name of the library to link against (as opposed to the
220 # name of the library into which to insert object files). On systems
221 # without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
222 # the Makefiles). 
223 AC_SUBST(MAKE_LDLIBRARY)
224 AC_SUBST(LDLIBRARY)
225 LDLIBRARY=''
227 # LINKCC is the command that links the python executable -- default is $(CC).
228 # This is altered for AIX and BeOS in order to build the export list before 
229 # linking.
230 AC_SUBST(LINKCC)
231 AC_MSG_CHECKING(LINKCC)
232 if test -z "$LINKCC" -a ! -z "$CXX"
233 then
234     LINKCC="$CXX"
236 if test -z "$LINKCC"
237 then
238         case $ac_sys_system in
239         AIX*)
240            LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
241         BeOS*)
242            LINKCC="\$(srcdir)/../BeOS/linkcc \$(LIBRARY) \$(PURIFY) \$(CC) \$(OPT)"
243            LDLIBRARY='libpython$(VERSION).so';;
244         dgux*)
245            LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
246         Monterey64*)
247            LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
248         *) LINKCC="\$(PURIFY) \$(CC)";;
249         esac
251 AC_MSG_RESULT($LINKCC)
253 AC_MSG_CHECKING(LDLIBRARY)
255 # NeXT framework builds require that the 'ar' library be converted into
256 # a bundle using libtool.
257 if test "$with_next_framework"
258 then
259   LDLIBRARY='libpython$(VERSION).dylib'
260 fi  
262 # DG/UX requires some fancy ld contortions to produce a .so from an .a
263 if test "$MACHDEP" = "dguxR4"
264 then
265   LDLIBRARY='libpython$(VERSION).so'
266   OPT="$OPT -pic"
268 AC_MSG_RESULT($LDLIBRARY)
270 # If LDLIBRARY is different from LIBRARY, emit a rule to build it.
271 if test -z "$LDLIBRARY"
272 then
273   LDLIBRARY='libpython$(VERSION).a'
274   MAKE_LDLIBRARY="true"
275 else
276   MAKE_LDLIBRARY='$(MAKE) $(LDLIBRARY)'
279 AC_PROG_RANLIB
280 AC_SUBST(AR)
281 AC_CHECK_PROGS(AR, ar aal, ar)
282 AC_SUBST(INSTALL)
283 AC_SUBST(INSTALL_PROGRAM)
284 AC_SUBST(INSTALL_DATA)
285 # Install just never works :-(
286 if test -z "$INSTALL"
287 then
288         INSTALL=cp
289         INSTALL_PROGRAM=cp
290         INSTALL_DATA=cp
291 else
292         INSTALL_PROGRAM="$INSTALL"
293         INSTALL_DATA="$INSTALL -m 644"
296 # Not every filesystem supports hard links
297 AC_SUBST(LN)
298 if test -z "$LN" ; then
299         case $ac_sys_system in
300                 BeOS*) LN="ln -s";;
301                 *) LN=ln;;
302         esac
305 # Optimizer/debugger flags passed between Makefiles
306 AC_SUBST(OPT)
307 if test -z "$OPT"
308 then
309         case $GCC in
310         yes)
311                 case $ac_cv_prog_cc_g in
312                 yes)    OPT="-g -O2";;
313                 *)      OPT="-O2";;
314                 esac
315                 ;;
316         *)      OPT="-O";;
317         esac
320 # The current (beta) Monterey compiler dies with optimizations
321 case $ac_sys_system in
322 Monterey*) OPT="";;
323 esac
325 if test "$ac_arch_flags"
326 then
327         OPT="$OPT $ac_arch_flags"
329 # checks for UNIX variants that set C preprocessor variables
330 AC_AIX
331 AC_MINIX
333 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
334 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
335 [ac_save_cc="$CC"
336 CC="$CC -OPT:Olimit=0"
337 AC_TRY_RUN([int main() { return 0; }],
338   ac_cv_opt_olimit_ok=yes,
339   ac_cv_opt_olimit_ok=no)
340 CC="$ac_save_cc"])
341 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
342 if test $ac_cv_opt_olimit_ok = yes; then
343   OPT="$OPT -OPT:Olimit=0"
344 else
345   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
346   AC_CACHE_VAL(ac_cv_olimit_ok,
347   [ac_save_cc="$CC"
348   CC="$CC -Olimit 1500"
349   AC_TRY_RUN([int main() { return 0; }],
350     ac_cv_olimit_ok=yes,
351     ac_cv_olimit_ok=no)
352   CC="$ac_save_cc"])
353   AC_MSG_RESULT($ac_cv_olimit_ok)
354   if test $ac_cv_olimit_ok = yes; then
355     OPT="$OPT -Olimit 1500"
356   fi
359 dnl # check for ANSI or K&R ("traditional") preprocessor
360 dnl AC_MSG_CHECKING(for C preprocessor type)
361 dnl AC_TRY_COMPILE([
362 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
363 dnl int foo;
364 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
365 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
366 dnl AC_MSG_RESULT($cpp_type)
368 # checks for header files
369 AC_HEADER_STDC
370 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
371 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
372 sys/audioio.h sys/file.h sys/lock.h \
373 sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \
374 sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h)
375 AC_HEADER_DIRENT
377 # checks for typedefs
378 was_it_defined=no
379 AC_MSG_CHECKING(for clock_t in time.h)
380 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
381 AC_MSG_RESULT($was_it_defined)
383 # Add some code to confdefs.h so that the test for off_t works on SCO
384 cat >> confdefs.h <<\EOF
385 #if defined(SCO_DS)
386 #undef _OFF_T
387 #endif
390 # Type availability checks
391 AC_TYPE_MODE_T
392 AC_TYPE_OFF_T
393 AC_TYPE_PID_T
394 AC_TYPE_SIGNAL
395 AC_TYPE_SIZE_T
396 AC_TYPE_UID_T
398 # Sizes of various common basic types
399 AC_CHECK_SIZEOF(int)
400 AC_CHECK_SIZEOF(long)
401 AC_CHECK_SIZEOF(void *)
402 AC_CHECK_SIZEOF(char)
403 AC_CHECK_SIZEOF(short)
404 AC_CHECK_SIZEOF(float)
405 AC_CHECK_SIZEOF(double)
406 AC_CHECK_SIZEOF(fpos_t)
408 AC_MSG_CHECKING(for long long support)
409 have_long_long=no
410 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
411 AC_MSG_RESULT($have_long_long)
412 if test "$have_long_long" = yes ; then
413 AC_CHECK_SIZEOF(long long)
416 AC_MSG_CHECKING(for uintptr_t support)
417 have_uintptr_t=no
418 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
419 AC_MSG_RESULT($have_uintptr_t)
420 if test "$have_uintptr_t" = yes ; then
421 AC_CHECK_SIZEOF(uintptr_t)
424 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
425 AC_MSG_CHECKING(size of off_t)
426 AC_CACHE_VAL(ac_cv_sizeof_off_t,
427 [AC_TRY_RUN([#include <stdio.h>
428 #include <sys/types.h>
429 main()
431   FILE *f=fopen("conftestval", "w");
432   if (!f) exit(1);
433   fprintf(f, "%d\n", sizeof(off_t));
434   exit(0);
435 }], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
437 AC_MSG_RESULT($ac_cv_sizeof_off_t)
438 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
440 AC_MSG_CHECKING(whether to enable large file support)
441 if test "$have_long_long" = yes -a \
442         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
443         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
444   AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
445   AC_MSG_RESULT(yes)
446 else
447   AC_MSG_RESULT(no)
450 # AC_CHECK_SIZEOF() doesn't include <time.h>.
451 AC_MSG_CHECKING(size of time_t)
452 AC_CACHE_VAL(ac_cv_sizeof_time_t,
453 [AC_TRY_RUN([#include <stdio.h>
454 #include <time.h>
455 main()
457   FILE *f=fopen("conftestval", "w");
458   if (!f) exit(1);
459   fprintf(f, "%d\n", sizeof(time_t));
460   exit(0);
461 }], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
463 AC_MSG_RESULT($ac_cv_sizeof_time_t)
464 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
467 # if have pthread_t then define SIZEOF_PTHREAD_T
468 AC_MSG_CHECKING(for pthread_t)
469 have_pthread_t=no
470 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = (pthread_t)0;], have_pthread_t=yes)
471 AC_MSG_RESULT($have_pthread_t)
472 if test "$have_pthread_t" = yes ; then
473   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
474   AC_MSG_CHECKING(size of pthread_t)
475   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
476   [AC_TRY_RUN([#include <stdio.h>
477   #include <pthread.h>
478   main()
479   {
480     FILE *f=fopen("conftestval", "w");
481     if (!f) exit(1);
482     fprintf(f, "%d\n", sizeof(pthread_t));
483     exit(0);
484   }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
485   ])
486   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
487   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
491 # Minor variations in building a framework between NextStep versions 4 and 5
492 AC_SUBST(LIBTOOL_CRUFT)
493 case $ac_sys_system/$ac_sys_release in
494   next/4*)
495     ns_undef_sym='__environ'
496     LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
497   next/5*)
498     ns_undef_sym='_environ'
499     LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
500 esac
502 AC_MSG_CHECKING(for --with-next-framework)
503 if test "$with_next_framework"
504 then
505         OPT="$OPT -fno-common"
506         # -U __environ is needed since bundles don't have access
507         # to crt0 when built but will always be linked against it
508         LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
509         AC_DEFINE(WITH_NEXT_FRAMEWORK)
510         AC_MSG_RESULT(yes)
511 else
512         AC_MSG_RESULT(no)
515 AC_MSG_CHECKING(for --with-dyld)
516 if test "$with_next_framework" -o "$with_dyld"
517 then
518         if test "$with_dyld"
519         then
520                 AC_MSG_RESULT(yes)
521         else
522                 AC_MSG_RESULT(required for framework build)
523         fi
524         AC_DEFINE(WITH_DYLD)
525         ns_dyld='set'
526 else
527         AC_MSG_RESULT(no)
530 # Set info about shared libraries.
531 AC_SUBST(SO)
532 AC_SUBST(LDSHARED)
533 AC_SUBST(CCSHARED)
534 AC_SUBST(LINKFORSHARED)
535 # SO is the extension of shared libraries `(including the dot!)
536 # -- usually .so, .sl on HP-UX
537 AC_MSG_CHECKING(SO)
538 if test -z "$SO"
539 then
540         case $ac_sys_system in
541         hp*|HP*)   SO=.sl;;
542         *)         SO=.so;;
543         esac
545 AC_MSG_RESULT($SO)
546 # LDSHARED is the ld *command* used to create shared library
547 # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
548 # (Shared libraries in this instance are shared modules to be loaded into
549 # Python, as opposed to building Python itself as a shared library.)
550 AC_MSG_CHECKING(LDSHARED)
551 if test -z "$LDSHARED"
552 then
553         case $ac_sys_system/$ac_sys_release in
554         AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
555         BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
556         IRIX/5*) LDSHARED="ld -shared";;
557         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
558         SunOS/4*) LDSHARED="ld";;
559         SunOS/5*) 
560                 if test "$GCC" = "yes"
561                 then LDSHARED='$(CC) -G'
562                 else LDSHARED="ld -G";
563                 fi ;;
564         hp*|HP*) LDSHARED="ld -b";;
565         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
566         DYNIX/ptx*) LDSHARED="ld -G";;
567         next/*) 
568                 if test "$ns_dyld"
569                 then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
570                 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
571                 fi
572                 if test "$with_next_framework" ; then
573                     LDSHARED="$LDSHARED \$(LDLIBRARY)"
574                 fi ;;
575         Linux*) LDSHARED="gcc -shared";;
576         dgux*) LDSHARED="ld -G";;
577         BSD/OS*/4*) LDSHARED="gcc -shared";;
578         FreeBSD*/[[34]]*) LDSHARED="gcc -shared";;
579         FreeBSD*|OpenBSD*) LDSHARED="ld -Bshareable";;
580         NetBSD*)
581                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
582                 then
583                         LDSHARED="cc -shared"
584                 else
585                         LDSHARED="ld -Bshareable"
586                 fi;;
587         SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
588         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
589         *)      LDSHARED="ld";;
590         esac
592 AC_MSG_RESULT($LDSHARED)
593 # CCSHARED are the C *flags* used to create objects to go into a shared
594 # library (module) -- this is only needed for a few systems
595 AC_MSG_CHECKING(CCSHARED)
596 if test -z "$CCSHARED"
597 then
598         case $ac_sys_system/$ac_sys_release in
599         hp*|HP*) if test "$GCC" = yes;
600                  then CCSHARED="-fpic";
601                  else CCSHARED="+z";
602                  fi;;
603         Linux*) CCSHARED="-fpic";;
604         BSD/OS*/4*) CCSHARED="-fpic";;
605         FreeBSD*|OpenBSD*) CCSHARED="-fpic";;
606         NetBSD*) CCSHARED="-fPIC";;
607         SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
608         Monterey*) CCSHARED="-G";;
609         IRIX*/6*)  case $CC in
610                    *gcc*) CCSHARED="-shared";;
611                    *) CCSHARED="";;
612                    esac;;
613         esac
615 AC_MSG_RESULT($CCSHARED)
616 # LINKFORSHARED are the flags passed to the $(CC) command that links
617 # the python executable -- this is only needed for a few systems
618 AC_MSG_CHECKING(LINKFORSHARED)
619 if test -z "$LINKFORSHARED"
620 then
621         case $ac_sys_system/$ac_sys_release in
622         AIX*)   LINKFORSHARED='-Wl,-bE:python.exp -lld';;
623         hp*|HP*)
624             LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
625         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
626         FreeBSD/[[34]]*) LINKFORSHARED="-Xlinker -export-dynamic";;
627         Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
628         # -u libsys_s pulls in all symbols in libsys
629         next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
630         # -u __dummy makes the linker aware of the objc runtime
631         # in System.framework; otherwise, __objcInit (referenced in
632         # crt1.o) gets erroneously defined as common, which breaks dynamic
633         # loading of any modules which reference it in System.framework
634         next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
635         SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
636         NetBSD*) 
637                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
638                 then
639                         LINKFORSHARED="-Wl,--export-dynamic"
640                 fi;;
641         SunOS/5*) case $CC in
642                   *gcc*)
643                     if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
644                     then
645                         LINKFORSHARED="-Xlinker --export-dynamic"
646                     fi;;
647                   esac;;
648         esac
650 AC_MSG_RESULT($LINKFORSHARED)
652 # checks for libraries
653 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
654 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
656 # checks for system dependent C++ extensions support
657 case "$ac_sys_system" in
658         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
659                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
660                             [loadAndInit("", 0, "")],
661                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
662                              AC_MSG_RESULT(yes)],
663                             [AC_MSG_RESULT(no)]);;
664         *) ;;
665 esac
667 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
668 # However on SGI IRIX, these exist but are broken.
669 # BeOS' sockets are stashed in libnet.
670 case "$ac_sys_system" in
671 IRIX*) ;;
673 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
674 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
676 esac
677 case "$ac_sys_system" in
678 BeOS*)
679 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
681 esac
683 AC_MSG_CHECKING(for --with-libs)
684 AC_ARG_WITH(libs,
685 [  --with-libs='lib1 ...'          link against additional libs], [
686 AC_MSG_RESULT($withval)
687 LIBS="$withval $LIBS"
688 ], AC_MSG_RESULT(no))
690 AC_MSG_CHECKING(for --with(out)-readline)
691 AC_ARG_WITH(readline,
692 [  --with(out)-readline            obsolete, edit Modules/Setup instead],
693 [AC_MSG_RESULT($withval)
694 AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)],
695 [AC_MSG_RESULT(not specified.)])
697 AC_SUBST(USE_THREAD_MODULE)
698 USE_THREAD_MODULE=""
700 AC_MSG_CHECKING(for --with-dec-threads)
701 AC_SUBST(LDLAST)
702 AC_ARG_WITH(dec-threads,
703 [  --with-dec-threads              use DEC Alpha/OSF1 thread-safe libraries], [
704 AC_MSG_RESULT($withval)
705 LDLAST=-threads
706 if test "${with_thread+set}" != set; then
707    with_thread="$withval";
708 fi],
709 AC_MSG_RESULT(no))
711 AC_MSG_CHECKING(for --with-threads)
712 AC_ARG_WITH(threads,
713 [  --with(out)-threads[=DIRECTORY] disable/enable thread support])
715 # --with-thread is deprecated, but check for it anyway
716 AC_ARG_WITH(thread,
717 [  --with(out)-thread[=DIRECTORY]  deprecated; use --with(out)-threads],[
718 with_threads=$with_thread])
720 if test -z "$with_threads"
721 then with_threads="yes"
723 AC_MSG_RESULT($with_threads)
725 if test "$with_threads" = "no"
726 then
727     USE_THREAD_MODULE="#"
728 else
729     if test -d "$with_threads"
730     then LDFLAGS="$LDFLAGS -L$with_threads"
731     fi
732     if test -d "$withval"
733     then LDFLAGS="$LDFLAGS -L$withval"
734     fi
735     AC_DEFINE(_REENTRANT)
736     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
737     AC_DEFINE(C_THREADS)
738     LIBOBJS="$LIBOBJS thread.o"],[
739     AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
740     AC_DEFINE(_POSIX_THREADS)
741     LIBS="-lpthread $LIBS"
742     LIBOBJS="$LIBOBJS thread.o"],[
743     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
744     AC_DEFINE(_POSIX_THREADS)
745     LIBOBJS="$LIBOBJS thread.o"],[
746     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
747     AC_DEFINE(BEOS_THREADS)
748     LIBOBJS="$LIBOBJS thread.o"],[
749     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
750     AC_DEFINE(_POSIX_THREADS)
751     LIBS="$LIBS -lpthreads"
752     LIBOBJS="$LIBOBJS thread.o"], [
753     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
754     AC_DEFINE(_POSIX_THREADS)
755     LIBS="$LIBS -lc_r"
756     LIBOBJS="$LIBOBJS thread.o"], [
757     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
758     AC_DEFINE(_POSIX_THREADS)
759     LIBS="$LIBS -lthread"
760     LIBOBJS="$LIBOBJS thread.o"], [
761     AC_CHECK_LIB(pth, pth_init, [AC_DEFINE(WITH_THREAD)
762     AC_DEFINE(_GNU_PTH)
763     LIBS="-lpth $LIBS"
764     LIBOBJS="$LIBOBJS thread.o"],[
765     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
766     AC_DEFINE(_POSIX_THREADS)
767     LIBS="$LIBS -lcma"
768     LIBOBJS="$LIBOBJS thread.o"])
769     ])])])])])])])])
771     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
772     LIBS="$LIBS -lmpc"
773     LIBOBJS="$LIBOBJS thread.o"])
774     AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
775     LIBS="$LIBS -lthread"
776     LIBOBJS="$LIBOBJS thread.o"])
779 # Check for GC support
780 AC_SUBST(USE_GC_MODULE)
781 USE_GC_MODULE=""
782 AC_MSG_CHECKING(for --with-cycle-gc)
783 AC_ARG_WITH(cycle-gc,
784 [  --with(out)-cycle-gc            disable/enable garbage collection])
786 if test -z "$with_cycle_gc"
787 then with_cycle_gc="yes"
789 if test "$with_cycle_gc" = "no"
790 then
791     USE_GC_MODULE="#"
792 else
793     AC_DEFINE(WITH_CYCLE_GC)
795 AC_MSG_RESULT($with_cycle_gc)
797 # Check for --with-wctype-functions
798 AC_MSG_CHECKING(for --with-wctype-functions)
799 AC_ARG_WITH(wctype-functions, 
800 [  --with-wctype-functions         use wctype.h functions], [
801 if test "$withval" != no
802 then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
803 else AC_MSG_RESULT(no)
804 fi],
805 [AC_MSG_RESULT(no)])
807 # -I${DLINCLDIR} is added to the compile rule for importdl.o
808 AC_SUBST(DLINCLDIR)
809 DLINCLDIR=/
811 AC_MSG_CHECKING(for --with-sgi-dl)
812 AC_ARG_WITH(sgi-dl,
813 [  --with-sgi-dl=DIRECTORY         IRIX 4 dynamic linking], [
814 AC_MSG_RESULT($withval)
815 AC_DEFINE(WITH_SGI_DL)
816 DYNLOADFILE="dynload_dl.o"
817 dldir=$withval
818 if test -d "$dldir"
819 then LDFLAGS="$LDFLAGS -L$dldir"
820 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
822 DLINCLDIR=${dldir}
823 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
825 AC_MSG_CHECKING(for --with-dl-dld)
826 AC_ARG_WITH(dl-dld, [  --with-dl-dld=DL_DIR,DLD_DIR    GNU dynamic linking], [
827 AC_MSG_RESULT($withval)
828 AC_DEFINE(WITH_DL_DLD)
829 DYNLOADFILE="dynload_dl.o"
830 dldir=`echo "$withval" | sed 's/,.*//'`
831 dlddir=`echo "$withval" | sed 's/.*,//'`
832 if test -d "$dldir" -a -d "$dlddir"
833 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
834 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
836 DLINCLDIR=${dldir}
837 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
839 # the dlopen() function means we might want to use dynload_shlib.o. some
840 # platforms, such as AIX, have dlopen(), but don't want to use it.
841 AC_CHECK_FUNCS(dlopen)
843 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
844 # loading of modules.
845 AC_SUBST(DYNLOADFILE)
846 AC_MSG_CHECKING(DYNLOADFILE)
847 if test -z "$DYNLOADFILE"
848 then
849         case $ac_sys_system/$ac_sys_release in
850         AIX*) DYNLOADFILE="dynload_aix.o";;
851         BeOS*) DYNLOADFILE="dynload_beos.o";;
852         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
853         next/*) DYNLOADFILE="dynload_next.o";;
854         *)
855         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
856         # out any dynamic loading
857         if test "$ac_cv_func_dlopen" = yes
858         then DYNLOADFILE="dynload_shlib.o"
859         else DYNLOADFILE="dynload_stub.o"
860         fi
861         ;;
862         esac
864 AC_MSG_RESULT($DYNLOADFILE)
865 if test "$DYNLOADFILE" != "dynload_stub.o"
866 then
867         AC_DEFINE(HAVE_DYNAMIC_LOADING)
870 # checks for library functions
871 AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
872  flock fork fsync fdatasync fpathconf ftime ftruncate \
873  getgroups getlogin getpeername getpid getpwent getwd \
874  kill link lstat mkfifo mktime mremap \
875  nice pathconf pause plock poll pthread_init \
876  putenv readlink \
877  select setegid seteuid setgid \
878  setlocale setregid setreuid setsid setpgid setuid setvbuf \
879  sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
880  tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
881  truncate uname waitpid _getpty)
883 # check for openpty and forkpty
885 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
886 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
888 # check for long file support functions
889 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
891 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
892 AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
893 AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
894 AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
896 # checks for structures
897 AC_HEADER_TIME
898 AC_STRUCT_TM
899 AC_STRUCT_TIMEZONE
901 AC_MSG_CHECKING(for time.h that defines altzone)
902 AC_CACHE_VAL(ac_cv_header_time_altzone,
903 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
904   ac_cv_header_time_altzone=yes,
905   ac_cv_header_time_altzone=no)])
906 AC_MSG_RESULT($ac_cv_header_time_altzone)
907 if test $ac_cv_header_time_altzone = yes; then
908   AC_DEFINE(HAVE_ALTZONE)
911 was_it_defined=no
912 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
913 AC_TRY_COMPILE([
914 #include <sys/types.h>
915 #include <sys/select.h>
916 #include <sys/time.h>
917 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
918 AC_MSG_RESULT($was_it_defined)
920 # checks for compiler characteristics
922 AC_C_CHAR_UNSIGNED
923 AC_C_CONST
924 AC_C_INLINE
926 works=no
927 AC_MSG_CHECKING(for working volatile)
928 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
929 AC_MSG_RESULT($works)
931 works=no
932 AC_MSG_CHECKING(for working signed char)
933 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
934 AC_MSG_RESULT($works)
936 have_prototypes=no
937 AC_MSG_CHECKING(for prototypes)
938 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
939 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
940 AC_MSG_RESULT($have_prototypes)
942 works=no
943 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
944 AC_TRY_COMPILE([
945 #include <stdarg.h>
946 int foo(int x, ...) {
947         va_list va;
948         va_start(va, x);
949         va_arg(va, int);
950         va_arg(va, char *);
951         va_arg(va, double);
952         return 0;
954 ], [return foo(10, "", 3.14);],
955 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
956 AC_MSG_RESULT($works)
958 if test "$have_prototypes" = yes; then
959 bad_prototypes=no
960 AC_MSG_CHECKING(for bad exec* prototypes)
961 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
962         AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
963 AC_MSG_RESULT($bad_prototypes)
966 bad_forward=no
967 AC_MSG_CHECKING(for bad static forward)
968 AC_TRY_RUN([
969 struct s { int a; int b; };
970 static struct s foo;
971 int foobar() {
972  static int random;
973  random = (int) &foo;
974  return random;
976 static struct s foo = { 1, 2 };
977 main() {
978  exit(!((int)&foo == foobar()));
980 ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
981 AC_MSG_RESULT($bad_forward)
983 va_list_is_array=no
984 AC_MSG_CHECKING(whether va_list is an array)
985 AC_TRY_COMPILE([
986 #ifdef HAVE_STDARG_PROTOTYPES
987 #include <stdarg.h>
988 #else
989 #include <varargs.h>
990 #endif
991 ], [va_list list1, list2; list1 = list2;], , 
992 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
993 AC_MSG_RESULT($va_list_is_array)
995 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
996 AC_CHECK_FUNC(gethostbyname_r, [
997   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
998   AC_MSG_CHECKING([gethostbyname_r with 6 args])
999   OLD_CFLAGS=$CFLAGS
1000   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1001   AC_TRY_COMPILE([
1002 #   include <netdb.h>
1003   ], [
1004     char *name;
1005     struct hostent *he, *res;
1006     char buffer[2048];
1007     int buflen = 2048;
1008     int h_errnop;
1010     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1011   ], [
1012     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1013     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1014     AC_MSG_RESULT(yes)
1015   ], [
1016     AC_MSG_RESULT(no)
1017     AC_MSG_CHECKING([gethostbyname_r with 5 args])
1018     AC_TRY_COMPILE([
1019 #     include <netdb.h>
1020     ], [
1021       char *name;
1022       struct hostent *he;
1023       char buffer[2048];
1024       int buflen = 2048;
1025       int h_errnop;
1027       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1028     ], [
1029       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1030       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1031       AC_MSG_RESULT(yes)
1032     ], [
1033       AC_MSG_RESULT(no)
1034       AC_MSG_CHECKING([gethostbyname_r with 3 args])
1035       AC_TRY_COMPILE([
1036 #       include <netdb.h>
1037       ], [
1038         char *name;
1039         struct hostent *he;
1040         struct hostent_data data;
1042         (void) gethostbyname_r(name, he, &data);
1043       ], [
1044         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1045         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1046         AC_MSG_RESULT(yes)
1047       ], [
1048         AC_MSG_RESULT(no)
1049       ])
1050     ])
1051   ])
1052   CFLAGS=$OLD_CFLAGS
1053 ], [
1054   AC_CHECK_FUNCS(gethostbyname)
1056 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1057 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1058 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
1059 AC_SUBST(HAVE_GETHOSTBYNAME_R)
1060 AC_SUBST(HAVE_GETHOSTBYNAME)
1062 # checks for system services
1063 # (none yet)
1065 # Linux requires this for correct f.p. operations
1066 AC_CHECK_FUNC(__fpu_control,
1067   [],
1068   [AC_CHECK_LIB(ieee, __fpu_control)
1071 # Check for --with-fpectl
1072 AC_MSG_CHECKING(for --with-fpectl)
1073 AC_ARG_WITH(fpectl,
1074 [  --with-fpectl                   enable SIGFPE catching], [
1075 if test "$withval" != no
1076 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1077 else AC_MSG_RESULT(no)
1078 fi],
1079 [AC_MSG_RESULT(no)])
1081 # check for --with-libm=...
1082 AC_SUBST(LIBM)
1083 case $ac_sys_system in
1084 next) ;;
1085 BeOS) ;;
1086 *) LIBM=-lm
1087 esac
1088 AC_MSG_CHECKING(for --with-libm=STRING)
1089 AC_ARG_WITH(libm, [  --with-libm=STRING              math library], [
1090 if test "$withval" = no
1091 then LIBM=
1092      AC_MSG_RESULT(force LIBM empty)
1093 elif test "$withval" != yes
1094 then LIBM=$withval
1095      AC_MSG_RESULT(set LIBM=\"$withval\")
1096 else AC_ERROR(proper usage is --with-libm=STRING)
1097 fi],
1098 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
1100 # check for --with-libc=...
1101 AC_SUBST(LIBC)
1102 AC_MSG_CHECKING(for --with-libc=STRING)
1103 AC_ARG_WITH(libc, [  --with-libc=STRING              C library], [
1104 if test "$withval" = no
1105 then LIBC=
1106      AC_MSG_RESULT(force LIBC empty)
1107 elif test "$withval" != yes
1108 then LIBC=$withval
1109      AC_MSG_RESULT(set LIBC=\"$withval\")
1110 else AC_ERROR(proper usage is --with-libc=STRING)
1111 fi],
1112 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
1114 # check for hypot() in math library
1115 LIBS_SAVE=$LIBS
1116 LIBS="$LIBS $LIBM"
1117 AC_REPLACE_FUNCS(hypot)
1118 LIBS=$LIBS_SAVE
1120 # check for getopt
1121 AC_MSG_CHECKING(for genuine getopt)
1122 AC_CACHE_VAL(ac_cv_func_getopt,
1123 [AC_TRY_RUN([#include <stdio.h>
1124 extern int optind, opterr, getopt();
1125 extern char* optarg;
1126 int main() {
1127         char* av[] = { "testprog", "parameter", "-fFlag", NULL };
1128         opterr = 0;
1129         if (getopt(3, av, "f:") == 'f') { exit(1); }
1130         exit(0);
1131 }], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
1132 AC_MSG_RESULT($ac_cv_func_getopt)
1133 test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
1134 AC_SUBST(LIBOBJS)dnl
1136 # check whether malloc(0) returns NULL or not
1137 AC_MSG_CHECKING(what malloc(0) returns)
1138 AC_CACHE_VAL(ac_cv_malloc_zero,
1139 [AC_TRY_RUN([#include <stdio.h>
1140 #ifdef HAVE_STDLIB
1141 #include <stdlib.h>
1142 #else
1143 char *malloc(), *realloc();
1144 int *free();
1145 #endif
1146 main() {
1147         char *p;
1148         p = malloc(0);
1149         if (p == NULL) exit(1);
1150         p = realloc(p, 0);
1151         if (p == NULL) exit(1);
1152         free(p);
1153         exit(0);
1154 }], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1155 AC_MSG_RESULT($ac_cv_malloc_zero)
1156 if test "$ac_cv_malloc_zero" = null
1157 then
1158   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1161 # check for wchar.h
1162 AC_CHECK_HEADER(wchar.h,
1163 AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1164 wchar_h="no"
1167 # check for usable wchar_t
1168 usable_wchar_t="unkown"
1169 AC_MSG_CHECKING(for usable wchar_t)
1170 AC_TRY_RUN([
1171 #include "wchar.h"
1172 #include "wctype.h"
1173 main() {
1174  wchar_t s;
1175  if (sizeof(s) == 2)
1176   exit(0);
1177  else
1178   exit(1);
1180 ], 
1181 AC_DEFINE(HAVE_USABLE_WCHAR_T) usable_wchar_t="yes",
1182 usable_wchar_t="no")
1183 AC_MSG_RESULT($usable_wchar_t)
1185 # check for endianness
1186 AC_C_BIGENDIAN
1188 # Check whether right shifting a negative integer extends the sign bit
1189 # or fills with zeros (like the Cray J90, according to Tim Peters).
1190 AC_MSG_CHECKING(whether right shift extends the sign bit)
1191 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
1192 AC_TRY_RUN([
1193 int main()
1195         exit(((-1)>>3 == -1) ? 0 : 1);
1197 ], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1198 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1199 if test "$ac_cv_rshift_extends_sign" = no
1200 then
1201   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1205 # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1206 # Add sys/socket.h to confdefs.h
1207 cat >> confdefs.h <<\EOF
1208 #ifdef HAVE_SYS_SOCKET_H
1209 #include <sys/socket.h>
1210 #endif
1212 AC_CHECK_TYPE(socklen_t, int)
1214 # generate output files
1215 AC_OUTPUT(Makefile \
1216  Objects/Makefile \
1217  Parser/Makefile \
1218  Grammar/Makefile \
1219  Python/Makefile \
1220  Modules/Makefile.pre \
1221  Modules/Setup.config)