Clarify portability and main program.
[python/dscho.git] / configure.in
blobf835b5653d48ce4552c072627476ab493baae44b
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=1.5
11 # NEXTSTEP stuff
12 if test -f /usr/lib/NextStep/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 | grep 'NeXT Mach.*:' | \
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
36 # Set name for machine-dependent library files
37 AC_SUBST(MACHDEP)
38 AC_MSG_CHECKING(MACHDEP)
39 if test -z "$MACHDEP"
40 then
41         ac_sys_system=`uname -s`
42         if test "$ac_sys_system" = "AIX" ; then
43                 ac_sys_release=`uname -v`
44         else
45                 ac_sys_release=`uname -r`
46         fi
47         ac_md_system=`echo $ac_sys_system |
48                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
49         ac_md_release=`echo $ac_sys_release |
50                            tr -d '[/ ]' | sed 's/\..*//'`
51         MACHDEP="$ac_md_system$ac_md_release"
53         case $MACHDEP in
54         '')     MACHDEP="unknown";;
55         esac
59 # SGI compilers allow the specification of the both the ABI and the
60 # ISA on the command line.  Depending on the values of these switches,
61 # different and often incompatable code will be generated.
63 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
64 # thus supply support for various ABI/ISA combinations.  The MACHDEP
65 # variable is also adjusted.
67 AC_SUBST(SGI_ABI)
68 if test ! -z "$SGI_ABI"
69 then
70         CC="cc $SGI_ABI"
71         LDFLAGS="$SGI_ABI $LDFLAGS"
72         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
74 AC_MSG_RESULT($MACHDEP)
77 # CCC is the command that compiles C++ programs
79 # Not all make programs have this predefined.
81 AC_SUBST(SET_CCC)
82 AC_MSG_CHECKING(CCC)
83 if test -z "$CCC"
84 then
85         case $ac_sys_system in
86         IRIX*)  SET_CCC="CCC= CC ${SGI_ABI}";;
87         Linux*) SET_CCC="CCC= g++";;
88         *)      SET_CCC=""
89         esac
90 else
91         SET_CCC="CCC= ${CCC}"
93 AC_MSG_RESULT($SET_CCC)
96 # checks for alternative programs
97 AC_MSG_CHECKING(for --without-gcc)
98 AC_ARG_WITH(gcc, [--without-gcc             never use gcc], [
99         case $withval in
100         no)     CC=cc
101                 without_gcc=yes;;
102         yes)    CC=gcc
103                 without_gcc=no;;
104         *)      CC=$withval
105                 without_gcc=$withval;;
106         esac], [
107         case $ac_sys_system in
108         OSF1)   CC=cc
109                 without_gcc=;;
110         BeOS*)  CC=cc
111                 without_gcc=;;
112         *)      without_gcc=no;;
113         esac])
114 AC_MSG_RESULT($without_gcc)
116 # If the user switches compilers, we can't believe the cache
117 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
118 then
119   AC_ERROR(cached CC is different -- throw away $cache_file
120 (it is also a good idea to do 'make clean' before compiling))
123 AC_PROG_CC
125 case $MACHDEP in
126 bsdos*)
127     case $CC in
128     gcc) CC="$CC -D_HAVE_BSDI";;
129     esac;;
130 esac
132 case $ac_sys_system in
133 hp*|HP*)
134     case $CC in
135     cc|*/cc) CC="$CC -Aa -D_HPUX_SOURCE";;
136     esac;;
137 BeOS*)
138         case $CC in
139         cc) CC=cc;;
140         esac;;
141 esac
143 # LINKCC is the command that links the python executable -- default is $(CC).
144 # This is altered for AIX and BeOS in order to build the export list before 
145 # linking.
146 AC_SUBST(LINKCC)
147 AC_MSG_CHECKING(LINKCC)
148 if test -z "$LINKCC"
149 then
150         case $ac_sys_system in
151         AIX*)
152            LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
153         BeOS*)
154            LINKCC="\$(srcdir)/../BeOS/linkcc \$(LIBRARY) \$(PURIFY) \$(CC) -nodup \$(OPT)"
155            REALLIBRARY='libpython$(VERSION).so';;
156         dgux*)
157            LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
158         *) LINKCC="\$(PURIFY) \$(CC)";;
159         esac
161 AC_MSG_RESULT($LINKCC)
163 AC_PROG_RANLIB
164 AC_SUBST(AR)
165 AC_CHECK_PROGS(AR, ar aal, ar)
166 AC_SUBST(INSTALL)
167 AC_SUBST(INSTALL_PROGRAM)
168 AC_SUBST(INSTALL_DATA)
169 AC_SUBST(REALLIBRARY)
170 # Install just never works :-(
171 if test -z "$INSTALL"
172 then
173         INSTALL=cp
174         INSTALL_PROGRAM=cp
175         INSTALL_DATA=cp
176 else
177         INSTALL_PROGRAM="$INSTALL"
178         INSTALL_DATA="$INSTALL -m 644"
181 # Not every filesystem supports hard links
182 AC_SUBST(LN)
183 if test -z "$LN" ; then
184         case $ac_sys_system in
185                 BeOS*) LN="ln -s";;
186                 *) LN=ln;;
187         esac
190 # Optimizer/debugger flags passed between Makefiles
191 AC_SUBST(OPT)
192 if test -z "$OPT"
193 then
194         case $GCC in
195         yes)
196                 case $ac_cv_prog_cc_g in
197                 yes)    OPT="-g -O2";;
198                 *)      OPT="-O2";;
199                 esac
200                 ;;
201         *)      OPT="-O";;
202         esac
205 if test "$ac_arch_flags"
206 then
207         OPT="$OPT $ac_arch_flags"
209 # checks for UNIX variants that set C preprocessor variables
210 AC_AIX
211 AC_MINIX
213 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
214 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
215 [ac_save_cc="$CC"
216 CC="$CC -OPT:Olimit=0"
217 AC_TRY_RUN([int main() { return 0; }],
218   ac_cv_opt_olimit_ok=yes,
219   ac_cv_opt_olimit_ok=no)
220 CC="$ac_save_cc"])
221 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
222 if test $ac_cv_opt_olimit_ok = yes; then
223   OPT="$OPT -OPT:Olimit=0"
224 else
225   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
226   AC_CACHE_VAL(ac_cv_olimit_ok,
227   [ac_save_cc="$CC"
228   CC="$CC -Olimit 1500"
229   AC_TRY_RUN([int main() { return 0; }],
230     ac_cv_olimit_ok=yes,
231     ac_cv_olimit_ok=no)
232   CC="$ac_save_cc"])
233   AC_MSG_RESULT($ac_cv_olimit_ok)
234   if test $ac_cv_olimit_ok = yes; then
235     OPT="$OPT -Olimit 1500"
236   fi
239 AC_SUBST(DGUX_IS_BROKEN)
240 if test "$MACHDEP" != "dguxR4"
241 then
242   REALLIBRARY='libpython$(VERSION).a'
243   DGUX_IS_BROKEN="true"
244 else
245   REALLIBRARY='libpython$(VERSION).so'
246   OPT="$OPT -pic"
247   DGUX_IS_BROKEN="make $REALLIBRARY"
250 # check for ANSI or K&R ("traditional") preprocessor
251 AC_MSG_CHECKING(for C preprocessor type)
252 AC_TRY_COMPILE([
253 #define spam(name, doc) {#name, &name, #name "() -- " doc}
254 int foo;
255 struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
256 ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
257 AC_MSG_RESULT($cpp_type)
259 # checks for header files
260 AC_HEADER_STDC
261 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h pthread.h \
262 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
263 sys/audioio.h sys/file.h sys/lock.h \
264 sys/param.h sys/select.h sys/time.h sys/times.h \
265 sys/un.h sys/utsname.h sys/wait.h)
266 AC_HEADER_DIRENT
268 # checks for typedefs
269 was_it_defined=no
270 AC_MSG_CHECKING(for clock_t in time.h)
271 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
272 AC_MSG_RESULT($was_it_defined)
274 # Add some code to confdefs.h so that the test for off_t works on SCO
275 cat >> confdefs.h <<\EOF
276 #if defined(SCO_DS)
277 #undef _OFF_T
278 #endif
281 AC_TYPE_MODE_T
282 AC_TYPE_OFF_T
283 AC_TYPE_PID_T
284 AC_TYPE_SIGNAL
285 AC_TYPE_SIZE_T
286 AC_TYPE_UID_T
288 AC_CHECK_SIZEOF(int)
289 AC_CHECK_SIZEOF(long)
290 AC_CHECK_SIZEOF(void *)
292 AC_MSG_CHECKING(for long long support)
293 have_long_long=no
294 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
295 AC_MSG_RESULT($have_long_long)
296 if test $have_long_long = yes ; then
297 AC_CHECK_SIZEOF(long long)
300 # Set info about shared libraries.
301 AC_SUBST(SO)
302 AC_SUBST(LDSHARED)
303 AC_SUBST(CCSHARED)
304 AC_SUBST(LINKFORSHARED)
305 # SO is the extension of shared libraries `(including the dot!)
306 # -- usually .so, .sl on HP-UX
307 AC_MSG_CHECKING(SO)
308 if test -z "$SO"
309 then
310         case $ac_sys_system in
311         hp*|HP*)   SO=.sl;;
312         *)         SO=.so;;
313         esac
315 AC_MSG_RESULT($SO)
316 # LDSHARED is the ld *command* used to create shared library
317 # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
318 AC_MSG_CHECKING(LDSHARED)
319 if test -z "$LDSHARED"
320 then
321         case $ac_sys_system/$ac_sys_release in
322         AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
323         BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
324         IRIX/5*) LDSHARED="ld -shared";;
325         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
326         SunOS/4*) LDSHARED="ld";;
327         SunOS/5*) LDSHARED="ld -G";;
328         hp*|HP*) LDSHARED="ld -b";;
329         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
330         DYNIX/ptx*) LDSHARED="ld -G";;
331         next/*) LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';;
332         Linux*) LDSHARED="gcc -shared";;
333         dgux*) LDSHARED="ld -G";;
334         FreeBSD*|NetBSD*|OpenBSD*) LDSHARED="ld -Bshareable";;
335         SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
336         *)      LDSHARED="ld";;
337         esac
339 AC_MSG_RESULT($LDSHARED)
340 # CCSHARED are the C *flags* used to create objects to go into a shared
341 # library -- this is only needed for a few systems
342 AC_MSG_CHECKING(CCSHARED)
343 if test -z "$CCSHARED"
344 then
345         case $ac_sys_system/$ac_sys_release in
346         hp*|HP*) if test "$GCC" = yes;
347                  then CCSHARED="-fpic";
348                  else CCSHARED="+z";
349                  fi;;
350         Linux*) CCSHARED="-fpic";;
351         FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fpic";;
352         SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
353         IRIX*/6*)  case $CC in
354                    *gcc*) CCSHARED="-shared";;
355                    *) CCSHARED="";;
356                    esac;;
357         esac
359 AC_MSG_RESULT($CCSHARED)
360 # LINKFORSHARED are the flags passed to the $(CC) command that links
361 # the python executable -- this is only needed for a few systems
362 AC_MSG_CHECKING(LINKFORSHARED)
363 if test -z "$LINKFORSHARED"
364 then
365         case $ac_sys_system/$ac_sys_release in
366         AIX*)   LINKFORSHARED='-Wl,-bE:python.exp -lld';;
367         hp*|HP*)
368             LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
369         Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
370         next/*) LINKFORSHARED="-u libsys_s";;
371         SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
372         SunOS/5*) case $CC in
373                   *gcc*)
374                     if $CC -Xlinker -V 2>/dev/null | grep BFD >/dev/null
375                     then
376                         LINKFORSHARED="-Xlinker --export-dynamic"
377                     fi;;
378                   esac;;
379         esac
381 AC_MSG_RESULT($LINKFORSHARED)
383 # checks for libraries
384 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
385 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
386 AC_CHECK_LIB(m, pow)            # Std math lib -- assume needed if it exists
387 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
388 # However on SGI IRIX, these exist but are broken.
389 # BeOS' sockets are stashed in libnet.
390 case "$ac_sys_system" in
391 IRIX*) ;;
393 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
394 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
395 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
397 esac
399 AC_MSG_CHECKING(for --with-libs)
400 AC_ARG_WITH(libs, [--with-libs='lib1 ...'    link against additional libs], [
401 AC_MSG_RESULT($withval)
402 LIBS="$withval $LIBS"
403 ], AC_MSG_RESULT(no))
405 AC_MSG_CHECKING(for --with(out)-readline)
406 AC_ARG_WITH(readline,
407 [--with(out)-readline      obsolete, edit Modules/Setup instead],
408 [AC_MSG_RESULT($withval)
409 AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)],
410 [AC_MSG_RESULT(not specified.)])
412 AC_SUBST(USE_THREAD_MODULE)
413 USE_THREAD_MODULE="#"
415 AC_MSG_CHECKING(for --with-dec-threads)
416 AC_SUBST(LDLAST)
417 AC_ARG_WITH(dec-threads,
418 [--with-dec-threads        use DEC Alpha/OSF1 thread-safe libraries],
419 [AC_MSG_RESULT($withval)
420 LDLAST=-threads
421 if test "${with_thread+set}" != set; then
422    with_thread="$withval";
423 fi],
424 AC_MSG_RESULT(no))
426 AC_MSG_CHECKING(for --with-threads)
427 AC_ARG_WITH(threads, [--with-threads            alias for --with-thread],
428 [AC_MSG_RESULT($withval)
429 if test "${with_thread+set}" != set; then
430    with_thread="$withval";
431 fi],
432 AC_MSG_RESULT(no))
434 AC_MSG_CHECKING(for --with-thread)
435 AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [
436 USE_THREAD_MODULE=
437 AC_MSG_RESULT($withval)
438 if test -d "$withval"
439 then LDFLAGS="$LDFLAGS -L$withval"
441 AC_DEFINE(_REENTRANT)
442 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
443 AC_DEFINE(C_THREADS)
444 LIBOBJS="$LIBOBJS thread.o"],[
445 AC_CHECK_FUNC(pthread_create, [AC_DEFINE(WITH_THREAD)
446 AC_DEFINE(_POSIX_THREADS)
447 LIBOBJS="$LIBOBJS thread.o"],[
448 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
449 AC_DEFINE(BEOS_THREADS)
450 LIBOBJS="$LIBOBJS thread.o"],[
451 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
452 AC_DEFINE(_POSIX_THREADS)
453 LIBS="$LIBS -lpthreads"
454 LIBOBJS="$LIBOBJS thread.o"], [
455 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
456 AC_DEFINE(_POSIX_THREADS)
457 LIBS="$LIBS -lpthread"
458 LIBOBJS="$LIBOBJS thread.o"], [
459 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
460 AC_DEFINE(_POSIX_THREADS)
461 LIBS="$LIBS -lc_r"
462 LIBOBJS="$LIBOBJS thread.o"], [
463 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
464 AC_DEFINE(_POSIX_THREADS)
465 LIBS="$LIBS -lthread"
466 LIBOBJS="$LIBOBJS thread.o"], [
467 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
468 AC_DEFINE(_POSIX_THREADS)
469 LIBS="$LIBS -lcma"
470 LIBOBJS="$LIBOBJS thread.o"])
471 ])])])])])])])
473 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
474 LIBS="$LIBS -lmpc"
475 LIBOBJS="$LIBOBJS thread.o"])
476 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
477 LIBS="$LIBS -lthread"
478 LIBOBJS="$LIBOBJS thread.o"])
479 ], AC_MSG_RESULT(no))
481 # -I${DLINCLDIR} is added to the compile rule for importdl.o
482 AC_SUBST(DLINCLDIR)
483 DLINCLDIR=/
485 AC_MSG_CHECKING(for --with-sgi-dl)
486 AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY   IRIX 4 dynamic linking], [
487 AC_MSG_RESULT($withval)
488 AC_DEFINE(WITH_SGI_DL)
489 dldir=$withval
490 if test -d "$dldir"
491 then LDFLAGS="$LDFLAGS -L$dldir"
492 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
494 DLINCLDIR=${dldir}
495 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
497 AC_MSG_CHECKING(for --with-dl-dld)
498 AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR  GNU dynamic linking], [
499 AC_MSG_RESULT($withval)
500 AC_DEFINE(WITH_DL_DLD)
501 dldir=`echo "$withval" | sed 's/,.*//'`
502 dlddir=`echo "$withval" | sed 's/.*,//'`
503 if test -d "$dldir" -a -d "$dlddir"
504 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
505 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
507 DLINCLDIR=${dldir}
508 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
510 # checks for library functions
511 AC_CHECK_FUNCS(alarm chown clock dlopen execv flock fork ftime ftruncate \
512  gethostname_r getpeername getpgrp getpid getpwent gettimeofday getwd \
513  kill link lstat mkfifo mktime nice pause plock pthread_init putenv readlink \
514  select setgid setlocale setuid setsid setpgid setpgrp setvbuf \
515  sigaction siginterrupt sigrelse strftime strptime symlink \
516  tcgetpgrp tcsetpgrp timegm times truncate uname waitpid)
517 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
518 AC_CHECK_FUNC(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
519 AC_CHECK_FUNC(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
520 AC_CHECK_FUNC(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
522 # checks for structures
523 AC_HEADER_TIME
524 AC_STRUCT_TM
525 AC_STRUCT_TIMEZONE
527 AC_MSG_CHECKING(for time.h that defines altzone)
528 AC_CACHE_VAL(ac_cv_header_time_altzone,
529 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
530   ac_cv_header_time_altzone=yes,
531   ac_cv_header_time_altzone=no)])
532 AC_MSG_RESULT($ac_cv_header_time_altzone)
533 if test $ac_cv_header_time_altzone = yes; then
534   AC_DEFINE(HAVE_ALTZONE)
537 was_it_defined=no
538 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
539 AC_TRY_COMPILE([
540 #include <sys/types.h>
541 #include <sys/select.h>
542 #include <sys/time.h>
543 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
544 AC_MSG_RESULT($was_it_defined)
546 # checks for compiler characteristics
548 AC_C_CHAR_UNSIGNED
550 AC_C_CONST
552 works=no
553 AC_MSG_CHECKING(for working volatile)
554 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
555 AC_MSG_RESULT($works)
557 works=no
558 AC_MSG_CHECKING(for working signed char)
559 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
560 AC_MSG_RESULT($works)
562 have_prototypes=no
563 AC_MSG_CHECKING(for prototypes)
564 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
565 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
566 AC_MSG_RESULT($have_prototypes)
568 works=no
569 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
570 AC_TRY_COMPILE([
571 #include <stdarg.h>
572 int foo(int x, ...) {
573         va_list va;
574         va_start(va, x);
575         va_arg(va, int);
576         va_arg(va, char *);
577         va_arg(va, double);
578         return 0;
580 ], [return foo(10, "", 3.14);],
581 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
582 AC_MSG_RESULT($works)
584 if test "$have_prototypes" = yes; then
585 bad_prototypes=no
586 AC_MSG_CHECKING(for bad exec* prototypes)
587 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
588         AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
589 AC_MSG_RESULT($bad_prototypes)
592 bad_forward=no
593 AC_MSG_CHECKING(for bad static forward)
594 AC_TRY_RUN([
595 struct s { int a; int b; };
596 static struct s foo;
597 int foobar() {
598  static int random;
599  random = (int) &foo;
600  return random;
602 static struct s foo = { 1, 2 };
603 main() {
604  exit(!((int)&foo == foobar()));
606 ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
607 AC_MSG_RESULT($bad_forward)
609 va_list_is_array=no
610 AC_MSG_CHECKING(whether va_list is an array)
611 AC_TRY_COMPILE([
612 #ifdef HAVE_STDARG_PROTOTYPES
613 #include <stdarg.h>
614 #else
615 #include <varargs.h>
616 #endif
617 ], [va_list list1, list2; list1 = list2;], , 
618 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
619 AC_MSG_RESULT($va_list_is_array)
621 # checks for system services
622 # (none yet)
624 # Linux requires this for correct f.p. operations
625 AC_CHECK_LIB(ieee, __fpu_control)
627 # Check for --with-fpectl
628 AC_MSG_CHECKING(for --with-fpectl)
629 AC_ARG_WITH(fpectl, [--with-fpectl             enable SIGFPE catching], [
630 if test "$withval" != no
631 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
632 else AC_MSG_RESULT(no)
633 fi])
635 # check for --with-libm=...
636 AC_SUBST(LIBM)
637 case $ac_sys_system in
638 next) ;;
639 BeOS) ;;
640 *) LIBM=-lm
641 esac
642 AC_MSG_CHECKING(for --with-libm=STRING)
643 AC_ARG_WITH(libm, [--with-libm=STRING        math library], [
644 if test "$withval" = no
645 then LIBM=
646      AC_MSG_RESULT(force LIBM empty)
647 elif test "$withval" != yes
648 then LIBM=$withval
649      AC_MSG_RESULT(set LIBM=\"$withval\")
650 else AC_ERROR(proper usage is --with-libm=STRING)
651 fi],
652 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
654 # check for --with-libc=...
655 AC_SUBST(LIBC)
656 AC_MSG_CHECKING(for --with-libc=STRING)
657 AC_ARG_WITH(libc, [--with-libc=STRING        C library], [
658 if test "$withval" = no
659 then LIBC=
660      AC_MSG_RESULT(force LIBC empty)
661 elif test "$withval" != yes
662 then LIBC=$withval
663      AC_MSG_RESULT(set LIBC=\"$withval\")
664 else AC_ERROR(proper usage is --with-libc=STRING)
665 fi],
666 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
668 # check for hypot() in math library
669 LIBS_SAVE=$LIBS
670 LIBS="$LIBS $LIBM"
671 AC_CHECK_FUNCS(hypot)
672 AC_REPLACE_FUNCS(hypot)
673 LIBS=$LIBS_SAVE
675 # check for getopt
676 AC_MSG_CHECKING(for genuine getopt)
677 AC_CACHE_VAL(ac_cv_func_getopt,
678 [AC_TRY_RUN([#include <stdio.h>
679 extern int optind, opterr, getopt();
680 extern char* optarg;
681 int main() {
682         char* av[] = { "testprog", "parameter", "-fFlag", NULL };
683         opterr = 0;
684         if (getopt(3, av, "f:") == 'f') { exit(1); }
685         exit(0);
686 }], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
687 AC_MSG_RESULT($ac_cv_func_getopt)
688 test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
689 AC_SUBST(LIBOBJS)dnl
691 # check whether malloc(0) returns NULL or not
692 AC_MSG_CHECKING(what malloc(0) returns)
693 AC_CACHE_VAL(ac_cv_malloc_zero,
694 [AC_TRY_RUN([#include <stdio.h>
695 #ifdef HAVE_STDLIB
696 #include <stdlib.h>
697 #else
698 char *malloc(), *realloc();
699 int *free();
700 #endif
701 main() {
702         char *p;
703         p = malloc(0);
704         if (p == NULL) exit(1);
705         p = realloc(p, 0);
706         if (p == NULL) exit(1);
707         free(p);
708         exit(0);
709 }], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
710 AC_MSG_RESULT($ac_cv_malloc_zero)
711 if test "$ac_cv_malloc_zero" = null
712 then
713   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
716 # generate output files
717 AC_OUTPUT(Makefile \
718  Objects/Makefile \
719  Parser/Makefile \
720  Python/Makefile \
721  Modules/Makefile.pre \
722  Modules/Setup.thread)