blob: f3da85a392974c2d25b1cd4e01bf7550302087b7 [file] [log] [blame]
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001dnl Process this file with autoconf 2.0 or later to make a configure script.
2AC_REVISION($Revision$)
3AC_PREREQ(2.0)
Guido van Rossum6085e321993-12-26 18:24:40 +00004AC_INIT(Include/object.h)
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +00005AC_CONFIG_HEADER(pyconfig.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +00006
Guido van Rossum642b6781997-07-19 19:35:41 +00007# Set VERSION so we only need to edit in one place (i.e., here)
8AC_SUBST(VERSION)
Guido van Rossum6db412b2001-04-18 04:37:57 +00009VERSION=2.2
Guido van Rossum642b6781997-07-19 19:35:41 +000010
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000011# Arguments passed to configure.
12AC_SUBST(CONFIG_ARGS)
13CONFIG_ARGS="$ac_configure_args"
14
Guido van Rossum4b6b5791996-09-09 20:09:34 +000015
Jack Jansenb6e9cad2001-08-15 01:26:28 +000016AC_ARG_ENABLE(framework,
17[ --enable-framework[=INSTALLDIR] Build (MacOSX|Darwin) framework],[
Jack Jansenb6e9cad2001-08-15 01:26:28 +000018 case $enableval in
19 yes)
20 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +000021 esac
22 case $enableval in
23 no)
24 PYTHONFRAMEWORK=
25 PYTHONFRAMEWORKDIR=no-framework
26 PYTHONFRAMEWORKPREFIX=
27 PYTHONFRAMEWORKINSTALLDIR=
28 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +000029 ;;
30 *)
Jack Jansen127e56e2001-09-11 14:41:54 +000031 PYTHONFRAMEWORK=Python
32 PYTHONFRAMEWORKDIR=Python.framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +000033 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +000034 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
35 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Jack Jansenb6e9cad2001-08-15 01:26:28 +000036 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +000037 ],[
38 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +000039 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +000040 PYTHONFRAMEWORKPREFIX=
41 PYTHONFRAMEWORKINSTALLDIR=
42 enable_framework=
43])
44AC_SUBST(PYTHONFRAMEWORK)
45AC_SUBST(PYTHONFRAMEWORKDIR)
46AC_SUBST(PYTHONFRAMEWORKPREFIX)
47AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Guido van Rossum4b6b5791996-09-09 20:09:34 +000048
Jack Jansenb6e9cad2001-08-15 01:26:28 +000049##AC_ARG_WITH(dyld,
50##[ --with-dyld Use (OpenStep|Rhapsody) dynamic linker],,)
51##
Guido van Rossumb418f891996-07-30 18:06:02 +000052# Set name for machine-dependent library files
53AC_SUBST(MACHDEP)
54AC_MSG_CHECKING(MACHDEP)
55if test -z "$MACHDEP"
56then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000057 ac_sys_system=`uname -s`
Martin v. Löwis130fb172001-07-19 11:00:41 +000058 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000059 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +000060 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +000061 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +000062 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000063 ac_md_system=`echo $ac_sys_system |
64 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
65 ac_md_release=`echo $ac_sys_release |
66 tr -d '[/ ]' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +000067 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +000068
Guido van Rossumbcd91e01997-03-20 20:46:29 +000069 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +000070 cygwin*) MACHDEP="cygwin";;
Guido van Rossumb97ef171997-09-28 05:44:03 +000071 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +000072 esac
73fi
Guido van Rossum91922671997-10-09 20:24:13 +000074
75#
76# SGI compilers allow the specification of the both the ABI and the
77# ISA on the command line. Depending on the values of these switches,
78# different and often incompatable code will be generated.
79#
80# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
81# thus supply support for various ABI/ISA combinations. The MACHDEP
82# variable is also adjusted.
83#
84AC_SUBST(SGI_ABI)
85if test ! -z "$SGI_ABI"
86then
87 CC="cc $SGI_ABI"
88 LDFLAGS="$SGI_ABI $LDFLAGS"
89 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
90fi
Guido van Rossumb418f891996-07-30 18:06:02 +000091AC_MSG_RESULT($MACHDEP)
92
Guido van Rossum627b2d71993-12-24 10:39:16 +000093# checks for alternative programs
Guido van Rossum5739e7e1995-01-20 16:50:53 +000094AC_MSG_CHECKING(for --without-gcc)
Barry Warsawc0d24d82000-06-29 16:12:00 +000095AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
Guido van Rossum433c8ad1994-08-01 12:07:07 +000096 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +000097 no) CC=cc
98 without_gcc=yes;;
99 yes) CC=gcc
100 without_gcc=no;;
101 *) CC=$withval
102 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000103 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000104 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000105 AIX*) CC=cc_r
106 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000107 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000108 case $BE_HOST_CPU in
109 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000110 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000111 without_gcc=yes
Fred Drake5790be12000-10-09 17:06:13 +0000112 OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000113 CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000114 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000115 ;;
116 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000117 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000118 without_gcc=no
Fred Drake5790be12000-10-09 17:06:13 +0000119 OPT=-O
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000120 ;;
121 *)
Fred Drake5790be12000-10-09 17:06:13 +0000122 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000123 ;;
124 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000125 AR="\$(srcdir)/Modules/ar_beos"
126 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000127 ;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000128 Monterey*)
129 RANLIB=:
Martin v. Löwis130fb172001-07-19 11:00:41 +0000130 without_gcc=;;
131 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000132 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000133AC_MSG_RESULT($without_gcc)
134
Guido van Rossum27552902001-01-23 01:52:26 +0000135AC_SUBST(CXX)
Guido van Rossum95012191999-12-16 17:50:52 +0000136AC_SUBST(MAINOBJ)
Fred Drakea1a84e72001-03-06 05:52:16 +0000137MAINOBJ=python.o
Guido van Rossum95012191999-12-16 17:50:52 +0000138AC_MSG_CHECKING(for --with-cxx=<compiler>)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000139AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
Martin v. Löwis537970f2000-12-13 17:37:02 +0000140 check_cxx=no
Guido van Rossum95012191999-12-16 17:50:52 +0000141 case $withval in
142 no) CXX=
143 with_cxx=no;;
144 *) CXX=$withval
Fred Drakea1a84e72001-03-06 05:52:16 +0000145 MAINOBJ=ccpython.o
Guido van Rossum95012191999-12-16 17:50:52 +0000146 with_cxx=$withval;;
147 esac], [
148 with_cxx=no
Martin v. Löwis537970f2000-12-13 17:37:02 +0000149 check_cxx=yes
Guido van Rossum95012191999-12-16 17:50:52 +0000150])
151AC_MSG_RESULT($with_cxx)
Martin v. Löwis537970f2000-12-13 17:37:02 +0000152
153dnl The following fragment works similar to AC_PROG_CXX.
154dnl It does not fail if CXX is not found, and it is not executed if
155dnl --with-cxx was given.
156dnl Finally, it does not test whether CXX is g++.
157
158if test "$check_cxx" = "yes"
159then
160 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
161 if test "$CXX" = "notfound"
162 then
163 CXX=
164 else
165 AC_PROG_CXX_WORKS
166 fi
167fi
168
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000169# If the user switches compilers, we can't believe the cache
170if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
171then
172 AC_ERROR(cached CC is different -- throw away $cache_file
173(it is also a good idea to do 'make clean' before compiling))
174fi
175
Guido van Rossum627b2d71993-12-24 10:39:16 +0000176AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000177
178# checks for UNIX variants that set C preprocessor variables
179AC_AIX
180AC_MINIX
181
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000182AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000183AC_MSG_CHECKING(for --with-suffix)
184AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
185 case $withval in
186 no) EXEEXT=;;
187 yes) EXEEXT=.exe;;
188 *) EXEEXT=$withval;;
189 esac])
190AC_MSG_RESULT($EXEEXT)
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000191# Test whether we're running on a non-case-sensitive system, in which
192# case we give a warning if no ext is given
193if test -d "python" -a -z "$EXEEXT"
194then
195 AC_MSG_WARN(This filesystem is not case-sensitive so you should probably use --with-suffix)
196fi
Guido van Rossumfb842551997-08-06 23:42:07 +0000197
Guido van Rossumdd997f71998-10-07 19:58:26 +0000198case $MACHDEP in
199bsdos*)
200 case $CC in
201 gcc) CC="$CC -D_HAVE_BSDI";;
202 esac;;
203esac
204
Guido van Rossum84561611997-08-21 00:08:11 +0000205case $ac_sys_system in
206hp*|HP*)
207 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000208 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000209 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000210Monterey*)
211 case $CC in
212 cc) CC="$CC -Wl,-Bexport";;
213 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000214SunOS*)
215 # Some functions have a prototype only with that define, e.g. confstr
216 AC_DEFINE(__EXTENSIONS__)
217 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000218esac
219
Martin v. Löwise8964d42001-03-06 12:09:07 +0000220
Neil Schemenauer61c51152001-01-26 16:18:16 +0000221AC_SUBST(LIBRARY)
222AC_MSG_CHECKING(LIBRARY)
223if test -z "$LIBRARY"
224then
225 LIBRARY='libpython$(VERSION).a'
226fi
227AC_MSG_RESULT($LIBRARY)
228
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000229# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000230# name of the library into which to insert object files). BLDLIBRARY is also
231# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
232# is blank as the main program is not linked directly against LDLIBRARY.
233# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
234# systems without shared libraries, LDLIBRARY is the same as LIBRARY
235# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
236# DLLLIBRARY is the shared (i.e., DLL) library.
237#
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000238AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000239AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000240AC_SUBST(BLDLIBRARY)
241AC_SUBST(LDLIBRARYDIR)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000242LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000243BLDLIBRARY='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000244DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000245LDLIBRARYDIR=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000246
Guido van Rossumfb842551997-08-06 23:42:07 +0000247# LINKCC is the command that links the python executable -- default is $(CC).
Fred Drake5790be12000-10-09 17:06:13 +0000248# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000249# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000250AC_SUBST(LINKCC)
251AC_MSG_CHECKING(LINKCC)
252if test -z "$LINKCC"
253then
254 case $ac_sys_system in
255 AIX*)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000256 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000257 dgux*)
258 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000259 Monterey64*)
260 LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
Guido van Rossum25f93031997-08-18 16:00:04 +0000261 *) LINKCC="\$(PURIFY) \$(CC)";;
Guido van Rossumfb842551997-08-06 23:42:07 +0000262 esac
263fi
264AC_MSG_RESULT($LINKCC)
265
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000266AC_MSG_CHECKING(LDLIBRARY)
267
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000268# DG/UX requires some fancy ld contortions to produce a .so from an .a
Fred Drake5790be12000-10-09 17:06:13 +0000269case $MACHDEP in
270dguxR4)
271 LDLIBRARY='libpython$(VERSION).so'
272 OPT="$OPT -pic"
273 ;;
274beos*)
275 LDLIBRARY='libpython$(VERSION).so'
276 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000277cygwin*)
278 LDLIBRARY='libpython$(VERSION).dll.a'
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000279 DLLLIBRARY='libpython$(VERSION).dll'
Guido van Rossumaef734b2001-01-10 21:09:12 +0000280 ;;
Fred Drake5790be12000-10-09 17:06:13 +0000281esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000282
Guido van Rossumb8552162001-09-05 14:58:11 +0000283# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
284# library that we build, but we do not want to link against it (we
285# will find it with a -framework option). For this reason there is an
286# extra variable BLDLIBRARY against which Python and the extension
287# modules are linked, BLDLIBRARY. This is normally the same as
288# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000289if test "$enable_framework"
290then
291 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
292 LDLIBRARYDIR='$(PYTHONFRAMEWORKDIR)'
293 BLDLIBRARY=''
294else
295 BLDLIBRARY='$(LDLIBRARY)'
296fi
297
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000298AC_MSG_RESULT($LDLIBRARY)
299
Guido van Rossum627b2d71993-12-24 10:39:16 +0000300AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000301AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000302AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000303
304case $MACHDEP in
305bsdos*)
306 # install -d does not work on BSDI
307 if test -z "$INSTALL"
308 then
309 INSTALL="${srcdir}/install-sh -c"
310 fi
311esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000312AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000313
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000314# Not every filesystem supports hard links
315AC_SUBST(LN)
316if test -z "$LN" ; then
317 case $ac_sys_system in
318 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000319 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000320 *) LN=ln;;
321 esac
322fi
323
Fred Drake9f715822001-07-11 06:27:00 +0000324# Check for --with-pydebug
325AC_MSG_CHECKING(for --with-pydebug)
326AC_ARG_WITH(pydebug,
327[ --with-pydebug build with Py_DEBUG defined], [
328if test "$withval" != no
329then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes); Py_DEBUG='true'
330else AC_MSG_RESULT(no); Py_DEBUG='false'
331fi],
332[AC_MSG_RESULT(no)])
333
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000334# Optimizer/debugger flags
Guido van Rossumb418f891996-07-30 18:06:02 +0000335AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000336if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000337then
Guido van Rossumb5875b61997-07-18 23:29:09 +0000338 case $GCC in
339 yes)
340 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000341 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000342 if test "$Py_DEBUG" = 'true' ; then
343 # Optimization messes up debuggers, so turn it off for
344 # debug builds.
345 OPT="-g -Wall -Wstrict-prototypes"
346 else
347 OPT="-g -O3 -Wall -Wstrict-prototypes"
348 fi;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000349 *)
Fred Drake9f715822001-07-11 06:27:00 +0000350 OPT="-O3 -Wall -Wstrict-prototypes";;
351 esac
352 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000353 *)
354 case $ac_sys_system in
355 UnixWare*)
356 OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
357 *)
358 OPT="-O";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000359 esac
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000360 esac
Jack Jansenca06bc62001-08-03 15:32:23 +0000361 case $ac_sys_system in
362 Darwin*)
363 OPT="$OPT -no-cpp-precomp";;
364 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000365fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000366
Trent Mick635f6fb2000-08-23 21:33:05 +0000367# The current (beta) Monterey compiler dies with optimizations
368case $ac_sys_system in
369Monterey*) OPT="";;
370esac
371
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000372if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000373then
374 OPT="$OPT $ac_arch_flags"
375fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000376
Guido van Rossum91922671997-10-09 20:24:13 +0000377AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
378AC_CACHE_VAL(ac_cv_opt_olimit_ok,
379[ac_save_cc="$CC"
380CC="$CC -OPT:Olimit=0"
381AC_TRY_RUN([int main() { return 0; }],
382 ac_cv_opt_olimit_ok=yes,
383 ac_cv_opt_olimit_ok=no)
384CC="$ac_save_cc"])
385AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000386if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000387 case $ac_sys_system in
388 Darwin*) OPT="$OPT" ;;
389 *) OPT="$OPT -OPT:Olimit=0";;
390 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000391else
392 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
393 AC_CACHE_VAL(ac_cv_olimit_ok,
394 [ac_save_cc="$CC"
395 CC="$CC -Olimit 1500"
396 AC_TRY_RUN([int main() { return 0; }],
397 ac_cv_olimit_ok=yes,
398 ac_cv_olimit_ok=no)
399 CC="$ac_save_cc"])
400 AC_MSG_RESULT($ac_cv_olimit_ok)
401 if test $ac_cv_olimit_ok = yes; then
402 OPT="$OPT -Olimit 1500"
403 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000404fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000405
Martin v. Löwis130fb172001-07-19 11:00:41 +0000406# -Kpthread, if available, provides the right #defines
407# and linker options to make pthread_create available
408AC_MSG_CHECKING(whether $CC accepts -Kpthread)
409AC_CACHE_VAL(ac_cv_kpthread,
410[ac_save_cc="$CC"
411CC="$CC -Kpthread"
412AC_TRY_LINK([#include <pthread.h>],[pthread_create(0,0,0,0)],
413 ac_cv_kpthread=yes,
414 ac_cv_kpthread=no)
415CC="$ac_save_cc"])
416
417# GCC does not reject -Kpthread as an illegal option, it merely complains that
418# it is unrecognized
419if test "$GCC" = "yes"
420then ac_cv_kpthread="no, we have gcc"
421fi
422AC_MSG_RESULT($ac_cv_kpthread)
423
Fred Drakece81d592000-07-09 14:39:29 +0000424dnl # check for ANSI or K&R ("traditional") preprocessor
425dnl AC_MSG_CHECKING(for C preprocessor type)
426dnl AC_TRY_COMPILE([
427dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
428dnl int foo;
429dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
430dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
431dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +0000432
Guido van Rossum627b2d71993-12-24 10:39:16 +0000433# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000434AC_HEADER_STDC
Martin v. Löwis9b75dca2001-08-10 13:58:50 +0000435AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h langinfo.h locale.h \
436ncurses.h poll.h pthread.h \
Eric S. Raymond13603592001-01-16 15:01:26 +0000437signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
Fred Drake2ca5f3b2001-05-11 16:10:56 +0000438sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
Andrew M. Kuchling881fd902001-07-14 20:55:52 +0000439sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
Fred Drakeae90f8d2000-09-15 03:38:12 +0000440sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis1ba3fd52001-08-10 20:29:40 +0000441ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000442AC_HEADER_DIRENT
Guido van Rossum627b2d71993-12-24 10:39:16 +0000443
444# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000445was_it_defined=no
446AC_MSG_CHECKING(for clock_t in time.h)
447AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
448AC_MSG_RESULT($was_it_defined)
449
Guido van Rossum810cc512001-09-09 23:51:39 +0000450# Two defines needed to enable largefile support on various platforms
451# These may affect some typedefs
452AC_DEFINE(_LARGEFILE_SOURCE)
453AC_DEFINE(_FILE_OFFSET_BITS, 64)
454
Guido van Rossum300fda71996-08-19 21:58:16 +0000455# Add some code to confdefs.h so that the test for off_t works on SCO
456cat >> confdefs.h <<\EOF
457#if defined(SCO_DS)
458#undef _OFF_T
459#endif
460EOF
461
Guido van Rossumef2255b2000-03-10 22:30:29 +0000462# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000463AC_TYPE_MODE_T
464AC_TYPE_OFF_T
465AC_TYPE_PID_T
466AC_TYPE_SIGNAL
467AC_TYPE_SIZE_T
468AC_TYPE_UID_T
Guido van Rossum627b2d71993-12-24 10:39:16 +0000469
Guido van Rossumef2255b2000-03-10 22:30:29 +0000470# Sizes of various common basic types
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000471AC_CHECK_SIZEOF(int)
472AC_CHECK_SIZEOF(long)
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000473AC_CHECK_SIZEOF(void *)
Guido van Rossumef2255b2000-03-10 22:30:29 +0000474AC_CHECK_SIZEOF(char)
475AC_CHECK_SIZEOF(short)
476AC_CHECK_SIZEOF(float)
477AC_CHECK_SIZEOF(double)
Fred Drakea3f6e912000-06-29 20:44:47 +0000478AC_CHECK_SIZEOF(fpos_t)
Guido van Rossumac405f61994-09-12 10:56:06 +0000479
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000480AC_MSG_CHECKING(for long long support)
481have_long_long=no
482AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
483AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000484if test "$have_long_long" = yes ; then
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000485AC_CHECK_SIZEOF(long long)
486fi
487
Barry Warsawbc7c7f92000-08-18 04:53:33 +0000488AC_MSG_CHECKING(for uintptr_t support)
489have_uintptr_t=no
490AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
491AC_MSG_RESULT($have_uintptr_t)
492if test "$have_uintptr_t" = yes ; then
493AC_CHECK_SIZEOF(uintptr_t)
494fi
495
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000496# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
497AC_MSG_CHECKING(size of off_t)
498AC_CACHE_VAL(ac_cv_sizeof_off_t,
499[AC_TRY_RUN([#include <stdio.h>
500#include <sys/types.h>
501main()
502{
503 FILE *f=fopen("conftestval", "w");
504 if (!f) exit(1);
505 fprintf(f, "%d\n", sizeof(off_t));
506 exit(0);
507}], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
508])
509AC_MSG_RESULT($ac_cv_sizeof_off_t)
510AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
511
512AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000513if test "$have_long_long" = yes -a \
514 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
515 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000516 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
517 AC_MSG_RESULT(yes)
518else
519 AC_MSG_RESULT(no)
520fi
521
Fred Drakea3f6e912000-06-29 20:44:47 +0000522# AC_CHECK_SIZEOF() doesn't include <time.h>.
523AC_MSG_CHECKING(size of time_t)
524AC_CACHE_VAL(ac_cv_sizeof_time_t,
525[AC_TRY_RUN([#include <stdio.h>
526#include <time.h>
527main()
528{
529 FILE *f=fopen("conftestval", "w");
530 if (!f) exit(1);
531 fprintf(f, "%d\n", sizeof(time_t));
532 exit(0);
533}], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
534])
535AC_MSG_RESULT($ac_cv_sizeof_time_t)
536AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
537
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000538
Trent Mick635f6fb2000-08-23 21:33:05 +0000539# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +0000540ac_save_cc="$CC"
541if test "$ac_cv_kpthread" = "yes"
542then CC="$CC -Kpthread"
543fi
Trent Mick635f6fb2000-08-23 21:33:05 +0000544AC_MSG_CHECKING(for pthread_t)
545have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +0000546AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +0000547AC_MSG_RESULT($have_pthread_t)
548if test "$have_pthread_t" = yes ; then
549 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
550 AC_MSG_CHECKING(size of pthread_t)
551 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
552 [AC_TRY_RUN([#include <stdio.h>
553 #include <pthread.h>
554 main()
555 {
556 FILE *f=fopen("conftestval", "w");
557 if (!f) exit(1);
558 fprintf(f, "%d\n", sizeof(pthread_t));
559 exit(0);
560 }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
561 ])
562 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
563 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
564fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +0000565CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +0000566
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000567AC_MSG_CHECKING(for --enable-toolbox-glue)
568AC_ARG_ENABLE(toolbox-glue,
569[ --enable-toolbox-glue disable/enable MacOSX glue code for extensions])
570
571if test -z "$enable_toolbox_glue"
572then
573 case $ac_sys_system/$ac_sys_release in
574 Darwin/*)
575 enable_toolbox_glue="yes";;
576 *)
577 enable_toolbox_glue="no";;
578 esac
579fi
580case "$enable_toolbox_glue" in
581yes)
582 extra_frameworks="-framework Carbon -framework Foundation"
583 extra_machdep_objs="Python/mactoolboxglue.o"
Jack Jansen591cbed2001-08-15 13:55:15 +0000584 extra_undefs="-u __dummy -u _PyMac_Error"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000585 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE)
586 ;;
587*)
588 extra_frameworks=""
589 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +0000590 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000591 ;;
592esac
593AC_MSG_RESULT($enable_toolbox_glue)
594
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000595AC_SUBST(LIBTOOL_CRUFT)
596case $ac_sys_system/$ac_sys_release in
Jack Jansena3891ea2001-09-07 14:25:12 +0000597 Darwin/1.4*)
598 ns_undef_sym='_environ'
599 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -flat_namespace -U $ns_undef_sym"
600 LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
601 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
602 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +0000603 Darwin/*)
604 ns_undef_sym='_environ'
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000605 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym"
606 LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
607 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
608 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000609esac
610
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000611AC_MSG_CHECKING(for --enable-framework)
612if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000613then
Jack Jansenca06bc62001-08-03 15:32:23 +0000614 OPT="$OPT -fno-common -dynamic"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000615 # -U __environ is needed since bundles don't have access
616 # to crt0 when built but will always be linked against it
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000617 # -F. is needed to allow linking to the framework while
618 # in the build location.
619
Jack Jansena3891ea2001-09-07 14:25:12 +0000620 case $ac_sys_system/$ac_sys_release in
621 Darwin/1.4*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-flat_namespace,-U,$ns_undef_sym";;
622 Darwin/*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-U,$ns_undef_sym";;
623 esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000624 AC_DEFINE(WITH_NEXT_FRAMEWORK)
625 AC_MSG_RESULT(yes)
626else
627 AC_MSG_RESULT(no)
628fi
629
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000630AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000631case $ac_sys_system/$ac_sys_release in
632 Darwin/*)
633 AC_DEFINE(WITH_DYLD)
634 AC_MSG_RESULT(always on for Darwin)
635 ;;
636 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000637 AC_MSG_RESULT(no)
638 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000639esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000640
Guido van Rossumac405f61994-09-12 10:56:06 +0000641# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +0000642AC_SUBST(SO)
643AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000644AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000645AC_SUBST(CCSHARED)
646AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000647# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +0000648# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000649AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000650if test -z "$SO"
651then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000652 case $ac_sys_system in
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000653 hp*|HP*) SO=.sl;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000654 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000655 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000656 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000657fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000658AC_MSG_RESULT($SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000659# LDSHARED is the ld *command* used to create shared library
Martin v. Löwis5b718fc2001-09-10 15:34:42 +0000660# -- "ld" on SunOS 4.x.x, "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000661# (Shared libraries in this instance are shared modules to be loaded into
662# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000663AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000664if test -z "$LDSHARED"
665then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000666 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000667 AIX*)
668 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
669 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
670 ;;
671 BeOS*)
672 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
673 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
674 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000675 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +0000676 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000677 SunOS/4*) LDSHARED="ld";;
Greg Ward57c9a662000-05-26 12:22:54 +0000678 SunOS/5*)
679 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +0000680 then LDSHARED='$(CC) -shared'
Martin v. Löwis5b718fc2001-09-10 15:34:42 +0000681 else LDSHARED="$(CC) -G";
Greg Ward57c9a662000-05-26 12:22:54 +0000682 fi ;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000683 hp*|HP*) LDSHARED="ld -b";;
Guido van Rossum71001e41995-01-26 00:44:03 +0000684 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Guido van Rossum7d473291995-01-20 14:12:16 +0000685 DYNIX/ptx*) LDSHARED="ld -G";;
Jack Jansena3891ea2001-09-07 14:25:12 +0000686 Darwin/1.4*)
687 LDSHARED='$(CC) $(LDFLAGS) -bundle'
688 if test "$enable_framework" ; then
689 # Link against the framework. All externals should be defined.
690 LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
691 else
692 # No framework. Ignore undefined symbols, assuming they come from Python
693 LDSHARED="$LDSHARED -flat_namespace -undefined suppress"
694 fi ;;
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000695 Darwin/*)
696 LDSHARED='$(CC) $(LDFLAGS) -bundle'
697 if test "$enable_framework" ; then
698 # Link against the framework. All externals should be defined.
699 LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
700 else
701 # No framework. Ignore undefined symbols, assuming they come from Python
702 LDSHARED="$LDSHARED -undefined suppress"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000703 fi ;;
Guido van Rossum81652ab1996-07-21 02:53:27 +0000704 Linux*) LDSHARED="gcc -shared";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000705 dgux*) LDSHARED="ld -G";;
Guido van Rossum458e7fa1999-09-17 15:40:40 +0000706 BSD/OS*/4*) LDSHARED="gcc -shared";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000707 OpenBSD*|NetBSD*|FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +0000708 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +0000709 then
710 LDSHARED="cc -shared ${LDFLAGS}"
711 else
712 LDSHARED="ld -Bshareable ${LDFLAGS}"
713 fi;;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000714 UnixWare*)
715 if test "$GCC" = "yes"
716 then LDSHARED="$(CC) -shared"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000717 else LDSHARED="$(CC) -G"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000718 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000719 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000720 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000721 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000722 *) LDSHARED="ld";;
723 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000724fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000725AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000726BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +0000727# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000728# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000729AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000730if test -z "$CCSHARED"
731then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000732 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +0000733 SunOS*) if test "$GCC" = yes;
734 then CCSHARED="-fPIC";
735 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +0000736 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +0000737 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +0000738 else CCSHARED="+z";
739 fi;;
Neil Schemenauer61c51152001-01-26 16:18:16 +0000740 Linux*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000741 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000742 FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000743 UnixWare*)
744 if test "$GCC" = "yes"
745 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000746 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000747 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000748 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000749 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000750 IRIX*/6*) case $CC in
751 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +0000752 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000753 esac;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000754 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000755 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000756fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000757AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000758# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000759# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000760AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000761if test -z "$LINKFORSHARED"
762then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000763 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000764 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000765 hp*|HP*)
Guido van Rossum304dd2d1997-10-20 23:10:56 +0000766 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000767 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum2d9feed1997-11-24 17:36:21 +0000768 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000769 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000770 Darwin/*)
771 # -u __dummy makes the linker aware of the objc runtime
772 # in System.framework; otherwise, __objcInit (referenced in
773 # crt1.o) gets erroneously defined as common, which breaks dynamic
774 # loading of any modules which reference it in System.framework.
775 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
776 # not used by the core itself but which needs to be in the core so
777 # that dynamically loaded extension modules have access to it.
Jack Jansen591cbed2001-08-15 13:55:15 +0000778 LINKFORSHARED="$extra_undefs -framework System"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000779 if test "$enable_framework"
780 then
781 LINKFORSHARED="$LINKFORSHARED -framework Python"
782 fi
783 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000784 UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Guido van Rossum300fda71996-08-19 21:58:16 +0000785 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +0000786 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000787 FreeBSD*|NetBSD*|OpenBSD*)
Guido van Rossumdf693651999-01-07 21:50:41 +0000788 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
789 then
790 LINKFORSHARED="-Wl,--export-dynamic"
791 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000792 SunOS/5*) case $CC in
793 *gcc*)
Guido van Rossum9c6ba9b2000-02-03 13:42:50 +0000794 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000795 then
796 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000797 fi;;
798 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000799 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000800fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000801AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000802
Neil Schemenauer61c51152001-01-26 16:18:16 +0000803AC_SUBST(CFLAGSFORSHARED)
804AC_MSG_CHECKING(CFLAGSFORSHARED)
805if test ! "$LIBRARY" = "$LDLIBRARY"
806then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +0000807 case $ac_sys_system in
808 CYGWIN*)
809 # Cygwin needs CCSHARED when building extension DLLs
810 # but not when building the interpreter DLL.
811 CFLAGSFORSHARED='';;
812 *)
813 CFLAGSFORSHARED='$(CCSHARED)'
814 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +0000815fi
816AC_MSG_RESULT($CFLAGSFORSHARED)
817
Guido van Rossum627b2d71993-12-24 10:39:16 +0000818# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000819AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
820AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000821
822# checks for system dependent C++ extensions support
823case "$ac_sys_system" in
824 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
825 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
826 [loadAndInit("", 0, "")],
827 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
828 AC_MSG_RESULT(yes)],
829 [AC_MSG_RESULT(no)]);;
830 *) ;;
831esac
832
Guido van Rossum70c7f481998-03-26 18:44:10 +0000833# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
834# However on SGI IRIX, these exist but are broken.
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000835# BeOS' sockets are stashed in libnet.
836case "$ac_sys_system" in
837IRIX*) ;;
Guido van Rossum2cb56601998-05-07 13:25:56 +0000838*)
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000839AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000840AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +0000841;;
842esac
843case "$ac_sys_system" in
844BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000845AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
846;;
847esac
Guido van Rossum70c7f481998-03-26 18:44:10 +0000848
Guido van Rossumc5a39031996-07-31 17:35:03 +0000849AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000850AC_ARG_WITH(libs,
851[ --with-libs='lib1 ...' link against additional libs], [
Guido van Rossumc5a39031996-07-31 17:35:03 +0000852AC_MSG_RESULT($withval)
853LIBS="$withval $LIBS"
854], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000855
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000856# Determine if signalmodule should be used.
857AC_SUBST(USE_SIGNAL_MODULE)
858AC_SUBST(SIGNAL_OBJS)
859AC_MSG_CHECKING(for --with-signal-module)
860AC_ARG_WITH(signal-module,
861[ --with-signal-module disable/enable signal module])
862
863if test -z "$with_signal_module"
864then with_signal_module="yes"
865fi
866AC_MSG_RESULT($with_signal_module)
867
868if test "${with_signal_module}" = "yes"; then
869 USE_SIGNAL_MODULE=""
870 SIGNAL_OBJS=""
871else
872 USE_SIGNAL_MODULE="#"
873 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
874fi
875
Guido van Rossum3d15bd82001-01-10 18:53:48 +0000876# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +0000877AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000878USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +0000879
Guido van Rossum54d93d41997-01-22 20:51:58 +0000880AC_MSG_CHECKING(for --with-dec-threads)
881AC_SUBST(LDLAST)
882AC_ARG_WITH(dec-threads,
Barry Warsawc0d24d82000-06-29 16:12:00 +0000883[ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
884AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +0000885LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +0000886if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +0000887 with_thread="$withval";
888fi],
889AC_MSG_RESULT(no))
890
891AC_MSG_CHECKING(for --with-threads)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000892AC_ARG_WITH(threads,
893[ --with(out)-threads[=DIRECTORY] disable/enable thread support])
Guido van Rossum54d93d41997-01-22 20:51:58 +0000894
Barry Warsawc0d24d82000-06-29 16:12:00 +0000895# --with-thread is deprecated, but check for it anyway
Barry Warsawa0f3c5c2000-06-30 16:39:35 +0000896AC_ARG_WITH(thread,
897[ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
898with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +0000899
900if test -z "$with_threads"
901then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000902fi
Barry Warsawc0d24d82000-06-29 16:12:00 +0000903AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +0000904
Barry Warsawc0d24d82000-06-29 16:12:00 +0000905if test "$with_threads" = "no"
906then
907 USE_THREAD_MODULE="#"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000908elif test "$ac_cv_kpthread" = "yes"
909then
910 CC="$CC -Kpthread"
911 AC_DEFINE(WITH_THREAD)
912 AC_DEFINE(_POSIX_THREADS)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000913 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +0000914 LIBOBJS="$LIBOBJS thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +0000915else
Martin v. Löwis130fb172001-07-19 11:00:41 +0000916 if test ! -z "$with_threads" -a -d "$with_threads"
917 then LDFLAGS="$LDFLAGS -L$with_threads"
918 fi
919 if test ! -z "$withval" -a -d "$withval"
920 then LDFLAGS="$LDFLAGS -L$withval"
921 fi
922 AC_DEFINE(_REENTRANT)
923 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
924 AC_DEFINE(C_THREADS)
925 LIBOBJS="$LIBOBJS thread.o"],[
926 AC_MSG_CHECKING(for --with-pth)
927 AC_ARG_WITH(pth,
928 [ --with-pth use GNU pth threading libraries], [
929 AC_MSG_RESULT($withval)
930 AC_DEFINE(WITH_THREAD)
931 AC_DEFINE(HAVE_PTH)
932 LIBS="-lpth $LIBS"
933 LIBOBJS="$LIBOBJS thread.o"],[
934 AC_MSG_RESULT(no)
935 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000936 case $ac_sys_system in
937 Darwin*) ;;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000938 *) AC_DEFINE(_POSIX_THREADS)
939 posix_threads=yes
940 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000941 esac
Martin v. Löwis130fb172001-07-19 11:00:41 +0000942 LIBS="-lpthread $LIBS"
943 LIBOBJS="$LIBOBJS thread.o"],[
944 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
945 case $ac_sys_system in
946 Darwin*) ;;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000947 *) AC_DEFINE(_POSIX_THREADS)
948 posix_threads=yes
949 ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000950 esac
951 LIBOBJS="$LIBOBJS thread.o"],[
952 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
953 AC_DEFINE(BEOS_THREADS)
954 LIBOBJS="$LIBOBJS thread.o"],[
955 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
956 AC_DEFINE(_POSIX_THREADS)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000957 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +0000958 LIBS="$LIBS -lpthreads"
959 LIBOBJS="$LIBOBJS thread.o"], [
960 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
961 AC_DEFINE(_POSIX_THREADS)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000962 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +0000963 LIBS="$LIBS -lc_r"
964 LIBOBJS="$LIBOBJS thread.o"], [
965 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
966 AC_DEFINE(_POSIX_THREADS)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000967 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +0000968 LIBS="$LIBS -lthread"
969 LIBOBJS="$LIBOBJS thread.o"], [
970 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
971 AC_DEFINE(_POSIX_THREADS)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000972 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +0000973 LIBS="$LIBS -lpthread"
974 LIBOBJS="$LIBOBJS thread.o"], [
975 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
976 AC_DEFINE(_POSIX_THREADS)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000977 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +0000978 LIBS="$LIBS -lcma"
979 LIBOBJS="$LIBOBJS thread.o"],[
980 USE_THREAD_MODULE="#"])
981 ])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +0000982
Guido van Rossumd0b69ec2001-09-10 14:10:54 +0000983 if test "$posix_threads" = "yes"; then
984 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
985 AC_CACHE_VAL(ac_cv_pthread_system_supported,
986 [AC_TRY_RUN([#include <pthread.h>
987 void *foo(void *parm) {
988 return NULL;
989 }
990 main() {
991 pthread_attr_t attr;
992 if (pthread_attr_init(&attr)) exit(-1);
993 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
994 if (pthread_create(NULL, &attr, foo, NULL)) exit(-1);
995 exit(0);
996 }], ac_cv_pthread_system_supported=yes, ac_cv_pthread_system_supported=no)
997 ])
998 AC_MSG_RESULT($ac_cv_pthread_system_supported)
999 if test "$ac_cv_pthread_system_supported" = "yes"; then
1000 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED)
1001 fi
1002 fi
1003
Martin v. Löwis130fb172001-07-19 11:00:41 +00001004 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1005 LIBS="$LIBS -lmpc"
1006 LIBOBJS="$LIBOBJS thread.o"
1007 USE_THREAD_MODULE=""])
1008 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1009 LIBS="$LIBS -lthread"
1010 LIBOBJS="$LIBOBJS thread.o"
1011 USE_THREAD_MODULE=""])
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001012
Martin v. Löwis130fb172001-07-19 11:00:41 +00001013 if test "$USE_THREAD_MODULE" != "#"
1014 then
1015 # If the above checks didn't disable threads, (at least) OSF1
1016 # needs this '-threads' argument during linking.
1017 case $ac_sys_system in
1018 OSF1) LDLAST=-threads;;
1019 esac
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001020 fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00001021fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001022
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001023# Check for enable-ipv6
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001024AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001025AC_ARG_ENABLE(ipv6,
1026[ --enable-ipv6 Enable ipv6 (with ipv4) support
1027 --disable-ipv6 Disable ipv6 support],
1028[ case "$enableval" in
1029 no)
1030 AC_MSG_RESULT(no)
1031 ipv6=no
1032 ;;
1033 *) AC_MSG_RESULT(yes)
1034 AC_DEFINE(ENABLE_IPV6)
1035 ipv6=yes
1036 ;;
1037 esac ],
1038
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001039[
1040dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001041 AC_TRY_RUN([ /* AF_INET6 available check */
1042#include <sys/types.h>
1043#include <sys/socket.h>
1044main()
1045{
1046 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1047 exit(1);
1048 else
1049 exit(0);
1050}
1051],
1052 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001053 ipv6=yes,
1054 AC_MSG_RESULT(no)
1055 ipv6=no,
1056 AC_MSG_RESULT(no)
1057 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001058)
1059
1060if test "$ipv6" = "yes"; then
1061 AC_MSG_CHECKING(if RFC2553 API is available)
1062 AC_TRY_COMPILE([#include <sys/types.h>
1063#include <netinet/in.h>],
1064 [struct sockaddr_in6 x;
1065x.sin6_scope_id;],
1066 AC_MSG_RESULT(yes)
1067 ipv6=yes,
1068 AC_MSG_RESULT(no, IPv6 disabled)
1069 ipv6=no)
1070fi
1071
1072if test "$ipv6" = "yes"; then
1073 AC_DEFINE(ENABLE_IPV6)
1074fi
1075])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001076
1077ipv6type=unknown
1078ipv6lib=none
1079ipv6trylibc=no
1080
1081if test "$ipv6" = "yes"; then
1082 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00001083 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1084 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001085 case $i in
1086 inria)
1087 dnl http://www.kame.net/
1088 AC_EGREP_CPP(yes, [dnl
1089#include <netinet/in.h>
1090#ifdef IPV6_INRIA_VERSION
1091yes
1092#endif],
1093 [ipv6type=$i;
1094 OPT="-DINET6 $OPT"])
1095 ;;
1096 kame)
1097 dnl http://www.kame.net/
1098 AC_EGREP_CPP(yes, [dnl
1099#include <netinet/in.h>
1100#ifdef __KAME__
1101yes
1102#endif],
1103 [ipv6type=$i;
1104 ipv6lib=inet6
1105 ipv6libdir=/usr/local/v6/lib
1106 ipv6trylibc=yes
1107 OPT="-DINET6 $OPT"])
1108 ;;
1109 linux-glibc)
1110 dnl http://www.v6.linux.or.jp/
1111 AC_EGREP_CPP(yes, [dnl
1112#include <features.h>
1113#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1114yes
1115#endif],
1116 [ipv6type=$i;
1117 ipv6trylibc=yes
1118 OPT="-DINET6 $OPT"])
1119 ;;
1120 linux-inet6)
1121 dnl http://www.v6.linux.or.jp/
1122 if test -d /usr/inet6; then
1123 ipv6type=$i
1124 ipv6lib=inet6
1125 ipv6libdir=/usr/inet6/lib
1126 OPT="-DINET6 -I/usr/inet6/include $OPT"
1127 fi
1128 ;;
1129 solaris)
1130 if test -f /etc/netconfig; then
1131 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1132 ipv6type=$i
1133 ipv6trylibc=yes
1134 OPT="-DINET6 $OPT"
1135 fi
1136 fi
1137 ;;
1138 toshiba)
1139 AC_EGREP_CPP(yes, [dnl
1140#include <sys/param.h>
1141#ifdef _TOSHIBA_INET6
1142yes
1143#endif],
1144 [ipv6type=$i;
1145 ipv6lib=inet6;
1146 ipv6libdir=/usr/local/v6/lib;
1147 OPT="-DINET6 $OPT"])
1148 ;;
1149 v6d)
1150 AC_EGREP_CPP(yes, [dnl
1151#include </usr/local/v6/include/sys/v6config.h>
1152#ifdef __V6D__
1153yes
1154#endif],
1155 [ipv6type=$i;
1156 ipv6lib=v6;
1157 ipv6libdir=/usr/local/v6/lib;
1158 OPT="-I/usr/local/v6/include $OPT"])
1159 ;;
1160 zeta)
1161 AC_EGREP_CPP(yes, [dnl
1162#include <sys/param.h>
1163#ifdef _ZETA_MINAMI_INET6
1164yes
1165#endif],
1166 [ipv6type=$i;
1167 ipv6lib=inet6;
1168 ipv6libdir=/usr/local/v6/lib;
1169 OPT="-DINET6 $OPT"])
1170 ;;
1171 esac
1172 if test "$ipv6type" != "unknown"; then
1173 break
1174 fi
1175 done
1176 AC_MSG_RESULT($ipv6type)
1177fi
1178
1179if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1180 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1181 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1182 echo "using lib$ipv6lib"
1183 else
1184 if test $ipv6trylibc = "yes"; then
1185 echo "using libc"
1186 else
1187 echo 'Fatal: no $ipv6lib library found. cannot continue.'
1188 echo "You need to fetch lib$ipv6lib.a from appropriate"
1189 echo 'ipv6 kit and compile beforehand.'
1190 exit 1
1191 fi
1192 fi
1193fi
1194
Barry Warsawef82cd72000-06-30 16:21:01 +00001195# Check for GC support
Barry Warsawef82cd72000-06-30 16:21:01 +00001196AC_MSG_CHECKING(for --with-cycle-gc)
1197AC_ARG_WITH(cycle-gc,
1198[ --with(out)-cycle-gc disable/enable garbage collection])
1199
1200if test -z "$with_cycle_gc"
1201then with_cycle_gc="yes"
1202fi
Neil Schemenauer9c63e6d2001-08-29 23:44:38 +00001203if test "$with_cycle_gc" != "no"
Barry Warsawef82cd72000-06-30 16:21:01 +00001204then
Barry Warsawef82cd72000-06-30 16:21:01 +00001205 AC_DEFINE(WITH_CYCLE_GC)
1206fi
1207AC_MSG_RESULT($with_cycle_gc)
1208
Neil Schemenauera35c6882001-02-27 04:45:05 +00001209# Check for Python-specific malloc support
1210AC_MSG_CHECKING(for --with-pymalloc)
1211AC_ARG_WITH(pymalloc,
1212[ --with(out)-pymalloc disable/enable specialized mallocs], [
1213if test "$withval" != no
1214then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
1215else AC_MSG_RESULT(no)
1216fi],
1217[AC_MSG_RESULT(no)])
1218
Barry Warsawef82cd72000-06-30 16:21:01 +00001219# Check for --with-wctype-functions
1220AC_MSG_CHECKING(for --with-wctype-functions)
1221AC_ARG_WITH(wctype-functions,
1222[ --with-wctype-functions use wctype.h functions], [
1223if test "$withval" != no
1224then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
1225else AC_MSG_RESULT(no)
1226fi],
1227[AC_MSG_RESULT(no)])
1228
Guido van Rossum68242b51996-05-28 22:53:03 +00001229# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001230AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00001231DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001232
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001233AC_MSG_CHECKING(for --with-sgi-dl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001234AC_ARG_WITH(sgi-dl,
1235[ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001236AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001237AC_DEFINE(WITH_SGI_DL)
Guido van Rossume97ee181999-12-20 21:27:22 +00001238DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001239dldir=$withval
Guido van Rossum40951012000-10-07 16:21:27 +00001240if test ! -z "$dldir" -a -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001241then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001242else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1243fi
1244DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001245LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001246
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001247AC_MSG_CHECKING(for --with-dl-dld)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001248AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001249AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001250AC_DEFINE(WITH_DL_DLD)
Guido van Rossume97ee181999-12-20 21:27:22 +00001251DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001252dldir=`echo "$withval" | sed 's/,.*//'`
1253dlddir=`echo "$withval" | sed 's/.*,//'`
Barry Warsaw7d1219d2000-10-05 18:45:53 +00001254if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001255then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001256else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1257fi
1258DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001259LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +00001260
Guido van Rossume97ee181999-12-20 21:27:22 +00001261# the dlopen() function means we might want to use dynload_shlib.o. some
1262# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00001263AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00001264
1265# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1266# loading of modules.
1267AC_SUBST(DYNLOADFILE)
1268AC_MSG_CHECKING(DYNLOADFILE)
1269if test -z "$DYNLOADFILE"
1270then
1271 case $ac_sys_system/$ac_sys_release in
1272 AIX*) DYNLOADFILE="dynload_aix.o";;
1273 BeOS*) DYNLOADFILE="dynload_beos.o";;
1274 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001275 Darwin/*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00001276 *)
1277 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1278 # out any dynamic loading
1279 if test "$ac_cv_func_dlopen" = yes
1280 then DYNLOADFILE="dynload_shlib.o"
1281 else DYNLOADFILE="dynload_stub.o"
1282 fi
1283 ;;
1284 esac
1285fi
1286AC_MSG_RESULT($DYNLOADFILE)
1287if test "$DYNLOADFILE" != "dynload_stub.o"
1288then
1289 AC_DEFINE(HAVE_DYNAMIC_LOADING)
1290fi
1291
Jack Jansenc49e5b72001-06-19 15:00:23 +00001292# MACHDEP_OBJS can be set to platform-specific object files needed by Python
1293
1294AC_SUBST(MACHDEP_OBJS)
1295AC_MSG_CHECKING(MACHDEP_OBJS)
1296if test -z "$MACHDEP_OBJS"
1297then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001298 MACHDEP_OBJS=$extra_machdep_objs
1299else
1300 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00001301fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001302AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00001303
Guido van Rossum627b2d71993-12-24 10:39:16 +00001304# checks for library functions
Thomas Wouters3a584202000-08-05 23:28:51 +00001305AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
Fred Drake35a092f1999-12-13 16:23:35 +00001306 flock fork fsync fdatasync fpathconf ftime ftruncate \
Martin v. Löwisf95dd0a2001-08-15 17:14:33 +00001307 gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
Martin v. Löwis864e9ff2001-08-04 22:32:03 +00001308 hstrerror inet_pton kill link lstat mkfifo mktime mremap \
Andrew M. Kuchling5821b772000-08-25 01:14:08 +00001309 nice pathconf pause plock poll pthread_init \
Fred Drake35a092f1999-12-13 16:23:35 +00001310 putenv readlink \
Andrew M. Kuchling8d2f2b22000-07-13 01:26:58 +00001311 select setegid seteuid setgid \
Martin v. Löwis791bfda2001-07-24 06:33:08 +00001312 setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
Fred Drake35a092f1999-12-13 16:23:35 +00001313 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
Fred Drake89143df1999-12-09 22:03:25 +00001314 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Thomas Woutersc2c12dc2001-07-11 14:45:34 +00001315 truncate uname waitpid _getpty getpriority)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001316
Fred Drake8cef4cf2000-06-28 16:40:38 +00001317# check for openpty and forkpty
1318
1319AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1320AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1321
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001322# check for long file support functions
1323AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1324
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001325AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Thomas Wouters3a584202000-08-05 23:28:51 +00001326AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1327AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1328AC_CHECK_FUNCS(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
Guido van Rossum627b2d71993-12-24 10:39:16 +00001329
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001330AC_CHECK_FUNCS(getaddrinfo, [dnl
1331AC_MSG_CHECKING(getaddrinfo bug)
1332AC_TRY_RUN([
1333#include <sys/types.h>
1334#include <netdb.h>
1335#include <string.h>
1336#include <sys/socket.h>
1337#include <netinet/in.h>
1338
1339main()
1340{
1341 int passive, gaierr, inet4 = 0, inet6 = 0;
1342 struct addrinfo hints, *ai, *aitop;
1343 char straddr[INET6_ADDRSTRLEN], strport[16];
1344
1345 for (passive = 0; passive <= 1; passive++) {
1346 memset(&hints, 0, sizeof(hints));
1347 hints.ai_family = AF_UNSPEC;
1348 hints.ai_flags = passive ? AI_PASSIVE : 0;
1349 hints.ai_socktype = SOCK_STREAM;
1350 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1351 (void)gai_strerror(gaierr);
1352 goto bad;
1353 }
1354 for (ai = aitop; ai; ai = ai->ai_next) {
1355 if (ai->ai_addr == NULL ||
1356 ai->ai_addrlen == 0 ||
1357 getnameinfo(ai->ai_addr, ai->ai_addrlen,
1358 straddr, sizeof(straddr), strport, sizeof(strport),
1359 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1360 goto bad;
1361 }
1362 switch (ai->ai_family) {
1363 case AF_INET:
1364 if (strcmp(strport, "54321") != 0) {
1365 goto bad;
1366 }
1367 if (passive) {
1368 if (strcmp(straddr, "0.0.0.0") != 0) {
1369 goto bad;
1370 }
1371 } else {
1372 if (strcmp(straddr, "127.0.0.1") != 0) {
1373 goto bad;
1374 }
1375 }
1376 inet4++;
1377 break;
1378 case AF_INET6:
1379 if (strcmp(strport, "54321") != 0) {
1380 goto bad;
1381 }
1382 if (passive) {
1383 if (strcmp(straddr, "::") != 0) {
1384 goto bad;
1385 }
1386 } else {
1387 if (strcmp(straddr, "::1") != 0) {
1388 goto bad;
1389 }
1390 }
1391 inet6++;
1392 break;
1393 case AF_UNSPEC:
1394 goto bad;
1395 break;
1396 default:
1397 /* another family support? */
1398 break;
1399 }
1400 }
1401 }
1402
1403 if (!(inet4 == 0 || inet4 == 2))
1404 goto bad;
1405 if (!(inet6 == 0 || inet6 == 2))
1406 goto bad;
1407
1408 if (aitop)
1409 freeaddrinfo(aitop);
1410 exit(0);
1411
1412 bad:
1413 if (aitop)
1414 freeaddrinfo(aitop);
1415 exit(1);
1416}
1417],
1418AC_MSG_RESULT(good)
1419buggygetaddrinfo=no,
1420AC_MSG_RESULT(buggy)
1421buggygetaddrinfo=yes,
1422AC_MSG_RESULT(buggy)
1423buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
1424
1425if test "$buggygetaddrinfo" = "yes"; then
1426 if test "$ipv6" = "yes"; then
1427 echo 'Fatal: You must get working getaddrinfo() function.'
1428 echo ' or you can specify "--disable-ipv6"'.
1429 exit 1
1430 fi
1431fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00001432AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001433
Guido van Rossum627b2d71993-12-24 10:39:16 +00001434# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001435AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00001436AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001437AC_STRUCT_TIMEZONE
1438
1439AC_MSG_CHECKING(for time.h that defines altzone)
1440AC_CACHE_VAL(ac_cv_header_time_altzone,
1441[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1442 ac_cv_header_time_altzone=yes,
1443 ac_cv_header_time_altzone=no)])
1444AC_MSG_RESULT($ac_cv_header_time_altzone)
1445if test $ac_cv_header_time_altzone = yes; then
1446 AC_DEFINE(HAVE_ALTZONE)
1447fi
1448
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001449was_it_defined=no
1450AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001451AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001452#include <sys/types.h>
1453#include <sys/select.h>
1454#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001455], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1456AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001457
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001458AC_MSG_CHECKING(for addrinfo)
1459AC_CACHE_VAL(ac_cv_struct_addrinfo,
1460AC_TRY_COMPILE([
1461# include <netdb.h>],
1462 [struct addrinfo a],
1463 ac_cv_struct_addrinfo=yes,
1464 ac_cv_struct_addrinfo=no))
1465AC_MSG_RESULT($ac_cv_struct_addrinfo)
1466if test $ac_cv_struct_addrinfo = yes; then
1467 AC_DEFINE(HAVE_ADDRINFO)
1468fi
1469
1470AC_MSG_CHECKING(for sockaddr_storage)
1471AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1472AC_TRY_COMPILE([
1473# include <sys/types.h>
1474# include <sys/socket.h>],
1475 [struct sockaddr_storage s],
1476 ac_cv_struct_sockaddr_storage=yes,
1477 ac_cv_struct_sockaddr_storage=no))
1478AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1479if test $ac_cv_struct_sockaddr_storage = yes; then
1480 AC_DEFINE(HAVE_SOCKADDR_STORAGE)
1481fi
1482
Guido van Rossum627b2d71993-12-24 10:39:16 +00001483# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001484
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001485AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001486AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001487
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001488works=no
1489AC_MSG_CHECKING(for working volatile)
1490AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1491AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00001492
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001493works=no
1494AC_MSG_CHECKING(for working signed char)
1495AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1496AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001497
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001498have_prototypes=no
1499AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001500AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1501AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001502AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001503
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001504works=no
1505AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001506AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001507#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00001508int foo(int x, ...) {
1509 va_list va;
1510 va_start(va, x);
1511 va_arg(va, int);
1512 va_arg(va, char *);
1513 va_arg(va, double);
1514 return 0;
1515}
1516], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001517AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1518AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001519
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001520if test "$have_prototypes" = yes; then
1521bad_prototypes=no
1522AC_MSG_CHECKING(for bad exec* prototypes)
1523AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1524 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1525AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001526fi
1527
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001528# check if sockaddr has sa_len member
1529AC_MSG_CHECKING(if sockaddr has sa_len member)
1530AC_TRY_COMPILE([#include <sys/types.h>
1531#include <sys/socket.h>],
1532[struct sockaddr x;
1533x.sa_len = 0;],
1534 AC_MSG_RESULT(yes)
1535 AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
1536 AC_MSG_RESULT(no))
1537
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001538AC_MSG_CHECKING(for bad static forward)
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001539AC_CACHE_VAL(ac_cv_bad_static_forward,
1540[AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001541struct s { int a; int b; };
1542static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001543int foobar() {
1544 static int random;
1545 random = (int) &foo;
1546 return random;
1547}
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001548static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001549main() {
1550 exit(!((int)&foo == foobar()));
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001551}], ac_cv_bad_static_forward=no, ac_cv_bad_static_forward=yes)])
1552AC_MSG_RESULT($ac_cv_bad_static_forward)
1553if test "$ac_cv_bad_static_forward" = yes
1554then
1555 AC_DEFINE(BAD_STATIC_FORWARD)
1556fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001557
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001558va_list_is_array=no
1559AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001560AC_TRY_COMPILE([
1561#ifdef HAVE_STDARG_PROTOTYPES
1562#include <stdarg.h>
1563#else
1564#include <varargs.h>
1565#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001566], [va_list list1, list2; list1 = list2;], ,
1567AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1568AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001569
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001570# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1571AC_CHECK_FUNC(gethostbyname_r, [
1572 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1573 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1574 OLD_CFLAGS=$CFLAGS
1575 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1576 AC_TRY_COMPILE([
1577# include <netdb.h>
1578 ], [
1579 char *name;
1580 struct hostent *he, *res;
1581 char buffer[2048];
1582 int buflen = 2048;
1583 int h_errnop;
1584
1585 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1586 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001587 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001588 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1589 AC_MSG_RESULT(yes)
1590 ], [
1591 AC_MSG_RESULT(no)
1592 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1593 AC_TRY_COMPILE([
1594# include <netdb.h>
1595 ], [
1596 char *name;
1597 struct hostent *he;
1598 char buffer[2048];
1599 int buflen = 2048;
1600 int h_errnop;
1601
1602 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1603 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001604 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001605 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1606 AC_MSG_RESULT(yes)
1607 ], [
1608 AC_MSG_RESULT(no)
1609 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1610 AC_TRY_COMPILE([
1611# include <netdb.h>
1612 ], [
1613 char *name;
1614 struct hostent *he;
1615 struct hostent_data data;
1616
1617 (void) gethostbyname_r(name, he, &data);
1618 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001619 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001620 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1621 AC_MSG_RESULT(yes)
1622 ], [
1623 AC_MSG_RESULT(no)
1624 ])
1625 ])
1626 ])
1627 CFLAGS=$OLD_CFLAGS
1628], [
Thomas Wouters3a584202000-08-05 23:28:51 +00001629 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001630])
1631AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1632AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1633AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001634AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001635AC_SUBST(HAVE_GETHOSTBYNAME)
1636
Guido van Rossum627b2d71993-12-24 10:39:16 +00001637# checks for system services
1638# (none yet)
1639
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001640# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00001641AC_CHECK_FUNC(__fpu_control,
1642 [],
1643 [AC_CHECK_LIB(ieee, __fpu_control)
1644])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001645
Guido van Rossum93274221997-05-09 02:42:00 +00001646# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00001647AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001648AC_ARG_WITH(fpectl,
1649[ --with-fpectl enable SIGFPE catching], [
Guido van Rossum93274221997-05-09 02:42:00 +00001650if test "$withval" != no
1651then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1652else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00001653fi],
1654[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00001655
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001656# check for --with-libm=...
1657AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001658case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00001659Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001660BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001661*) LIBM=-lm
1662esac
Guido van Rossum93274221997-05-09 02:42:00 +00001663AC_MSG_CHECKING(for --with-libm=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001664AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001665if test "$withval" = no
1666then LIBM=
1667 AC_MSG_RESULT(force LIBM empty)
1668elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001669then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001670 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001671else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001672fi],
1673[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001674
1675# check for --with-libc=...
1676AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00001677AC_MSG_CHECKING(for --with-libc=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001678AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001679if test "$withval" = no
1680then LIBC=
1681 AC_MSG_RESULT(force LIBC empty)
1682elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001683then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001684 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001685else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001686fi],
1687[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001688
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001689# check for hypot() in math library
1690LIBS_SAVE=$LIBS
1691LIBS="$LIBS $LIBM"
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001692AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001693LIBS=$LIBS_SAVE
1694
Guido van Rossumad713701997-07-10 22:42:38 +00001695# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +00001696AC_MSG_CHECKING(what malloc(0) returns)
1697AC_CACHE_VAL(ac_cv_malloc_zero,
1698[AC_TRY_RUN([#include <stdio.h>
1699#ifdef HAVE_STDLIB
1700#include <stdlib.h>
1701#else
1702char *malloc(), *realloc();
1703int *free();
1704#endif
1705main() {
1706 char *p;
1707 p = malloc(0);
1708 if (p == NULL) exit(1);
1709 p = realloc(p, 0);
1710 if (p == NULL) exit(1);
1711 free(p);
1712 exit(0);
1713}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1714AC_MSG_RESULT($ac_cv_malloc_zero)
1715if test "$ac_cv_malloc_zero" = null
1716then
1717 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1718fi
1719
Guido van Rossumef2255b2000-03-10 22:30:29 +00001720# check for wchar.h
1721AC_CHECK_HEADER(wchar.h,
1722AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1723wchar_h="no"
1724)
1725
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001726# determine wchar_t size
1727if test "$wchar_h" = yes
1728then
1729 AC_CHECK_SIZEOF(wchar_t)
1730fi
1731
1732AC_MSG_CHECKING(what type to use for unicode)
1733AC_ARG_ENABLE(unicode,
1734[ --enable-unicode[=ucs2,ucs4] Enable Unicode strings (default is yes)],,enable_unicode=yes)
1735
1736if test $enable_unicode = yes
1737then
Martin v. Löwisfd917792001-06-27 20:22:04 +00001738 # Without any arguments, Py_UNICODE defaults to two-byte mode
1739 enable_unicode="ucs2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001740fi
1741
1742case "$enable_unicode" in
1743ucs2) unicode_size="2"
1744 AC_DEFINE(Py_UNICODE_SIZE,2)
1745 ;;
1746ucs4) unicode_size="4"
1747 AC_DEFINE(Py_UNICODE_SIZE,4)
1748 ;;
1749esac
1750
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001751AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001752if test "$enable_unicode" = "no"
1753then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001754 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001755 AC_MSG_RESULT(not used)
1756else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001757 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001758 AC_DEFINE(Py_USING_UNICODE)
1759 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
1760 then
1761 PY_UNICODE_TYPE="wchar_t"
1762 AC_DEFINE(HAVE_USABLE_WCHAR_T)
1763 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
1764 elif test "$ac_cv_sizeof_short" = "$unicode_size"
1765 then
1766 PY_UNICODE_TYPE="unsigned short"
1767 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
1768 elif test "$ac_cv_sizeof_long" = "$unicode_size"
1769 then
1770 PY_UNICODE_TYPE="unsigned long"
1771 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
1772 else
1773 PY_UNICODE_TYPE="no type found"
1774 fi
1775 AC_MSG_RESULT($PY_UNICODE_TYPE)
1776fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00001777
1778# check for endianness
1779AC_C_BIGENDIAN
1780
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001781# Check whether right shifting a negative integer extends the sign bit
1782# or fills with zeros (like the Cray J90, according to Tim Peters).
1783AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00001784AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001785AC_TRY_RUN([
1786int main()
1787{
Vladimir Marangozova6180282000-07-12 05:05:06 +00001788 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001789}
Vladimir Marangozova6180282000-07-12 05:05:06 +00001790], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1791AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1792if test "$ac_cv_rshift_extends_sign" = no
1793then
1794 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1795fi
1796
Guido van Rossumcadfaec2001-01-05 14:45:49 +00001797# check for getc_unlocked and related locking functions
1798AC_MSG_CHECKING(for getc_unlocked() and friends)
1799AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1800AC_TRY_LINK([#include <stdio.h>],[
1801 FILE *f = fopen("/dev/null", "r");
1802 flockfile(f);
1803 getc_unlocked(f);
1804 funlockfile(f);
1805], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1806AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1807if test "$ac_cv_have_getc_unlocked" = yes
1808then
1809 AC_DEFINE(HAVE_GETC_UNLOCKED)
1810fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001811
Guido van Rossum353ae582001-07-10 16:45:32 +00001812# check for readline 4.2
1813AC_CHECK_LIB(readline, rl_completion_matches,
1814 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
1815
Thomas Wouterse38b2f12001-07-11 22:35:31 +00001816AC_MSG_CHECKING(for broken nice())
1817AC_CACHE_VAL(ac_cv_broken_nice, [
1818AC_TRY_RUN([
1819int main()
1820{
1821 int val1 = nice(1);
1822 if (val1 != -1 && val1 == nice(2))
1823 exit(0);
1824 exit(1);
1825}
1826],ac_cv_broken_nice=yes, ac_cv_broken_nice=no)])
1827AC_MSG_RESULT($ac_cv_broken_nice)
1828if test "$ac_cv_broken_nice" = yes
1829then
1830 AC_DEFINE(HAVE_BROKEN_NICE)
1831fi
1832
Guido van Rossum95713eb2000-05-18 20:53:31 +00001833# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1834# Add sys/socket.h to confdefs.h
1835cat >> confdefs.h <<\EOF
1836#ifdef HAVE_SYS_SOCKET_H
1837#include <sys/socket.h>
1838#endif
1839EOF
1840AC_CHECK_TYPE(socklen_t, int)
1841
Neil Schemenauerf25cf6c2001-03-04 06:39:33 +00001842# Add Python/ prefix to LIBOBJS
1843libobjs=$LIBOBJS
1844LIBOBJS=
1845for obj in $libobjs; do
1846 LIBOBJS="$LIBOBJS Python/$obj"
1847done
1848
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001849#AC_MSG_CHECKING(for Modules/Setup)
1850#if test ! -f Modules/Setup ; then
1851# if test ! -d Modules ; then
1852# mkdir Modules
1853# fi
1854# cp "$srcdir/Modules/Setup.dist" Modules/Setup
1855# AC_MSG_RESULT(creating)
1856#else
1857# AC_MSG_RESULT(already exists)
1858#fi
1859
1860AC_SUBST(SRCDIRS)
Neil Schemenaueracbf9ef2001-02-27 02:15:14 +00001861SRCDIRS="Parser Grammar Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001862AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001863for dir in $SRCDIRS; do
1864 if test ! -d $dir; then
1865 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00001866 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001867done
1868AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00001869
Guido van Rossum627b2d71993-12-24 10:39:16 +00001870# generate output files
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001871AC_OUTPUT(Makefile.pre Modules/Setup.config)
Neil Schemenauer61c51152001-01-26 16:18:16 +00001872
1873echo "creating Setup"
1874if test ! -f Modules/Setup
1875then
1876 cp $srcdir/Modules/Setup.dist Modules/Setup
1877fi
1878
1879echo "creating Setup.local"
1880if test ! -f Modules/Setup.local
1881then
1882 echo "# Edit this file for local setup changes" >Modules/Setup.local
1883fi
1884
1885echo "creating Makefile"
1886$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1887 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00001888 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00001889mv config.c Modules