Added all documentation.
[python/dscho.git] / configure.in
blob5932e0631353fb02e192fe20238aff4023983590
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 -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|MacOS10) framework],,)
37 AC_ARG_WITH(dyld, 
38 [--with-dyld               Use (OpenStep|Rhapsody|MacOS10) 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" ; 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}"
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 -O3 -mpentiumpro"
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         *)      without_gcc=no;;
152         esac])
153 AC_MSG_RESULT($without_gcc)
155 # If the user switches compilers, we can't believe the cache
156 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
157 then
158   AC_ERROR(cached CC is different -- throw away $cache_file
159 (it is also a good idea to do 'make clean' before compiling))
162 AC_PROG_CC
164 case $MACHDEP in
165 bsdos*)
166     case $CC in
167     gcc) CC="$CC -D_HAVE_BSDI";;
168     esac;;
169 esac
171 case $ac_sys_system in
172 hp*|HP*)
173     case $CC in
174     cc|*/cc) CC="$CC -Aa -D_HPUX_SOURCE";;
175     esac;;
176 BeOS*)
177         case $CC in
178         cc) CC=cc;;
179         esac;;
180 esac
182 # LDLIBRARY is the name of the library to link against (as opposed to the
183 # name of the library into which to insert object files). On systems
184 # without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
185 # the Makefiles). 
186 AC_SUBST(MAKE_LDLIBRARY)
187 AC_SUBST(LDLIBRARY)
188 LDLIBRARY=''
190 # LINKCC is the command that links the python executable -- default is $(CC).
191 # This is altered for AIX and BeOS in order to build the export list before 
192 # linking.
193 AC_SUBST(LINKCC)
194 AC_MSG_CHECKING(LINKCC)
195 if test -z "$LINKCC"
196 then
197         case $ac_sys_system in
198         AIX*)
199            LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
200         BeOS*)
201            LINKCC="\$(srcdir)/../BeOS/linkcc \$(LIBRARY) \$(PURIFY) \$(CC) \$(OPT)"
202            LDLIBRARY='libpython$(VERSION).so';;
203         dgux*)
204            LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
205         *) LINKCC="\$(PURIFY) \$(CC)";;
206         esac
208 AC_MSG_RESULT($LINKCC)
210 AC_MSG_CHECKING(LDLIBRARY)
212 # NeXT framework builds require that the 'ar' library be converted into
213 # a bundle using libtool.
214 if test "$with_next_framework"
215 then
216   LDLIBRARY='libpython$(VERSION).dylib'
217 fi  
219 # DG/UX requires some fancy ld contortions to produce a .so from an .a
220 if test "$MACHDEP" = "dguxR4"
221 then
222   LDLIBRARY='libpython$(VERSION).so'
223   OPT="$OPT -pic"
225 AC_MSG_RESULT($LDLIBRARY)
227 # If LDLIBRARY is different from LIBRARY, emit a rule to build it.
228 if test -z "$LDLIBRARY"
229 then
230   LDLIBRARY='libpython$(VERSION).a'
231   MAKE_LDLIBRARY="true"
232 else
233   MAKE_LDLIBRARY='$(MAKE) $(LDLIBRARY)'
236 AC_PROG_RANLIB
237 AC_SUBST(AR)
238 AC_CHECK_PROGS(AR, ar aal, ar)
239 AC_SUBST(INSTALL)
240 AC_SUBST(INSTALL_PROGRAM)
241 AC_SUBST(INSTALL_DATA)
242 # Install just never works :-(
243 if test -z "$INSTALL"
244 then
245         INSTALL=cp
246         INSTALL_PROGRAM=cp
247         INSTALL_DATA=cp
248 else
249         INSTALL_PROGRAM="$INSTALL"
250         INSTALL_DATA="$INSTALL -m 644"
253 # Not every filesystem supports hard links
254 AC_SUBST(LN)
255 if test -z "$LN" ; then
256         case $ac_sys_system in
257                 BeOS*) LN="ln -s";;
258                 *) LN=ln;;
259         esac
262 # Optimizer/debugger flags passed between Makefiles
263 AC_SUBST(OPT)
264 if test -z "$OPT"
265 then
266         case $GCC in
267         yes)
268                 case $ac_cv_prog_cc_g in
269                 yes)    OPT="-g -O2";;
270                 *)      OPT="-O2";;
271                 esac
272                 ;;
273         *)      OPT="-O";;
274         esac
277 if test "$ac_arch_flags"
278 then
279         OPT="$OPT $ac_arch_flags"
281 # checks for UNIX variants that set C preprocessor variables
282 AC_AIX
283 AC_MINIX
285 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
286 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
287 [ac_save_cc="$CC"
288 CC="$CC -OPT:Olimit=0"
289 AC_TRY_RUN([int main() { return 0; }],
290   ac_cv_opt_olimit_ok=yes,
291   ac_cv_opt_olimit_ok=no)
292 CC="$ac_save_cc"])
293 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
294 if test $ac_cv_opt_olimit_ok = yes; then
295   OPT="$OPT -OPT:Olimit=0"
296 else
297   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
298   AC_CACHE_VAL(ac_cv_olimit_ok,
299   [ac_save_cc="$CC"
300   CC="$CC -Olimit 1500"
301   AC_TRY_RUN([int main() { return 0; }],
302     ac_cv_olimit_ok=yes,
303     ac_cv_olimit_ok=no)
304   CC="$ac_save_cc"])
305   AC_MSG_RESULT($ac_cv_olimit_ok)
306   if test $ac_cv_olimit_ok = yes; then
307     OPT="$OPT -Olimit 1500"
308   fi
311 # check for ANSI or K&R ("traditional") preprocessor
312 AC_MSG_CHECKING(for C preprocessor type)
313 AC_TRY_COMPILE([
314 #define spam(name, doc) {#name, &name, #name "() -- " doc}
315 int foo;
316 struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
317 ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
318 AC_MSG_RESULT($cpp_type)
320 # checks for header files
321 AC_HEADER_STDC
322 AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h pthread.h \
323 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
324 sys/audioio.h sys/file.h sys/lock.h \
325 sys/param.h sys/select.h sys/time.h sys/times.h \
326 sys/un.h sys/utsname.h sys/wait.h)
327 AC_HEADER_DIRENT
329 # checks for typedefs
330 was_it_defined=no
331 AC_MSG_CHECKING(for clock_t in time.h)
332 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
333 AC_MSG_RESULT($was_it_defined)
335 # Add some code to confdefs.h so that the test for off_t works on SCO
336 cat >> confdefs.h <<\EOF
337 #if defined(SCO_DS)
338 #undef _OFF_T
339 #endif
342 AC_TYPE_MODE_T
343 AC_TYPE_OFF_T
344 AC_TYPE_PID_T
345 AC_TYPE_SIGNAL
346 AC_TYPE_SIZE_T
347 AC_TYPE_UID_T
349 AC_CHECK_SIZEOF(int)
350 AC_CHECK_SIZEOF(long)
351 AC_CHECK_SIZEOF(void *)
353 AC_MSG_CHECKING(for long long support)
354 have_long_long=no
355 AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
356 AC_MSG_RESULT($have_long_long)
357 if test "$have_long_long" = yes ; then
358 AC_CHECK_SIZEOF(long long)
361 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
362 AC_MSG_CHECKING(size of off_t)
363 AC_CACHE_VAL(ac_cv_sizeof_off_t,
364 [AC_TRY_RUN([#include <stdio.h>
365 #include <sys/types.h>
366 main()
368   FILE *f=fopen("conftestval", "w");
369   if (!f) exit(1);
370   fprintf(f, "%d\n", sizeof(off_t));
371   exit(0);
372 }], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
374 AC_MSG_RESULT($ac_cv_sizeof_off_t)
375 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
377 AC_MSG_CHECKING(whether to enable large file support)
378 if test "$have_long_long" = yes -a \
379         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
380         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
381   AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
382   AC_MSG_RESULT(yes)
383 else
384   AC_MSG_RESULT(no)
388 # Minor variations in building a framework between NextStep versions 4 and 5
389 AC_SUBST(LIBTOOL_CRUFT)
390 case $ac_sys_system/$ac_sys_release in
391   next/4*)
392     ns_undef_sym='__environ'
393     LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
394   next/5*)
395     ns_undef_sym='_environ'
396     LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
397 esac
399 AC_MSG_CHECKING(for --with-next-framework)
400 if test "$with_next_framework"
401 then
402         OPT="$OPT -fno-common"
403         # -U __environ is needed since bundles don't have access
404         # to crt0 when built but will always be linked against it
405         LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
406         AC_DEFINE(WITH_NEXT_FRAMEWORK)
407         AC_MSG_RESULT(yes)
408 else
409         AC_MSG_RESULT(no)
412 AC_MSG_CHECKING(for --with-dyld)
413 if test "$with_next_framework" -o "$with_dyld"
414 then
415         if test "$with_dyld"
416         then
417                 AC_MSG_RESULT(yes)
418         else
419                 AC_MSG_RESULT(required for framework build)
420         fi
421         AC_DEFINE(WITH_DYLD)
422         ns_dyld='set'
423 else
424         AC_MSG_RESULT(no)
427 # Set info about shared libraries.
428 AC_SUBST(SO)
429 AC_SUBST(LDSHARED)
430 AC_SUBST(CCSHARED)
431 AC_SUBST(LINKFORSHARED)
432 # SO is the extension of shared libraries `(including the dot!)
433 # -- usually .so, .sl on HP-UX
434 AC_MSG_CHECKING(SO)
435 if test -z "$SO"
436 then
437         case $ac_sys_system in
438         hp*|HP*)   SO=.sl;;
439         *)         SO=.so;;
440         esac
442 AC_MSG_RESULT($SO)
443 # LDSHARED is the ld *command* used to create shared library
444 # -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
445 # (Shared libraries in this instance are shared modules to be loaded into
446 # Python, as opposed to building Python itself as a shared library.)
447 AC_MSG_CHECKING(LDSHARED)
448 if test -z "$LDSHARED"
449 then
450         case $ac_sys_system/$ac_sys_release in
451         AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
452         BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
453         IRIX/5*) LDSHARED="ld -shared";;
454         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
455         SunOS/4*) LDSHARED="ld";;
456         SunOS/5*) LDSHARED="ld -G";;
457         hp*|HP*) LDSHARED="ld -b";;
458         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
459         DYNIX/ptx*) LDSHARED="ld -G";;
460         next/*) 
461                 if test "$ns_dyld"
462                 then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
463                 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
464                 fi
465                 if test "$with_next_framework" ; then
466                     LDSHARED="$LDSHARED \$(LDLIBRARY)"
467                 fi ;;
468         Linux*) LDSHARED="gcc -shared";;
469         dgux*) LDSHARED="ld -G";;
470         BSD/OS*/4*) LDSHARED="gcc -shared";;
471         FreeBSD*/[[34]]*) LDSHARED="gcc -shared";;
472         FreeBSD*|OpenBSD*) LDSHARED="ld -Bshareable";;
473         NetBSD*)
474                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
475                 then
476                         LDSHARED="cc -shared"
477                 else
478                         LDSHARED="ld -Bshareable"
479                 fi;;
480         SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
481         *)      LDSHARED="ld";;
482         esac
484 AC_MSG_RESULT($LDSHARED)
485 # CCSHARED are the C *flags* used to create objects to go into a shared
486 # library (module) -- this is only needed for a few systems
487 AC_MSG_CHECKING(CCSHARED)
488 if test -z "$CCSHARED"
489 then
490         case $ac_sys_system/$ac_sys_release in
491         hp*|HP*) if test "$GCC" = yes;
492                  then CCSHARED="-fpic";
493                  else CCSHARED="+z";
494                  fi;;
495         Linux*) CCSHARED="-fpic";;
496         FreeBSD*|OpenBSD*) CCSHARED="-fpic";;
497         NetBSD*) CCSHARED="-fPIC";;
498         SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
499         IRIX*/6*)  case $CC in
500                    *gcc*) CCSHARED="-shared";;
501                    *) CCSHARED="";;
502                    esac;;
503         esac
505 AC_MSG_RESULT($CCSHARED)
506 # LINKFORSHARED are the flags passed to the $(CC) command that links
507 # the python executable -- this is only needed for a few systems
508 AC_MSG_CHECKING(LINKFORSHARED)
509 if test -z "$LINKFORSHARED"
510 then
511         case $ac_sys_system/$ac_sys_release in
512         AIX*)   LINKFORSHARED='-Wl,-bE:python.exp -lld';;
513         hp*|HP*)
514             LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
515         FreeBSD/[[34]]*) LINKFORSHARED="-Xlinker -export-dynamic";;
516         Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
517         # -u libsys_s pulls in all symbols in libsys
518         next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
519         # -u __dummy makes the linker aware of the objc runtime
520         # in System.framework; otherwise, __objcInit (referenced in
521         # crt1.o) gets erroneously defined as common, which breaks dynamic
522         # loading of any modules which reference it in System.framework
523         next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
524         SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
525         NetBSD*) 
526                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
527                 then
528                         LINKFORSHARED="-Wl,--export-dynamic"
529                 fi;;
530         SunOS/5*) case $CC in
531                   *gcc*)
532                     if $CC -Xlinker -V 2>/dev/null | grep BFD >/dev/null
533                     then
534                         LINKFORSHARED="-Xlinker --export-dynamic"
535                     fi;;
536                   esac;;
537         esac
539 AC_MSG_RESULT($LINKFORSHARED)
541 # checks for libraries
542 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
543 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
544 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
545 # However on SGI IRIX, these exist but are broken.
546 # BeOS' sockets are stashed in libnet.
547 case "$ac_sys_system" in
548 IRIX*) ;;
550 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
551 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
552 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
554 esac
556 AC_MSG_CHECKING(for --with-libs)
557 AC_ARG_WITH(libs, [--with-libs='lib1 ...'    link against additional libs], [
558 AC_MSG_RESULT($withval)
559 LIBS="$withval $LIBS"
560 ], AC_MSG_RESULT(no))
562 AC_MSG_CHECKING(for --with(out)-readline)
563 AC_ARG_WITH(readline,
564 [--with(out)-readline      obsolete, edit Modules/Setup instead],
565 [AC_MSG_RESULT($withval)
566 AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)],
567 [AC_MSG_RESULT(not specified.)])
569 AC_SUBST(USE_THREAD_MODULE)
570 USE_THREAD_MODULE="#"
572 AC_MSG_CHECKING(for --with-dec-threads)
573 AC_SUBST(LDLAST)
574 AC_ARG_WITH(dec-threads,
575 [--with-dec-threads        use DEC Alpha/OSF1 thread-safe libraries],
576 [AC_MSG_RESULT($withval)
577 LDLAST=-threads
578 if test "${with_thread+set}" != set; then
579    with_thread="$withval";
580 fi],
581 AC_MSG_RESULT(no))
583 AC_MSG_CHECKING(for --with-threads)
584 AC_ARG_WITH(threads, [--with-threads            alias for --with-thread],
585 [AC_MSG_RESULT($withval)
586 if test "${with_thread+set}" != set; then
587    with_thread="$withval";
588 fi],
589 AC_MSG_RESULT(no))
591 AC_MSG_CHECKING(for --with-thread)
592 AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [
593 USE_THREAD_MODULE=
594 AC_MSG_RESULT($withval)
595 if test -d "$withval"
596 then LDFLAGS="$LDFLAGS -L$withval"
598 AC_DEFINE(_REENTRANT)
599 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
600 AC_DEFINE(C_THREADS)
601 LIBOBJS="$LIBOBJS thread.o"],[
602 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
603 AC_DEFINE(_POSIX_THREADS)
604 LIBOBJS="$LIBOBJS thread.o"],[
605 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
606 AC_DEFINE(BEOS_THREADS)
607 LIBOBJS="$LIBOBJS thread.o"],[
608 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
609 AC_DEFINE(_POSIX_THREADS)
610 LIBS="$LIBS -lpthreads"
611 LIBOBJS="$LIBOBJS thread.o"], [
612 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
613 AC_DEFINE(_POSIX_THREADS)
614 LIBS="$LIBS -lpthread"
615 LIBOBJS="$LIBOBJS thread.o"], [
616 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
617 AC_DEFINE(_POSIX_THREADS)
618 LIBS="$LIBS -lc_r"
619 LIBOBJS="$LIBOBJS thread.o"], [
620 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
621 AC_DEFINE(_POSIX_THREADS)
622 LIBS="$LIBS -lthread"
623 LIBOBJS="$LIBOBJS thread.o"], [
624 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
625 AC_DEFINE(_POSIX_THREADS)
626 LIBS="$LIBS -lcma"
627 LIBOBJS="$LIBOBJS thread.o"])
628 ])])])])])])])
630 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
631 LIBS="$LIBS -lmpc"
632 LIBOBJS="$LIBOBJS thread.o"])
633 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
634 LIBS="$LIBS -lthread"
635 LIBOBJS="$LIBOBJS thread.o"])
636 ], AC_MSG_RESULT(no))
638 # -I${DLINCLDIR} is added to the compile rule for importdl.o
639 AC_SUBST(DLINCLDIR)
640 DLINCLDIR=/
642 AC_MSG_CHECKING(for --with-sgi-dl)
643 AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY   IRIX 4 dynamic linking], [
644 AC_MSG_RESULT($withval)
645 AC_DEFINE(WITH_SGI_DL)
646 dldir=$withval
647 if test -d "$dldir"
648 then LDFLAGS="$LDFLAGS -L$dldir"
649 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
651 DLINCLDIR=${dldir}
652 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
654 AC_MSG_CHECKING(for --with-dl-dld)
655 AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR  GNU dynamic linking], [
656 AC_MSG_RESULT($withval)
657 AC_DEFINE(WITH_DL_DLD)
658 dldir=`echo "$withval" | sed 's/,.*//'`
659 dlddir=`echo "$withval" | sed 's/.*,//'`
660 if test -d "$dldir" -a -d "$dlddir"
661 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
662 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
664 DLINCLDIR=${dldir}
665 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
667 # checks for library functions
668 AC_CHECK_FUNCS(alarm chown clock dlopen execv flock fork \
669  fsync fdatasync ftime ftruncate \
670  getpeername getpgrp getpid getpwent gettimeofday getwd \
671  kill link lstat mkfifo mktime nice pause plock pthread_init putenv readlink \
672  select setgid setlocale setuid setsid setpgid setpgrp setvbuf \
673  sigaction siginterrupt sigrelse strftime strptime symlink \
674  tcgetpgrp tcsetpgrp timegm times truncate uname waitpid)
676 # check for long file support functions
677 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
679 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
680 AC_CHECK_FUNC(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
681 AC_CHECK_FUNC(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
682 AC_CHECK_FUNC(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
684 # checks for structures
685 AC_HEADER_TIME
686 AC_STRUCT_TM
687 AC_STRUCT_TIMEZONE
689 AC_MSG_CHECKING(for time.h that defines altzone)
690 AC_CACHE_VAL(ac_cv_header_time_altzone,
691 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
692   ac_cv_header_time_altzone=yes,
693   ac_cv_header_time_altzone=no)])
694 AC_MSG_RESULT($ac_cv_header_time_altzone)
695 if test $ac_cv_header_time_altzone = yes; then
696   AC_DEFINE(HAVE_ALTZONE)
699 was_it_defined=no
700 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
701 AC_TRY_COMPILE([
702 #include <sys/types.h>
703 #include <sys/select.h>
704 #include <sys/time.h>
705 ], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
706 AC_MSG_RESULT($was_it_defined)
708 # checks for compiler characteristics
710 AC_C_CHAR_UNSIGNED
712 AC_C_CONST
714 works=no
715 AC_MSG_CHECKING(for working volatile)
716 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
717 AC_MSG_RESULT($works)
719 works=no
720 AC_MSG_CHECKING(for working signed char)
721 AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
722 AC_MSG_RESULT($works)
724 have_prototypes=no
725 AC_MSG_CHECKING(for prototypes)
726 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
727 AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
728 AC_MSG_RESULT($have_prototypes)
730 works=no
731 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
732 AC_TRY_COMPILE([
733 #include <stdarg.h>
734 int foo(int x, ...) {
735         va_list va;
736         va_start(va, x);
737         va_arg(va, int);
738         va_arg(va, char *);
739         va_arg(va, double);
740         return 0;
742 ], [return foo(10, "", 3.14);],
743 AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
744 AC_MSG_RESULT($works)
746 if test "$have_prototypes" = yes; then
747 bad_prototypes=no
748 AC_MSG_CHECKING(for bad exec* prototypes)
749 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
750         AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
751 AC_MSG_RESULT($bad_prototypes)
754 bad_forward=no
755 AC_MSG_CHECKING(for bad static forward)
756 AC_TRY_RUN([
757 struct s { int a; int b; };
758 static struct s foo;
759 int foobar() {
760  static int random;
761  random = (int) &foo;
762  return random;
764 static struct s foo = { 1, 2 };
765 main() {
766  exit(!((int)&foo == foobar()));
768 ], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
769 AC_MSG_RESULT($bad_forward)
771 va_list_is_array=no
772 AC_MSG_CHECKING(whether va_list is an array)
773 AC_TRY_COMPILE([
774 #ifdef HAVE_STDARG_PROTOTYPES
775 #include <stdarg.h>
776 #else
777 #include <varargs.h>
778 #endif
779 ], [va_list list1, list2; list1 = list2;], , 
780 AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
781 AC_MSG_RESULT($va_list_is_array)
783 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
784 AC_CHECK_FUNC(gethostbyname_r, [
785   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
786   AC_MSG_CHECKING([gethostbyname_r with 6 args])
787   OLD_CFLAGS=$CFLAGS
788   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
789   AC_TRY_COMPILE([
790 #   include <netdb.h>
791   ], [
792     char *name;
793     struct hostent *he, *res;
794     char buffer[2048];
795     int buflen = 2048;
796     int h_errnop;
798     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
799   ], [
800     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
801     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
802     AC_MSG_RESULT(yes)
803   ], [
804     AC_MSG_RESULT(no)
805     AC_MSG_CHECKING([gethostbyname_r with 5 args])
806     AC_TRY_COMPILE([
807 #     include <netdb.h>
808     ], [
809       char *name;
810       struct hostent *he;
811       char buffer[2048];
812       int buflen = 2048;
813       int h_errnop;
815       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
816     ], [
817       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
818       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
819       AC_MSG_RESULT(yes)
820     ], [
821       AC_MSG_RESULT(no)
822       AC_MSG_CHECKING([gethostbyname_r with 3 args])
823       AC_TRY_COMPILE([
824 #       include <netdb.h>
825       ], [
826         char *name;
827         struct hostent *he;
828         struct hostent_data data;
830         (void) gethostbyname_r(name, he, &data);
831       ], [
832         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
833         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
834         AC_MSG_RESULT(yes)
835       ], [
836         AC_MSG_RESULT(no)
837       ])
838     ])
839   ])
840   CFLAGS=$OLD_CFLAGS
841 ], [
842   AC_CHECK_FUNC(gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME))
844 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
845 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
846 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
847 AC_SUBST(HAVE_GETHOSTBYNAME_R)
848 AC_SUBST(HAVE_GETHOSTBYNAME)
850 # checks for system services
851 # (none yet)
853 # Linux requires this for correct f.p. operations
854 AC_CHECK_LIB(ieee, __fpu_control)
856 # Check for --with-fpectl
857 AC_MSG_CHECKING(for --with-fpectl)
858 AC_ARG_WITH(fpectl, [--with-fpectl             enable SIGFPE catching], [
859 if test "$withval" != no
860 then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
861 else AC_MSG_RESULT(no)
862 fi])
864 # check for --with-libm=...
865 AC_SUBST(LIBM)
866 case $ac_sys_system in
867 next) ;;
868 BeOS) ;;
869 *) LIBM=-lm
870 esac
871 AC_MSG_CHECKING(for --with-libm=STRING)
872 AC_ARG_WITH(libm, [--with-libm=STRING        math library], [
873 if test "$withval" = no
874 then LIBM=
875      AC_MSG_RESULT(force LIBM empty)
876 elif test "$withval" != yes
877 then LIBM=$withval
878      AC_MSG_RESULT(set LIBM=\"$withval\")
879 else AC_ERROR(proper usage is --with-libm=STRING)
880 fi],
881 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
883 # check for --with-libc=...
884 AC_SUBST(LIBC)
885 AC_MSG_CHECKING(for --with-libc=STRING)
886 AC_ARG_WITH(libc, [--with-libc=STRING        C library], [
887 if test "$withval" = no
888 then LIBC=
889      AC_MSG_RESULT(force LIBC empty)
890 elif test "$withval" != yes
891 then LIBC=$withval
892      AC_MSG_RESULT(set LIBC=\"$withval\")
893 else AC_ERROR(proper usage is --with-libc=STRING)
894 fi],
895 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
897 # check for hypot() in math library
898 LIBS_SAVE=$LIBS
899 LIBS="$LIBS $LIBM"
900 AC_CHECK_FUNCS(hypot)
901 AC_REPLACE_FUNCS(hypot)
902 LIBS=$LIBS_SAVE
904 # check for getopt
905 AC_MSG_CHECKING(for genuine getopt)
906 AC_CACHE_VAL(ac_cv_func_getopt,
907 [AC_TRY_RUN([#include <stdio.h>
908 extern int optind, opterr, getopt();
909 extern char* optarg;
910 int main() {
911         char* av[] = { "testprog", "parameter", "-fFlag", NULL };
912         opterr = 0;
913         if (getopt(3, av, "f:") == 'f') { exit(1); }
914         exit(0);
915 }], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
916 AC_MSG_RESULT($ac_cv_func_getopt)
917 test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
918 AC_SUBST(LIBOBJS)dnl
920 # check whether malloc(0) returns NULL or not
921 AC_MSG_CHECKING(what malloc(0) returns)
922 AC_CACHE_VAL(ac_cv_malloc_zero,
923 [AC_TRY_RUN([#include <stdio.h>
924 #ifdef HAVE_STDLIB
925 #include <stdlib.h>
926 #else
927 char *malloc(), *realloc();
928 int *free();
929 #endif
930 main() {
931         char *p;
932         p = malloc(0);
933         if (p == NULL) exit(1);
934         p = realloc(p, 0);
935         if (p == NULL) exit(1);
936         free(p);
937         exit(0);
938 }], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
939 AC_MSG_RESULT($ac_cv_malloc_zero)
940 if test "$ac_cv_malloc_zero" = null
941 then
942   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
945 # generate output files
946 AC_OUTPUT(Makefile \
947  Objects/Makefile \
948  Parser/Makefile \
949  Python/Makefile \
950  Modules/Makefile.pre \
951  Modules/Setup.thread)