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