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

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

emx -> os2emx.

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