openfile(): Go back to opening the files in text mode. This undoes
[python/dscho.git] / configure.in
blob80c4e54751f59dfd4ad62ef58bc2540a6d24aeb9
1 dnl Process this file with autoconf 2.0 or later to make a configure script.
2 AC_REVISION($Revision$)
3 AC_PREREQ(2.53)
4 AC_INIT(Include/object.h)
5 AC_CONFIG_HEADER(pyconfig.h)
7 # This is for stuff that absolutely must end up in pyconfig.h.
8 # Please use pyport.h instead, if possible.
9 AH_BOTTOM([
10 /* Define the macros needed if on a UnixWare 7.x system. */
11 #if defined(__USLC__) && defined(__SCO_VERSION__)
12 #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
13 #endif
16 # Set VERSION so we only need to edit in one place (i.e., here)
17 AC_SUBST(VERSION)
18 VERSION=2.3
20 AC_SUBST(SOVERSION)
21 SOVERSION=1.0
23 # The later defininition of _XOPEN_SOURCE disables certain features
24 # on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
25 AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
27 # The definition of _GNU_SOURCE potentially causes a change of the value
28 # of _XOPEN_SOURCE. So define it only conditionally.
29 AH_VERBATIM([_XOPEN_SOURCE],
30 [/* Define on UNIX to activate XPG/5 features.  */
31 #ifndef _XOPEN_SOURCE
32 # define _XOPEN_SOURCE 500
33 #endif])
34 AC_DEFINE(_XOPEN_SOURCE, 500)
36 # Arguments passed to configure.
37 AC_SUBST(CONFIG_ARGS)
38 CONFIG_ARGS="$ac_configure_args"
41 AC_ARG_ENABLE(framework,
42 [  --enable-framework[=INSTALLDIR] Build (MacOSX|Darwin) framework],[
43         case $enableval in
44         yes) 
45                 enableval=/Library/Frameworks
46         esac
47         case $enableval in
48         no)
49                 PYTHONFRAMEWORK=
50                 PYTHONFRAMEWORKDIR=no-framework
51                 PYTHONFRAMEWORKPREFIX=
52                 PYTHONFRAMEWORKINSTALLDIR=
53                 enable_framework=
54                 ;;
55         *)
56                 PYTHONFRAMEWORK=Python
57                 PYTHONFRAMEWORKDIR=Python.framework
58                 PYTHONFRAMEWORKPREFIX=$enableval
59                 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
60                 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
61         esac
62         ],[
63         PYTHONFRAMEWORK=
64         PYTHONFRAMEWORKDIR=no-framework
65         PYTHONFRAMEWORKPREFIX=
66         PYTHONFRAMEWORKINSTALLDIR=
67         enable_framework=
69 AC_SUBST(PYTHONFRAMEWORK)
70 AC_SUBST(PYTHONFRAMEWORKDIR)
71 AC_SUBST(PYTHONFRAMEWORKPREFIX)
72 AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
74 ##AC_ARG_WITH(dyld,
75 ##[  --with-dyld                     Use (OpenStep|Rhapsody) dynamic linker],,)
77 # Set name for machine-dependent library files
78 AC_SUBST(MACHDEP)
79 AC_MSG_CHECKING(MACHDEP)
80 if test -z "$MACHDEP"
81 then
82         ac_sys_system=`uname -s`
83         if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
84         -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
85                 ac_sys_release=`uname -v`
86         else
87                 ac_sys_release=`uname -r`
88         fi
89         ac_md_system=`echo $ac_sys_system |
90                            tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
91         ac_md_release=`echo $ac_sys_release |
92                            tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
93         MACHDEP="$ac_md_system$ac_md_release"
95         case $MACHDEP in
96         cygwin*) MACHDEP="cygwin";;
97         darwin*) MACHDEP="darwin";;
98         atheos*) MACHDEP="atheos";;
99         '')     MACHDEP="unknown";;
100         esac
104 # SGI compilers allow the specification of the both the ABI and the
105 # ISA on the command line.  Depending on the values of these switches,
106 # different and often incompatable code will be generated.
108 # The SGI_ABI variable can be used to modify the CC and LDFLAGS and
109 # thus supply support for various ABI/ISA combinations.  The MACHDEP
110 # variable is also adjusted.
112 AC_SUBST(SGI_ABI)
113 if test ! -z "$SGI_ABI"
114 then
115         CC="cc $SGI_ABI"
116         LDFLAGS="$SGI_ABI $LDFLAGS"
117         MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
119 AC_MSG_RESULT($MACHDEP)
121 # checks for alternative programs
122 AC_MSG_CHECKING(for --without-gcc)
123 AC_ARG_WITH(gcc, [  --without-gcc                   never use gcc], [
124         case $withval in
125         no)     CC=cc
126                 without_gcc=yes;;
127         yes)    CC=gcc
128                 without_gcc=no;;
129         *)      CC=$withval
130                 without_gcc=$withval;;
131         esac], [
132         case $ac_sys_system in
133         AIX*)   CC=cc_r
134                 without_gcc=;;
135         BeOS*)
136                 case $BE_HOST_CPU in
137                 ppc)
138                         CC=mwcc
139                         without_gcc=yes
140                         OPT="-O -export pragma"
141                         LDFLAGS="$LDFLAGS -nodup"
142                         ;;
143                 x86)
144                         CC=gcc
145                         without_gcc=no
146                         OPT=-O
147                         ;;
148                 *)
149                         AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
150                         ;;
151                 esac
152                 AR="\$(srcdir)/Modules/ar_beos"
153                 RANLIB=:
154                 ;;
155     Monterey*)
156         RANLIB=:
157         without_gcc=;;
158         *)      without_gcc=no;;
159         esac])
160 AC_MSG_RESULT($without_gcc)
162 AC_SUBST(CXX)
163 AC_SUBST(MAINOBJ)
164 MAINOBJ=python.o
165 AC_MSG_CHECKING(for --with-cxx=<compiler>)
166 AC_ARG_WITH(cxx, [  --with-cxx=<compiler>           enable C++ support],[
167         check_cxx=no
168         case $withval in
169         no)     CXX=
170                 with_cxx=no;;
171         *)      CXX=$withval
172                 MAINOBJ=ccpython.o
173                 with_cxx=$withval;;
174         esac], [
175         with_cxx=no
176         check_cxx=yes
178 AC_MSG_RESULT($with_cxx)
180 if test "$with_cxx" = "yes"
181 then
182         AC_ERROR(must supply a compiler when using --with-cxx)
185 dnl The following fragment works similar to AC_PROG_CXX.
186 dnl It does not fail if CXX is not found, and it is not executed if 
187 dnl --without-cxx was given.
188 dnl Finally, it does not test whether CXX is g++.
190 dnl Autoconf 2.5x does not have AC_PROG_CXX_WORKS anymore
191 ifdef([AC_PROG_CXX_WORKS],[],
192       [AC_DEFUN([AC_PROG_CXX_WORKS],
193       [AC_LANG_PUSH(C++)dnl
194        _AC_COMPILER_EXEEXT
195        AC_LANG_POP()
196       ]
199 if test "$check_cxx" = "yes" 
200 then
201         AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
202         if test "$CXX" = "notfound"
203         then
204                 CXX=
205         else
206                 AC_PROG_CXX_WORKS
207         fi
210 # If the user switches compilers, we can't believe the cache
211 if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
212 then
213   AC_ERROR(cached CC is different -- throw away $cache_file
214 (it is also a good idea to do 'make clean' before compiling))
217 AC_PROG_CC
219 # checks for UNIX variants that set C preprocessor variables
220 AC_AIX
221 AC_MINIX
223 AC_EXEEXT
224 AC_MSG_CHECKING(for --with-suffix)
225 AC_ARG_WITH(suffix, [  --with-suffix=.exe              set executable suffix],[
226         case $withval in
227         no)     EXEEXT=;;
228         yes)    EXEEXT=.exe;;
229         *)      EXEEXT=$withval;;
230         esac])
231 AC_MSG_RESULT($EXEEXT)
233 # Test whether we're running on a non-case-sensitive system, in which
234 # case we give a warning if no ext is given
235 AC_SUBST(BUILDEXEEXT)
236 AC_MSG_CHECKING(for case-insensitive build directory)
237 if test -d "${srcdir}/python"
238 then
239     AC_MSG_RESULT(yes)
240     BUILDEXEEXT=.exe
241 else
242         AC_MSG_RESULT(no)
243         BUILDEXEEXT=$EXEEXT
246 case $MACHDEP in
247 bsdos*)
248     case $CC in
249     gcc) CC="$CC -D_HAVE_BSDI";;
250     esac;;
251 esac
253 case $ac_sys_system in
254 hp*|HP*)
255     case $CC in
256     cc|*/cc) CC="$CC -Ae";;
257     esac;;
258 Monterey*)
259     case $CC in
260     cc) CC="$CC -Wl,-Bexport";;
261     esac;;
262 SunOS*)
263     # Some functions have a prototype only with that define, e.g. confstr
264     AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
265     ;;
266 esac
269 AC_SUBST(LIBRARY)
270 AC_MSG_CHECKING(LIBRARY)
271 if test -z "$LIBRARY"
272 then
273         LIBRARY='libpython$(VERSION).a'
275 AC_MSG_RESULT($LIBRARY)
277 # LDLIBRARY is the name of the library to link against (as opposed to the
278 # name of the library into which to insert object files). BLDLIBRARY is also
279 # the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
280 # is blank as the main program is not linked directly against LDLIBRARY.
281 # LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
282 # systems without shared libraries, LDLIBRARY is the same as LIBRARY
283 # (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
284 # DLLLIBRARY is the shared (i.e., DLL) library.
286 # RUNSHARED is used to run shared python without installed libraries
288 # INSTSONAME is the name of the shared library that will be use to install
289 # on the system - some systems like version suffix, others don't
290 AC_SUBST(LDLIBRARY)
291 AC_SUBST(DLLLIBRARY)
292 AC_SUBST(BLDLIBRARY)
293 AC_SUBST(LDLIBRARYDIR)
294 AC_SUBST(INSTSONAME)
295 AC_SUBST(RUNSHARED)
296 LDLIBRARY="$LIBRARY"
297 BLDLIBRARY='$(LDLIBRARY)'
298 INSTSONAME='$(LDLIBRARY)'
299 DLLLIBRARY=''
300 LDLIBRARYDIR=''
301 RUNSHARED=''
303 # LINKCC is the command that links the python executable -- default is $(CC).
304 # If CXX is set, and if it is needed to link a main function that was
305 # compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
306 # python might then depend on the C++ runtime
307 # This is altered for AIX in order to build the export list before 
308 # linking.
309 AC_SUBST(LINKCC)
310 AC_MSG_CHECKING(LINKCC)
311 if test -z "$LINKCC"
312 then
313         if test -z "$CXX"; then
314               LINKCC="\$(PURIFY) \$(CC)"
315         else
316               echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
317               $CXX -c conftest.$ac_ext 2>&5
318               if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
319                  && test -s conftest$ac_exeext && ./conftest$ac_exeext
320               then
321                  LINKCC="\$(PURIFY) \$(CC)"
322               else
323                  LINKCC="\$(PURIFY) \$(CXX)"
324               fi
325               rm -fr conftest*
326         fi
327         case $ac_sys_system in
328         AIX*)
329            LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";;
330         dgux*)
331            LINKCC="LD_RUN_PATH=$libdir $LINKCC";;
332         Monterey64*)
333            LINKCC="$LINKCC -L/usr/lib/ia64l64";;
334         esac
336 AC_MSG_RESULT($LINKCC)
338 AC_MSG_CHECKING(for --enable-shared)
339 AC_ARG_ENABLE(shared,
340 [  --enable-shared                 disable/enable building shared python library])
342 if test -z "$enable_shared"
343 then 
344   case $ac_sys_system in
345   CYGWIN* | atheos*)
346     enable_shared="yes";;
347   *)
348     enable_shared="no";;
349   esac
351 AC_MSG_RESULT($enable_shared)
354 AC_MSG_CHECKING(LDLIBRARY)
356 # MacOSX framework builds need more magic. LDLIBRARY is the dynamic
357 # library that we build, but we do not want to link against it (we
358 # will find it with a -framework option). For this reason there is an
359 # extra variable BLDLIBRARY against which Python and the extension
360 # modules are linked, BLDLIBRARY. This is normally the same as
361 # LDLIBRARY, but empty for MacOSX framework builds.
362 if test "$enable_framework"
363 then
364   LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
365   LDLIBRARYDIR='$(PYTHONFRAMEWORKDIR)'
366   BLDLIBRARY=''
367 else
368   BLDLIBRARY='$(LDLIBRARY)'
369 fi  
371 # Other platforms follow
372 if test $enable_shared = "yes"; then
373   AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
374   case $ac_sys_system in
375     BeOS*)
376           LDLIBRARY='libpython$(VERSION).so'
377           ;;
378     CYGWIN*)
379           LDLIBRARY='libpython$(VERSION).dll.a'
380           DLLLIBRARY='libpython$(VERSION).dll'
381           ;;
382     SunOS*)
383           LDLIBRARY='libpython$(VERSION).so'
384           BLDLIBRARY='-Wl,-rpath,$(LIBDIR) -L. -lpython$(VERSION)'
385           RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
386           ;;
387     Linux*|GNU*)
388           LDLIBRARY='libpython$(VERSION).so'
389           BLDLIBRARY='-L. -lpython$(VERSION)'
390           RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
391           INSTSONAME="$LDLIBRARY".$SOVERSION
392           ;;
393     hp*|HP*)
394           LDLIBRARY='libpython$(VERSION).sl'
395           BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
396           RUNSHARED=SHLIB_PATH=`pwd`:$SHLIB_PATH
397           ;;
398     OSF*)
399           LDLIBRARY='libpython$(VERSION).so'
400          BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
401           RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
402           ;;
403     atheos*)
404           LDLIBRARY='libpython$(VERSION).so'
405           BLDLIBRARY='-L. -lpython$(VERSION)'
406           RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
407           ;;
408   esac
409   # DG/UX requires some fancy ld contortions to produce a .so from an .a
410   case $MACHDEP in
411   dguxR4)
412         LDLIBRARY='libpython$(VERSION).so'
413         OPT="$OPT -pic"
414         ;;
415   esac
418 AC_MSG_RESULT($LDLIBRARY)
420 AC_PROG_RANLIB
421 AC_SUBST(AR)
422 AC_CHECK_PROGS(AR, ar aal, ar)
424 case $MACHDEP in
425 bsdos*|hp*|HP*)
426         # install -d does not work on BSDI or HP-UX
427         if test -z "$INSTALL"
428         then
429                 INSTALL="${srcdir}/install-sh -c"
430         fi
431 esac
432 AC_PROG_INSTALL
434 # Not every filesystem supports hard links
435 AC_SUBST(LN)
436 if test -z "$LN" ; then
437         case $ac_sys_system in
438                 BeOS*) LN="ln -s";;
439                 CYGWIN*) LN="ln -s";;
440                 atheos*) LN="ln -s";;
441                 *) LN=ln;;
442         esac
445 # Check for --with-pydebug
446 AC_MSG_CHECKING(for --with-pydebug)
447 AC_ARG_WITH(pydebug, 
448 [  --with-pydebug                  build with Py_DEBUG defined], [
449 if test "$withval" != no
450 then 
451   AC_DEFINE(Py_DEBUG, 1, 
452   [Define if you want to build an interpreter with many run-time checks.]) 
453   AC_MSG_RESULT(yes); 
454   Py_DEBUG='true'
455 else AC_MSG_RESULT(no); Py_DEBUG='false'
456 fi],
457 [AC_MSG_RESULT(no)])
459 # Optimizer/debugger flags
460 AC_SUBST(OPT)
461 if test -z "$OPT"
462 then
463         case $GCC in
464         yes)
465                 case $ac_cv_prog_cc_g in
466         yes)
467             if test "$Py_DEBUG" = 'true' ; then
468                 # Optimization messes up debuggers, so turn it off for
469                 # debug builds.
470                 OPT="-g -Wall -Wstrict-prototypes"
471             else
472                 OPT="-g -O3 -Wall -Wstrict-prototypes"
473             fi;;
474         *)
475             OPT="-O3 -Wall -Wstrict-prototypes";;
476         esac
477         case $ac_sys_system in
478             SCO_SV*) OPT="$OPT -m486 -DSCO5";;
479         esac
480         ;;
481     *)
482         case $ac_sys_system in
483         OpenUNIX*|UnixWare*)
484             OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
485         SCO_SV*)
486             CFLAGS="$CFLAGS -belf"
487             OPT="-belf -O -Ki486 -DSCO5";;
488         *)
489             OPT="-O";;
490         esac
491     esac
492     case $ac_sys_system in
493     Darwin*)
494         OPT="$OPT -Wno-long-double -no-cpp-precomp";;
495     esac
498 if test "$Py_DEBUG" = 'true'; then
499   :
500 else
501   OPT="-DNDEBUG $OPT"
504 # The current (beta) Monterey compiler dies with optimizations
505 case $ac_sys_system in
506 Monterey*) OPT="";;
507 esac
509 if test "$ac_arch_flags"
510 then
511         OPT="$OPT $ac_arch_flags"
514 AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
515 AC_CACHE_VAL(ac_cv_opt_olimit_ok,
516 [ac_save_cc="$CC"
517 CC="$CC -OPT:Olimit=0"
518 AC_TRY_RUN([int main() { return 0; }],
519   ac_cv_opt_olimit_ok=yes,
520   ac_cv_opt_olimit_ok=no,
521   ac_cv_opt_olimit_ok=no)
522 CC="$ac_save_cc"])
523 AC_MSG_RESULT($ac_cv_opt_olimit_ok)
524 if test $ac_cv_opt_olimit_ok = yes; then
525     case $ac_sys_system in
526       Darwin*) OPT="$OPT" ;;
527       *) OPT="$OPT -OPT:Olimit=0";;
528     esac
529 else
530   AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
531   AC_CACHE_VAL(ac_cv_olimit_ok,
532   [ac_save_cc="$CC"
533   CC="$CC -Olimit 1500"
534   AC_TRY_RUN([int main() { return 0; }],
535     ac_cv_olimit_ok=yes,
536     ac_cv_olimit_ok=no,
537     ac_cv_olimit_ok=no)
538   CC="$ac_save_cc"])
539   AC_MSG_RESULT($ac_cv_olimit_ok)
540   if test $ac_cv_olimit_ok = yes; then
541     OPT="$OPT -Olimit 1500"
542   fi
545 # On some compilers, pthreads are available without further options
546 # (e.g. MacOS X). On some of these systems, the compiler will not
547 # complain if unaccepted options are passed (e.g. gcc on Mac OS X).
548 # So we have to see first whether pthreads are available without
549 # options before we can check whether -Kpthread improves anything.
550 AC_MSG_CHECKING(whether pthreads are available without options)
551 AC_CACHE_VAL(ac_cv_pthread_is_default,
552 [AC_TRY_RUN([
553 #include <pthread.h>
555 void* routine(void* p){return NULL;}
557 int main(){
558   pthread_t p;
559   if(pthread_create(&p,NULL,routine,NULL)!=0)
560     return 1;
561   (void)pthread_detach(p);
562   return 0;
565   ac_cv_pthread_is_default=yes,
566   ac_cv_pthread_is_default=no,
567   ac_cv_pthread_is_default=no)
569 AC_MSG_RESULT($ac_cv_pthread_is_default)
572 if test $ac_cv_pthread_is_default = yes 
573 then
574   ac_cv_kpthread=no
575 else
576 # -Kpthread, if available, provides the right #defines
577 # and linker options to make pthread_create available
578 # Some compilers won't report that they do not support -Kpthread,
579 # so we need to run a program to see whether it really made the
580 # function available.
581 AC_MSG_CHECKING(whether $CC accepts -Kpthread)
582 AC_CACHE_VAL(ac_cv_kpthread,
583 [ac_save_cc="$CC"
584 CC="$CC -Kpthread"
585 AC_TRY_RUN([
586 #include <pthread.h>
588 void* routine(void* p){return NULL;}
590 int main(){
591   pthread_t p;
592   if(pthread_create(&p,NULL,routine,NULL)!=0)
593     return 1;
594   (void)pthread_detach(p);
595   return 0;
598   ac_cv_kpthread=yes,
599   ac_cv_kpthread=no,
600   ac_cv_kpthread=no)
601 CC="$ac_save_cc"])
602 AC_MSG_RESULT($ac_cv_kpthread)
605 dnl # check for ANSI or K&R ("traditional") preprocessor
606 dnl AC_MSG_CHECKING(for C preprocessor type)
607 dnl AC_TRY_COMPILE([
608 dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
609 dnl int foo;
610 dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
611 dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
612 dnl AC_MSG_RESULT($cpp_type)
614 # checks for header files
615 AC_HEADER_STDC
616 AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h \
617 libintl.h locale.h ncurses.h poll.h pthread.h \
618 signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
619 sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
620 sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
621 sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
622 sys/resource.h netpacket/packet.h)
623 AC_HEADER_DIRENT
625 # checks for typedefs
626 was_it_defined=no
627 AC_MSG_CHECKING(for clock_t in time.h)
628 AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
629     AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
631 AC_MSG_RESULT($was_it_defined)
633 # Check whether using makedev requires defining _OSF_SOURCE
634 AC_MSG_CHECKING(for makedev)
635 AC_TRY_LINK([ #include <sys/types.h> ],
636             [ makedev(0, 0) ],
637             ac_cv_has_makedev=yes,
638             ac_cv_has_makedev=no)
639 if test "$ac_cv_has_makedev" = "no"; then
640     # we didn't link, try if _OSF_SOURCE will allow us to link
641     AC_TRY_LINK([
642     #define _OSF_SOURCE 1
643     #include <sys/types.h>
644     ],
645     [ makedev(0, 0) ],
646     ac_cv_has_makedev=yes,
647     ac_cv_has_makedev=no)
648     if test "$ac_cv_has_makedev" = "yes"; then
649         AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
650     fi
652 AC_MSG_RESULT($ac_cv_has_makedev)
653 if test "$ac_cv_has_makedev" = "yes"; then
654     AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
657 # Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
658 # the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
659 # defined, but the compiler does not support pragma redefine_extname,
660 # and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
661 # structures (such as rlimit64) without declaring them. As a
662 # work-around, disable LFS on such configurations
664 use_lfs=yes
665 AC_MSG_CHECKING(Solaris LFS bug)
666 AC_TRY_COMPILE([
667 #define _LARGEFILE_SOURCE 1
668 #define _FILE_OFFSET_BITS 64
669 #include <sys/resource.h>
670 ],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
671 AC_MSG_RESULT($sol_lfs_bug)
672 if test "$sol_lfs_bug" = "yes"; then
673   use_lfs=no
676 if test "$use_lfs" = "yes"; then
677 # Two defines needed to enable largefile support on various platforms
678 # These may affect some typedefs
679 AC_DEFINE(_LARGEFILE_SOURCE, 1, 
680 [This must be defined on some systems to enable large file support.])
681 AC_DEFINE(_FILE_OFFSET_BITS, 64,
682 [This must be set to 64 on some systems to enable large file support.])
685 # Add some code to confdefs.h so that the test for off_t works on SCO
686 cat >> confdefs.h <<\EOF
687 #if defined(SCO_DS)
688 #undef _OFF_T
689 #endif
692 # Type availability checks
693 AC_TYPE_MODE_T
694 AC_TYPE_OFF_T
695 AC_TYPE_PID_T
696 AC_TYPE_SIGNAL
697 AC_TYPE_SIZE_T
698 AC_TYPE_UID_T
700 # Sizes of various common basic types
701 AC_CHECK_SIZEOF(int, 4)
702 AC_CHECK_SIZEOF(long, 4)
703 AC_CHECK_SIZEOF(void *, 4)
704 AC_CHECK_SIZEOF(char, 1)
705 AC_CHECK_SIZEOF(short, 2)
706 AC_CHECK_SIZEOF(float, 4)
707 AC_CHECK_SIZEOF(double, 8)
708 AC_CHECK_SIZEOF(fpos_t, 4)
710 AC_MSG_CHECKING(for long long support)
711 have_long_long=no
712 AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
713   AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.]) 
714   have_long_long=yes
716 AC_MSG_RESULT($have_long_long)
717 if test "$have_long_long" = yes ; then
718 AC_CHECK_SIZEOF(long long, 8)
721 AC_MSG_CHECKING(for uintptr_t support)
722 have_uintptr_t=no
723 AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], [
724   AC_DEFINE(HAVE_UINTPTR_T, 1, [Define this if you have the type uintptr_t.]) 
725   have_uintptr_t=yes
727 AC_MSG_RESULT($have_uintptr_t)
728 if test "$have_uintptr_t" = yes ; then
729 AC_CHECK_SIZEOF(uintptr_t, 4)
732 # Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
733 AC_MSG_CHECKING(size of off_t)
734 AC_CACHE_VAL(ac_cv_sizeof_off_t,
735 [AC_TRY_RUN([#include <stdio.h>
736 #include <sys/types.h>
737 main()
739   FILE *f=fopen("conftestval", "w");
740   if (!f) exit(1);
741   fprintf(f, "%d\n", sizeof(off_t));
742   exit(0);
744 ac_cv_sizeof_off_t=`cat conftestval`,
745 ac_cv_sizeof_off_t=0,
746 ac_cv_sizeof_off_t=4)
748 AC_MSG_RESULT($ac_cv_sizeof_off_t)
749 AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
750 [The number of bytes in an off_t.])
752 AC_MSG_CHECKING(whether to enable large file support)
753 if test "$have_long_long" = yes -a \
754         "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
755         "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
756   AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1, 
757   [Defined to enable large file support when an off_t is bigger than a long
758    and long long is available and at least as big as an off_t. You may need
759    to add some flags for configuration and compilation to enable this mode.
760    (For Solaris and Linux, the necessary defines are already defined.)])
761   AC_MSG_RESULT(yes)
762 else
763   AC_MSG_RESULT(no)
766 # AC_CHECK_SIZEOF() doesn't include <time.h>.
767 AC_MSG_CHECKING(size of time_t)
768 AC_CACHE_VAL(ac_cv_sizeof_time_t,
769 [AC_TRY_RUN([#include <stdio.h>
770 #include <time.h>
771 main()
773   FILE *f=fopen("conftestval", "w");
774   if (!f) exit(1);
775   fprintf(f, "%d\n", sizeof(time_t));
776   exit(0);
778 ac_cv_sizeof_time_t=`cat conftestval`,
779 ac_cv_sizeof_time_t=0,
780 ac_cv_sizeof_time_t=4)
782 AC_MSG_RESULT($ac_cv_sizeof_time_t)
783 AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t, 
784 [The number of bytes in a time_t.])
787 # if have pthread_t then define SIZEOF_PTHREAD_T
788 ac_save_cc="$CC"
789 if test "$ac_cv_kpthread" = "yes"
790 then CC="$CC -Kpthread"
792 AC_MSG_CHECKING(for pthread_t)
793 have_pthread_t=no
794 AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
795 AC_MSG_RESULT($have_pthread_t)
796 if test "$have_pthread_t" = yes ; then
797   # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
798   AC_MSG_CHECKING(size of pthread_t)
799   AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
800   [AC_TRY_RUN([#include <stdio.h>
801   #include <pthread.h>
802   main()
803   {
804     FILE *f=fopen("conftestval", "w");
805     if (!f) exit(1);
806     fprintf(f, "%d\n", sizeof(pthread_t));
807     exit(0);
808   }],
809   ac_cv_sizeof_pthread_t=`cat conftestval`,
810   ac_cv_sizeof_pthread_t=0,
811   ac_cv_sizeof_pthread_t=4)
812   ])
813   AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
814   AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
815    [The number of bytes in a pthread_t.])
817 CC="$ac_save_cc"
819 AC_MSG_CHECKING(for --enable-toolbox-glue)
820 AC_ARG_ENABLE(toolbox-glue,
821 [  --enable-toolbox-glue            disable/enable MacOSX glue code for extensions])
823 if test -z "$enable_toolbox_glue"
824 then 
825         case $ac_sys_system/$ac_sys_release in
826         Darwin/*)
827                 enable_toolbox_glue="yes";;
828         *)
829                 enable_toolbox_glue="no";;
830         esac
832 case "$enable_toolbox_glue" in
833 yes)
834         extra_frameworks="-framework CoreServices -framework Foundation"
835         extra_machdep_objs="Python/mactoolboxglue.o"
836         extra_undefs="-u __dummy -u _PyMac_Error"
837         AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
838          [Define if you want to use MacPython modules on MacOSX in unix-Python.])
839         ;;
841         extra_frameworks=""
842         extra_machdep_objs=""
843         extra_undefs=""
844         ;;
845 esac
846 AC_MSG_RESULT($enable_toolbox_glue)
848 AC_SUBST(LIBTOOL_CRUFT)
849 case $ac_sys_system/$ac_sys_release in
850   Darwin/1.3*)
851     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
852         LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
853     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
854     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
855   Darwin/*)
856     LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
857       LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
858     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
859     LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
860 esac
862 AC_MSG_CHECKING(for --enable-framework)
863 if test "$enable_framework"
864 then
865         OPT="$OPT -fno-common -dynamic"
866         # -F. is needed to allow linking to the framework while 
867         # in the build location.
868         LDFLAGS="$LDFLAGS -Wl,-F."
869         AC_DEFINE(WITH_NEXT_FRAMEWORK, 1, 
870          [Define if you want to produce an OpenStep/Rhapsody framework
871          (shared library plus accessory files).])
872         AC_MSG_RESULT(yes)
873 else
874         AC_MSG_RESULT(no)
877 AC_MSG_CHECKING(for dyld)
878 case $ac_sys_system/$ac_sys_release in
879   Darwin/*)
880         AC_DEFINE(WITH_DYLD, 1, 
881         [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
882          dynamic linker (dyld) instead of the old-style (NextStep) dynamic
883          linker (rld). Dyld is necessary to support frameworks.])
884         AC_MSG_RESULT(always on for Darwin)
885         ;;
886   *)
887         AC_MSG_RESULT(no)
888         ;;
889 esac
891 # Set info about shared libraries.
892 AC_SUBST(SO)
893 AC_SUBST(LDSHARED)
894 AC_SUBST(BLDSHARED)
895 AC_SUBST(CCSHARED)
896 AC_SUBST(LINKFORSHARED)
897 # SO is the extension of shared libraries `(including the dot!)
898 # -- usually .so, .sl on HP-UX, .dll on Cygwin
899 AC_MSG_CHECKING(SO)
900 if test -z "$SO"
901 then
902         case $ac_sys_system in
903         hp*|HP*)   SO=.sl;;
904         CYGWIN*)   SO=.dll;;
905         *)         SO=.so;;
906         esac
908 AC_MSG_RESULT($SO)
909 # LDSHARED is the ld *command* used to create shared library
910 # -- "ld" on SunOS 4.x.x, "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
911 # (Shared libraries in this instance are shared modules to be loaded into
912 # Python, as opposed to building Python itself as a shared library.)
913 AC_MSG_CHECKING(LDSHARED)
914 if test -z "$LDSHARED"
915 then
916         case $ac_sys_system/$ac_sys_release in
917         AIX*)
918                 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
919                 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
920                 ;;
921         BeOS*)
922                 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
923                 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
924                 ;;
925         IRIX/5*) LDSHARED="ld -shared";;
926         IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
927         SunOS/4*) LDSHARED="ld";;
928         SunOS/5*) 
929                 if test "$GCC" = "yes"
930                 then LDSHARED='$(CC) -shared'
931                 else LDSHARED='$(CC) -G';
932                 fi ;;
933         hp*|HP*) LDSHARED="ld -b";;
934         OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
935         DYNIX/ptx*) LDSHARED="ld -G";;
936         Darwin/1.3*)
937                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
938                 if test "$enable_framework" ; then
939                         # Link against the framework. All externals should be defined.
940                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
941                 else
942                         # No framework. Ignore undefined symbols, assuming they come from Python
943                         LDSHARED="$LDSHARED -undefined suppress"
944                 fi ;;
945         Darwin/*)
946                 LDSHARED='$(CC) $(LDFLAGS) -bundle'
947                 if test "$enable_framework" ; then
948                         # Link against the framework. All externals should be defined.
949                         LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
950                 else
951                         # No framework, use the Python app as bundle-loader
952                         BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
953                         LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/$(PYTHON)'
954                 fi ;;
955         Linux*|GNU*) LDSHARED='$(CC) -shared';;
956         dgux*) LDSHARED="ld -G";;
957         BSD/OS*/4*) LDSHARED="gcc -shared";;
958         OpenBSD*|FreeBSD*)
959                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
960                 then
961                         LDSHARED="cc -shared ${LDFLAGS}"
962                 else
963                         LDSHARED="ld -Bshareable ${LDFLAGS}"
964                 fi;;
965         NetBSD*) LDSHARED="cc -shared ${LDFLAGS}";;
966         OpenUNIX*|UnixWare*)
967                 if test "$GCC" = "yes"
968                 then LDSHARED="$(CC) -shared"
969                 else LDSHARED="$(CC) -G"
970                 fi;;
971         SCO_SV*) LDSHARED="$(CC) -Wl,-G,-Bexport";;
972         Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
973         CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
974         atheos*) LDSHARED="gcc -shared";;
975         *)      LDSHARED="ld";;
976         esac
978 AC_MSG_RESULT($LDSHARED)
979 BLDSHARED=${BLDSHARED-$LDSHARED}
980 # CCSHARED are the C *flags* used to create objects to go into a shared
981 # library (module) -- this is only needed for a few systems
982 AC_MSG_CHECKING(CCSHARED)
983 if test -z "$CCSHARED"
984 then
985         case $ac_sys_system/$ac_sys_release in
986         SunOS*) if test "$GCC" = yes;
987                 then CCSHARED="-fPIC";
988                 fi;;
989         hp*|HP*) if test "$GCC" = yes;
990                  then CCSHARED="-fPIC";
991                  else CCSHARED="+z";
992                  fi;;
993         Linux*|GNU*) CCSHARED="-fPIC";;
994         BSD/OS*/4*) CCSHARED="-fpic";;
995         FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
996         OpenUNIX*|UnixWare*)
997                 if test "$GCC" = "yes"
998                 then CCSHARED="-fPIC"
999                 else CCSHARED="-KPIC"
1000                 fi;;
1001         SCO_SV*)
1002                 if test "$GCC" = "yes"
1003                 then CCSHARED="-fPIC"
1004                 else CCSHARED="-Kpic -belf"
1005                 fi;;
1006         Monterey*) CCSHARED="-G";;
1007         IRIX*/6*)  case $CC in
1008                    *gcc*) CCSHARED="-shared";;
1009                    *) CCSHARED="";;
1010                    esac;;
1011         atheos*) CCSHARED="-fPIC";;
1012         esac
1014 AC_MSG_RESULT($CCSHARED)
1015 # LINKFORSHARED are the flags passed to the $(CC) command that links
1016 # the python executable -- this is only needed for a few systems
1017 AC_MSG_CHECKING(LINKFORSHARED)
1018 if test -z "$LINKFORSHARED"
1019 then
1020         case $ac_sys_system/$ac_sys_release in
1021         AIX*)   LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1022         hp*|HP*)
1023             LINKFORSHARED="-Wl,-E -Wl,+s";;
1024 #           LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1025         BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1026         Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1027         # -u libsys_s pulls in all symbols in libsys
1028         Darwin/*) 
1029                 # -u __dummy makes the linker aware of the objc runtime
1030                 # in System.framework; otherwise, __objcInit (referenced in
1031                 # crt1.o) gets erroneously defined as common, which breaks dynamic
1032                 # loading of any modules which reference it in System.framework.
1033                 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
1034                 # not used by the core itself but which needs to be in the core so
1035                 # that dynamically loaded extension modules have access to it.
1036                 LINKFORSHARED="$extra_undefs -framework System"
1037                 if test "$enable_framework"
1038                 then
1039                         LINKFORSHARED="$LINKFORSHARED -framework Python"
1040                 fi
1041                 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
1042         OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1043         SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1044         ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1045         FreeBSD*|NetBSD*|OpenBSD*) 
1046                 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1047                 then
1048                         LINKFORSHARED="-Wl,--export-dynamic"
1049                 fi;;
1050         SunOS/5*) case $CC in
1051                   *gcc*)
1052                     if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1053                     then
1054                         LINKFORSHARED="-Xlinker --export-dynamic"
1055                     fi;;
1056                   esac;;
1057         esac
1059 AC_MSG_RESULT($LINKFORSHARED)
1061 AC_SUBST(CFLAGSFORSHARED)
1062 AC_MSG_CHECKING(CFLAGSFORSHARED)
1063 if test ! "$LIBRARY" = "$LDLIBRARY"
1064 then
1065         case $ac_sys_system in
1066         CYGWIN*)
1067                 # Cygwin needs CCSHARED when building extension DLLs
1068                 # but not when building the interpreter DLL.
1069                 CFLAGSFORSHARED='';;
1070         *)
1071                 CFLAGSFORSHARED='$(CCSHARED)'
1072         esac
1074 AC_MSG_RESULT($CFLAGSFORSHARED)
1076 # SHLIBS are libraries (except -lc and -lm) to link to the python shared
1077 # library (with --enable-shared).
1078 # For platforms on which shared libraries are not allowed to have unresolved
1079 # symbols, this must be set to $(LIBS) (expanded by make). We do this even
1080 # if it is not required, since it creates a dependency of the shared library
1081 # to LIBS. This, in turn, means that applications linking the shared libpython
1082 # don't need to link LIBS explicitly. The default should be only changed
1083 # on systems where this approach causes problems.
1084 AC_SUBST(SHLIBS)
1085 AC_MSG_CHECKING(SHLIBS)
1086 case "$ac_sys_system" in
1087         *)
1088                 SHLIBS='$(LIBS)';;
1089 esac
1090 AC_MSG_RESULT($SHLIBS)
1093 # checks for libraries
1094 AC_CHECK_LIB(dl, dlopen)        # Dynamic linking for SunOS/Solaris and SYSV
1095 AC_CHECK_LIB(dld, shl_load)     # Dynamic linking for HP-UX
1096 AC_SEARCH_LIBS(sem_init, rt posix4)     # 'Real Time' functions on Solaris,
1097                                         # posix4 on Solaris 2.6
1099 # checks for system dependent C++ extensions support
1100 case "$ac_sys_system" in
1101         AIX*)   AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1102                 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1103                             [loadAndInit("", 0, "")],
1104                             [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1105                       [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1106                        and you want support for AIX C++ shared extension modules.])
1107                              AC_MSG_RESULT(yes)],
1108                             [AC_MSG_RESULT(no)]);;
1109         *) ;;
1110 esac
1112 # Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1113 # However on SGI IRIX, these exist but are broken.
1114 # BeOS' sockets are stashed in libnet.
1115 case "$ac_sys_system" in
1116 IRIX*) ;;
1118 AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1119 AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1121 esac
1122 case "$ac_sys_system" in
1123 BeOS*)
1124 AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1126 esac
1128 AC_MSG_CHECKING(for --with-libs)
1129 AC_ARG_WITH(libs,
1130 [  --with-libs='lib1 ...'          link against additional libs], [
1131 AC_MSG_RESULT($withval)
1132 LIBS="$withval $LIBS"
1133 ], AC_MSG_RESULT(no))
1135 # Determine if signalmodule should be used.
1136 AC_SUBST(USE_SIGNAL_MODULE)
1137 AC_SUBST(SIGNAL_OBJS)
1138 AC_MSG_CHECKING(for --with-signal-module)
1139 AC_ARG_WITH(signal-module,
1140 [  --with-signal-module            disable/enable signal module])
1142 if test -z "$with_signal_module"
1143 then with_signal_module="yes"
1145 AC_MSG_RESULT($with_signal_module)
1147 if test "${with_signal_module}" = "yes"; then
1148         USE_SIGNAL_MODULE=""
1149         SIGNAL_OBJS=""
1150 else
1151         USE_SIGNAL_MODULE="#"
1152         SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1155 # This is used to generate Setup.config
1156 AC_SUBST(USE_THREAD_MODULE)
1157 USE_THREAD_MODULE=""
1159 AC_MSG_CHECKING(for --with-dec-threads)
1160 AC_SUBST(LDLAST)
1161 AC_ARG_WITH(dec-threads,
1162 [  --with-dec-threads              use DEC Alpha/OSF1 thread-safe libraries], [
1163 AC_MSG_RESULT($withval)
1164 LDLAST=-threads
1165 if test "${with_thread+set}" != set; then
1166    with_thread="$withval";
1167 fi],
1168 AC_MSG_RESULT(no))
1170 # Templates for things AC_DEFINEd more than once.
1171 # For a single AC_DEFINE, no template is needed.
1172 AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1173 AH_TEMPLATE(_REENTRANT,
1174   [Define to force use of thread-safe errno, h_errno, and other functions])
1175 AH_TEMPLATE(WITH_THREAD,
1176   [Define if you want to compile in rudimentary thread support])
1178 AC_MSG_CHECKING(for --with-threads)
1179 AC_ARG_WITH(threads,
1180 [  --with(out)-threads[=DIRECTORY] disable/enable thread support])
1182 # --with-thread is deprecated, but check for it anyway
1183 AC_ARG_WITH(thread,
1184 [  --with(out)-thread[=DIRECTORY]  deprecated; use --with(out)-threads],[
1185 with_threads=$with_thread])
1187 if test -z "$with_threads"
1188 then with_threads="yes"
1190 AC_MSG_RESULT($with_threads)
1192 AC_SUBST(THREADOBJ)
1193 if test "$with_threads" = "no"
1194 then
1195     USE_THREAD_MODULE="#"
1196 elif test "$ac_cv_pthread_is_default" = yes
1197 then
1198     AC_DEFINE(WITH_THREAD)
1199     # Defining _REENTRANT on system with POSIX threads should not hurt.
1200     AC_DEFINE(_REENTRANT)
1201     posix_threads=yes
1202     THREADOBJ="Python/thread.o"    
1203 elif test "$ac_cv_kpthread" = "yes"
1204 then
1205     CC="$CC -Kpthread"
1206     AC_DEFINE(WITH_THREAD)
1207     posix_threads=yes
1208     THREADOBJ="Python/thread.o"
1209 else
1210     if test ! -z "$with_threads" -a -d "$with_threads"
1211     then LDFLAGS="$LDFLAGS -L$with_threads"
1212     fi
1213     if test ! -z "$withval" -a -d "$withval"
1214     then LDFLAGS="$LDFLAGS -L$withval"
1215     fi
1217     # According to the POSIX spec, a pthreads implementation must
1218     # define _POSIX_THREADS in unistd.h. Some apparently don't (which ones?)
1219     AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1220     AC_EGREP_CPP(yes,
1221     [#include <unistd.h>
1222      #ifdef _POSIX_THREADS
1223      yes
1224      #endif
1225     ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1226     AC_MSG_RESULT($unistd_defines_pthreads)
1228     AC_DEFINE(_REENTRANT)
1229     AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1230     AC_DEFINE(C_THREADS)
1231     AC_DEFINE(HURD_C_THREADS, 1,
1232     [Define if you are using Mach cthreads directly under /include])
1233     LIBS="$LIBS -lthreads"
1234     THREADOBJ="Python/thread.o"],[
1235     AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1236     AC_DEFINE(C_THREADS)
1237     AC_DEFINE(MACH_C_THREADS, 1,
1238     [Define if you are using Mach cthreads under mach /])
1239     THREADOBJ="Python/thread.o"],[
1240     AC_MSG_CHECKING(for --with-pth)
1241     AC_ARG_WITH(pth,
1242     [  --with-pth                      use GNU pth threading libraries], [
1243     AC_MSG_RESULT($withval)
1244     AC_DEFINE(WITH_THREAD)
1245     AC_DEFINE(HAVE_PTH, 1, [Define if you have GNU PTH threads.])
1246     LIBS="-lpth $LIBS"
1247     THREADOBJ="Python/thread.o"],[
1248     AC_MSG_RESULT(no)
1250     # Just looking for pthread_create in libpthread is not enough:
1251     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1252     # So we really have to include pthread.h, and then link.
1253     _libs=$LIBS
1254     LIBS="$LIBS -lpthread"
1255     AC_MSG_CHECKING([for pthread_create in -lpthread])
1256     AC_TRY_LINK([#include <pthread.h>
1258 void * start_routine (void *arg) { exit (0); }], [
1259 pthread_create (NULL, NULL, start_routine, NULL)], [
1260     AC_MSG_RESULT(yes)
1261     AC_DEFINE(WITH_THREAD)
1262     posix_threads=yes
1263     THREADOBJ="Python/thread.o"],[
1264     LIBS=$_libs
1265     AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
1266     posix_threads=yes
1267     THREADOBJ="Python/thread.o"],[
1268     AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1269     AC_DEFINE(ATHEOS_THREADS, 1,
1270     [Define this if you have AtheOS threads.])
1271     THREADOBJ="Python/thread.o"],[
1272     AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1273     AC_DEFINE(BEOS_THREADS, 1,
1274     [Define this if you have BeOS threads.])
1275     THREADOBJ="Python/thread.o"],[
1276     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
1277     posix_threads=yes
1278     LIBS="$LIBS -lpthreads"
1279     THREADOBJ="Python/thread.o"], [
1280     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
1281     posix_threads=yes
1282     LIBS="$LIBS -lc_r"
1283     THREADOBJ="Python/thread.o"], [
1284     AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
1285     posix_threads=yes
1286     LIBS="$LIBS -lthread"
1287     THREADOBJ="Python/thread.o"], [
1288     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
1289     posix_threads=yes
1290     LIBS="$LIBS -lpthread"
1291     THREADOBJ="Python/thread.o"], [
1292     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
1293     posix_threads=yes
1294     LIBS="$LIBS -lcma"
1295     THREADOBJ="Python/thread.o"],[
1296     USE_THREAD_MODULE="#"])
1297     ])])])])])])])])])])])
1299     if test "$posix_threads" = "yes"; then
1300       if test "$unistd_defines_pthreads" = "no"; then
1301          AC_DEFINE(_POSIX_THREADS, 1,
1302          [Define if you have POSIX threads, 
1303           and your system does not define that.])
1304       fi
1306       AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
1307       AC_CACHE_VAL(ac_cv_pthread_system_supported,
1308       [AC_TRY_RUN([#include <pthread.h>
1309       void *foo(void *parm) {
1310         return NULL;
1311       }
1312       main() {
1313         pthread_attr_t attr;
1314         pthread_t id;
1315         if (pthread_attr_init(&attr)) exit(-1);
1316         if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
1317         if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
1318         exit(0);
1319       }],
1320       ac_cv_pthread_system_supported=yes,
1321       ac_cv_pthread_system_supported=no,
1322       ac_cv_pthread_system_supported=no)
1323       ])
1324       AC_MSG_RESULT($ac_cv_pthread_system_supported)
1325       if test "$ac_cv_pthread_system_supported" = "yes"; then
1326         AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
1327       fi
1328       AC_CHECK_FUNCS(pthread_sigmask)
1329     fi
1331     AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1332     LIBS="$LIBS -lmpc"
1333     THREADOBJ="Python/thread.o"
1334     USE_THREAD_MODULE=""])
1336     if test $posix_threads != "yes"; then     
1337       AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1338       LIBS="$LIBS -lthread"
1339       THREADOBJ="Python/thread.o"
1340       USE_THREAD_MODULE=""])
1341     fi
1343     if test "$USE_THREAD_MODULE" != "#"
1344     then
1345         # If the above checks didn't disable threads, (at least) OSF1
1346         # needs this '-threads' argument during linking.
1347         case $ac_sys_system in
1348         OSF1) LDLAST=-threads;;
1349         esac
1350     fi
1352     if test "$posix_threads" = yes -a \
1353                 "$ac_sys_system" = "SunOS" -a \
1354                 "$ac_sys_release" = "5.6"; then
1355                 AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
1356                 [Defined for Solaris 2.6 bug in pthread header.])
1357         fi
1361 # Check for enable-ipv6
1362 AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
1363 AC_MSG_CHECKING([if --enable-ipv6 is specified])
1364 AC_ARG_ENABLE(ipv6,
1365 [  --enable-ipv6                   Enable ipv6 (with ipv4) support
1366   --disable-ipv6                  Disable ipv6 support],
1367 [ case "$enableval" in
1368   no)
1369        AC_MSG_RESULT(no)
1370        ipv6=no
1371        ;;
1372   *)   AC_MSG_RESULT(yes)
1373        AC_DEFINE(ENABLE_IPV6)
1374        ipv6=yes
1375        ;;
1376   esac ],
1379 dnl the check does not work on cross compilation case...
1380   AC_TRY_RUN([ /* AF_INET6 available check */
1381 #include <sys/types.h>
1382 #include <sys/socket.h>
1383 main()
1385  if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1386    exit(1);
1387  else
1388    exit(0);
1391   AC_MSG_RESULT(yes)
1392   ipv6=yes,
1393   AC_MSG_RESULT(no)
1394   ipv6=no,
1395   AC_MSG_RESULT(no)
1396   ipv6=no
1399 if test "$ipv6" = "yes"; then
1400         AC_MSG_CHECKING(if RFC2553 API is available)
1401         AC_TRY_COMPILE([#include <sys/types.h>
1402 #include <netinet/in.h>],
1403         [struct sockaddr_in6 x;
1404 x.sin6_scope_id;],
1405                 AC_MSG_RESULT(yes)
1406                 ipv6=yes,
1407                 AC_MSG_RESULT(no, IPv6 disabled)
1408                 ipv6=no)
1411 if test "$ipv6" = "yes"; then
1412         AC_DEFINE(ENABLE_IPV6)
1416 ipv6type=unknown
1417 ipv6lib=none
1418 ipv6trylibc=no
1420 if test "$ipv6" = "yes"; then
1421         AC_MSG_CHECKING([ipv6 stack type])
1422         for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1423         do
1424                 case $i in
1425                 inria)
1426                         dnl http://www.kame.net/
1427                         AC_EGREP_CPP(yes, [
1428 #include <netinet/in.h>
1429 #ifdef IPV6_INRIA_VERSION
1431 #endif],
1432                                 [ipv6type=$i])
1433                         ;;
1434                 kame)
1435                         dnl http://www.kame.net/
1436                         AC_EGREP_CPP(yes, [
1437 #include <netinet/in.h>
1438 #ifdef __KAME__
1440 #endif],
1441                                 [ipv6type=$i;
1442                                 ipv6lib=inet6
1443                                 ipv6libdir=/usr/local/v6/lib
1444                                 ipv6trylibc=yes])
1445                         ;;
1446                 linux-glibc)
1447                         dnl http://www.v6.linux.or.jp/
1448                         AC_EGREP_CPP(yes, [
1449 #include <features.h>
1450 #if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1452 #endif],
1453                                 [ipv6type=$i;
1454                                 ipv6trylibc=yes])
1455                         ;;
1456                 linux-inet6)
1457                         dnl http://www.v6.linux.or.jp/
1458                         if test -d /usr/inet6; then
1459                                 ipv6type=$i
1460                                 ipv6lib=inet6
1461                                 ipv6libdir=/usr/inet6/lib
1462                                 OPT="-I/usr/inet6/include $OPT"
1463                         fi
1464                         ;;
1465                 solaris)
1466                         if test -f /etc/netconfig; then
1467                           if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1468                                 ipv6type=$i
1469                                 ipv6trylibc=yes
1470                           fi
1471                         fi
1472                         ;;
1473                 toshiba)
1474                         AC_EGREP_CPP(yes, [
1475 #include <sys/param.h>
1476 #ifdef _TOSHIBA_INET6
1478 #endif],
1479                                 [ipv6type=$i;
1480                                 ipv6lib=inet6;
1481                                 ipv6libdir=/usr/local/v6/lib])
1482                         ;;
1483                 v6d)
1484                         AC_EGREP_CPP(yes, [
1485 #include </usr/local/v6/include/sys/v6config.h>
1486 #ifdef __V6D__
1488 #endif],
1489                                 [ipv6type=$i;
1490                                 ipv6lib=v6;
1491                                 ipv6libdir=/usr/local/v6/lib;
1492                                 OPT="-I/usr/local/v6/include $OPT"])
1493                         ;;
1494                 zeta)
1495                         AC_EGREP_CPP(yes, [
1496 #include <sys/param.h>
1497 #ifdef _ZETA_MINAMI_INET6
1499 #endif],
1500                                 [ipv6type=$i;
1501                                 ipv6lib=inet6;
1502                                 ipv6libdir=/usr/local/v6/lib])
1503                         ;;
1504                 esac
1505                 if test "$ipv6type" != "unknown"; then
1506                         break
1507                 fi
1508         done
1509         AC_MSG_RESULT($ipv6type)
1512 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1513         if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1514                 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1515                 echo "using lib$ipv6lib"
1516         else
1517                 if test $ipv6trylibc = "yes"; then
1518                         echo "using libc"
1519                 else
1520                         echo 'Fatal: no $ipv6lib library found.  cannot continue.'
1521                         echo "You need to fetch lib$ipv6lib.a from appropriate"
1522                         echo 'ipv6 kit and compile beforehand.'
1523                         exit 1
1524                 fi
1525         fi
1528 # Check for universal newline support
1529 AC_MSG_CHECKING(for --with-universal-newlines)
1530 AC_ARG_WITH(universal-newlines,
1531 [  --with(out)-universal-newlines            disable/enable foreign newlines])
1533 if test -z "$with_universal_newlines"
1534 then with_universal_newlines="yes"
1536 if test "$with_universal_newlines" != "no"
1537 then
1538     AC_DEFINE(WITH_UNIVERSAL_NEWLINES, 1,
1539       [Define if you want to read files with foreign newlines.])
1541 AC_MSG_RESULT($with_universal_newlines)
1543 # Check for --with-doc-strings
1544 AC_MSG_CHECKING(for --with-doc-strings)
1545 AC_ARG_WITH(doc-strings,
1546 [  --with(out)-doc-strings         disable/enable documentation strings])
1548 if test -z "$with_doc_strings"
1549 then with_doc_strings="yes"
1551 if test "$with_doc_strings" != "no"
1552 then
1553     AC_DEFINE(WITH_DOC_STRINGS, 1,
1554       [Define if you want documentation strings in extension modules])
1556 AC_MSG_RESULT($with_doc_strings)
1558 # Check for Python-specific malloc support
1559 AC_MSG_CHECKING(for --with-pymalloc)
1560 AC_ARG_WITH(pymalloc,
1561 [  --with(out)-pymalloc            disable/enable specialized mallocs])
1563 if test -z "$with_pymalloc"
1564 then with_pymalloc="yes"
1566 if test "$with_pymalloc" != "no"
1567 then
1568     AC_DEFINE(WITH_PYMALLOC, 1, 
1569      [Define if you want to compile in Python-specific mallocs])
1571 AC_MSG_RESULT($with_pymalloc)
1573 # Check for --with-wctype-functions
1574 AC_MSG_CHECKING(for --with-wctype-functions)
1575 AC_ARG_WITH(wctype-functions, 
1576 [  --with-wctype-functions         use wctype.h functions], [
1577 if test "$withval" != no
1578 then 
1579   AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
1580   [Define if you want wctype.h functions to be used instead of the
1581    one supplied by Python itself. (see Include/unicodectype.h).]) 
1582   AC_MSG_RESULT(yes)
1583 else AC_MSG_RESULT(no)
1584 fi],
1585 [AC_MSG_RESULT(no)])
1587 # -I${DLINCLDIR} is added to the compile rule for importdl.o
1588 AC_SUBST(DLINCLDIR)
1589 DLINCLDIR=.
1591 AC_MSG_CHECKING(for --with-sgi-dl)
1592 AC_ARG_WITH(sgi-dl,
1593 [  --with-sgi-dl=DIRECTORY         IRIX 4 dynamic linking], [
1594 AC_MSG_RESULT($withval)
1595 AC_DEFINE(WITH_SGI_DL, 1,
1596   [Define if you want to use SGI (IRIX 4) dynamic linking.
1597    This requires the "dl" library by Jack Jansen,
1598    ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z.
1599    Do not bother on IRIX 5, it already has dynamic linking using SunOS
1600    style shared libraries])
1601 DYNLOADFILE="dynload_dl.o"
1602 dldir=$withval
1603 if test ! -z "$dldir" -a -d "$dldir"
1604 then LDFLAGS="$LDFLAGS -L$dldir"
1605 else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1607 DLINCLDIR=${dldir}
1608 LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
1610 AC_MSG_CHECKING(for --with-dl-dld)
1611 AC_ARG_WITH(dl-dld, [  --with-dl-dld=DL_DIR,DLD_DIR    GNU dynamic linking], [
1612 AC_MSG_RESULT($withval)
1613 AC_DEFINE(WITH_DL_DLD, 1, 
1614   [Define if you want to emulate SGI (IRIX 4) dynamic linking.
1615    This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4),
1616    Sequent Symmetry (Dynix), and Atari ST.
1617    This requires the 'dl-dld' library,
1618    ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z,
1619    as well as the 'GNU dld' library,
1620    ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z.
1621    Do not bother on SunOS 4 or 5, they already have dynamic linking using
1622    shared libraries.])
1623 DYNLOADFILE="dynload_dl.o"
1624 dldir=`echo "$withval" | sed 's/,.*//'`
1625 dlddir=`echo "$withval" | sed 's/.*,//'`
1626 if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
1627 then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
1628 else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1630 DLINCLDIR=${dldir}
1631 LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
1633 # the dlopen() function means we might want to use dynload_shlib.o. some
1634 # platforms, such as AIX, have dlopen(), but don't want to use it.
1635 AC_CHECK_FUNCS(dlopen)
1637 # DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1638 # loading of modules.
1639 AC_SUBST(DYNLOADFILE)
1640 AC_MSG_CHECKING(DYNLOADFILE)
1641 if test -z "$DYNLOADFILE"
1642 then
1643         case $ac_sys_system/$ac_sys_release in
1644         AIX*) DYNLOADFILE="dynload_aix.o";;
1645         BeOS*) DYNLOADFILE="dynload_beos.o";;
1646         hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
1647         Darwin/*) DYNLOADFILE="dynload_next.o";;
1648         atheos*) DYNLOADFILE="dynload_atheos.o";;
1649         *)
1650         # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1651         # out any dynamic loading
1652         if test "$ac_cv_func_dlopen" = yes
1653         then DYNLOADFILE="dynload_shlib.o"
1654         else DYNLOADFILE="dynload_stub.o"
1655         fi
1656         ;;
1657         esac
1659 AC_MSG_RESULT($DYNLOADFILE)
1660 if test "$DYNLOADFILE" != "dynload_stub.o"
1661 then
1662         AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
1663         [Defined when any dynamic module loading is enabled.])
1666 # MACHDEP_OBJS can be set to platform-specific object files needed by Python
1668 AC_SUBST(MACHDEP_OBJS)
1669 AC_MSG_CHECKING(MACHDEP_OBJS)
1670 if test -z "$MACHDEP_OBJS"
1671 then
1672         MACHDEP_OBJS=$extra_machdep_objs
1673 else
1674         MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
1676 AC_MSG_RESULT(MACHDEP_OBJS)
1678 # checks for library functions
1679 AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \
1680  fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
1681  gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
1682  hstrerror inet_pton iswprint kill killpg lchown link lstat mbtowc mkfifo \
1683  mknod mktime mremap nice pathconf pause plock poll pthread_init \
1684  putenv readlink \
1685  select setegid seteuid setgid setgroups \
1686  setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
1687  sigaction siginterrupt sigrelse strftime strptime symlink \
1688  sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
1689  truncate uname unsetenv utimes waitpid _getpty getpriority)
1691 # check for openpty and forkpty
1693 AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"]))
1694 AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"]))
1696 # check for long file support functions
1697 AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1699 AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
1700 AC_CHECK_FUNCS(getpgrp, 
1701   AC_TRY_COMPILE([#include <unistd.h>], 
1702    [getpgrp(0);], 
1703    AC_DEFINE(GETPGRP_HAVE_ARG, 1,
1704    [Define if getpgrp() must be called as getpgrp(0).])
1707 AC_FUNC_SETPGRP(AC_DEFINE(SETPGRP_HAVE_ARG, 1,
1708            [Define if setpgrp() must be called as setpgrp(0, 0).])
1710 AC_CHECK_FUNCS(gettimeofday, 
1711   AC_TRY_COMPILE([#include <sys/time.h>], 
1712     [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
1713     AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
1714     [Define if gettimeofday() does not have second (timezone) argument
1715      This is the case on Motorola V4 (R40V4.2)])
1716   )
1720 # On OSF/1 V5.1, getaddrinfo is available, but a define
1721 # for [no]getaddrinfo in netdb.h. 
1722 AC_MSG_CHECKING(for getaddrinfo)
1723 AC_TRY_LINK([
1724 #include <sys/types.h>
1725 #include <sys/socket.h>
1726 #include <netdb.h>
1727 #include <stdio.h>
1729 getaddrinfo(NULL, NULL, NULL, NULL);
1730 ], [
1731 AC_MSG_RESULT(yes)
1732 AC_MSG_CHECKING(getaddrinfo bug)
1733 AC_TRY_RUN([
1734 #include <sys/types.h>
1735 #include <netdb.h>
1736 #include <string.h>
1737 #include <sys/socket.h>
1738 #include <netinet/in.h>
1740 main()
1742   int passive, gaierr, inet4 = 0, inet6 = 0;
1743   struct addrinfo hints, *ai, *aitop;
1744   char straddr[INET6_ADDRSTRLEN], strport[16];
1746   for (passive = 0; passive <= 1; passive++) {
1747     memset(&hints, 0, sizeof(hints));
1748     hints.ai_family = AF_UNSPEC;
1749     hints.ai_flags = passive ? AI_PASSIVE : 0;
1750     hints.ai_socktype = SOCK_STREAM;
1751     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1752       (void)gai_strerror(gaierr);
1753       goto bad;
1754     }
1755     for (ai = aitop; ai; ai = ai->ai_next) {
1756       if (ai->ai_addr == NULL ||
1757           ai->ai_addrlen == 0 ||
1758           getnameinfo(ai->ai_addr, ai->ai_addrlen,
1759                       straddr, sizeof(straddr), strport, sizeof(strport),
1760                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1761         goto bad;
1762       }
1763       switch (ai->ai_family) {
1764       case AF_INET:
1765         if (strcmp(strport, "54321") != 0) {
1766           goto bad;
1767         }
1768         if (passive) {
1769           if (strcmp(straddr, "0.0.0.0") != 0) {
1770             goto bad;
1771           }
1772         } else {
1773           if (strcmp(straddr, "127.0.0.1") != 0) {
1774             goto bad;
1775           }
1776         }
1777         inet4++;
1778         break;
1779       case AF_INET6:
1780         if (strcmp(strport, "54321") != 0) {
1781           goto bad;
1782         }
1783         if (passive) {
1784           if (strcmp(straddr, "::") != 0) {
1785             goto bad;
1786           }
1787         } else {
1788           if (strcmp(straddr, "::1") != 0) {
1789             goto bad;
1790           }
1791         }
1792         inet6++;
1793         break;
1794       case AF_UNSPEC:
1795         goto bad;
1796         break;
1797       default:
1798         /* another family support? */
1799         break;
1800       }
1801     }
1802   }
1804   if (!(inet4 == 0 || inet4 == 2))
1805     goto bad;
1806   if (!(inet6 == 0 || inet6 == 2))
1807     goto bad;
1809   if (aitop)
1810     freeaddrinfo(aitop);
1811   exit(0);
1813  bad:
1814   if (aitop)
1815     freeaddrinfo(aitop);
1816   exit(1);
1819 AC_MSG_RESULT(good)
1820 buggygetaddrinfo=no,
1821 AC_MSG_RESULT(buggy)
1822 buggygetaddrinfo=yes,
1823 AC_MSG_RESULT(buggy)
1824 buggygetaddrinfo=yes)], [
1825 AC_MSG_RESULT(no)
1826 buggygetaddrinfo=yes
1829 if test "$buggygetaddrinfo" = "yes"; then
1830         if test "$ipv6" = "yes"; then
1831                 echo 'Fatal: You must get working getaddrinfo() function.'
1832                 echo '       or you can specify "--disable-ipv6"'.
1833                 exit 1
1834         fi
1835 else
1836         AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
1838 AC_CHECK_FUNCS(getnameinfo)
1840 # checks for structures
1841 AC_HEADER_TIME
1842 AC_STRUCT_TM
1843 AC_STRUCT_TIMEZONE
1844 AC_STRUCT_ST_RDEV
1845 AC_STRUCT_ST_BLKSIZE
1846 AC_STRUCT_ST_BLOCKS
1848 AC_MSG_CHECKING(for time.h that defines altzone)
1849 AC_CACHE_VAL(ac_cv_header_time_altzone,
1850 [AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1851   ac_cv_header_time_altzone=yes,
1852   ac_cv_header_time_altzone=no)])
1853 AC_MSG_RESULT($ac_cv_header_time_altzone)
1854 if test $ac_cv_header_time_altzone = yes; then
1855   AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
1858 was_it_defined=no
1859 AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
1860 AC_TRY_COMPILE([
1861 #include <sys/types.h>
1862 #include <sys/select.h>
1863 #include <sys/time.h>
1864 ], [;], [
1865   AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
1866   [Define if  you can safely include both <sys/select.h> and <sys/time.h>
1867    (which you can't on SCO ODT 3.0).]) 
1868   was_it_defined=yes
1870 AC_MSG_RESULT($was_it_defined)
1872 AC_MSG_CHECKING(for addrinfo)
1873 AC_CACHE_VAL(ac_cv_struct_addrinfo,
1874 AC_TRY_COMPILE([
1875 #               include <netdb.h>],
1876         [struct addrinfo a],
1877         ac_cv_struct_addrinfo=yes,
1878         ac_cv_struct_addrinfo=no))
1879 AC_MSG_RESULT($ac_cv_struct_addrinfo)
1880 if test $ac_cv_struct_addrinfo = yes; then
1881         AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
1884 AC_MSG_CHECKING(for sockaddr_storage)
1885 AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1886 AC_TRY_COMPILE([
1887 #               include <sys/types.h>
1888 #               include <sys/socket.h>],
1889         [struct sockaddr_storage s],
1890         ac_cv_struct_sockaddr_storage=yes,
1891         ac_cv_struct_sockaddr_storage=no))
1892 AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1893 if test $ac_cv_struct_sockaddr_storage = yes; then
1894         AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
1897 # checks for compiler characteristics
1899 AC_C_CHAR_UNSIGNED
1900 AC_C_CONST
1902 works=no
1903 AC_MSG_CHECKING(for working volatile)
1904 AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, 
1905   AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
1907 AC_MSG_RESULT($works)
1909 works=no
1910 AC_MSG_CHECKING(for working signed char)
1911 AC_TRY_COMPILE([], [signed char c;], works=yes, 
1912   AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
1914 AC_MSG_RESULT($works)
1916 have_prototypes=no
1917 AC_MSG_CHECKING(for prototypes)
1918 AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
1919   AC_DEFINE(HAVE_PROTOTYPES, 1, 
1920    [Define if your compiler supports function prototype]) 
1921   have_prototypes=yes
1923 AC_MSG_RESULT($have_prototypes)
1925 works=no
1926 AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
1927 AC_TRY_COMPILE([
1928 #include <stdarg.h>
1929 int foo(int x, ...) {
1930         va_list va;
1931         va_start(va, x);
1932         va_arg(va, int);
1933         va_arg(va, char *);
1934         va_arg(va, double);
1935         return 0;
1937 ], [return foo(10, "", 3.14);], [
1938   AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
1939    [Define if your compiler supports variable length function prototypes
1940    (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>]) 
1941   works=yes
1943 AC_MSG_RESULT($works)
1945 if test "$have_prototypes" = yes; then
1946 bad_prototypes=no
1947 AC_MSG_CHECKING(for bad exec* prototypes)
1948 AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1949     AC_DEFINE(BAD_EXEC_PROTOTYPES, 1,
1950     [Define if your <unistd.h> contains bad prototypes for exec*()
1951     (as it does on SGI IRIX 4.x)]) 
1952     bad_prototypes=yes
1954 AC_MSG_RESULT($bad_prototypes)
1957 # check if sockaddr has sa_len member
1958 AC_MSG_CHECKING(if sockaddr has sa_len member)
1959 AC_TRY_COMPILE([#include <sys/types.h>
1960 #include <sys/socket.h>],
1961 [struct sockaddr x;
1962 x.sa_len = 0;],
1963         AC_MSG_RESULT(yes)
1964         AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
1965         AC_MSG_RESULT(no))
1967 va_list_is_array=no
1968 AC_MSG_CHECKING(whether va_list is an array)
1969 AC_TRY_COMPILE([
1970 #ifdef HAVE_STDARG_PROTOTYPES
1971 #include <stdarg.h>
1972 #else
1973 #include <varargs.h>
1974 #endif
1975 ], [va_list list1, list2; list1 = list2;], , [
1976  AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind]) 
1977  va_list_is_array=yes
1979 AC_MSG_RESULT($va_list_is_array)
1981 # sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1982 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
1983   [Define this if you have some version of gethostbyname_r()])
1985 AC_CHECK_FUNC(gethostbyname_r, [
1986   AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1987   AC_MSG_CHECKING([gethostbyname_r with 6 args])
1988   OLD_CFLAGS=$CFLAGS
1989   CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1990   AC_TRY_COMPILE([
1991 #   include <netdb.h>
1992   ], [
1993     char *name;
1994     struct hostent *he, *res;
1995     char buffer[2048];
1996     int buflen = 2048;
1997     int h_errnop;
1999     (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2000   ], [
2001     AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2002     AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2003     [Define this if you have the 6-arg version of gethostbyname_r().])
2004     AC_MSG_RESULT(yes)
2005   ], [
2006     AC_MSG_RESULT(no)
2007     AC_MSG_CHECKING([gethostbyname_r with 5 args])
2008     AC_TRY_COMPILE([
2009 #     include <netdb.h>
2010     ], [
2011       char *name;
2012       struct hostent *he;
2013       char buffer[2048];
2014       int buflen = 2048;
2015       int h_errnop;
2017       (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2018     ], [
2019       AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2020       AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2021       [Define this if you have the 5-arg version of gethostbyname_r().])
2022       AC_MSG_RESULT(yes)
2023     ], [
2024       AC_MSG_RESULT(no)
2025       AC_MSG_CHECKING([gethostbyname_r with 3 args])
2026       AC_TRY_COMPILE([
2027 #       include <netdb.h>
2028       ], [
2029         char *name;
2030         struct hostent *he;
2031         struct hostent_data data;
2033         (void) gethostbyname_r(name, he, &data);
2034       ], [
2035         AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2036         AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2037         [Define this if you have the 3-arg version of gethostbyname_r().])
2038         AC_MSG_RESULT(yes)
2039       ], [
2040         AC_MSG_RESULT(no)
2041       ])
2042     ])
2043   ])
2044   CFLAGS=$OLD_CFLAGS
2045 ], [
2046   AC_CHECK_FUNCS(gethostbyname)
2048 AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2049 AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2050 AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
2051 AC_SUBST(HAVE_GETHOSTBYNAME_R)
2052 AC_SUBST(HAVE_GETHOSTBYNAME)
2054 # checks for system services
2055 # (none yet)
2057 # Linux requires this for correct f.p. operations
2058 AC_CHECK_FUNC(__fpu_control,
2059   [],
2060   [AC_CHECK_LIB(ieee, __fpu_control)
2063 # Check for --with-fpectl
2064 AC_MSG_CHECKING(for --with-fpectl)
2065 AC_ARG_WITH(fpectl,
2066 [  --with-fpectl                   enable SIGFPE catching], [
2067 if test "$withval" != no
2068 then 
2069   AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2070   [Define if you want SIGFPE handled (see Include/pyfpe.h).]) 
2071   AC_MSG_RESULT(yes)
2072 else AC_MSG_RESULT(no)
2073 fi],
2074 [AC_MSG_RESULT(no)])
2076 # check for --with-libm=...
2077 AC_SUBST(LIBM)
2078 case $ac_sys_system in
2079 Darwin) ;;
2080 BeOS) ;;
2081 *) LIBM=-lm
2082 esac
2083 AC_MSG_CHECKING(for --with-libm=STRING)
2084 AC_ARG_WITH(libm, [  --with-libm=STRING              math library], [
2085 if test "$withval" = no
2086 then LIBM=
2087      AC_MSG_RESULT(force LIBM empty)
2088 elif test "$withval" != yes
2089 then LIBM=$withval
2090      AC_MSG_RESULT(set LIBM=\"$withval\")
2091 else AC_ERROR(proper usage is --with-libm=STRING)
2092 fi],
2093 [AC_MSG_RESULT(default LIBM=\"$LIBM\")])
2095 # check for --with-libc=...
2096 AC_SUBST(LIBC)
2097 AC_MSG_CHECKING(for --with-libc=STRING)
2098 AC_ARG_WITH(libc, [  --with-libc=STRING              C library], [
2099 if test "$withval" = no
2100 then LIBC=
2101      AC_MSG_RESULT(force LIBC empty)
2102 elif test "$withval" != yes
2103 then LIBC=$withval
2104      AC_MSG_RESULT(set LIBC=\"$withval\")
2105 else AC_ERROR(proper usage is --with-libc=STRING)
2106 fi],
2107 [AC_MSG_RESULT(default LIBC=\"$LIBC\")])
2109 # check for hypot() in math library
2110 LIBS_SAVE=$LIBS
2111 LIBS="$LIBS $LIBM"
2112 AC_REPLACE_FUNCS(hypot)
2113 LIBS=$LIBS_SAVE
2115 # check whether malloc(0) returns NULL or not
2116 AC_MSG_CHECKING(what malloc(0) returns)
2117 AC_CACHE_VAL(ac_cv_malloc_zero,
2118 [AC_TRY_RUN([#include <stdio.h>
2119 #ifdef HAVE_STDLIB
2120 #include <stdlib.h>
2121 #else
2122 char *malloc(), *realloc();
2123 int *free();
2124 #endif
2125 main() {
2126         char *p;
2127         p = malloc(0);
2128         if (p == NULL) exit(1);
2129         p = realloc(p, 0);
2130         if (p == NULL) exit(1);
2131         free(p);
2132         exit(0);
2134 ac_cv_malloc_zero=nonnull,
2135 ac_cv_malloc_zero=null,
2136 ac_cv_malloc_zero=nonnull)]) # XXX arm cross-compile?
2137 AC_MSG_RESULT($ac_cv_malloc_zero)
2138 if test "$ac_cv_malloc_zero" = null
2139 then
2140   AC_DEFINE(MALLOC_ZERO_RETURNS_NULL, 1,
2141   [Define if malloc(0) returns a NULL pointer.])
2144 # check for wchar.h
2145 AC_CHECK_HEADER(wchar.h, [
2146   AC_DEFINE(HAVE_WCHAR_H, 1, 
2147   [Define if the compiler provides a wchar.h header file.]) 
2148   wchar_h="yes"
2150 wchar_h="no"
2153 # determine wchar_t size
2154 if test "$wchar_h" = yes
2155 then
2156   AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
2159 AC_MSG_CHECKING(what type to use for unicode)
2160 AC_ARG_ENABLE(unicode, 
2161 [  --enable-unicode[=ucs2,ucs4]    Enable Unicode strings (default is yes)],,enable_unicode=yes)
2163 if test $enable_unicode = yes
2164 then
2165   # Without any arguments, Py_UNICODE defaults to two-byte mode
2166   enable_unicode="ucs2"
2169 AH_TEMPLATE(Py_UNICODE_SIZE,
2170   [Define as the size of the unicode type.])
2171 case "$enable_unicode" in
2172 ucs2) unicode_size="2"
2173       AC_DEFINE(Py_UNICODE_SIZE,2)
2174       ;;
2175 ucs4) unicode_size="4"
2176       AC_DEFINE(Py_UNICODE_SIZE,4)
2177       ;;
2178 esac
2180 AH_TEMPLATE(PY_UNICODE_TYPE,
2181   [Define as the integral type used for Unicode representation.])
2183 AC_SUBST(UNICODE_OBJS)
2184 if test "$enable_unicode" = "no"
2185 then
2186   UNICODE_OBJS=""
2187   AC_MSG_RESULT(not used)
2188 else
2189   UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
2190   AC_DEFINE(Py_USING_UNICODE, 1,
2191   [Define if you want to have a Unicode type.])
2192   if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
2193   then
2194     PY_UNICODE_TYPE="wchar_t"
2195     AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
2196     [Define if you have a useable wchar_t type defined in wchar.h; useable
2197      means wchar_t must be 16-bit unsigned type. (see
2198      Include/unicodeobject.h).])
2199     AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
2200   elif test "$ac_cv_sizeof_short" = "$unicode_size"
2201   then
2202        PY_UNICODE_TYPE="unsigned short"
2203        AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
2204   elif test "$ac_cv_sizeof_long" = "$unicode_size"
2205   then
2206        PY_UNICODE_TYPE="unsigned long"
2207        AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
2208   else
2209        PY_UNICODE_TYPE="no type found"
2210   fi
2211   AC_MSG_RESULT($PY_UNICODE_TYPE)
2214 # check for endianness
2215 AC_C_BIGENDIAN
2217 # Check whether right shifting a negative integer extends the sign bit
2218 # or fills with zeros (like the Cray J90, according to Tim Peters).
2219 AC_MSG_CHECKING(whether right shift extends the sign bit)
2220 AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
2221 AC_TRY_RUN([
2222 int main()
2224         exit(((-1)>>3 == -1) ? 0 : 1);
2227 ac_cv_rshift_extends_sign=yes,
2228 ac_cv_rshift_extends_sign=no,
2229 ac_cv_rshift_extends_sign=yes)])
2230 AC_MSG_RESULT($ac_cv_rshift_extends_sign)
2231 if test "$ac_cv_rshift_extends_sign" = no
2232 then
2233   AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
2234   [Define if i>>j for signed int i does not extend the sign bit
2235    when i < 0])
2238 # check for getc_unlocked and related locking functions
2239 AC_MSG_CHECKING(for getc_unlocked() and friends)
2240 AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
2241 AC_TRY_LINK([#include <stdio.h>],[
2242         FILE *f = fopen("/dev/null", "r");
2243         flockfile(f);
2244         getc_unlocked(f);
2245         funlockfile(f);
2246 ], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
2247 AC_MSG_RESULT($ac_cv_have_getc_unlocked)
2248 if test "$ac_cv_have_getc_unlocked" = yes
2249 then
2250   AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
2251   [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
2254 # check for readline 4.0
2255 AC_CHECK_LIB(readline, rl_pre_input_hook,
2256         AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
2257         [Define if you have readline 4.0]), , -ltermcap)
2259 # check for readline 4.2
2260 AC_CHECK_LIB(readline, rl_completion_matches,
2261         AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
2262         [Define if you have readline 4.2]), , -ltermcap)
2264 AC_MSG_CHECKING(for broken nice())
2265 AC_CACHE_VAL(ac_cv_broken_nice, [
2266 AC_TRY_RUN([
2267 int main()
2269         int val1 = nice(1);
2270         if (val1 != -1 && val1 == nice(2))
2271                 exit(0);
2272         exit(1);
2275 ac_cv_broken_nice=yes,
2276 ac_cv_broken_nice=no,
2277 ac_cv_broken_nice=no)])
2278 AC_MSG_RESULT($ac_cv_broken_nice)
2279 if test "$ac_cv_broken_nice" = yes
2280 then
2281   AC_DEFINE(HAVE_BROKEN_NICE, 1,
2282   [Define if nice() returns success/failure instead of the new priority.])
2285 # Look for subsecond timestamps in struct stat
2286 AC_MSG_CHECKING(for tv_nsec in struct stat)
2287 AC_CACHE_VAL(ac_cv_stat_tv_nsec,
2288 AC_TRY_COMPILE([#include <sys/stat.h>], [
2289 struct stat st;
2290 st.st_mtim.tv_nsec = 1;
2292 ac_cv_stat_tv_nsec=yes,
2293 ac_cv_stat_tv_nsec=no,
2294 ac_cv_stat_tv_nsec=no))
2295 AC_MSG_RESULT($ac_cv_stat_tv_nsec)
2296 if test "$ac_cv_stat_tv_nsec" = yes
2297 then
2298   AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
2299   [Define if you have struct stat.st_mtim.tv_nsec])
2302 # On HP/UX 11.0, mvwdelch is a block with a return statement
2303 AC_MSG_CHECKING(whether mvwdelch is an expression)
2304 AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
2305 AC_TRY_COMPILE([#include <curses.h>], [
2306   int rtn;
2307   rtn = mvwdelch(0,0,0);
2308 ], ac_cv_mvwdelch_is_expression=yes,
2309    ac_cv_mvwdelch_is_expression=no,
2310    ac_cv_mvwdelch_is_expression=yes))
2311 AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
2313 if test "$ac_cv_mvwdelch_is_expression" = yes
2314 then
2315   AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
2316   [Define if mvwdelch in curses.h is an expression.])
2319 AC_MSG_CHECKING(whether WINDOW has _flags)
2320 AC_CACHE_VAL(ac_cv_window_has_flags,
2321 AC_TRY_COMPILE([#include <curses.h>], [
2322   WINDOW *w;
2323   w->_flags = 0;
2324 ], ac_cv_window_has_flags=yes,
2325    ac_cv_window_has_flags=no,
2326    ac_cv_window_has_flags=no))
2327 AC_MSG_RESULT($ac_cv_window_has_flags)
2330 if test "$ac_cv_window_has_flags" = yes
2331 then
2332   AC_DEFINE(WINDOW_HAS_FLAGS, 1, 
2333   [Define if WINDOW in curses.h offers a field _flags.])
2336 # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
2337 # Add sys/socket.h to confdefs.h
2338 cat >> confdefs.h <<\EOF
2339 #ifdef HAVE_SYS_SOCKET_H
2340 #include <sys/socket.h>
2341 #endif
2343 AC_CHECK_TYPE(socklen_t, int)
2345 #AC_MSG_CHECKING(for Modules/Setup)
2346 #if test ! -f Modules/Setup ; then
2347 #    if test ! -d Modules ; then
2348 #        mkdir Modules
2349 #    fi
2350 #    cp "$srcdir/Modules/Setup.dist" Modules/Setup
2351 #    AC_MSG_RESULT(creating)
2352 #else
2353 #    AC_MSG_RESULT(already exists)
2356 AC_SUBST(THREADHEADERS)
2358 for h in `(cd $srcdir;echo Python/thread_*.h)`
2360   THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
2361 done
2363 AC_SUBST(SRCDIRS)
2364 SRCDIRS="Parser Grammar Objects Python Modules Mac Mac/Python"
2365 AC_MSG_CHECKING(for build directories)
2366 for dir in $SRCDIRS; do
2367     if test ! -d $dir; then
2368         mkdir $dir
2369     fi
2370 done
2371 AC_MSG_RESULT(done)
2373 # generate output files
2374 AC_OUTPUT(Makefile.pre Modules/Setup.config)
2376 echo "creating Setup"
2377 if test ! -f Modules/Setup
2378 then
2379         cp $srcdir/Modules/Setup.dist Modules/Setup
2382 echo "creating Setup.local"
2383 if test ! -f Modules/Setup.local
2384 then
2385         echo "# Edit this file for local setup changes" >Modules/Setup.local
2388 echo "creating Makefile"
2389 $SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
2390                         -s Modules Modules/Setup.config \
2391                         Modules/Setup.local Modules/Setup
2392 mv config.c Modules