source: trunk/essentials/dev-lang/python/configure.in@ 3368

Last change on this file since 3368 was 3368, checked in by bird, 18 years ago

a couple of fixes.

File size: 94.6 KB
Line 
1dnl Process this file with autoconf 2.0 or later to make a configure script.
2
3# Set VERSION so we only need to edit in one place (i.e., here)
4m4_define(PYTHON_VERSION, 2.5)
5
6AC_REVISION($Revision: 51727 $)
7AC_PREREQ(2.59)
8AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs)
9AC_CONFIG_SRCDIR([Include/object.h])
10AC_CONFIG_HEADER(pyconfig.h)
11
12dnl This is for stuff that absolutely must end up in pyconfig.h.
13dnl Please use pyport.h instead, if possible.
14AH_TOP([
15#ifndef Py_PYCONFIG_H
16#define Py_PYCONFIG_H
17])
18AH_BOTTOM([
19/* Define the macros needed if on a UnixWare 7.x system. */
20#if defined(__USLC__) && defined(__SCO_VERSION__)
21#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
22#endif
23
24#endif /*Py_PYCONFIG_H*/
25])
26
27# We don't use PACKAGE_ variables, and they cause conflicts
28# with other autoconf-based packages that include Python.h
29grep -v 'define PACKAGE_' <confdefs.h >confdefs.h.new
30rm confdefs.h
31mv confdefs.h.new confdefs.h
32
33AC_SUBST(VERSION)
34VERSION=PYTHON_VERSION
35
36AC_SUBST(SOVERSION)
37SOVERSION=1.0
38
39# The later defininition of _XOPEN_SOURCE disables certain features
40# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
41AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])
42
43# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
44# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
45# them.
46AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])
47
48# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
49# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
50# them.
51AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])
52
53# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
54# u_int on Irix 5.3. Defining _BSD_TYPES brings it back.
55AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int])
56
57define_xopen_source=yes
58
59# Arguments passed to configure.
60AC_SUBST(CONFIG_ARGS)
61CONFIG_ARGS="$ac_configure_args"
62
63AC_ARG_ENABLE(universalsdk,
64 AC_HELP_STRING(--enable-universalsdk@<:@SDKDIR@:>@, Build agains Mac OS X 10.4u SDK (ppc/i386)),
65[
66 case $enableval in
67 yes)
68 enableval=/Developer/SDKs/MacOSX10.4u.sdk
69 ;;
70 esac
71 case $enableval in
72 no)
73 UNIVERSALSDK=
74 enable_universalsdk=
75 ;;
76 *)
77 UNIVERSALSDK=$enableval
78 ;;
79 esac
80],[
81 UNIVERSALSDK=
82 enable_universalsdk=
83])
84AC_SUBST(UNIVERSALSDK)
85
86dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
87AC_ARG_ENABLE(framework,
88 AC_HELP_STRING(--enable-framework@<:@=INSTALLDIR@:>@, Build (MacOSX|Darwin) framework),
89[
90 case $enableval in
91 yes)
92 enableval=/Library/Frameworks
93 esac
94 case $enableval in
95 no)
96 PYTHONFRAMEWORK=
97 PYTHONFRAMEWORKDIR=no-framework
98 PYTHONFRAMEWORKPREFIX=
99 PYTHONFRAMEWORKINSTALLDIR=
100 FRAMEWORKINSTALLFIRST=
101 FRAMEWORKINSTALLLAST=
102 FRAMEWORKALTINSTALLFIRST=
103 FRAMEWORKALTINSTALLLAST=
104 if test "x${prefix}" = "xNONE"; then
105 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
106 else
107 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
108 fi
109 enable_framework=
110 ;;
111 *)
112 PYTHONFRAMEWORK=Python
113 PYTHONFRAMEWORKDIR=Python.framework
114 PYTHONFRAMEWORKPREFIX=$enableval
115 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
116 FRAMEWORKINSTALLFIRST="frameworkinstallstructure"
117 FRAMEWORKINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools"
118 FRAMEWORKALTINSTALLFIRST="${FRAMEWORKINSTALLFIRST} bininstall maninstall"
119 FRAMEWORKALTINSTALLLAST="frameworkinstallmaclib frameworkinstallapps frameworkaltinstallunixtools"
120 if test "x${prefix}" = "xNONE" ; then
121 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
122 else
123 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
124 fi
125 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
126
127 # Add makefiles for Mac specific code to the list of output
128 # files:
129 AC_CONFIG_FILES(Mac/Makefile)
130 AC_CONFIG_FILES(Mac/PythonLauncher/Makefile)
131 AC_CONFIG_FILES(Mac/IDLE/Makefile)
132 esac
133 ],[
134 PYTHONFRAMEWORK=
135 PYTHONFRAMEWORKDIR=no-framework
136 PYTHONFRAMEWORKPREFIX=
137 PYTHONFRAMEWORKINSTALLDIR=
138 FRAMEWORKINSTALLFIRST=
139 FRAMEWORKINSTALLLAST=
140 FRAMEWORKALTINSTALLFIRST=
141 FRAMEWORKALTINSTALLLAST=
142 if test "x${prefix}" = "xNONE" ; then
143 FRAMEWORKUNIXTOOLSPREFIX="${ac_default_prefix}"
144 else
145 FRAMEWORKUNIXTOOLSPREFIX="${prefix}"
146 fi
147 enable_framework=
148])
149AC_SUBST(PYTHONFRAMEWORK)
150AC_SUBST(PYTHONFRAMEWORKDIR)
151AC_SUBST(PYTHONFRAMEWORKPREFIX)
152AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
153AC_SUBST(FRAMEWORKINSTALLFIRST)
154AC_SUBST(FRAMEWORKINSTALLLAST)
155AC_SUBST(FRAMEWORKALTINSTALLFIRST)
156AC_SUBST(FRAMEWORKALTINSTALLLAST)
157AC_SUBST(FRAMEWORKUNIXTOOLSPREFIX)
158
159##AC_ARG_WITH(dyld,
160## AC_HELP_STRING(--with-dyld,
161## Use (OpenStep|Rhapsody) dynamic linker))
162##
163# Set name for machine-dependent library files
164AC_SUBST(MACHDEP)
165AC_MSG_CHECKING(MACHDEP)
166if test -z "$MACHDEP"
167then
168 ac_sys_system=`uname -s`
169 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64" \
170 -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
171 ac_sys_release=`uname -v`
172 else
173 ac_sys_release=`uname -r`
174 fi
175 ac_md_system=`echo $ac_sys_system |
176 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
177 ac_md_release=`echo $ac_sys_release |
178 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
179 MACHDEP="$ac_md_system$ac_md_release"
180
181 case $MACHDEP in
182 cygwin*) MACHDEP="cygwin";;
183 darwin*) MACHDEP="darwin";;
184 atheos*) MACHDEP="atheos";;
185 irix646) MACHDEP="irix6";;
186 os2*|emx*) MACHDEP="emx";;
187
188 '') MACHDEP="unknown";;
189 esac
190fi
191
192# Some systems cannot stand _XOPEN_SOURCE being defined at all; they
193# disable features if it is defined, without any means to access these
194# features as extensions. For these systems, we skip the definition of
195# _XOPEN_SOURCE. Before adding a system to the list to gain access to
196# some feature, make sure there is no alternative way to access this
197# feature. Also, when using wildcards, make sure you have verified the
198# need for not defining _XOPEN_SOURCE on all systems matching the
199# wildcard, and that the wildcard does not include future systems
200# (which may remove their limitations).
201dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
202case $ac_sys_system/$ac_sys_release in
203 # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined,
204 # even though select is a POSIX function. Reported by J. Ribbens.
205 # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish.
206 OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@)
207 define_xopen_source=no;;
208 # On Solaris 2.6, sys/wait.h is inconsistent in the usage
209 # of union __?sigval. Reported by Stuart Bishop.
210 SunOS/5.6)
211 define_xopen_source=no;;
212 # On UnixWare 7, u_long is never defined with _XOPEN_SOURCE,
213 # but used in /usr/include/netinet/tcp.h. Reported by Tim Rice.
214 # Reconfirmed for 7.1.4 by Martin v. Loewis.
215 OpenUNIX/8.0.0| UnixWare/7.1.@<:@0-4@:>@)
216 define_xopen_source=no;;
217 # On OpenServer 5, u_short is never defined with _XOPEN_SOURCE,
218 # but used in struct sockaddr.sa_family. Reported by Tim Rice.
219 SCO_SV/3.2)
220 define_xopen_source=no;;
221 # On FreeBSD 4.8 and MacOS X 10.2, a bug in ncurses.h means that
222 # it craps out if _XOPEN_EXTENDED_SOURCE is defined. Apparently,
223 # this is fixed in 10.3, which identifies itself as Darwin/7.*
224 # This should hopefully be fixed in FreeBSD 4.9
225 FreeBSD/4.8* | Darwin/6* )
226 define_xopen_source=no;;
227 # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
228 # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
229 # or has another value. By not (re)defining it, the defaults come in place.
230 AIX/4)
231 define_xopen_source=no;;
232 AIX/5)
233 if test `uname -r` -eq 1; then
234 define_xopen_source=no
235 fi
236 ;;
237 # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
238 # disables platform specific features beyond repair.
239 # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE
240 # has no effect, don't bother defining them
241 Darwin/@<:@789@:>@.*)
242 define_xopen_source=no
243 ;;
244
245esac
246
247if test $define_xopen_source = yes
248then
249 # On Solaris w/ g++ it appears that _XOPEN_SOURCE has to be
250 # defined precisely as g++ defines it
251 # Furthermore, on Solaris 10, XPG6 requires the use of a C99
252 # compiler
253 case $ac_sys_system/$ac_sys_release in
254 SunOS/5.8|SunOS/5.9|SunOS/5.10)
255 AC_DEFINE(_XOPEN_SOURCE, 500,
256 Define to the level of X/Open that your system supports)
257 ;;
258 *)
259 AC_DEFINE(_XOPEN_SOURCE, 600,
260 Define to the level of X/Open that your system supports)
261 ;;
262 esac
263
264 # On Tru64 Unix 4.0F, defining _XOPEN_SOURCE also requires
265 # definition of _XOPEN_SOURCE_EXTENDED and _POSIX_C_SOURCE, or else
266 # several APIs are not declared. Since this is also needed in some
267 # cases for HP-UX, we define it globally.
268 # except for Solaris 10, where it must not be defined,
269 # as it implies XPG4.2
270 case $ac_sys_system/$ac_sys_release in
271 SunOS/5.10)
272 ;;
273 *)
274 AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1,
275 Define to activate Unix95-and-earlier features)
276 ;;
277 esac
278
279 AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001)
280
281fi
282
283#
284# SGI compilers allow the specification of the both the ABI and the
285# ISA on the command line. Depending on the values of these switches,
286# different and often incompatable code will be generated.
287#
288# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
289# thus supply support for various ABI/ISA combinations. The MACHDEP
290# variable is also adjusted.
291#
292AC_SUBST(SGI_ABI)
293if test ! -z "$SGI_ABI"
294then
295 CC="cc $SGI_ABI"
296 LDFLAGS="$SGI_ABI $LDFLAGS"
297 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
298fi
299AC_MSG_RESULT($MACHDEP)
300
301# And add extra plat-mac for darwin
302AC_SUBST(EXTRAPLATDIR)
303AC_SUBST(EXTRAMACHDEPPATH)
304AC_MSG_CHECKING(EXTRAPLATDIR)
305if test -z "$EXTRAPLATDIR"
306then
307 case $MACHDEP in
308 darwin)
309 EXTRAPLATDIR="\$(PLATMACDIRS)"
310 EXTRAMACHDEPPATH="\$(PLATMACPATH)"
311 ;;
312 *)
313 EXTRAPLATDIR=""
314 EXTRAMACHDEPPATH=""
315 ;;
316 esac
317fi
318AC_MSG_RESULT($EXTRAPLATDIR)
319
320# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET,
321# it may influence the way we can build extensions, so distutils
322# needs to check it
323AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
324AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
325CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
326EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
327
328# checks for alternative programs
329
330# compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just
331# for debug/optimization stuff. BASECFLAGS is for flags that are required
332# just to get things to compile and link. Users are free to override OPT
333# when running configure or make. The build should not break if they do.
334# BASECFLAGS should generally not be messed with, however.
335
336# XXX shouldn't some/most/all of this code be merged with the stuff later
337# on that fiddles with OPT and BASECFLAGS?
338AC_MSG_CHECKING(for --without-gcc)
339AC_ARG_WITH(gcc,
340 AC_HELP_STRING(--without-gcc,never use gcc),
341[
342 case $withval in
343 no) CC=cc
344 without_gcc=yes;;
345 yes) CC=gcc
346 without_gcc=no;;
347 *) CC=$withval
348 without_gcc=$withval;;
349 esac], [
350 case $ac_sys_system in
351 AIX*) CC=cc_r
352 without_gcc=;;
353 BeOS*)
354 case $BE_HOST_CPU in
355 ppc)
356 CC=mwcc
357 without_gcc=yes
358 BASECFLAGS="$BASECFLAGS -export pragma"
359 OPT="$OPT -O"
360 LDFLAGS="$LDFLAGS -nodup"
361 ;;
362 x86)
363 CC=gcc
364 without_gcc=no
365 OPT="$OPT -O"
366 ;;
367 *)
368 AC_MSG_ERROR([Unknown BeOS platform "$BE_HOST_CPU"])
369 ;;
370 esac
371 AR="\$(srcdir)/Modules/ar_beos"
372 RANLIB=:
373 ;;
374 Monterey*)
375 RANLIB=:
376 without_gcc=;;
377 *) without_gcc=no;;
378 esac])
379AC_MSG_RESULT($without_gcc)
380
381# If the user switches compilers, we can't believe the cache
382if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
383then
384 AC_MSG_ERROR([cached CC is different -- throw away $cache_file
385(it is also a good idea to do 'make clean' before compiling)])
386fi
387
388AC_PROG_CC
389
390AC_SUBST(CXX)
391AC_SUBST(MAINCC)
392AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
393AC_ARG_WITH(cxx_main,
394 AC_HELP_STRING([--with-cxx-main=<compiler>],
395 [compile main() and link python executable with C++ compiler]),
396[
397
398 case $withval in
399 no) with_cxx_main=no
400 MAINCC='$(CC)';;
401 yes) with_cxx_main=yes
402 MAINCC='$(CXX)';;
403 *) with_cxx_main=yes
404 MAINCC=$withval
405 if test -z "$CXX"
406 then
407 CXX=$withval
408 fi;;
409 esac], [
410 with_cxx_main=no
411 MAINCC='$(CC)'
412])
413AC_MSG_RESULT($with_cxx_main)
414
415preset_cxx="$CXX"
416if test -z "$CXX"
417then
418 case "$CC" in
419 gcc) AC_PATH_PROG(CXX, [g++], [g++], [notfound]) ;;
420 cc) AC_PATH_PROG(CXX, [c++], [c++], [notfound]) ;;
421 esac
422 if test "$CXX" = "notfound"
423 then
424 CXX=""
425 fi
426fi
427if test -z "$CXX"
428then
429 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
430 if test "$CXX" = "notfound"
431 then
432 CXX=""
433 fi
434fi
435if test "$preset_cxx" != "$CXX"
436then
437 AC_MSG_WARN([
438
439 By default, distutils will build C++ extension modules with "$CXX".
440 If this is not intended, then set CXX on the configure command line.
441 ])
442fi
443
444
445# checks for UNIX variants that set C preprocessor variables
446AC_AIX
447
448# Check for unsupported systems
449case $ac_sys_system/$ac_sys_release in
450Linux*/1*)
451 echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
452 echo See README for details.
453 exit 1;;
454esac
455
456AC_EXEEXT
457AC_MSG_CHECKING(for --with-suffix)
458AC_ARG_WITH(suffix,
459 AC_HELP_STRING(--with-suffix=.exe, set executable suffix),
460[
461 case $withval in
462 no) EXEEXT=;;
463 yes) EXEEXT=.exe;;
464 *) EXEEXT=$withval;;
465 esac])
466AC_MSG_RESULT($EXEEXT)
467
468# Test whether we're running on a non-case-sensitive system, in which
469# case we give a warning if no ext is given
470AC_SUBST(BUILDEXEEXT)
471AC_MSG_CHECKING(for case-insensitive build directory)
472if test ! -d CaseSensitiveTestDir; then
473mkdir CaseSensitiveTestDir
474fi
475
476if test -d casesensitivetestdir
477then
478 AC_MSG_RESULT(yes)
479 BUILDEXEEXT=.exe
480else
481 AC_MSG_RESULT(no)
482 BUILDEXEEXT=$EXEEXT
483fi
484rmdir CaseSensitiveTestDir
485
486case $MACHDEP in
487bsdos*)
488 case $CC in
489 gcc) CC="$CC -D_HAVE_BSDI";;
490 esac;;
491os2*|emx*)
492 CC="$CC -DPYOS_OS2=1 -DPYCC_GCC=1"
493 ;;
494esac
495
496case $ac_sys_system in
497hp*|HP*)
498 case $CC in
499 cc|*/cc) CC="$CC -Ae";;
500 esac;;
501Monterey*)
502 case $CC in
503 cc) CC="$CC -Wl,-Bexport";;
504 esac;;
505SunOS*)
506 # Some functions have a prototype only with that define, e.g. confstr
507 AC_DEFINE(__EXTENSIONS__, 1, [Defined on Solaris to see additional function prototypes.])
508 ;;
509esac
510
511
512AC_SUBST(LIBRARY)
513AC_MSG_CHECKING(LIBRARY)
514if test -z "$LIBRARY"
515then
516 LIBRARY='libpython$(VERSION).a'
517fi
518AC_MSG_RESULT($LIBRARY)
519
520# LDLIBRARY is the name of the library to link against (as opposed to the
521# name of the library into which to insert object files). BLDLIBRARY is also
522# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
523# is blank as the main program is not linked directly against LDLIBRARY.
524# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
525# systems without shared libraries, LDLIBRARY is the same as LIBRARY
526# (defined in the Makefiles). On Cygwin and OS/2 LDLIBRARY is the import
527# library, DLLLIBRARY is the shared (i.e., DLL) library.
528#
529# RUNSHARED is used to run shared python without installed libraries
530#
531# INSTSONAME is the name of the shared library that will be use to install
532# on the system - some systems like version suffix, others don't
533AC_SUBST(LDLIBRARY)
534AC_SUBST(DLLLIBRARY)
535AC_SUBST(BLDLIBRARY)
536AC_SUBST(LDLIBRARYDIR)
537AC_SUBST(INSTSONAME)
538AC_SUBST(RUNSHARED)
539LDLIBRARY="$LIBRARY"
540BLDLIBRARY='$(LDLIBRARY)'
541INSTSONAME='$(LDLIBRARY)'
542DLLLIBRARY=''
543LDLIBRARYDIR=''
544RUNSHARED=''
545
546# LINKCC is the command that links the python executable -- default is $(CC).
547# If CXX is set, and if it is needed to link a main function that was
548# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
549# python might then depend on the C++ runtime
550# This is altered for AIX in order to build the export list before
551# linking.
552AC_SUBST(LINKCC)
553AC_MSG_CHECKING(LINKCC)
554if test -z "$LINKCC"
555then
556 LINKCC='$(PURIFY) $(MAINCC)'
557 case $ac_sys_system in
558 AIX*)
559 exp_extra="\"\""
560 if test $ac_sys_release -ge 5 -o \
561 $ac_sys_release -eq 4 -a `uname -r` -ge 2 ; then
562 exp_extra="."
563 fi
564 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp $exp_extra \$(LIBRARY); $LINKCC";;
565 Monterey64*)
566 LINKCC="$LINKCC -L/usr/lib/ia64l64";;
567 esac
568fi
569AC_MSG_RESULT($LINKCC)
570
571AC_MSG_CHECKING(for --enable-shared)
572AC_ARG_ENABLE(shared,
573 AC_HELP_STRING(--enable-shared, disable/enable building shared python library))
574
575if test -z "$enable_shared"
576then
577 case $ac_sys_system in
578 CYGWIN* | atheos*)
579 enable_shared="yes";;
580 *)
581 enable_shared="no";;
582 esac
583fi
584AC_MSG_RESULT($enable_shared)
585
586AC_MSG_CHECKING(for --enable-profiling)
587AC_ARG_ENABLE(profiling,
588 AC_HELP_STRING(--enable-profiling, enable C-level code profiling),
589[ac_save_cc="$CC"
590 CC="$CC -pg"
591 AC_TRY_RUN([int main() { return 0; }],
592 ac_enable_profiling="yes",
593 ac_enable_profiling="no",
594 ac_enable_profiling="no")
595 CC="$ac_save_cc"])
596AC_MSG_RESULT($ac_enable_profiling)
597
598case "$ac_enable_profiling" in
599 "yes")
600 BASECFLAGS="-pg $BASECFLAGS"
601 LDFLAGS="-pg $LDFLAGS"
602 ;;
603esac
604
605AC_MSG_CHECKING(LDLIBRARY)
606
607# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
608# library that we build, but we do not want to link against it (we
609# will find it with a -framework option). For this reason there is an
610# extra variable BLDLIBRARY against which Python and the extension
611# modules are linked, BLDLIBRARY. This is normally the same as
612# LDLIBRARY, but empty for MacOSX framework builds.
613if test "$enable_framework"
614then
615 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
616 RUNSHARED=DYLD_FRAMEWORK_PATH="`pwd`:$DYLD_FRAMEWORK_PATH"
617 BLDLIBRARY=''
618else
619 BLDLIBRARY='$(LDLIBRARY)'
620fi
621
622# Other platforms follow
623if test $enable_shared = "yes"; then
624 AC_DEFINE(Py_ENABLE_SHARED, 1, [Defined if Python is built as a shared library.])
625 case $ac_sys_system in
626 BeOS*)
627 LDLIBRARY='libpython$(VERSION).so'
628 ;;
629 CYGWIN*)
630 LDLIBRARY='libpython$(VERSION).dll.a'
631 DLLLIBRARY='libpython$(VERSION).dll'
632 ;;
633 SunOS*)
634 LDLIBRARY='libpython$(VERSION).so'
635 BLDLIBRARY='-Wl,-R,$(LIBDIR) -L. -lpython$(VERSION)'
636 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
637 INSTSONAME="$LDLIBRARY".$SOVERSION
638 ;;
639 Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*)
640 LDLIBRARY='libpython$(VERSION).so'
641 BLDLIBRARY='-L. -lpython$(VERSION)'
642 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
643 case $ac_sys_system in
644 FreeBSD*)
645 SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
646 ;;
647 esac
648 INSTSONAME="$LDLIBRARY".$SOVERSION
649 ;;
650 hp*|HP*)
651 case `uname -m` in
652 ia64)
653 LDLIBRARY='libpython$(VERSION).so'
654 ;;
655 *)
656 LDLIBRARY='libpython$(VERSION).sl'
657 ;;
658 esac
659 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
660 RUNSHARED=SHLIB_PATH=`pwd`:${SHLIB_PATH}
661 ;;
662 OSF*)
663 LDLIBRARY='libpython$(VERSION).so'
664 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
665 RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
666 ;;
667 atheos*)
668 LDLIBRARY='libpython$(VERSION).so'
669 BLDLIBRARY='-L. -lpython$(VERSION)'
670 RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
671 ;;
672 os2*|emx*)
673 LDLIBRARY='python$(VERSION)_dll.a'
674 BLDLIBRARY='-L. -lpython$(VERSION)'
675 RUNSHARED=BEGINLIBPATH="`pwd`;$BEGINLIBPATH"
676 CONDENSED_VERSION=`echo "$(VERSION)" | tr -d .,"`
677 DLLLIBRARY='python$(CONDENSED_VERSION).dll'
678 ;;
679 esac
680else # shared is disabled
681 case $ac_sys_system in
682 CYGWIN*)
683 BLDLIBRARY='$(LIBRARY)'
684 LDLIBRARY='libpython$(VERSION).dll.a'
685 ;;
686 esac
687fi
688
689AC_MSG_RESULT($LDLIBRARY)
690
691AC_PROG_RANLIB
692AC_SUBST(AR)
693AC_CHECK_PROGS(AR, ar aal, ar)
694
695AC_SUBST(SVNVERSION)
696AC_CHECK_PROG(SVNVERSION, svnversion, found, not-found)
697if test $SVNVERSION = found
698then
699 SVNVERSION="svnversion \$(srcdir)"
700else
701 SVNVERSION="echo exported"
702fi
703
704case $MACHDEP in
705bsdos*|hp*|HP*)
706 # install -d does not work on BSDI or HP-UX
707 if test -z "$INSTALL"
708 then
709 INSTALL="${srcdir}/install-sh -c"
710 fi
711esac
712AC_PROG_INSTALL
713
714# Not every filesystem supports hard links
715AC_SUBST(LN)
716if test -z "$LN" ; then
717 case $ac_sys_system in
718 BeOS*) LN="ln -s";;
719 CYGWIN*) LN="ln -s";;
720 os2*|emx*) LN="ln -s";;
721 atheos*) LN="ln -s";;
722 *) LN=ln;;
723 esac
724fi
725
726# Check for --with-pydebug
727AC_MSG_CHECKING(for --with-pydebug)
728AC_ARG_WITH(pydebug,
729 AC_HELP_STRING(--with-pydebug, build with Py_DEBUG defined),
730[
731if test "$withval" != no
732then
733 AC_DEFINE(Py_DEBUG, 1,
734 [Define if you want to build an interpreter with many run-time checks.])
735 AC_MSG_RESULT(yes);
736 Py_DEBUG='true'
737else AC_MSG_RESULT(no); Py_DEBUG='false'
738fi],
739[AC_MSG_RESULT(no)])
740
741# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
742# merged with this chunk of code?
743
744# Optimizer/debugger flags
745# ------------------------
746# (The following bit of code is complicated enough - please keep things
747# indented properly. Just pretend you're editing Python code. ;-)
748
749# There are two parallel sets of case statements below, one that checks to
750# see if OPT was set and one that does BASECFLAGS setting based upon
751# compiler and platform. BASECFLAGS tweaks need to be made even if the
752# user set OPT.
753
754# tweak OPT based on compiler and platform, only if the user didn't set
755# it on the command line
756AC_SUBST(OPT)
757if test -z "$OPT"
758then
759 case $GCC in
760 yes)
761 if test "$CC" != 'g++' ; then
762 STRICT_PROTO="-Wstrict-prototypes"
763 fi
764 case $ac_cv_prog_cc_g in
765 yes)
766 if test "$Py_DEBUG" = 'true' ; then
767 # Optimization messes up debuggers, so turn it off for
768 # debug builds.
769 OPT="-g -Wall $STRICT_PROTO"
770 else
771 OPT="-g -O3 -Wall $STRICT_PROTO"
772 fi
773 ;;
774 *)
775 OPT="-O3 -Wall $STRICT_PROTO"
776 ;;
777 esac
778 case $ac_sys_system in
779 SCO_SV*) OPT="$OPT -m486 -DSCO5"
780 ;;
781 esac
782 ;;
783
784 *)
785 OPT="-O"
786 ;;
787 esac
788
789 # The current (beta) Monterey compiler dies with optimizations
790 # XXX what is Monterey? Does it still die w/ -O? Can we get rid of this?
791 case $ac_sys_system in
792 Monterey*)
793 OPT=""
794 ;;
795 esac
796
797fi
798
799AC_SUBST(BASECFLAGS)
800# tweak BASECFLAGS based on compiler and platform
801case $GCC in
802yes)
803 # Python violates C99 rules, by casting between incompatible
804 # pointer types. GCC may generate bad code as a result of that,
805 # so use -fno-strict-aliasing if supported.
806 AC_MSG_CHECKING(whether $CC accepts -fno-strict-aliasing)
807 ac_save_cc="$CC"
808 CC="$CC -fno-strict-aliasing"
809 AC_TRY_RUN([int main() { return 0; }],
810 ac_cv_no_strict_aliasing_ok=yes,
811 ac_cv_no_strict_aliasing_ok=no,
812 ac_cv_no_strict_aliasing_ok=no)
813 CC="$ac_save_cc"
814 AC_MSG_RESULT($ac_cv_no_strict_aliasing_ok)
815 if test $ac_cv_no_strict_aliasing_ok = yes
816 then
817 BASECFLAGS="$BASECFLAGS -fno-strict-aliasing"
818 fi
819 case $ac_sys_system in
820 SCO_SV*)
821 BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
822 ;;
823 # is there any other compiler on Darwin besides gcc?
824 Darwin*)
825 BASECFLAGS="$BASECFLAGS -Wno-long-double -no-cpp-precomp -mno-fused-madd"
826 if test "${enable_universalsdk}"; then
827 BASECFLAGS="-arch ppc -arch i386 -isysroot ${UNIVERSALSDK} ${BASECFLAGS}"
828 fi
829
830 ;;
831 OSF*)
832 BASECFLAGS="$BASECFLAGS -mieee"
833 ;;
834 esac
835 ;;
836
837*)
838 case $ac_sys_system in
839 OpenUNIX*|UnixWare*)
840 BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
841 ;;
842 OSF*)
843 BASECFLAGS="$BASECFLAGS -ieee -std"
844 ;;
845 SCO_SV*)
846 BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
847 ;;
848 esac
849 ;;
850esac
851
852if test "$Py_DEBUG" = 'true'; then
853 :
854else
855 OPT="-DNDEBUG $OPT"
856fi
857
858if test "$ac_arch_flags"
859then
860 BASECFLAGS="$BASECFLAGS $ac_arch_flags"
861fi
862
863# disable check for icc since it seems to pass, but generates a warning
864if test "$CC" = icc
865then
866 ac_cv_opt_olimit_ok=no
867fi
868
869AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
870AC_CACHE_VAL(ac_cv_opt_olimit_ok,
871[ac_save_cc="$CC"
872CC="$CC -OPT:Olimit=0"
873AC_TRY_RUN([int main() { return 0; }],
874 ac_cv_opt_olimit_ok=yes,
875 ac_cv_opt_olimit_ok=no,
876 ac_cv_opt_olimit_ok=no)
877CC="$ac_save_cc"])
878AC_MSG_RESULT($ac_cv_opt_olimit_ok)
879if test $ac_cv_opt_olimit_ok = yes; then
880 case $ac_sys_system in
881 # XXX is this branch needed? On MacOSX 10.2.2 the result of the
882 # olimit_ok test is "no". Is it "yes" in some other Darwin-esque
883 # environment?
884 Darwin*)
885 ;;
886 *)
887 BASECFLAGS="$BASECFLAGS -OPT:Olimit=0"
888 ;;
889 esac
890else
891 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
892 AC_CACHE_VAL(ac_cv_olimit_ok,
893 [ac_save_cc="$CC"
894 CC="$CC -Olimit 1500"
895 AC_TRY_RUN([int main() { return 0; }],
896 ac_cv_olimit_ok=yes,
897 ac_cv_olimit_ok=no,
898 ac_cv_olimit_ok=no)
899 CC="$ac_save_cc"])
900 AC_MSG_RESULT($ac_cv_olimit_ok)
901 if test $ac_cv_olimit_ok = yes; then
902 BASECFLAGS="$BASECFLAGS -Olimit 1500"
903 fi
904fi
905
906# On some compilers, pthreads are available without further options
907# (e.g. MacOS X). On some of these systems, the compiler will not
908# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
909# So we have to see first whether pthreads are available without
910# options before we can check whether -Kpthread improves anything.
911AC_MSG_CHECKING(whether pthreads are available without options)
912AC_CACHE_VAL(ac_cv_pthread_is_default,
913[AC_TRY_RUN([
914#include <pthread.h>
915
916void* routine(void* p){return NULL;}
917
918int main(){
919 pthread_t p;
920 if(pthread_create(&p,NULL,routine,NULL)!=0)
921 return 1;
922 (void)pthread_detach(p);
923 return 0;
924}
925],
926[
927 ac_cv_pthread_is_default=yes
928 ac_cv_kthread=no
929 ac_cv_pthread=no
930],
931 ac_cv_pthread_is_default=no,
932 ac_cv_pthread_is_default=no)
933])
934AC_MSG_RESULT($ac_cv_pthread_is_default)
935
936
937if test $ac_cv_pthread_is_default = yes
938then
939 ac_cv_kpthread=no
940else
941# -Kpthread, if available, provides the right #defines
942# and linker options to make pthread_create available
943# Some compilers won't report that they do not support -Kpthread,
944# so we need to run a program to see whether it really made the
945# function available.
946AC_MSG_CHECKING(whether $CC accepts -Kpthread)
947AC_CACHE_VAL(ac_cv_kpthread,
948[ac_save_cc="$CC"
949CC="$CC -Kpthread"
950AC_TRY_RUN([
951#include <pthread.h>
952
953void* routine(void* p){return NULL;}
954
955int main(){
956 pthread_t p;
957 if(pthread_create(&p,NULL,routine,NULL)!=0)
958 return 1;
959 (void)pthread_detach(p);
960 return 0;
961}
962],
963 ac_cv_kpthread=yes,
964 ac_cv_kpthread=no,
965 ac_cv_kpthread=no)
966CC="$ac_save_cc"])
967AC_MSG_RESULT($ac_cv_kpthread)
968fi
969
970if test $ac_cv_kpthread = no -a $ac_cv_pthread_is_default = no
971then
972# -Kthread, if available, provides the right #defines
973# and linker options to make pthread_create available
974# Some compilers won't report that they do not support -Kthread,
975# so we need to run a program to see whether it really made the
976# function available.
977AC_MSG_CHECKING(whether $CC accepts -Kthread)
978AC_CACHE_VAL(ac_cv_kthread,
979[ac_save_cc="$CC"
980CC="$CC -Kthread"
981AC_TRY_RUN([
982#include <pthread.h>
983
984void* routine(void* p){return NULL;}
985
986int main(){
987 pthread_t p;
988 if(pthread_create(&p,NULL,routine,NULL)!=0)
989 return 1;
990 (void)pthread_detach(p);
991 return 0;
992}
993],
994 ac_cv_kthread=yes,
995 ac_cv_kthread=no,
996 ac_cv_kthread=no)
997CC="$ac_save_cc"])
998AC_MSG_RESULT($ac_cv_kthread)
999fi
1000
1001if test $ac_cv_kthread = no -a $ac_cv_pthread_is_default = no
1002then
1003# -pthread, if available, provides the right #defines
1004# and linker options to make pthread_create available
1005# Some compilers won't report that they do not support -pthread,
1006# so we need to run a program to see whether it really made the
1007# function available.
1008AC_MSG_CHECKING(whether $CC accepts -pthread)
1009AC_CACHE_VAL(ac_cv_thread,
1010[ac_save_cc="$CC"
1011CC="$CC -pthread"
1012AC_TRY_RUN([
1013#include <pthread.h>
1014
1015void* routine(void* p){return NULL;}
1016
1017int main(){
1018 pthread_t p;
1019 if(pthread_create(&p,NULL,routine,NULL)!=0)
1020 return 1;
1021 (void)pthread_detach(p);
1022 return 0;
1023}
1024],
1025 ac_cv_pthread=yes,
1026 ac_cv_pthread=no,
1027 ac_cv_pthread=no)
1028CC="$ac_save_cc"])
1029AC_MSG_RESULT($ac_cv_pthread)
1030fi
1031
1032# If we have set a CC compiler flag for thread support then
1033# check if it works for CXX, too.
1034ac_cv_cxx_thread=no
1035if test ! -z "$CXX"
1036then
1037AC_MSG_CHECKING(whether $CXX also accepts flags for thread support)
1038ac_save_cxx="$CXX"
1039
1040if test "$ac_cv_kpthread" = "yes"
1041then
1042 CXX="$CXX -Kpthread"
1043 ac_cv_cxx_thread=yes
1044elif test "$ac_cv_kthread" = "yes"
1045then
1046 CXX="$CXX -Kthread"
1047 ac_cv_cxx_thread=yes
1048elif test "$ac_cv_pthread" = "yes"
1049then
1050 CXX="$CXX -pthread"
1051 ac_cv_cxx_thread=yes
1052fi
1053
1054if test $ac_cv_cxx_thread = yes
1055then
1056 echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext
1057 $CXX -c conftest.$ac_ext 2>&5
1058 if $CXX -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
1059 && test -s conftest$ac_exeext && ./conftest$ac_exeext
1060 then
1061 ac_cv_cxx_thread=yes
1062 else
1063 ac_cv_cxx_thread=no
1064 fi
1065 rm -fr conftest*
1066fi
1067AC_MSG_RESULT($ac_cv_cxx_thread)
1068fi
1069CXX="$ac_save_cxx"
1070
1071dnl # check for ANSI or K&R ("traditional") preprocessor
1072dnl AC_MSG_CHECKING(for C preprocessor type)
1073dnl AC_TRY_COMPILE([
1074dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
1075dnl int foo;
1076dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
1077dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
1078dnl AC_MSG_RESULT($cpp_type)
1079
1080# checks for header files
1081AC_HEADER_STDC
1082AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
1083fcntl.h grp.h \
1084shadow.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \
1085signal.h stropts.h termios.h thread.h \
1086unistd.h utime.h \
1087sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \
1088sys/modem.h \
1089sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \
1090sys/time.h \
1091sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
1092sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
1093bluetooth/bluetooth.h)
1094AC_HEADER_DIRENT
1095AC_HEADER_MAJOR
1096
1097# On Solaris, term.h requires curses.h
1098AC_CHECK_HEADERS(term.h,,,[
1099#ifdef HAVE_CURSES_H
1100#include <curses.h>
1101#endif
1102])
1103
1104# On Linux, netlink.h requires asm/types.h
1105AC_CHECK_HEADERS(linux/netlink.h,,,[
1106#ifdef HAVE_ASM_TYPES_H
1107#include <asm/types.h>
1108#endif
1109#ifdef HAVE_SYS_SOCKET_H
1110#include <sys/socket.h>
1111#endif
1112])
1113
1114# checks for typedefs
1115was_it_defined=no
1116AC_MSG_CHECKING(for clock_t in time.h)
1117AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, [
1118 AC_DEFINE(clock_t, long, [Define to 'long' if <time.h> doesn't define.])
1119])
1120AC_MSG_RESULT($was_it_defined)
1121
1122# Check whether using makedev requires defining _OSF_SOURCE
1123AC_MSG_CHECKING(for makedev)
1124AC_TRY_LINK([#include <sys/types.h> ],
1125 [ makedev(0, 0) ],
1126 ac_cv_has_makedev=yes,
1127 ac_cv_has_makedev=no)
1128if test "$ac_cv_has_makedev" = "no"; then
1129 # we didn't link, try if _OSF_SOURCE will allow us to link
1130 AC_TRY_LINK([
1131#define _OSF_SOURCE 1
1132#include <sys/types.h>
1133 ],
1134 [ makedev(0, 0) ],
1135 ac_cv_has_makedev=yes,
1136 ac_cv_has_makedev=no)
1137 if test "$ac_cv_has_makedev" = "yes"; then
1138 AC_DEFINE(_OSF_SOURCE, 1, [Define _OSF_SOURCE to get the makedev macro.])
1139 fi
1140fi
1141AC_MSG_RESULT($ac_cv_has_makedev)
1142if test "$ac_cv_has_makedev" = "yes"; then
1143 AC_DEFINE(HAVE_MAKEDEV, 1, [Define this if you have the makedev macro.])
1144fi
1145
1146# Enabling LFS on Solaris (2.6 to 9) with gcc 2.95 triggers a bug in
1147# the system headers: If _XOPEN_SOURCE and _LARGEFILE_SOURCE are
1148# defined, but the compiler does not support pragma redefine_extname,
1149# and _LARGEFILE64_SOURCE is not defined, the headers refer to 64-bit
1150# structures (such as rlimit64) without declaring them. As a
1151# work-around, disable LFS on such configurations
1152
1153use_lfs=yes
1154AC_MSG_CHECKING(Solaris LFS bug)
1155AC_TRY_COMPILE([
1156#define _LARGEFILE_SOURCE 1
1157#define _FILE_OFFSET_BITS 64
1158#include <sys/resource.h>
1159],struct rlimit foo;,sol_lfs_bug=no,sol_lfs_bug=yes)
1160AC_MSG_RESULT($sol_lfs_bug)
1161if test "$sol_lfs_bug" = "yes"; then
1162 use_lfs=no
1163fi
1164
1165if test "$use_lfs" = "yes"; then
1166# Two defines needed to enable largefile support on various platforms
1167# These may affect some typedefs
1168AC_DEFINE(_LARGEFILE_SOURCE, 1,
1169[This must be defined on some systems to enable large file support.])
1170AC_DEFINE(_FILE_OFFSET_BITS, 64,
1171[This must be set to 64 on some systems to enable large file support.])
1172fi
1173
1174# Add some code to confdefs.h so that the test for off_t works on SCO
1175cat >> confdefs.h <<\EOF
1176#if defined(SCO_DS)
1177#undef _OFF_T
1178#endif
1179EOF
1180
1181# Type availability checks
1182AC_TYPE_MODE_T
1183AC_TYPE_OFF_T
1184AC_TYPE_PID_T
1185AC_TYPE_SIGNAL
1186AC_TYPE_SIZE_T
1187AC_TYPE_UID_T
1188AC_CHECK_TYPE(ssize_t,
1189 AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
1190
1191# Sizes of various common basic types
1192# ANSI C requires sizeof(char) == 1, so no need to check it
1193AC_CHECK_SIZEOF(int, 4)
1194AC_CHECK_SIZEOF(long, 4)
1195AC_CHECK_SIZEOF(void *, 4)
1196AC_CHECK_SIZEOF(short, 2)
1197AC_CHECK_SIZEOF(float, 4)
1198AC_CHECK_SIZEOF(double, 8)
1199AC_CHECK_SIZEOF(fpos_t, 4)
1200AC_CHECK_SIZEOF(size_t, 4)
1201
1202AC_MSG_CHECKING(for long long support)
1203have_long_long=no
1204AC_TRY_COMPILE([], [long long x; x = (long long)0;], [
1205 AC_DEFINE(HAVE_LONG_LONG, 1, [Define this if you have the type long long.])
1206 have_long_long=yes
1207])
1208AC_MSG_RESULT($have_long_long)
1209if test "$have_long_long" = yes ; then
1210AC_CHECK_SIZEOF(long long, 8)
1211fi
1212
1213AC_MSG_CHECKING(for uintptr_t support)
1214have_uintptr_t=no
1215AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], [
1216 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define this if you have the type uintptr_t.])
1217 have_uintptr_t=yes
1218])
1219AC_MSG_RESULT($have_uintptr_t)
1220if test "$have_uintptr_t" = yes ; then
1221AC_CHECK_SIZEOF(uintptr_t, 4)
1222fi
1223
1224# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
1225AC_MSG_CHECKING(size of off_t)
1226AC_CACHE_VAL(ac_cv_sizeof_off_t,
1227[AC_TRY_RUN([#include <stdio.h>
1228#include <sys/types.h>
1229main()
1230{
1231 FILE *f=fopen("conftestval", "w");
1232 if (!f) exit(1);
1233 fprintf(f, "%d\n", sizeof(off_t));
1234 exit(0);
1235}],
1236ac_cv_sizeof_off_t=`cat conftestval`,
1237ac_cv_sizeof_off_t=0,
1238ac_cv_sizeof_off_t=4)
1239])
1240AC_MSG_RESULT($ac_cv_sizeof_off_t)
1241AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t,
1242[The number of bytes in an off_t.])
1243
1244AC_MSG_CHECKING(whether to enable large file support)
1245if test "$have_long_long" = yes -a \
1246 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
1247 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
1248 AC_DEFINE(HAVE_LARGEFILE_SUPPORT, 1,
1249 [Defined to enable large file support when an off_t is bigger than a long
1250 and long long is available and at least as big as an off_t. You may need
1251 to add some flags for configuration and compilation to enable this mode.
1252 (For Solaris and Linux, the necessary defines are already defined.)])
1253 AC_MSG_RESULT(yes)
1254else
1255 AC_MSG_RESULT(no)
1256fi
1257
1258# AC_CHECK_SIZEOF() doesn't include <time.h>.
1259AC_MSG_CHECKING(size of time_t)
1260AC_CACHE_VAL(ac_cv_sizeof_time_t,
1261[AC_TRY_RUN([#include <stdio.h>
1262#include <time.h>
1263main()
1264{
1265 FILE *f=fopen("conftestval", "w");
1266 if (!f) exit(1);
1267 fprintf(f, "%d\n", sizeof(time_t));
1268 exit(0);
1269}],
1270ac_cv_sizeof_time_t=`cat conftestval`,
1271ac_cv_sizeof_time_t=0,
1272ac_cv_sizeof_time_t=4)
1273])
1274AC_MSG_RESULT($ac_cv_sizeof_time_t)
1275AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t,
1276[The number of bytes in a time_t.])
1277
1278
1279# if have pthread_t then define SIZEOF_PTHREAD_T
1280ac_save_cc="$CC"
1281if test "$ac_cv_kpthread" = "yes"
1282then CC="$CC -Kpthread"
1283elif test "$ac_cv_kthread" = "yes"
1284then CC="$CC -Kthread"
1285elif test "$ac_cv_pthread" = "yes"
1286then CC="$CC -pthread"
1287fi
1288AC_MSG_CHECKING(for pthread_t)
1289have_pthread_t=no
1290AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
1291AC_MSG_RESULT($have_pthread_t)
1292if test "$have_pthread_t" = yes ; then
1293 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
1294 AC_MSG_CHECKING(size of pthread_t)
1295 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
1296 [AC_TRY_RUN([#include <stdio.h>
1297#include <pthread.h>
1298 main()
1299 {
1300 FILE *f=fopen("conftestval", "w");
1301 if (!f) exit(1);
1302 fprintf(f, "%d\n", sizeof(pthread_t));
1303 exit(0);
1304 }],
1305 ac_cv_sizeof_pthread_t=`cat conftestval`,
1306 ac_cv_sizeof_pthread_t=0,
1307 ac_cv_sizeof_pthread_t=4)
1308 ])
1309 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
1310 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t,
1311 [The number of bytes in a pthread_t.])
1312fi
1313CC="$ac_save_cc"
1314
1315AC_MSG_CHECKING(for --enable-toolbox-glue)
1316AC_ARG_ENABLE(toolbox-glue,
1317 AC_HELP_STRING(--enable-toolbox-glue, disable/enable MacOSX glue code for extensions))
1318
1319if test -z "$enable_toolbox_glue"
1320then
1321 case $ac_sys_system/$ac_sys_release in
1322 Darwin/*)
1323 enable_toolbox_glue="yes";;
1324 *)
1325 enable_toolbox_glue="no";;
1326 esac
1327fi
1328case "$enable_toolbox_glue" in
1329yes)
1330 extra_machdep_objs="Python/mactoolboxglue.o"
1331 extra_undefs="-u _PyMac_Error"
1332 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE, 1,
1333 [Define if you want to use MacPython modules on MacOSX in unix-Python.])
1334 ;;
1335*)
1336 extra_machdep_objs=""
1337 extra_undefs=""
1338 ;;
1339esac
1340AC_MSG_RESULT($enable_toolbox_glue)
1341
1342AC_SUBST(OTHER_LIBTOOL_OPT)
1343case $ac_sys_system/$ac_sys_release in
1344 Darwin/@<:@01567@:>@\..*)
1345 OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000"
1346 ;;
1347 Darwin/*)
1348 OTHER_LIBTOOL_OPT=""
1349 ;;
1350esac
1351
1352AC_SUBST(LIBTOOL_CRUFT)
1353case $ac_sys_system/$ac_sys_release in
1354 Darwin/@<:@01567@:>@\..*)
1355 LIBTOOL_CRUFT="-framework System -lcc_dynamic"
1356 if test "${enable_universalsdk}"; then
1357 :
1358 else
1359 LIBTOOL_CRUFT="${LIBTOOL_CRUFT} -arch_only `arch`"
1360 fi
1361 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1362 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1363 Darwin/*)
1364 gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3`
1365 if test ${gcc_version} '<' 4.0
1366 then
1367 LIBTOOL_CRUFT="-lcc_dynamic"
1368 else
1369 LIBTOOL_CRUFT=""
1370 fi
1371 LIBTOOL_CRUFT=$LIBTOOL_CRUFT" -lSystem -lSystemStubs -arch_only `arch`"
1372 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1373 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
1374esac
1375
1376AC_MSG_CHECKING(for --enable-framework)
1377if test "$enable_framework"
1378then
1379 BASECFLAGS="$BASECFLAGS -fno-common -dynamic"
1380 # -F. is needed to allow linking to the framework while
1381 # in the build location.
1382 AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
1383 [Define if you want to produce an OpenStep/Rhapsody framework
1384 (shared library plus accessory files).])
1385 AC_MSG_RESULT(yes)
1386else
1387 AC_MSG_RESULT(no)
1388fi
1389
1390AC_MSG_CHECKING(for dyld)
1391case $ac_sys_system/$ac_sys_release in
1392 Darwin/*)
1393 AC_DEFINE(WITH_DYLD, 1,
1394 [Define if you want to use the new-style (Openstep, Rhapsody, MacOS)
1395 dynamic linker (dyld) instead of the old-style (NextStep) dynamic
1396 linker (rld). Dyld is necessary to support frameworks.])
1397 AC_MSG_RESULT(always on for Darwin)
1398 ;;
1399 *)
1400 AC_MSG_RESULT(no)
1401 ;;
1402esac
1403
1404# Set info about shared libraries.
1405AC_SUBST(SO)
1406AC_SUBST(LDSHARED)
1407AC_SUBST(BLDSHARED)
1408AC_SUBST(CCSHARED)
1409AC_SUBST(LINKFORSHARED)
1410# SO is the extension of shared libraries `(including the dot!)
1411# -- usually .so, .sl on HP-UX, .dll on Cygwin and OS/2
1412AC_MSG_CHECKING(SO)
1413if test -z "$SO"
1414then
1415 case $ac_sys_system in
1416 hp*|HP*)
1417 case `uname -m` in
1418 ia64) SO=.so;;
1419 *) SO=.sl;;
1420 esac
1421 ;;
1422 CYGWIN*) SO=.dll;;
1423 os2*|emx*) SO=.dll;;
1424 *) SO=.so;;
1425 esac
1426else
1427 # this might also be a termcap variable, see #610332
1428 echo
1429 echo '====================================================================='
1430 echo '+ +'
1431 echo '+ WARNING: You have set SO in your environment. +'
1432 echo '+ Do you really mean to change the extension for shared libraries? +'
1433 echo '+ Continuing in 10 seconds to let you to ponder. +'
1434 echo '+ +'
1435 echo '====================================================================='
1436 sleep 10
1437fi
1438AC_MSG_RESULT($SO)
1439AC_DEFINE_UNQUOTED(SHLIB_EXT, "$SO", [Define this to be extension of shared libraries (including the dot!).])
1440# LDSHARED is the ld *command* used to create shared library
1441# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
1442# (Shared libraries in this instance are shared modules to be loaded into
1443# Python, as opposed to building Python itself as a shared library.)
1444AC_MSG_CHECKING(LDSHARED)
1445if test -z "$LDSHARED"
1446then
1447 case $ac_sys_system/$ac_sys_release in
1448 AIX*)
1449 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
1450 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
1451 ;;
1452 BeOS*)
1453 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
1454 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
1455 ;;
1456 IRIX/5*) LDSHARED="ld -shared";;
1457 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
1458 SunOS/5*)
1459 if test "$GCC" = "yes"
1460 then LDSHARED='$(CC) -shared'
1461 else LDSHARED='$(CC) -G';
1462 fi ;;
1463 hp*|HP*) LDSHARED="ld -b";;
1464 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
1465 Darwin/1.3*)
1466 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1467 if test "$enable_framework" ; then
1468 # Link against the framework. All externals should be defined.
1469 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1470 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1471 else
1472 # No framework. Ignore undefined symbols, assuming they come from Python
1473 LDSHARED="$LDSHARED -undefined suppress"
1474 fi ;;
1475 Darwin/1.4*|Darwin/5.*|Darwin/6.*)
1476 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1477 if test "$enable_framework" ; then
1478 # Link against the framework. All externals should be defined.
1479 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1480 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1481 else
1482 # No framework, use the Python app as bundle-loader
1483 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1484 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1485 fi ;;
1486 Darwin/*)
1487 # Use -undefined dynamic_lookup whenever possible (10.3 and later).
1488 # This allows an extension to be used in any Python
1489 cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
1490 if test ${cur_target} '>' 10.2; then
1491 cur_target=10.3
1492 fi
1493 CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
1494 EXPORT_MACOSX_DEPLOYMENT_TARGET=''
1495 if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2
1496 then
1497 if test "${enable_universalsdk}"; then
1498 LDFLAGS="-arch i386 -arch ppc -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
1499 fi
1500 LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup'
1501 BLDSHARED="$LDSHARED"
1502 else
1503 LDSHARED='$(CC) $(LDFLAGS) -bundle'
1504 if test "$enable_framework" ; then
1505 # Link against the framework. All externals should be defined.
1506 BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1507 LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1508 else
1509 # No framework, use the Python app as bundle-loader
1510 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
1511 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
1512 fi
1513 fi
1514 ;;
1515 Linux*|GNU*) LDSHARED='$(CC) -shared';;
1516 BSD/OS*/4*) LDSHARED="gcc -shared";;
1517 FreeBSD*)
1518 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1519 then
1520 LDSHARED="$CC -shared ${LDFLAGS}"
1521 else
1522 LDSHARED="ld -Bshareable ${LDFLAGS}"
1523 fi;;
1524 OpenBSD*)
1525 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1526 then
1527 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1528 else
1529 case `uname -r` in
1530 [[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
1531 LDSHARED="ld -Bshareable ${LDFLAGS}"
1532 ;;
1533 *)
1534 LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
1535 ;;
1536 esac
1537 fi;;
1538 NetBSD*|DragonFly*) LDSHARED="cc -shared ${LDFLAGS}";;
1539 OpenUNIX*|UnixWare*)
1540 if test "$GCC" = "yes"
1541 then LDSHARED='$(CC) -shared'
1542 else LDSHARED='$(CC) -G'
1543 fi;;
1544 SCO_SV*) LDSHARED='$(CC) -Wl,-G,-Bexport';;
1545 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
1546 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
1547 atheos*) LDSHARED="gcc -shared";;
1548 *) LDSHARED="ld";;
1549 esac
1550fi
1551AC_MSG_RESULT($LDSHARED)
1552BLDSHARED=${BLDSHARED-$LDSHARED}
1553# CCSHARED are the C *flags* used to create objects to go into a shared
1554# library (module) -- this is only needed for a few systems
1555AC_MSG_CHECKING(CCSHARED)
1556if test -z "$CCSHARED"
1557then
1558 case $ac_sys_system/$ac_sys_release in
1559 SunOS*) if test "$GCC" = yes;
1560 then CCSHARED="-fPIC";
1561 else CCSHARED="-xcode=pic32";
1562 fi;;
1563 hp*|HP*) if test "$GCC" = yes;
1564 then CCSHARED="-fPIC";
1565 else CCSHARED="+z";
1566 fi;;
1567 Linux*|GNU*) CCSHARED="-fPIC";;
1568 BSD/OS*/4*) CCSHARED="-fpic";;
1569 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
1570 OpenUNIX*|UnixWare*)
1571 if test "$GCC" = "yes"
1572 then CCSHARED="-fPIC"
1573 else CCSHARED="-KPIC"
1574 fi;;
1575 SCO_SV*)
1576 if test "$GCC" = "yes"
1577 then CCSHARED="-fPIC"
1578 else CCSHARED="-Kpic -belf"
1579 fi;;
1580 Monterey*) CCSHARED="-G";;
1581 IRIX*/6*) case $CC in
1582 *gcc*) CCSHARED="-shared";;
1583 *) CCSHARED="";;
1584 esac;;
1585 atheos*) CCSHARED="-fPIC";;
1586 esac
1587fi
1588AC_MSG_RESULT($CCSHARED)
1589# LINKFORSHARED are the flags passed to the $(CC) command that links
1590# the python executable -- this is only needed for a few systems
1591AC_MSG_CHECKING(LINKFORSHARED)
1592if test -z "$LINKFORSHARED"
1593then
1594 case $ac_sys_system/$ac_sys_release in
1595 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
1596 hp*|HP*)
1597 LINKFORSHARED="-Wl,-E -Wl,+s";;
1598# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
1599 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
1600 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
1601 # -u libsys_s pulls in all symbols in libsys
1602 Darwin/*)
1603 # -u _PyMac_Error is needed to pull in the mac toolbox glue,
1604 # which is
1605 # not used by the core itself but which needs to be in the core so
1606 # that dynamically loaded extension modules have access to it.
1607 # -prebind is no longer used, because it actually seems to give a
1608 # slowdown in stead of a speedup, maybe due to the large number of
1609 # dynamic loads Python does.
1610
1611 LINKFORSHARED="$extra_undefs"
1612 if test "$enable_framework"
1613 then
1614 LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
1615 fi
1616 LINKFORSHARED="$LINKFORSHARED";;
1617 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
1618 SCO_SV*) LINKFORSHARED="-Wl,-Bexport";;
1619 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
1620 FreeBSD*|NetBSD*|OpenBSD*|DragonFly*)
1621 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
1622 then
1623 LINKFORSHARED="-Wl,--export-dynamic"
1624 fi;;
1625 SunOS/5*) case $CC in
1626 *gcc*)
1627 if $CC -Xlinker --help 2>&1 | grep export-dynamic >/dev/null
1628 then
1629 LINKFORSHARED="-Xlinker --export-dynamic"
1630 fi;;
1631 esac;;
1632 CYGWIN*)
1633 if test $enable_shared = "no"
1634 then
1635 LINKFORSHARED='-Wl,--out-implib=$(LDLIBRARY)'
1636 fi;;
1637 esac
1638fi
1639AC_MSG_RESULT($LINKFORSHARED)
1640
1641AC_SUBST(CFLAGSFORSHARED)
1642AC_MSG_CHECKING(CFLAGSFORSHARED)
1643if test ! "$LIBRARY" = "$LDLIBRARY"
1644then
1645 case $ac_sys_system in
1646 CYGWIN*)
1647 # Cygwin needs CCSHARED when building extension DLLs
1648 # but not when building the interpreter DLL.
1649 CFLAGSFORSHARED='';;
1650 *)
1651 CFLAGSFORSHARED='$(CCSHARED)'
1652 esac
1653fi
1654AC_MSG_RESULT($CFLAGSFORSHARED)
1655
1656# SHLIBS are libraries (except -lc and -lm) to link to the python shared
1657# library (with --enable-shared).
1658# For platforms on which shared libraries are not allowed to have unresolved
1659# symbols, this must be set to $(LIBS) (expanded by make). We do this even
1660# if it is not required, since it creates a dependency of the shared library
1661# to LIBS. This, in turn, means that applications linking the shared libpython
1662# don't need to link LIBS explicitly. The default should be only changed
1663# on systems where this approach causes problems.
1664AC_SUBST(SHLIBS)
1665AC_MSG_CHECKING(SHLIBS)
1666case "$ac_sys_system" in
1667 *)
1668 SHLIBS='$(LIBS)';;
1669esac
1670AC_MSG_RESULT($SHLIBS)
1671
1672
1673# checks for libraries
1674AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
1675AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
1676
1677# only check for sem_ini if thread support is requested
1678if test "$with_threads" = "yes" -o -z "$with_threads"; then
1679 AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
1680 # posix4 on Solaris 2.6
1681 # pthread (first!) on Linux
1682fi
1683
1684# check if we need libintl for locale functions
1685AC_CHECK_LIB(intl, textdomain,
1686 AC_DEFINE(WITH_LIBINTL, 1,
1687 [Define to 1 if libintl is needed for locale functions.]))
1688
1689# checks for system dependent C++ extensions support
1690case "$ac_sys_system" in
1691 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
1692 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
1693 [loadAndInit("", 0, "")],
1694 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS, 1,
1695 [Define for AIX if your compiler is a genuine IBM xlC/xlC_r
1696 and you want support for AIX C++ shared extension modules.])
1697 AC_MSG_RESULT(yes)],
1698 [AC_MSG_RESULT(no)]);;
1699 *) ;;
1700esac
1701
1702# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
1703# BeOS' sockets are stashed in libnet.
1704AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
1705AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
1706
1707case "$ac_sys_system" in
1708BeOS*)
1709AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
1710;;
1711esac
1712
1713AC_MSG_CHECKING(for --with-libs)
1714AC_ARG_WITH(libs,
1715 AC_HELP_STRING(--with-libs='lib1 ...', link against additional libs),
1716[
1717AC_MSG_RESULT($withval)
1718LIBS="$withval $LIBS"
1719],
1720[AC_MSG_RESULT(no)])
1721
1722# Check for use of the system libffi library
1723AC_MSG_CHECKING(for --with-system-ffi)
1724AC_ARG_WITH(system_ffi,
1725 AC_HELP_STRING(--with-system-ffi, build _ctypes module using an installed ffi library))
1726
1727if test -z "$with_system_ffi"
1728then with_system_ffi="no"
1729fi
1730AC_MSG_RESULT($with_system_ffi)
1731
1732# Determine if signalmodule should be used.
1733AC_SUBST(USE_SIGNAL_MODULE)
1734AC_SUBST(SIGNAL_OBJS)
1735AC_MSG_CHECKING(for --with-signal-module)
1736AC_ARG_WITH(signal-module,
1737 AC_HELP_STRING(--with-signal-module, disable/enable signal module))
1738
1739if test -z "$with_signal_module"
1740then with_signal_module="yes"
1741fi
1742AC_MSG_RESULT($with_signal_module)
1743
1744if test "${with_signal_module}" = "yes"; then
1745 USE_SIGNAL_MODULE=""
1746 SIGNAL_OBJS=""
1747else
1748 USE_SIGNAL_MODULE="#"
1749 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1750fi
1751
1752# This is used to generate Setup.config
1753AC_SUBST(USE_THREAD_MODULE)
1754USE_THREAD_MODULE=""
1755
1756AC_MSG_CHECKING(for --with-dec-threads)
1757AC_SUBST(LDLAST)
1758AC_ARG_WITH(dec-threads,
1759 AC_HELP_STRING(--with-dec-threads, use DEC Alpha/OSF1 thread-safe libraries),
1760[
1761AC_MSG_RESULT($withval)
1762LDLAST=-threads
1763if test "${with_thread+set}" != set; then
1764 with_thread="$withval";
1765fi],
1766[AC_MSG_RESULT(no)])
1767
1768# Templates for things AC_DEFINEd more than once.
1769# For a single AC_DEFINE, no template is needed.
1770AH_TEMPLATE(C_THREADS,[Define if you have the Mach cthreads package])
1771AH_TEMPLATE(_REENTRANT,
1772 [Define to force use of thread-safe errno, h_errno, and other functions])
1773AH_TEMPLATE(WITH_THREAD,
1774 [Define if you want to compile in rudimentary thread support])
1775
1776AC_MSG_CHECKING(for --with-threads)
1777dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1778AC_ARG_WITH(threads,
1779 AC_HELP_STRING(--with(out)-threads@<:@=DIRECTORY@:>@, disable/enable thread support))
1780
1781# --with-thread is deprecated, but check for it anyway
1782dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
1783AC_ARG_WITH(thread,
1784 AC_HELP_STRING(--with(out)-thread@<:@=DIRECTORY@:>@, deprecated; use --with(out)-threads),
1785 [with_threads=$with_thread])
1786
1787if test -z "$with_threads"
1788then with_threads="yes"
1789fi
1790AC_MSG_RESULT($with_threads)
1791
1792AC_SUBST(THREADOBJ)
1793if test "$with_threads" = "no"
1794then
1795 USE_THREAD_MODULE="#"
1796elif test "$ac_cv_pthread_is_default" = yes
1797then
1798 AC_DEFINE(WITH_THREAD)
1799 # Defining _REENTRANT on system with POSIX threads should not hurt.
1800 AC_DEFINE(_REENTRANT)
1801 posix_threads=yes
1802 THREADOBJ="Python/thread.o"
1803elif test "$ac_cv_kpthread" = "yes"
1804then
1805 CC="$CC -Kpthread"
1806 if test "$ac_cv_cxx_thread" = "yes"; then
1807 CXX="$CXX -Kpthread"
1808 fi
1809 AC_DEFINE(WITH_THREAD)
1810 posix_threads=yes
1811 THREADOBJ="Python/thread.o"
1812elif test "$ac_cv_kthread" = "yes"
1813then
1814 CC="$CC -Kthread"
1815 if test "$ac_cv_cxx_thread" = "yes"; then
1816 CXX="$CXX -Kthread"
1817 fi
1818 AC_DEFINE(WITH_THREAD)
1819 posix_threads=yes
1820 THREADOBJ="Python/thread.o"
1821elif test "$ac_cv_pthread" = "yes"
1822then
1823 CC="$CC -pthread"
1824 if test "$ac_cv_cxx_thread" = "yes"; then
1825 CXX="$CXX -pthread"
1826 fi
1827 AC_DEFINE(WITH_THREAD)
1828 posix_threads=yes
1829 THREADOBJ="Python/thread.o"
1830else
1831 if test ! -z "$with_threads" -a -d "$with_threads"
1832 then LDFLAGS="$LDFLAGS -L$with_threads"
1833 fi
1834 if test ! -z "$withval" -a -d "$withval"
1835 then LDFLAGS="$LDFLAGS -L$withval"
1836 fi
1837
1838 # According to the POSIX spec, a pthreads implementation must
1839 # define _POSIX_THREADS in unistd.h. Some apparently don't
1840 # (e.g. gnu pth with pthread emulation)
1841 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1842 AC_EGREP_CPP(yes,
1843 [
1844#include <unistd.h>
1845#ifdef _POSIX_THREADS
1846yes
1847#endif
1848 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1849 AC_MSG_RESULT($unistd_defines_pthreads)
1850
1851 AC_DEFINE(_REENTRANT)
1852 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1853 AC_DEFINE(C_THREADS)
1854 AC_DEFINE(HURD_C_THREADS, 1,
1855 [Define if you are using Mach cthreads directly under /include])
1856 LIBS="$LIBS -lthreads"
1857 THREADOBJ="Python/thread.o"],[
1858 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1859 AC_DEFINE(C_THREADS)
1860 AC_DEFINE(MACH_C_THREADS, 1,
1861 [Define if you are using Mach cthreads under mach /])
1862 THREADOBJ="Python/thread.o"],[
1863 AC_MSG_CHECKING(for --with-pth)
1864 AC_ARG_WITH([pth],
1865 AC_HELP_STRING(--with-pth, use GNU pth threading libraries),
1866 [AC_MSG_RESULT($withval)
1867 AC_DEFINE([WITH_THREAD])
1868 AC_DEFINE([HAVE_PTH], 1,
1869 [Define if you have GNU PTH threads.])
1870 LIBS="-lpth $LIBS"
1871 THREADOBJ="Python/thread.o"],
1872 [AC_MSG_RESULT(no)
1873
1874 # Just looking for pthread_create in libpthread is not enough:
1875 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1876 # So we really have to include pthread.h, and then link.
1877 _libs=$LIBS
1878 LIBS="$LIBS -lpthread"
1879 AC_MSG_CHECKING([for pthread_create in -lpthread])
1880 AC_TRY_LINK([#include <pthread.h>
1881
1882void * start_routine (void *arg) { exit (0); }], [
1883pthread_create (NULL, NULL, start_routine, NULL)], [
1884 AC_MSG_RESULT(yes)
1885 AC_DEFINE(WITH_THREAD)
1886 posix_threads=yes
1887 THREADOBJ="Python/thread.o"],[
1888 LIBS=$_libs
1889 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
1890 posix_threads=yes
1891 THREADOBJ="Python/thread.o"],[
1892 AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD)
1893 AC_DEFINE(ATHEOS_THREADS, 1,
1894 [Define this if you have AtheOS threads.])
1895 THREADOBJ="Python/thread.o"],[
1896 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1897 AC_DEFINE(BEOS_THREADS, 1,
1898 [Define this if you have BeOS threads.])
1899 THREADOBJ="Python/thread.o"],[
1900 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
1901 posix_threads=yes
1902 LIBS="$LIBS -lpthreads"
1903 THREADOBJ="Python/thread.o"], [
1904 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
1905 posix_threads=yes
1906 LIBS="$LIBS -lc_r"
1907 THREADOBJ="Python/thread.o"], [
1908 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
1909 posix_threads=yes
1910 LIBS="$LIBS -lpthread"
1911 THREADOBJ="Python/thread.o"], [
1912 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
1913 posix_threads=yes
1914 LIBS="$LIBS -lcma"
1915 THREADOBJ="Python/thread.o"],[
1916 USE_THREAD_MODULE="#"])
1917 ])])])])])])])])])])
1918
1919 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1920 LIBS="$LIBS -lmpc"
1921 THREADOBJ="Python/thread.o"
1922 USE_THREAD_MODULE=""])
1923
1924 if test "$posix_threads" != "yes"; then
1925 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1926 LIBS="$LIBS -lthread"
1927 THREADOBJ="Python/thread.o"
1928 USE_THREAD_MODULE=""])
1929 fi
1930
1931 if test "$USE_THREAD_MODULE" != "#"
1932 then
1933 # If the above checks didn't disable threads, (at least) OSF1
1934 # needs this '-threads' argument during linking.
1935 case $ac_sys_system in
1936 OSF1) LDLAST=-threads;;
1937 esac
1938 fi
1939fi
1940
1941if test "$posix_threads" = "yes"; then
1942 if test "$unistd_defines_pthreads" = "no"; then
1943 AC_DEFINE(_POSIX_THREADS, 1,
1944 [Define if you have POSIX threads,
1945 and your system does not define that.])
1946 fi
1947
1948 # Bug 662787: Using semaphores causes unexplicable hangs on Solaris 8.
1949 case $ac_sys_system/$ac_sys_release in
1950 SunOS/5.6) AC_DEFINE(HAVE_PTHREAD_DESTRUCTOR, 1,
1951 Defined for Solaris 2.6 bug in pthread header.)
1952 ;;
1953 SunOS/5.8) AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
1954 Define if the Posix semaphores do not work on your system)
1955 ;;
1956 esac
1957
1958 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
1959 AC_CACHE_VAL(ac_cv_pthread_system_supported,
1960 [AC_TRY_RUN([#include <pthread.h>
1961 void *foo(void *parm) {
1962 return NULL;
1963 }
1964 main() {
1965 pthread_attr_t attr;
1966 pthread_t id;
1967 if (pthread_attr_init(&attr)) exit(-1);
1968 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
1969 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
1970 exit(0);
1971 }],
1972 ac_cv_pthread_system_supported=yes,
1973 ac_cv_pthread_system_supported=no,
1974 ac_cv_pthread_system_supported=no)
1975 ])
1976 AC_MSG_RESULT($ac_cv_pthread_system_supported)
1977 if test "$ac_cv_pthread_system_supported" = "yes"; then
1978 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED, 1, [Defined if PTHREAD_SCOPE_SYSTEM supported.])
1979 fi
1980 AC_CHECK_FUNCS(pthread_sigmask,
1981 [case $ac_sys_system in
1982 CYGWIN*)
1983 AC_DEFINE(HAVE_BROKEN_PTHREAD_SIGMASK, 1,
1984 [Define if pthread_sigmask() does not work on your system.])
1985 ;;
1986 esac])
1987fi
1988
1989
1990# Check for enable-ipv6
1991AH_TEMPLATE(ENABLE_IPV6, [Define if --enable-ipv6 is specified])
1992AC_MSG_CHECKING([if --enable-ipv6 is specified])
1993AC_ARG_ENABLE(ipv6,
1994[ --enable-ipv6 Enable ipv6 (with ipv4) support
1995 --disable-ipv6 Disable ipv6 support],
1996[ case "$enableval" in
1997 no)
1998 AC_MSG_RESULT(no)
1999 ipv6=no
2000 ;;
2001 *) AC_MSG_RESULT(yes)
2002 AC_DEFINE(ENABLE_IPV6)
2003 ipv6=yes
2004 ;;
2005 esac ],
2006
2007[
2008dnl the check does not work on cross compilation case...
2009 AC_TRY_RUN([ /* AF_INET6 available check */
2010#include <sys/types.h>
2011#include <sys/socket.h>
2012main()
2013{
2014 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
2015 exit(1);
2016 else
2017 exit(0);
2018}
2019],
2020 AC_MSG_RESULT(yes)
2021 ipv6=yes,
2022 AC_MSG_RESULT(no)
2023 ipv6=no,
2024 AC_MSG_RESULT(no)
2025 ipv6=no
2026)
2027
2028if test "$ipv6" = "yes"; then
2029 AC_MSG_CHECKING(if RFC2553 API is available)
2030 AC_TRY_COMPILE([#include <sys/types.h>
2031#include <netinet/in.h>],
2032 [struct sockaddr_in6 x;
2033x.sin6_scope_id;],
2034 AC_MSG_RESULT(yes)
2035 ipv6=yes,
2036 AC_MSG_RESULT(no, IPv6 disabled)
2037 ipv6=no)
2038fi
2039
2040if test "$ipv6" = "yes"; then
2041 AC_DEFINE(ENABLE_IPV6)
2042fi
2043])
2044
2045ipv6type=unknown
2046ipv6lib=none
2047ipv6trylibc=no
2048
2049if test "$ipv6" = "yes"; then
2050 AC_MSG_CHECKING([ipv6 stack type])
2051 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
2052 do
2053 case $i in
2054 inria)
2055 dnl http://www.kame.net/
2056 AC_EGREP_CPP(yes, [
2057#include <netinet/in.h>
2058#ifdef IPV6_INRIA_VERSION
2059yes
2060#endif],
2061 [ipv6type=$i])
2062 ;;
2063 kame)
2064 dnl http://www.kame.net/
2065 AC_EGREP_CPP(yes, [
2066#include <netinet/in.h>
2067#ifdef __KAME__
2068yes
2069#endif],
2070 [ipv6type=$i;
2071 ipv6lib=inet6
2072 ipv6libdir=/usr/local/v6/lib
2073 ipv6trylibc=yes])
2074 ;;
2075 linux-glibc)
2076 dnl http://www.v6.linux.or.jp/
2077 AC_EGREP_CPP(yes, [
2078#include <features.h>
2079#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
2080yes
2081#endif],
2082 [ipv6type=$i;
2083 ipv6trylibc=yes])
2084 ;;
2085 linux-inet6)
2086 dnl http://www.v6.linux.or.jp/
2087 if test -d /usr/inet6; then
2088 ipv6type=$i
2089 ipv6lib=inet6
2090 ipv6libdir=/usr/inet6/lib
2091 BASECFLAGS="-I/usr/inet6/include $BASECFLAGS"
2092 fi
2093 ;;
2094 solaris)
2095 if test -f /etc/netconfig; then
2096 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
2097 ipv6type=$i
2098 ipv6trylibc=yes
2099 fi
2100 fi
2101 ;;
2102 toshiba)
2103 AC_EGREP_CPP(yes, [
2104#include <sys/param.h>
2105#ifdef _TOSHIBA_INET6
2106yes
2107#endif],
2108 [ipv6type=$i;
2109 ipv6lib=inet6;
2110 ipv6libdir=/usr/local/v6/lib])
2111 ;;
2112 v6d)
2113 AC_EGREP_CPP(yes, [
2114#include </usr/local/v6/include/sys/v6config.h>
2115#ifdef __V6D__
2116yes
2117#endif],
2118 [ipv6type=$i;
2119 ipv6lib=v6;
2120 ipv6libdir=/usr/local/v6/lib;
2121 BASECFLAGS="-I/usr/local/v6/include $BASECFLAGS"])
2122 ;;
2123 zeta)
2124 AC_EGREP_CPP(yes, [
2125#include <sys/param.h>
2126#ifdef _ZETA_MINAMI_INET6
2127yes
2128#endif],
2129 [ipv6type=$i;
2130 ipv6lib=inet6;
2131 ipv6libdir=/usr/local/v6/lib])
2132 ;;
2133 esac
2134 if test "$ipv6type" != "unknown"; then
2135 break
2136 fi
2137 done
2138 AC_MSG_RESULT($ipv6type)
2139fi
2140
2141if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
2142 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
2143 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
2144 echo "using lib$ipv6lib"
2145 else
2146 if test $ipv6trylibc = "yes"; then
2147 echo "using libc"
2148 else
2149 echo 'Fatal: no $ipv6lib library found. cannot continue.'
2150 echo "You need to fetch lib$ipv6lib.a from appropriate"
2151 echo 'ipv6 kit and compile beforehand.'
2152 exit 1
2153 fi
2154 fi
2155fi
2156
2157# Check for --with-doc-strings
2158AC_MSG_CHECKING(for --with-doc-strings)
2159AC_ARG_WITH(doc-strings,
2160 AC_HELP_STRING(--with(out)-doc-strings, disable/enable documentation strings))
2161
2162if test -z "$with_doc_strings"
2163then with_doc_strings="yes"
2164fi
2165if test "$with_doc_strings" != "no"
2166then
2167 AC_DEFINE(WITH_DOC_STRINGS, 1,
2168 [Define if you want documentation strings in extension modules])
2169fi
2170AC_MSG_RESULT($with_doc_strings)
2171
2172# Check for Python-specific malloc support
2173AC_MSG_CHECKING(for --with-tsc)
2174AC_ARG_WITH(tsc,
2175[ --with(out)-tsc enable/disable timestamp counter profile], [
2176if test "$withval" != no
2177then
2178 AC_DEFINE(WITH_TSC, 1,
2179 [Define to profile with the Pentium timestamp counter])
2180 AC_MSG_RESULT(yes)
2181else AC_MSG_RESULT(no)
2182fi],
2183[AC_MSG_RESULT(no)])
2184
2185# Check for Python-specific malloc support
2186AC_MSG_CHECKING(for --with-pymalloc)
2187AC_ARG_WITH(pymalloc,
2188 AC_HELP_STRING(--with(out)-pymalloc, disable/enable specialized mallocs))
2189
2190if test -z "$with_pymalloc"
2191then with_pymalloc="yes"
2192fi
2193if test "$with_pymalloc" != "no"
2194then
2195 AC_DEFINE(WITH_PYMALLOC, 1,
2196 [Define if you want to compile in Python-specific mallocs])
2197fi
2198AC_MSG_RESULT($with_pymalloc)
2199
2200# Check for --with-wctype-functions
2201AC_MSG_CHECKING(for --with-wctype-functions)
2202AC_ARG_WITH(wctype-functions,
2203 AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
2204[
2205if test "$withval" != no
2206then
2207 AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
2208 [Define if you want wctype.h functions to be used instead of the
2209 one supplied by Python itself. (see Include/unicodectype.h).])
2210 AC_MSG_RESULT(yes)
2211else AC_MSG_RESULT(no)
2212fi],
2213[AC_MSG_RESULT(no)])
2214
2215# -I${DLINCLDIR} is added to the compile rule for importdl.o
2216AC_SUBST(DLINCLDIR)
2217DLINCLDIR=.
2218
2219# the dlopen() function means we might want to use dynload_shlib.o. some
2220# platforms, such as AIX, have dlopen(), but don't want to use it.
2221AC_CHECK_FUNCS(dlopen)
2222
2223# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
2224# loading of modules.
2225AC_SUBST(DYNLOADFILE)
2226AC_MSG_CHECKING(DYNLOADFILE)
2227if test -z "$DYNLOADFILE"
2228then
2229 case $ac_sys_system/$ac_sys_release in
2230 AIX*) # Use dynload_shlib.c and dlopen() if we have it; otherwise dynload_aix.c
2231 if test "$ac_cv_func_dlopen" = yes
2232 then DYNLOADFILE="dynload_shlib.o"
2233 else DYNLOADFILE="dynload_aix.o"
2234 fi
2235 ;;
2236 BeOS*) DYNLOADFILE="dynload_beos.o";;
2237 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
2238 # Use dynload_next.c only on 10.2 and below, which don't have native dlopen()
2239 Darwin/@<:@0156@:>@\..*) DYNLOADFILE="dynload_next.o";;
2240 atheos*) DYNLOADFILE="dynload_atheos.o";;
2241 *)
2242 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
2243 # out any dynamic loading
2244 if test "$ac_cv_func_dlopen" = yes
2245 then DYNLOADFILE="dynload_shlib.o"
2246 else DYNLOADFILE="dynload_stub.o"
2247 fi
2248 ;;
2249 esac
2250fi
2251AC_MSG_RESULT($DYNLOADFILE)
2252if test "$DYNLOADFILE" != "dynload_stub.o"
2253then
2254 AC_DEFINE(HAVE_DYNAMIC_LOADING, 1,
2255 [Defined when any dynamic module loading is enabled.])
2256fi
2257
2258# MACHDEP_OBJS can be set to platform-specific object files needed by Python
2259
2260AC_SUBST(MACHDEP_OBJS)
2261AC_MSG_CHECKING(MACHDEP_OBJS)
2262if test -z "$MACHDEP_OBJS"
2263then
2264 MACHDEP_OBJS=$extra_machdep_objs
2265else
2266 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
2267fi
2268AC_MSG_RESULT(MACHDEP_OBJS)
2269
2270# checks for library functions
2271AC_CHECK_FUNCS(alarm bind_textdomain_codeset chown clock confstr ctermid \
2272 execv fork fpathconf ftime ftruncate \
2273 gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \
2274 getpriority getpwent getspnam getspent getsid getwd \
2275 kill killpg lchown lstat mkfifo mknod mktime \
2276 mremap nice pathconf pause plock poll pthread_init \
2277 putenv readlink realpath \
2278 select setegid seteuid setgid \
2279 setlocale setregid setreuid setsid setpgid setpgrp setuid setvbuf snprintf \
2280 sigaction siginterrupt sigrelse strftime \
2281 sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
2282 truncate uname unsetenv utimes waitpid wait3 wait4 wcscoll _getpty)
2283
2284# For some functions, having a definition is not sufficient, since
2285# we want to take their address.
2286AC_MSG_CHECKING(for chroot)
2287AC_TRY_COMPILE([#include <unistd.h>], void *x=chroot,
2288 AC_DEFINE(HAVE_CHROOT, 1, Define if you have the 'chroot' function.)
2289 AC_MSG_RESULT(yes),
2290 AC_MSG_RESULT(no)
2291)
2292AC_MSG_CHECKING(for link)
2293AC_TRY_COMPILE([#include <unistd.h>], void *x=link,
2294 AC_DEFINE(HAVE_LINK, 1, Define if you have the 'link' function.)
2295 AC_MSG_RESULT(yes),
2296 AC_MSG_RESULT(no)
2297)
2298AC_MSG_CHECKING(for symlink)
2299AC_TRY_COMPILE([#include <unistd.h>], void *x=symlink,
2300 AC_DEFINE(HAVE_SYMLINK, 1, Define if you have the 'symlink' function.)
2301 AC_MSG_RESULT(yes),
2302 AC_MSG_RESULT(no)
2303)
2304AC_MSG_CHECKING(for fchdir)
2305AC_TRY_COMPILE([#include <unistd.h>], void *x=fchdir,
2306 AC_DEFINE(HAVE_FCHDIR, 1, Define if you have the 'fchdir' function.)
2307 AC_MSG_RESULT(yes),
2308 AC_MSG_RESULT(no)
2309)
2310AC_MSG_CHECKING(for fsync)
2311AC_TRY_COMPILE([#include <unistd.h>], void *x=fsync,
2312 AC_DEFINE(HAVE_FSYNC, 1, Define if you have the 'fsync' function.)
2313 AC_MSG_RESULT(yes),
2314 AC_MSG_RESULT(no)
2315)
2316AC_MSG_CHECKING(for fdatasync)
2317AC_TRY_COMPILE([#include <unistd.h>], void *x=fdatasync,
2318 AC_DEFINE(HAVE_FDATASYNC, 1, Define if you have the 'fdatasync' function.)
2319 AC_MSG_RESULT(yes),
2320 AC_MSG_RESULT(no)
2321)
2322
2323# On some systems (eg. FreeBSD 5), we would find a definition of the
2324# functions ctermid_r, setgroups in the library, but no prototype
2325# (e.g. because we use _XOPEN_SOURCE). See whether we can take their
2326# address to avoid compiler warnings and potential miscompilations
2327# because of the missing prototypes.
2328
2329AC_MSG_CHECKING(for ctermid_r)
2330AC_TRY_COMPILE([
2331#include "confdefs.h"
2332#include <stdio.h>
2333], void* p = ctermid_r,
2334 AC_DEFINE(HAVE_CTERMID_R, 1, Define if you have the 'ctermid_r' function.)
2335 AC_MSG_RESULT(yes),
2336 AC_MSG_RESULT(no)
2337)
2338
2339AC_MSG_CHECKING(for flock)
2340AC_TRY_COMPILE([
2341#include "confdefs.h"
2342#include <sys/file.h>
2343], void* p = flock,
2344 AC_DEFINE(HAVE_FLOCK, 1, Define if you have the 'flock' function.)
2345 AC_MSG_RESULT(yes),
2346 AC_MSG_RESULT(no)
2347)
2348
2349AC_MSG_CHECKING(for getpagesize)
2350AC_TRY_COMPILE([
2351#include "confdefs.h"
2352#include <unistd.h>
2353], void* p = getpagesize,
2354 AC_DEFINE(HAVE_GETPAGESIZE, 1, Define if you have the 'getpagesize' function.)
2355 AC_MSG_RESULT(yes),
2356 AC_MSG_RESULT(no)
2357)
2358
2359dnl check for true
2360AC_CHECK_PROGS(TRUE, true, /bin/true)
2361
2362dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
2363dnl On others, they are in the C library, so we to take no action
2364AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
2365 AC_CHECK_LIB(resolv, inet_aton)
2366)
2367
2368dnl Check if system zlib has *Copy() functions
2369dnl
2370dnl On MacOSX the linker will search for dylibs on the entire linker path
2371dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
2372dnl to revert to a more traditional unix behaviour and make it possible to
2373dnl override the system libz with a local static library of libz. Temporarily
2374dnl add that flag to our CFLAGS as well to ensure that we check the version
2375dnl of libz that will be used by setup.py.
2376dnl The -L/usr/local/lib is needed as wel to get the same compilation
2377dnl environment as setup.py (and leaving it out can cause configure to use the
2378dnl wrong version of the library)
2379case $ac_sys_system/$ac_sys_release in
2380Darwin/*)
2381 _CUR_CFLAGS="${CFLAGS}"
2382 _CUR_LDFLAGS="${LDFLAGS}"
2383 CFLAGS="${CFLAGS} -Wl,-search_paths_first"
2384 LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
2385 ;;
2386esac
2387
2388AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
2389
2390case $ac_sys_system/$ac_sys_release in
2391Darwin/*)
2392 CFLAGS="${_CUR_CFLAGS}"
2393 LDFLAGS="${_CUR_LDFLAGS}"
2394 ;;
2395esac
2396
2397AC_MSG_CHECKING(for hstrerror)
2398AC_TRY_LINK([
2399#include "confdefs.h"
2400#include <netdb.h>
2401], void* p = hstrerror; hstrerror(0),
2402 AC_DEFINE(HAVE_HSTRERROR, 1, Define if you have the 'hstrerror' function.)
2403 AC_MSG_RESULT(yes),
2404 AC_MSG_RESULT(no)
2405)
2406
2407AC_MSG_CHECKING(for inet_aton)
2408AC_TRY_LINK([
2409#include "confdefs.h"
2410#include <sys/types.h>
2411#include <sys/socket.h>
2412#include <netinet/in.h>
2413#include <arpa/inet.h>
2414], void* p = inet_aton;inet_aton(0,0),
2415 AC_DEFINE(HAVE_INET_ATON, 1, Define if you have the 'inet_aton' function.)
2416 AC_MSG_RESULT(yes),
2417 AC_MSG_RESULT(no)
2418)
2419
2420AC_MSG_CHECKING(for inet_pton)
2421AC_TRY_COMPILE([
2422#include "confdefs.h"
2423#include <sys/types.h>
2424#include <sys/socket.h>
2425#include <netinet/in.h>
2426#include <arpa/inet.h>
2427], void* p = inet_pton,
2428 AC_DEFINE(HAVE_INET_PTON, 1, Define if you have the 'inet_pton' function.)
2429 AC_MSG_RESULT(yes),
2430 AC_MSG_RESULT(no)
2431)
2432
2433# On some systems, setgroups is in unistd.h, on others, in grp.h
2434AC_MSG_CHECKING(for setgroups)
2435AC_TRY_COMPILE([
2436#include "confdefs.h"
2437#include <unistd.h>
2438#ifdef HAVE_GRP_H
2439#include <grp.h>
2440#endif
2441],
2442void* p = setgroups,
2443 AC_DEFINE(HAVE_SETGROUPS, 1, Define if you have the 'setgroups' function.)
2444 AC_MSG_RESULT(yes),
2445 AC_MSG_RESULT(no)
2446)
2447
2448# check for openpty and forkpty
2449
2450AC_CHECK_FUNCS(openpty,,
2451 AC_CHECK_LIB(util,openpty,
2452 [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"],
2453 AC_CHECK_LIB(bsd,openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lbsd"])
2454 )
2455)
2456AC_CHECK_FUNCS(forkpty,,
2457 AC_CHECK_LIB(util,forkpty,
2458 [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lutil"],
2459 AC_CHECK_LIB(bsd,forkpty, [AC_DEFINE(HAVE_FORKPTY) LIBS="$LIBS -lbsd"])
2460 )
2461)
2462
2463# check for long file support functions
2464AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
2465
2466AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
2467AC_CHECK_FUNCS(getpgrp,
2468 AC_TRY_COMPILE([#include <unistd.h>],
2469 [getpgrp(0);],
2470 AC_DEFINE(GETPGRP_HAVE_ARG, 1,
2471 [Define if getpgrp() must be called as getpgrp(0).])
2472 )
2473)
2474AC_CHECK_FUNCS(setpgrp,
2475 AC_TRY_COMPILE([#include <unistd.h>],
2476 [setpgrp(0,0);],
2477 AC_DEFINE(SETPGRP_HAVE_ARG, 1,
2478 [Define if setpgrp() must be called as setpgrp(0, 0).])
2479 )
2480)
2481AC_CHECK_FUNCS(gettimeofday,
2482 AC_TRY_COMPILE([#include <sys/time.h>],
2483 [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,
2484 AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1,
2485 [Define if gettimeofday() does not have second (timezone) argument
2486 This is the case on Motorola V4 (R40V4.2)])
2487 )
2488)
2489
2490AC_MSG_CHECKING(for major, minor, and makedev)
2491AC_TRY_LINK([
2492#if defined(MAJOR_IN_MKDEV)
2493#include <sys/mkdev.h>
2494#elif defined(MAJOR_IN_SYSMACROS)
2495#include <sys/sysmacros.h>
2496#else
2497#include <sys/types.h>
2498#endif
2499],[
2500 makedev(major(0),minor(0));
2501],[
2502 AC_DEFINE(HAVE_DEVICE_MACROS, 1,
2503 [Define to 1 if you have the device macros.])
2504 AC_MSG_RESULT(yes)
2505],[
2506 AC_MSG_RESULT(no)
2507])
2508
2509# On OSF/1 V5.1, getaddrinfo is available, but a define
2510# for [no]getaddrinfo in netdb.h.
2511AC_MSG_CHECKING(for getaddrinfo)
2512AC_TRY_LINK([
2513#include <sys/types.h>
2514#include <sys/socket.h>
2515#include <netdb.h>
2516#include <stdio.h>
2517],[
2518getaddrinfo(NULL, NULL, NULL, NULL);
2519], [
2520AC_MSG_RESULT(yes)
2521AC_MSG_CHECKING(getaddrinfo bug)
2522AC_TRY_RUN([
2523#include <sys/types.h>
2524#include <netdb.h>
2525#include <string.h>
2526#include <sys/socket.h>
2527#include <netinet/in.h>
2528
2529main()
2530{
2531 int passive, gaierr, inet4 = 0, inet6 = 0;
2532 struct addrinfo hints, *ai, *aitop;
2533 char straddr[INET6_ADDRSTRLEN], strport[16];
2534
2535 for (passive = 0; passive <= 1; passive++) {
2536 memset(&hints, 0, sizeof(hints));
2537 hints.ai_family = AF_UNSPEC;
2538 hints.ai_flags = passive ? AI_PASSIVE : 0;
2539 hints.ai_socktype = SOCK_STREAM;
2540 hints.ai_protocol = IPPROTO_TCP;
2541 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2542 (void)gai_strerror(gaierr);
2543 goto bad;
2544 }
2545 for (ai = aitop; ai; ai = ai->ai_next) {
2546 if (ai->ai_addr == NULL ||
2547 ai->ai_addrlen == 0 ||
2548 getnameinfo(ai->ai_addr, ai->ai_addrlen,
2549 straddr, sizeof(straddr), strport, sizeof(strport),
2550 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2551 goto bad;
2552 }
2553 switch (ai->ai_family) {
2554 case AF_INET:
2555 if (strcmp(strport, "54321") != 0) {
2556 goto bad;
2557 }
2558 if (passive) {
2559 if (strcmp(straddr, "0.0.0.0") != 0) {
2560 goto bad;
2561 }
2562 } else {
2563 if (strcmp(straddr, "127.0.0.1") != 0) {
2564 goto bad;
2565 }
2566 }
2567 inet4++;
2568 break;
2569 case AF_INET6:
2570 if (strcmp(strport, "54321") != 0) {
2571 goto bad;
2572 }
2573 if (passive) {
2574 if (strcmp(straddr, "::") != 0) {
2575 goto bad;
2576 }
2577 } else {
2578 if (strcmp(straddr, "::1") != 0) {
2579 goto bad;
2580 }
2581 }
2582 inet6++;
2583 break;
2584 case AF_UNSPEC:
2585 goto bad;
2586 break;
2587 default:
2588 /* another family support? */
2589 break;
2590 }
2591 }
2592 }
2593
2594 if (!(inet4 == 0 || inet4 == 2))
2595 goto bad;
2596 if (!(inet6 == 0 || inet6 == 2))
2597 goto bad;
2598
2599 if (aitop)
2600 freeaddrinfo(aitop);
2601 exit(0);
2602
2603 bad:
2604 if (aitop)
2605 freeaddrinfo(aitop);
2606 exit(1);
2607}
2608],
2609AC_MSG_RESULT(good)
2610buggygetaddrinfo=no,
2611AC_MSG_RESULT(buggy)
2612buggygetaddrinfo=yes,
2613AC_MSG_RESULT(buggy)
2614buggygetaddrinfo=yes)], [
2615AC_MSG_RESULT(no)
2616buggygetaddrinfo=yes
2617])
2618
2619if test "$buggygetaddrinfo" = "yes"; then
2620 if test "$ipv6" = "yes"; then
2621 echo 'Fatal: You must get working getaddrinfo() function.'
2622 echo ' or you can specify "--disable-ipv6"'.
2623 exit 1
2624 fi
2625else
2626 AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have the getaddrinfo function.])
2627fi
2628AC_CHECK_FUNCS(getnameinfo)
2629
2630# checks for structures
2631AC_HEADER_TIME
2632AC_STRUCT_TM
2633AC_STRUCT_TIMEZONE
2634AC_CHECK_MEMBERS([struct stat.st_rdev])
2635AC_CHECK_MEMBERS([struct stat.st_blksize])
2636AC_CHECK_MEMBERS([struct stat.st_flags])
2637AC_CHECK_MEMBERS([struct stat.st_gen])
2638AC_CHECK_MEMBERS([struct stat.st_birthtime])
2639AC_STRUCT_ST_BLOCKS
2640
2641AC_MSG_CHECKING(for time.h that defines altzone)
2642AC_CACHE_VAL(ac_cv_header_time_altzone,
2643[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
2644 ac_cv_header_time_altzone=yes,
2645 ac_cv_header_time_altzone=no)])
2646AC_MSG_RESULT($ac_cv_header_time_altzone)
2647if test $ac_cv_header_time_altzone = yes; then
2648 AC_DEFINE(HAVE_ALTZONE, 1, [Define this if your time.h defines altzone.])
2649fi
2650
2651was_it_defined=no
2652AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
2653AC_TRY_COMPILE([
2654#include <sys/types.h>
2655#include <sys/select.h>
2656#include <sys/time.h>
2657], [;], [
2658 AC_DEFINE(SYS_SELECT_WITH_SYS_TIME, 1,
2659 [Define if you can safely include both <sys/select.h> and <sys/time.h>
2660 (which you can't on SCO ODT 3.0).])
2661 was_it_defined=yes
2662])
2663AC_MSG_RESULT($was_it_defined)
2664
2665AC_MSG_CHECKING(for addrinfo)
2666AC_CACHE_VAL(ac_cv_struct_addrinfo,
2667AC_TRY_COMPILE([
2668# include <netdb.h>],
2669 [struct addrinfo a],
2670 ac_cv_struct_addrinfo=yes,
2671 ac_cv_struct_addrinfo=no))
2672AC_MSG_RESULT($ac_cv_struct_addrinfo)
2673if test $ac_cv_struct_addrinfo = yes; then
2674 AC_DEFINE(HAVE_ADDRINFO, 1, [struct addrinfo (netdb.h)])
2675fi
2676
2677AC_MSG_CHECKING(for sockaddr_storage)
2678AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
2679AC_TRY_COMPILE([
2680# include <sys/types.h>
2681# include <sys/socket.h>],
2682 [struct sockaddr_storage s],
2683 ac_cv_struct_sockaddr_storage=yes,
2684 ac_cv_struct_sockaddr_storage=no))
2685AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
2686if test $ac_cv_struct_sockaddr_storage = yes; then
2687 AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [struct sockaddr_storage (sys/socket.h)])
2688fi
2689
2690# checks for compiler characteristics
2691
2692AC_C_CHAR_UNSIGNED
2693AC_C_CONST
2694
2695works=no
2696AC_MSG_CHECKING(for working volatile)
2697AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes,
2698 AC_DEFINE(volatile, [], [Define to empty if the keyword does not work.])
2699)
2700AC_MSG_RESULT($works)
2701
2702works=no
2703AC_MSG_CHECKING(for working signed char)
2704AC_TRY_COMPILE([], [signed char c;], works=yes,
2705 AC_DEFINE(signed, [], [Define to empty if the keyword does not work.])
2706)
2707AC_MSG_RESULT($works)
2708
2709have_prototypes=no
2710AC_MSG_CHECKING(for prototypes)
2711AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],[
2712 AC_DEFINE(HAVE_PROTOTYPES, 1,
2713 [Define if your compiler supports function prototype])
2714 have_prototypes=yes
2715])
2716AC_MSG_RESULT($have_prototypes)
2717
2718works=no
2719AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
2720AC_TRY_COMPILE([
2721#include <stdarg.h>
2722int foo(int x, ...) {
2723 va_list va;
2724 va_start(va, x);
2725 va_arg(va, int);
2726 va_arg(va, char *);
2727 va_arg(va, double);
2728 return 0;
2729}
2730], [return foo(10, "", 3.14);], [
2731 AC_DEFINE(HAVE_STDARG_PROTOTYPES, 1,
2732 [Define if your compiler supports variable length function prototypes
2733 (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>])
2734 works=yes
2735])
2736AC_MSG_RESULT($works)
2737
2738# check for socketpair
2739AC_MSG_CHECKING(for socketpair)
2740AC_TRY_COMPILE([
2741#include <sys/types.h>
2742#include <sys/socket.h>
2743], void *x=socketpair,
2744 AC_DEFINE(HAVE_SOCKETPAIR, 1, Define if you have the 'socketpair' function.)
2745 AC_MSG_RESULT(yes),
2746 AC_MSG_RESULT(no)
2747)
2748
2749# check if sockaddr has sa_len member
2750AC_MSG_CHECKING(if sockaddr has sa_len member)
2751AC_TRY_COMPILE([#include <sys/types.h>
2752#include <sys/socket.h>],
2753[struct sockaddr x;
2754x.sa_len = 0;],
2755 AC_MSG_RESULT(yes)
2756 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Define if sockaddr has sa_len member]),
2757 AC_MSG_RESULT(no))
2758
2759va_list_is_array=no
2760AC_MSG_CHECKING(whether va_list is an array)
2761AC_TRY_COMPILE([
2762#ifdef HAVE_STDARG_PROTOTYPES
2763#include <stdarg.h>
2764#else
2765#include <varargs.h>
2766#endif
2767], [va_list list1, list2; list1 = list2;], , [
2768 AC_DEFINE(VA_LIST_IS_ARRAY, 1, [Define if a va_list is an array of some kind])
2769 va_list_is_array=yes
2770])
2771AC_MSG_RESULT($va_list_is_array)
2772
2773# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
2774AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
2775 [Define this if you have some version of gethostbyname_r()])
2776
2777AC_CHECK_FUNC(gethostbyname_r, [
2778 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2779 AC_MSG_CHECKING([gethostbyname_r with 6 args])
2780 OLD_CFLAGS=$CFLAGS
2781 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
2782 AC_TRY_COMPILE([
2783# include <netdb.h>
2784 ], [
2785 char *name;
2786 struct hostent *he, *res;
2787 char buffer[2048];
2788 int buflen = 2048;
2789 int h_errnop;
2790
2791 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
2792 ], [
2793 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2794 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
2795 [Define this if you have the 6-arg version of gethostbyname_r().])
2796 AC_MSG_RESULT(yes)
2797 ], [
2798 AC_MSG_RESULT(no)
2799 AC_MSG_CHECKING([gethostbyname_r with 5 args])
2800 AC_TRY_COMPILE([
2801# include <netdb.h>
2802 ], [
2803 char *name;
2804 struct hostent *he;
2805 char buffer[2048];
2806 int buflen = 2048;
2807 int h_errnop;
2808
2809 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
2810 ], [
2811 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2812 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
2813 [Define this if you have the 5-arg version of gethostbyname_r().])
2814 AC_MSG_RESULT(yes)
2815 ], [
2816 AC_MSG_RESULT(no)
2817 AC_MSG_CHECKING([gethostbyname_r with 3 args])
2818 AC_TRY_COMPILE([
2819# include <netdb.h>
2820 ], [
2821 char *name;
2822 struct hostent *he;
2823 struct hostent_data data;
2824
2825 (void) gethostbyname_r(name, he, &data);
2826 ], [
2827 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
2828 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
2829 [Define this if you have the 3-arg version of gethostbyname_r().])
2830 AC_MSG_RESULT(yes)
2831 ], [
2832 AC_MSG_RESULT(no)
2833 ])
2834 ])
2835 ])
2836 CFLAGS=$OLD_CFLAGS
2837], [
2838 AC_CHECK_FUNCS(gethostbyname)
2839])
2840AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
2841AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
2842AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
2843AC_SUBST(HAVE_GETHOSTBYNAME_R)
2844AC_SUBST(HAVE_GETHOSTBYNAME)
2845
2846# checks for system services
2847# (none yet)
2848
2849# Linux requires this for correct f.p. operations
2850AC_CHECK_FUNC(__fpu_control,
2851 [],
2852 [AC_CHECK_LIB(ieee, __fpu_control)
2853])
2854
2855# Check for --with-fpectl
2856AC_MSG_CHECKING(for --with-fpectl)
2857AC_ARG_WITH(fpectl,
2858 AC_HELP_STRING(--with-fpectl, enable SIGFPE catching),
2859[
2860if test "$withval" != no
2861then
2862 AC_DEFINE(WANT_SIGFPE_HANDLER, 1,
2863 [Define if you want SIGFPE handled (see Include/pyfpe.h).])
2864 AC_MSG_RESULT(yes)
2865else AC_MSG_RESULT(no)
2866fi],
2867[AC_MSG_RESULT(no)])
2868
2869# check for --with-libm=...
2870AC_SUBST(LIBM)
2871case $ac_sys_system in
2872Darwin) ;;
2873BeOS) ;;
2874*) LIBM=-lm
2875esac
2876AC_MSG_CHECKING(for --with-libm=STRING)
2877AC_ARG_WITH(libm,
2878 AC_HELP_STRING(--with-libm=STRING, math library),
2879[
2880if test "$withval" = no
2881then LIBM=
2882 AC_MSG_RESULT(force LIBM empty)
2883elif test "$withval" != yes
2884then LIBM=$withval
2885 AC_MSG_RESULT(set LIBM="$withval")
2886else AC_MSG_ERROR([proper usage is --with-libm=STRING])
2887fi],
2888[AC_MSG_RESULT(default LIBM="$LIBM")])
2889
2890# check for --with-libc=...
2891AC_SUBST(LIBC)
2892AC_MSG_CHECKING(for --with-libc=STRING)
2893AC_ARG_WITH(libc,
2894 AC_HELP_STRING(--with-libc=STRING, C library),
2895[
2896if test "$withval" = no
2897then LIBC=
2898 AC_MSG_RESULT(force LIBC empty)
2899elif test "$withval" != yes
2900then LIBC=$withval
2901 AC_MSG_RESULT(set LIBC="$withval")
2902else AC_MSG_ERROR([proper usage is --with-libc=STRING])
2903fi],
2904[AC_MSG_RESULT(default LIBC="$LIBC")])
2905
2906# check for hypot() in math library
2907LIBS_SAVE=$LIBS
2908LIBS="$LIBS $LIBM"
2909AC_REPLACE_FUNCS(hypot)
2910LIBS=$LIBS_SAVE
2911
2912# check for wchar.h
2913AC_CHECK_HEADER(wchar.h, [
2914 AC_DEFINE(HAVE_WCHAR_H, 1,
2915 [Define if the compiler provides a wchar.h header file.])
2916 wchar_h="yes"
2917],
2918wchar_h="no"
2919)
2920
2921# determine wchar_t size
2922if test "$wchar_h" = yes
2923then
2924 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
2925fi
2926
2927AC_MSG_CHECKING(for UCS-4 tcl)
2928have_ucs4_tcl=no
2929AC_TRY_COMPILE([
2930#include <tcl.h>
2931#if TCL_UTF_MAX != 6
2932# error "NOT UCS4_TCL"
2933#endif], [], [
2934 AC_DEFINE(HAVE_UCS4_TCL, 1, [Define this if you have tcl and TCL_UTF_MAX==6])
2935 have_ucs4_tcl=yes
2936])
2937AC_MSG_RESULT($have_ucs4_tcl)
2938
2939# check whether wchar_t is signed or not
2940if test "$wchar_h" = yes
2941then
2942 # check whether wchar_t is signed or not
2943 AC_MSG_CHECKING(whether wchar_t is signed)
2944 AC_CACHE_VAL(ac_cv_wchar_t_signed, [
2945 AC_TRY_RUN([
2946 #include <wchar.h>
2947 int main()
2948 {
2949 /* Success: exit code 0 */
2950 exit((((wchar_t) -1) < ((wchar_t) 0)) ? 0 : 1);
2951 }
2952 ],
2953 ac_cv_wchar_t_signed=yes,
2954 ac_cv_wchar_t_signed=no,
2955 ac_cv_wchar_t_signed=yes)])
2956 AC_MSG_RESULT($ac_cv_wchar_t_signed)
2957fi
2958
2959AC_MSG_CHECKING(what type to use for unicode)
2960dnl quadrigraphs "@<:@" and "@:>@" produce "[" and "]" in the output
2961AC_ARG_ENABLE(unicode,
2962 AC_HELP_STRING(--enable-unicode@<:@=ucs@<:@24@:>@@:>@, Enable Unicode strings (default is yes)),
2963 [],
2964 [enable_unicode=yes])
2965
2966if test $enable_unicode = yes
2967then
2968 # Without any arguments, Py_UNICODE defaults to two-byte mode
2969 case "$have_ucs4_tcl" in
2970 yes) enable_unicode="ucs4"
2971 ;;
2972 *) enable_unicode="ucs2"
2973 ;;
2974 esac
2975fi
2976
2977AH_TEMPLATE(Py_UNICODE_SIZE,
2978 [Define as the size of the unicode type.])
2979case "$enable_unicode" in
2980ucs2) unicode_size="2"
2981 AC_DEFINE(Py_UNICODE_SIZE,2)
2982 ;;
2983ucs4) unicode_size="4"
2984 AC_DEFINE(Py_UNICODE_SIZE,4)
2985 ;;
2986esac
2987
2988AH_TEMPLATE(PY_UNICODE_TYPE,
2989 [Define as the integral type used for Unicode representation.])
2990
2991AC_SUBST(UNICODE_OBJS)
2992if test "$enable_unicode" = "no"
2993then
2994 UNICODE_OBJS=""
2995 AC_MSG_RESULT(not used)
2996else
2997 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
2998 AC_DEFINE(Py_USING_UNICODE, 1,
2999 [Define if you want to have a Unicode type.])
3000
3001 # wchar_t is only usable if it maps to an unsigned type
3002 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" \
3003 -a "$ac_cv_wchar_t_signed" = "no"
3004 then
3005 PY_UNICODE_TYPE="wchar_t"
3006 AC_DEFINE(HAVE_USABLE_WCHAR_T, 1,
3007 [Define if you have a useable wchar_t type defined in wchar.h; useable
3008 means wchar_t must be an unsigned type with at least 16 bits. (see
3009 Include/unicodeobject.h).])
3010 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
3011 elif test "$ac_cv_sizeof_short" = "$unicode_size"
3012 then
3013 PY_UNICODE_TYPE="unsigned short"
3014 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
3015 elif test "$ac_cv_sizeof_long" = "$unicode_size"
3016 then
3017 PY_UNICODE_TYPE="unsigned long"
3018 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
3019 else
3020 PY_UNICODE_TYPE="no type found"
3021 fi
3022 AC_MSG_RESULT($PY_UNICODE_TYPE)
3023fi
3024
3025# check for endianness
3026AC_C_BIGENDIAN
3027AH_VERBATIM([WORDS_BIGENDIAN],
3028[
3029 /* Define to 1 if your processor stores words with the most significant byte
3030 first (like Motorola and SPARC, unlike Intel and VAX).
3031
3032 The block below does compile-time checking for endianness on platforms
3033 that use GCC and therefore allows compiling fat binaries on OSX by using
3034 '-arch ppc -arch i386' as the compile flags. The phrasing was choosen
3035 such that the configure-result is used on systems that don't use GCC.
3036 */
3037#ifdef __BIG_ENDIAN__
3038#define WORDS_BIGENDIAN 1
3039#else
3040#ifndef __LITTLE_ENDIAN__
3041#undef WORDS_BIGENDIAN
3042#endif
3043#endif])
3044
3045# Check whether right shifting a negative integer extends the sign bit
3046# or fills with zeros (like the Cray J90, according to Tim Peters).
3047AC_MSG_CHECKING(whether right shift extends the sign bit)
3048AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
3049AC_TRY_RUN([
3050int main()
3051{
3052 exit(((-1)>>3 == -1) ? 0 : 1);
3053}
3054],
3055ac_cv_rshift_extends_sign=yes,
3056ac_cv_rshift_extends_sign=no,
3057ac_cv_rshift_extends_sign=yes)])
3058AC_MSG_RESULT($ac_cv_rshift_extends_sign)
3059if test "$ac_cv_rshift_extends_sign" = no
3060then
3061 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS, 1,
3062 [Define if i>>j for signed int i does not extend the sign bit
3063 when i < 0])
3064fi
3065
3066# check for getc_unlocked and related locking functions
3067AC_MSG_CHECKING(for getc_unlocked() and friends)
3068AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
3069AC_TRY_LINK([#include <stdio.h>],[
3070 FILE *f = fopen("/dev/null", "r");
3071 flockfile(f);
3072 getc_unlocked(f);
3073 funlockfile(f);
3074], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
3075AC_MSG_RESULT($ac_cv_have_getc_unlocked)
3076if test "$ac_cv_have_getc_unlocked" = yes
3077then
3078 AC_DEFINE(HAVE_GETC_UNLOCKED, 1,
3079 [Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
3080fi
3081
3082# check where readline lives
3083# save the value of LIBS so we don't actually link Python with readline
3084LIBS_no_readline=$LIBS
3085AC_CHECK_LIB(readline, readline)
3086if test "$ac_cv_have_readline_readline" = no
3087then
3088 AC_CHECK_LIB(termcap, readline)
3089fi
3090
3091# check for readline 2.1
3092AC_CHECK_LIB(readline, rl_callback_handler_install,
3093 AC_DEFINE(HAVE_RL_CALLBACK, 1,
3094 [Define if you have readline 2.1]), , )
3095
3096# check for readline 2.2
3097AC_TRY_CPP([#include <readline/readline.h>],
3098have_readline=yes, have_readline=no)
3099if test $have_readline = yes
3100then
3101 AC_EGREP_HEADER([extern int rl_completion_append_character;],
3102 [readline/readline.h],
3103 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
3104 [Define if you have readline 2.2]), )
3105fi
3106
3107# check for readline 4.0
3108AC_CHECK_LIB(readline, rl_pre_input_hook,
3109 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
3110 [Define if you have readline 4.0]), , )
3111
3112# check for readline 4.2
3113AC_CHECK_LIB(readline, rl_completion_matches,
3114 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES, 1,
3115 [Define if you have readline 4.2]), , )
3116
3117# also in readline 4.2
3118AC_TRY_CPP([#include <readline/readline.h>],
3119have_readline=yes, have_readline=no)
3120if test $have_readline = yes
3121then
3122 AC_EGREP_HEADER([extern int rl_catch_signals;],
3123 [readline/readline.h],
3124 AC_DEFINE(HAVE_RL_CATCH_SIGNAL, 1,
3125 [Define if you can turn off readline's signal handling.]), )
3126fi
3127
3128# End of readline checks: restore LIBS
3129LIBS=$LIBS_no_readline
3130
3131AC_MSG_CHECKING(for broken nice())
3132AC_CACHE_VAL(ac_cv_broken_nice, [
3133AC_TRY_RUN([
3134int main()
3135{
3136 int val1 = nice(1);
3137 if (val1 != -1 && val1 == nice(2))
3138 exit(0);
3139 exit(1);
3140}
3141],
3142ac_cv_broken_nice=yes,
3143ac_cv_broken_nice=no,
3144ac_cv_broken_nice=no)])
3145AC_MSG_RESULT($ac_cv_broken_nice)
3146if test "$ac_cv_broken_nice" = yes
3147then
3148 AC_DEFINE(HAVE_BROKEN_NICE, 1,
3149 [Define if nice() returns success/failure instead of the new priority.])
3150fi
3151
3152AC_MSG_CHECKING(for broken poll())
3153AC_TRY_RUN([
3154#include <poll.h>
3155
3156int main (void)
3157 {
3158 struct pollfd poll_struct = { 42, POLLIN|POLLPRI|POLLOUT, 0 };
3159
3160 close (42);
3161
3162 int poll_test = poll (&poll_struct, 1, 0);
3163
3164 if (poll_test < 0)
3165 {
3166 exit(0);
3167 }
3168 else if (poll_test == 0 && poll_struct.revents != POLLNVAL)
3169 {
3170 exit(0);
3171 }
3172 else
3173 {
3174 exit(1);
3175 }
3176 }
3177],
3178ac_cv_broken_poll=yes,
3179ac_cv_broken_poll=no,
3180ac_cv_broken_poll=no)
3181AC_MSG_RESULT($ac_cv_broken_poll)
3182if test "$ac_cv_broken_poll" = yes
3183then
3184 AC_DEFINE(HAVE_BROKEN_POLL, 1,
3185 [Define if poll() sets errno on invalid file descriptors.])
3186fi
3187
3188# Before we can test tzset, we need to check if struct tm has a tm_zone
3189# (which is not required by ISO C or UNIX spec) and/or if we support
3190# tzname[]
3191AC_STRUCT_TIMEZONE
3192
3193# check tzset(3) exists and works like we expect it to
3194AC_MSG_CHECKING(for working tzset())
3195AC_CACHE_VAL(ac_cv_working_tzset, [
3196AC_TRY_RUN([
3197#include <stdlib.h>
3198#include <time.h>
3199#include <string.h>
3200
3201#if HAVE_TZNAME
3202extern char *tzname[];
3203#endif
3204
3205int main()
3206{
3207 /* Note that we need to ensure that not only does tzset(3)
3208 do 'something' with localtime, but it works as documented
3209 in the library reference and as expected by the test suite.
3210 This includes making sure that tzname is set properly if
3211 tm->tm_zone does not exist since it is the alternative way
3212 of getting timezone info.
3213
3214 Red Hat 6.2 doesn't understand the southern hemisphere
3215 after New Year's Day.
3216 */
3217
3218 time_t groundhogday = 1044144000; /* GMT-based */
3219 time_t midyear = groundhogday + (365 * 24 * 3600 / 2);
3220
3221 putenv("TZ=UTC+0");
3222 tzset();
3223 if (localtime(&groundhogday)->tm_hour != 0)
3224 exit(1);
3225#if HAVE_TZNAME
3226 /* For UTC, tzname[1] is sometimes "", sometimes " " */
3227 if (strcmp(tzname[0], "UTC") ||
3228 (tzname[1][0] != 0 && tzname[1][0] != ' '))
3229 exit(1);
3230#endif
3231
3232 putenv("TZ=EST+5EDT,M4.1.0,M10.5.0");
3233 tzset();
3234 if (localtime(&groundhogday)->tm_hour != 19)
3235 exit(1);
3236#if HAVE_TZNAME
3237 if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT"))
3238 exit(1);
3239#endif
3240
3241 putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0");
3242 tzset();
3243 if (localtime(&groundhogday)->tm_hour != 11)
3244 exit(1);
3245#if HAVE_TZNAME
3246 if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT"))
3247 exit(1);
3248#endif
3249
3250#if HAVE_STRUCT_TM_TM_ZONE
3251 if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT"))
3252 exit(1);
3253 if (strcmp(localtime(&midyear)->tm_zone, "AEST"))
3254 exit(1);
3255#endif
3256
3257 exit(0);
3258}
3259],
3260ac_cv_working_tzset=yes,
3261ac_cv_working_tzset=no,
3262ac_cv_working_tzset=no)])
3263AC_MSG_RESULT($ac_cv_working_tzset)
3264if test "$ac_cv_working_tzset" = yes
3265then
3266 AC_DEFINE(HAVE_WORKING_TZSET, 1,
3267 [Define if tzset() actually switches the local timezone in a meaningful way.])
3268fi
3269
3270# Look for subsecond timestamps in struct stat
3271AC_MSG_CHECKING(for tv_nsec in struct stat)
3272AC_CACHE_VAL(ac_cv_stat_tv_nsec,
3273AC_TRY_COMPILE([#include <sys/stat.h>], [
3274struct stat st;
3275st.st_mtim.tv_nsec = 1;
3276],
3277ac_cv_stat_tv_nsec=yes,
3278ac_cv_stat_tv_nsec=no,
3279ac_cv_stat_tv_nsec=no))
3280AC_MSG_RESULT($ac_cv_stat_tv_nsec)
3281if test "$ac_cv_stat_tv_nsec" = yes
3282then
3283 AC_DEFINE(HAVE_STAT_TV_NSEC, 1,
3284 [Define if you have struct stat.st_mtim.tv_nsec])
3285fi
3286
3287# Look for BSD style subsecond timestamps in struct stat
3288AC_MSG_CHECKING(for tv_nsec2 in struct stat)
3289AC_CACHE_VAL(ac_cv_stat_tv_nsec2,
3290AC_TRY_COMPILE([#include <sys/stat.h>], [
3291struct stat st;
3292st.st_mtimespec.tv_nsec = 1;
3293],
3294ac_cv_stat_tv_nsec2=yes,
3295ac_cv_stat_tv_nsec2=no,
3296ac_cv_stat_tv_nsec2=no))
3297AC_MSG_RESULT($ac_cv_stat_tv_nsec2)
3298if test "$ac_cv_stat_tv_nsec2" = yes
3299then
3300 AC_DEFINE(HAVE_STAT_TV_NSEC2, 1,
3301 [Define if you have struct stat.st_mtimensec])
3302fi
3303
3304# On HP/UX 11.0, mvwdelch is a block with a return statement
3305AC_MSG_CHECKING(whether mvwdelch is an expression)
3306AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
3307AC_TRY_COMPILE([#include <curses.h>], [
3308 int rtn;
3309 rtn = mvwdelch(0,0,0);
3310], ac_cv_mvwdelch_is_expression=yes,
3311 ac_cv_mvwdelch_is_expression=no,
3312 ac_cv_mvwdelch_is_expression=yes))
3313AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
3314
3315if test "$ac_cv_mvwdelch_is_expression" = yes
3316then
3317 AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1,
3318 [Define if mvwdelch in curses.h is an expression.])
3319fi
3320
3321AC_MSG_CHECKING(whether WINDOW has _flags)
3322AC_CACHE_VAL(ac_cv_window_has_flags,
3323AC_TRY_COMPILE([#include <curses.h>], [
3324 WINDOW *w;
3325 w->_flags = 0;
3326], ac_cv_window_has_flags=yes,
3327 ac_cv_window_has_flags=no,
3328 ac_cv_window_has_flags=no))
3329AC_MSG_RESULT($ac_cv_window_has_flags)
3330
3331
3332if test "$ac_cv_window_has_flags" = yes
3333then
3334 AC_DEFINE(WINDOW_HAS_FLAGS, 1,
3335 [Define if WINDOW in curses.h offers a field _flags.])
3336fi
3337
3338AC_MSG_CHECKING(for is_term_resized)
3339AC_TRY_COMPILE([#include <curses.h>], void *x=is_term_resized,
3340 AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.)
3341 AC_MSG_RESULT(yes),
3342 AC_MSG_RESULT(no)
3343)
3344
3345AC_MSG_CHECKING(for resize_term)
3346AC_TRY_COMPILE([#include <curses.h>], void *x=resize_term,
3347 AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.)
3348 AC_MSG_RESULT(yes),
3349 AC_MSG_RESULT(no)
3350)
3351
3352AC_MSG_CHECKING(for resizeterm)
3353AC_TRY_COMPILE([#include <curses.h>], void *x=resizeterm,
3354 AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.)
3355 AC_MSG_RESULT(yes),
3356 AC_MSG_RESULT(no)
3357)
3358
3359AC_CHECK_FILE(/dev/ptmx, AC_DEFINE(HAVE_DEV_PTMX, 1, [Define if we have /dev/ptmx.]))
3360AC_CHECK_FILE(/dev/ptc, AC_DEFINE(HAVE_DEV_PTC, 1, [Define if we have /dev/ptc.]))
3361
3362AC_MSG_CHECKING(for %zd printf() format support)
3363AC_TRY_RUN([#include <stdio.h>
3364#include <stddef.h>
3365#include <string.h>
3366
3367int main()
3368{
3369 char buffer[4];
3370
3371 if(sprintf(buffer, "%zd", (size_t)123) < 0)
3372 return 1;
3373
3374 if (strncmp(buffer, "123", 3))
3375 return 1;
3376
3377 return 0;
3378}],
3379[AC_MSG_RESULT(yes)
3380 AC_DEFINE(PY_FORMAT_SIZE_T, "z", [Define to printf format modifier for Py_ssize_t])],
3381 AC_MSG_RESULT(no))
3382
3383AC_CHECK_TYPE(socklen_t,,
3384 AC_DEFINE(socklen_t,int,
3385 Define to `int' if <sys/socket.h> does not define.),[
3386#ifdef HAVE_SYS_TYPES_H
3387#include <sys/types.h>
3388#endif
3389#ifdef HAVE_SYS_SOCKET_H
3390#include <sys/socket.h>
3391#endif
3392])
3393
3394AC_SUBST(THREADHEADERS)
3395
3396for h in `(cd $srcdir;echo Python/thread_*.h)`
3397do
3398 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
3399done
3400
3401AC_SUBST(SRCDIRS)
3402SRCDIRS="Parser Grammar Objects Python Modules Mac"
3403AC_MSG_CHECKING(for build directories)
3404for dir in $SRCDIRS; do
3405 if test ! -d $dir; then
3406 mkdir $dir
3407 fi
3408done
3409AC_MSG_RESULT(done)
3410
3411# generate output files
3412AC_CONFIG_FILES(Makefile.pre Modules/Setup.config)
3413AC_OUTPUT
3414
3415echo "creating Modules/Setup"
3416if test ! -f Modules/Setup
3417then
3418 if test "$MACHDEP" = "emx"; then
3419 cp $srcdir/PC/os2emx/Setup.os2emx Modules/Setup
3420 else
3421 cp $srcdir/Modules/Setup.dist Modules/Setup
3422 fi
3423fi
3424
3425echo "creating Modules/Setup.local"
3426if test ! -f Modules/Setup.local
3427then
3428 echo "# Edit this file for local setup changes" >Modules/Setup.local
3429fi
3430
3431echo "creating Makefile"
3432$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
3433 -s Modules Modules/Setup.config \
3434 Modules/Setup.local Modules/Setup
3435mv config.c Modules
Note: See TracBrowser for help on using the repository browser.