blob: ce059d19b4b431a90a5d15d5b5861d91749dac1d [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],[
18 PYTHONFRAMEWORK=Python
19 PYTHONFRAMEWORKDIR=Python.framework
20 case $enableval in
21 yes)
22 enableval=/Library/Frameworks
23 PYTHONFRAMEWORKPREFIX=$enableval
24 ;;
25 *)
26 PYTHONFRAMEWORKPREFIX=$enableval
27 esac
28 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
29 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
30 ],[
31 PYTHONFRAMEWORK=
32 PYTHONFRAMEWORKDIR=
33 PYTHONFRAMEWORKPREFIX=
34 PYTHONFRAMEWORKINSTALLDIR=
35 enable_framework=
36])
37AC_SUBST(PYTHONFRAMEWORK)
38AC_SUBST(PYTHONFRAMEWORKDIR)
39AC_SUBST(PYTHONFRAMEWORKPREFIX)
40AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Guido van Rossum4b6b5791996-09-09 20:09:34 +000041
Jack Jansenb6e9cad2001-08-15 01:26:28 +000042##AC_ARG_WITH(dyld,
43##[ --with-dyld Use (OpenStep|Rhapsody) dynamic linker],,)
44##
Guido van Rossumb418f891996-07-30 18:06:02 +000045# Set name for machine-dependent library files
46AC_SUBST(MACHDEP)
47AC_MSG_CHECKING(MACHDEP)
48if test -z "$MACHDEP"
49then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000050 ac_sys_system=`uname -s`
Martin v. Löwis130fb172001-07-19 11:00:41 +000051 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000052 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +000053 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +000054 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +000055 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000056 ac_md_system=`echo $ac_sys_system |
57 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
58 ac_md_release=`echo $ac_sys_release |
59 tr -d '[/ ]' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +000060 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +000061
Guido van Rossumbcd91e01997-03-20 20:46:29 +000062 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +000063 cygwin*) MACHDEP="cygwin";;
Guido van Rossumb97ef171997-09-28 05:44:03 +000064 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +000065 esac
66fi
Guido van Rossum91922671997-10-09 20:24:13 +000067
68#
69# SGI compilers allow the specification of the both the ABI and the
70# ISA on the command line. Depending on the values of these switches,
71# different and often incompatable code will be generated.
72#
73# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
74# thus supply support for various ABI/ISA combinations. The MACHDEP
75# variable is also adjusted.
76#
77AC_SUBST(SGI_ABI)
78if test ! -z "$SGI_ABI"
79then
80 CC="cc $SGI_ABI"
81 LDFLAGS="$SGI_ABI $LDFLAGS"
82 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
83fi
Guido van Rossumb418f891996-07-30 18:06:02 +000084AC_MSG_RESULT($MACHDEP)
85
Guido van Rossum627b2d71993-12-24 10:39:16 +000086# checks for alternative programs
Guido van Rossum5739e7e1995-01-20 16:50:53 +000087AC_MSG_CHECKING(for --without-gcc)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +000088AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
Guido van Rossum433c8ad1994-08-01 12:07:07 +000089 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +000090 no) CC=cc
91 without_gcc=yes;;
92 yes) CC=gcc
93 without_gcc=no;;
94 *) CC=$withval
95 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +000096 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +000097 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +000098 AIX*) CC=cc_r
99 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000100 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000101 case $BE_HOST_CPU in
102 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000103 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000104 without_gcc=yes
Fred Drake5790be12000-10-09 17:06:13 +0000105 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 +0000106 CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000107 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000108 ;;
109 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000110 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000111 without_gcc=no
Fred Drake5790be12000-10-09 17:06:13 +0000112 OPT=-O
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000113 ;;
114 *)
Fred Drake5790be12000-10-09 17:06:13 +0000115 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000116 ;;
117 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000118 AR="\$(srcdir)/Modules/ar_beos"
119 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000120 ;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000121 Monterey*)
122 RANLIB=:
Martin v. Löwis130fb172001-07-19 11:00:41 +0000123 without_gcc=;;
124 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000125 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000126AC_MSG_RESULT($without_gcc)
127
Guido van Rossum27552902001-01-23 01:52:26 +0000128AC_SUBST(CXX)
Guido van Rossum95012191999-12-16 17:50:52 +0000129AC_SUBST(MAINOBJ)
Fred Drakea1a84e72001-03-06 05:52:16 +0000130MAINOBJ=python.o
Guido van Rossum95012191999-12-16 17:50:52 +0000131AC_MSG_CHECKING(for --with-cxx=<compiler>)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000132AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
Martin v. Löwis537970f2000-12-13 17:37:02 +0000133 check_cxx=no
Guido van Rossum95012191999-12-16 17:50:52 +0000134 case $withval in
135 no) CXX=
136 with_cxx=no;;
137 *) CXX=$withval
Fred Drakea1a84e72001-03-06 05:52:16 +0000138 MAINOBJ=ccpython.o
Guido van Rossum95012191999-12-16 17:50:52 +0000139 with_cxx=$withval;;
140 esac], [
141 with_cxx=no
Martin v. Löwis537970f2000-12-13 17:37:02 +0000142 check_cxx=yes
Guido van Rossum95012191999-12-16 17:50:52 +0000143])
144AC_MSG_RESULT($with_cxx)
Martin v. Löwis537970f2000-12-13 17:37:02 +0000145
146dnl The following fragment works similar to AC_PROG_CXX.
147dnl It does not fail if CXX is not found, and it is not executed if
148dnl --with-cxx was given.
149dnl Finally, it does not test whether CXX is g++.
150
151if test "$check_cxx" = "yes"
152then
153 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
154 if test "$CXX" = "notfound"
155 then
156 CXX=
157 else
158 AC_PROG_CXX_WORKS
159 fi
160fi
161
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000162# If the user switches compilers, we can't believe the cache
163if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
164then
165 AC_ERROR(cached CC is different -- throw away $cache_file
166(it is also a good idea to do 'make clean' before compiling))
167fi
168
Guido van Rossum627b2d71993-12-24 10:39:16 +0000169AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000170
171# checks for UNIX variants that set C preprocessor variables
172AC_AIX
173AC_MINIX
174
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000175AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000176AC_MSG_CHECKING(for --with-suffix)
177AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
178 case $withval in
179 no) EXEEXT=;;
180 yes) EXEEXT=.exe;;
181 *) EXEEXT=$withval;;
182 esac])
183AC_MSG_RESULT($EXEEXT)
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000184# Test whether we're running on a non-case-sensitive system, in which
185# case we give a warning if no ext is given
186if test -d "python" -a -z "$EXEEXT"
187then
188 AC_MSG_WARN(This filesystem is not case-sensitive so you should probably use --with-suffix)
189fi
Guido van Rossumfb842551997-08-06 23:42:07 +0000190
Guido van Rossumdd997f71998-10-07 19:58:26 +0000191case $MACHDEP in
192bsdos*)
193 case $CC in
194 gcc) CC="$CC -D_HAVE_BSDI";;
195 esac;;
196esac
197
Guido van Rossum84561611997-08-21 00:08:11 +0000198case $ac_sys_system in
199hp*|HP*)
200 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000201 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000202 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000203Monterey*)
204 case $CC in
205 cc) CC="$CC -Wl,-Bexport";;
206 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000207SunOS*)
208 # Some functions have a prototype only with that define, e.g. confstr
209 AC_DEFINE(__EXTENSIONS__)
210 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000211esac
212
Martin v. Löwise8964d42001-03-06 12:09:07 +0000213
Neil Schemenauer61c51152001-01-26 16:18:16 +0000214AC_SUBST(LIBRARY)
215AC_MSG_CHECKING(LIBRARY)
216if test -z "$LIBRARY"
217then
218 LIBRARY='libpython$(VERSION).a'
219fi
220AC_MSG_RESULT($LIBRARY)
221
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000222# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000223# name of the library into which to insert object files). BLDLIBRARY is also
224# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
225# is blank as the main program is not linked directly against LDLIBRARY.
226# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
227# systems without shared libraries, LDLIBRARY is the same as LIBRARY
228# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
229# DLLLIBRARY is the shared (i.e., DLL) library.
230#
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000231AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000232AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000233AC_SUBST(BLDLIBRARY)
234AC_SUBST(LDLIBRARYDIR)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000235LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000236BLDLIBRARY='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000237DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000238LDLIBRARYDIR=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000239
Guido van Rossumfb842551997-08-06 23:42:07 +0000240# LINKCC is the command that links the python executable -- default is $(CC).
Fred Drake5790be12000-10-09 17:06:13 +0000241# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000242# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000243AC_SUBST(LINKCC)
244AC_MSG_CHECKING(LINKCC)
245if test -z "$LINKCC"
246then
247 case $ac_sys_system in
248 AIX*)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000249 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000250 dgux*)
251 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000252 Monterey64*)
253 LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
Guido van Rossum25f93031997-08-18 16:00:04 +0000254 *) LINKCC="\$(PURIFY) \$(CC)";;
Guido van Rossumfb842551997-08-06 23:42:07 +0000255 esac
256fi
257AC_MSG_RESULT($LINKCC)
258
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000259AC_MSG_CHECKING(LDLIBRARY)
260
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000261# DG/UX requires some fancy ld contortions to produce a .so from an .a
Fred Drake5790be12000-10-09 17:06:13 +0000262case $MACHDEP in
263dguxR4)
264 LDLIBRARY='libpython$(VERSION).so'
265 OPT="$OPT -pic"
266 ;;
267beos*)
268 LDLIBRARY='libpython$(VERSION).so'
269 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000270cygwin*)
271 LDLIBRARY='libpython$(VERSION).dll.a'
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000272 DLLLIBRARY='libpython$(VERSION).dll'
Guido van Rossumaef734b2001-01-10 21:09:12 +0000273 ;;
Fred Drake5790be12000-10-09 17:06:13 +0000274esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000275
Guido van Rossumb8552162001-09-05 14:58:11 +0000276# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
277# library that we build, but we do not want to link against it (we
278# will find it with a -framework option). For this reason there is an
279# extra variable BLDLIBRARY against which Python and the extension
280# modules are linked, BLDLIBRARY. This is normally the same as
281# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000282if test "$enable_framework"
283then
284 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
285 LDLIBRARYDIR='$(PYTHONFRAMEWORKDIR)'
286 BLDLIBRARY=''
287else
288 BLDLIBRARY='$(LDLIBRARY)'
289fi
290
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000291AC_MSG_RESULT($LDLIBRARY)
292
Guido van Rossum627b2d71993-12-24 10:39:16 +0000293AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000294AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000295AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000296
297case $MACHDEP in
298bsdos*)
299 # install -d does not work on BSDI
300 if test -z "$INSTALL"
301 then
302 INSTALL="${srcdir}/install-sh -c"
303 fi
304esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000305AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000306
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000307# Not every filesystem supports hard links
308AC_SUBST(LN)
309if test -z "$LN" ; then
310 case $ac_sys_system in
311 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000312 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000313 *) LN=ln;;
314 esac
315fi
316
Fred Drake9f715822001-07-11 06:27:00 +0000317# Check for --with-pydebug
318AC_MSG_CHECKING(for --with-pydebug)
319AC_ARG_WITH(pydebug,
320[ --with-pydebug build with Py_DEBUG defined], [
321if test "$withval" != no
322then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes); Py_DEBUG='true'
323else AC_MSG_RESULT(no); Py_DEBUG='false'
324fi],
325[AC_MSG_RESULT(no)])
326
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000327# Optimizer/debugger flags
Guido van Rossumb418f891996-07-30 18:06:02 +0000328AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000329if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000330then
Guido van Rossumb5875b61997-07-18 23:29:09 +0000331 case $GCC in
332 yes)
333 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000334 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000335 if test "$Py_DEBUG" = 'true' ; then
336 # Optimization messes up debuggers, so turn it off for
337 # debug builds.
338 OPT="-g -Wall -Wstrict-prototypes"
339 else
340 OPT="-g -O3 -Wall -Wstrict-prototypes"
341 fi;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000342 *)
Fred Drake9f715822001-07-11 06:27:00 +0000343 OPT="-O3 -Wall -Wstrict-prototypes";;
344 esac
345 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000346 *)
347 case $ac_sys_system in
348 UnixWare*)
349 OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
350 *)
351 OPT="-O";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000352 esac
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000353 esac
Jack Jansenca06bc62001-08-03 15:32:23 +0000354 case $ac_sys_system in
355 Darwin*)
356 OPT="$OPT -no-cpp-precomp";;
357 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000358fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000359
Trent Mick635f6fb2000-08-23 21:33:05 +0000360# The current (beta) Monterey compiler dies with optimizations
361case $ac_sys_system in
362Monterey*) OPT="";;
363esac
364
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000365if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000366then
367 OPT="$OPT $ac_arch_flags"
368fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000369
Guido van Rossum91922671997-10-09 20:24:13 +0000370AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
371AC_CACHE_VAL(ac_cv_opt_olimit_ok,
372[ac_save_cc="$CC"
373CC="$CC -OPT:Olimit=0"
374AC_TRY_RUN([int main() { return 0; }],
375 ac_cv_opt_olimit_ok=yes,
376 ac_cv_opt_olimit_ok=no)
377CC="$ac_save_cc"])
378AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000379if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000380 case $ac_sys_system in
381 Darwin*) OPT="$OPT" ;;
382 *) OPT="$OPT -OPT:Olimit=0";;
383 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000384else
385 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
386 AC_CACHE_VAL(ac_cv_olimit_ok,
387 [ac_save_cc="$CC"
388 CC="$CC -Olimit 1500"
389 AC_TRY_RUN([int main() { return 0; }],
390 ac_cv_olimit_ok=yes,
391 ac_cv_olimit_ok=no)
392 CC="$ac_save_cc"])
393 AC_MSG_RESULT($ac_cv_olimit_ok)
394 if test $ac_cv_olimit_ok = yes; then
395 OPT="$OPT -Olimit 1500"
396 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000397fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000398
Martin v. Löwis130fb172001-07-19 11:00:41 +0000399# -Kpthread, if available, provides the right #defines
400# and linker options to make pthread_create available
401AC_MSG_CHECKING(whether $CC accepts -Kpthread)
402AC_CACHE_VAL(ac_cv_kpthread,
403[ac_save_cc="$CC"
404CC="$CC -Kpthread"
405AC_TRY_LINK([#include <pthread.h>],[pthread_create(0,0,0,0)],
406 ac_cv_kpthread=yes,
407 ac_cv_kpthread=no)
408CC="$ac_save_cc"])
409
410# GCC does not reject -Kpthread as an illegal option, it merely complains that
411# it is unrecognized
412if test "$GCC" = "yes"
413then ac_cv_kpthread="no, we have gcc"
414fi
415AC_MSG_RESULT($ac_cv_kpthread)
416
Fred Drakece81d592000-07-09 14:39:29 +0000417dnl # check for ANSI or K&R ("traditional") preprocessor
418dnl AC_MSG_CHECKING(for C preprocessor type)
419dnl AC_TRY_COMPILE([
420dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
421dnl int foo;
422dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
423dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
424dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +0000425
Guido van Rossum627b2d71993-12-24 10:39:16 +0000426# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000427AC_HEADER_STDC
Martin v. Löwis9b75dca2001-08-10 13:58:50 +0000428AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h langinfo.h locale.h \
429ncurses.h poll.h pthread.h \
Eric S. Raymond13603592001-01-16 15:01:26 +0000430signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
Fred Drake2ca5f3b2001-05-11 16:10:56 +0000431sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
Andrew M. Kuchling881fd902001-07-14 20:55:52 +0000432sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
Fred Drakeae90f8d2000-09-15 03:38:12 +0000433sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Martin v. Löwis1ba3fd52001-08-10 20:29:40 +0000434ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000435AC_HEADER_DIRENT
Guido van Rossum627b2d71993-12-24 10:39:16 +0000436
437# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000438was_it_defined=no
439AC_MSG_CHECKING(for clock_t in time.h)
440AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
441AC_MSG_RESULT($was_it_defined)
442
Guido van Rossum300fda71996-08-19 21:58:16 +0000443# Add some code to confdefs.h so that the test for off_t works on SCO
444cat >> confdefs.h <<\EOF
445#if defined(SCO_DS)
446#undef _OFF_T
447#endif
448EOF
449
Guido van Rossumef2255b2000-03-10 22:30:29 +0000450# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000451AC_TYPE_MODE_T
452AC_TYPE_OFF_T
453AC_TYPE_PID_T
454AC_TYPE_SIGNAL
455AC_TYPE_SIZE_T
456AC_TYPE_UID_T
Guido van Rossum627b2d71993-12-24 10:39:16 +0000457
Guido van Rossumef2255b2000-03-10 22:30:29 +0000458# Sizes of various common basic types
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000459AC_CHECK_SIZEOF(int)
460AC_CHECK_SIZEOF(long)
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000461AC_CHECK_SIZEOF(void *)
Guido van Rossumef2255b2000-03-10 22:30:29 +0000462AC_CHECK_SIZEOF(char)
463AC_CHECK_SIZEOF(short)
464AC_CHECK_SIZEOF(float)
465AC_CHECK_SIZEOF(double)
Fred Drakea3f6e912000-06-29 20:44:47 +0000466AC_CHECK_SIZEOF(fpos_t)
Guido van Rossumac405f61994-09-12 10:56:06 +0000467
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000468AC_MSG_CHECKING(for long long support)
469have_long_long=no
470AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
471AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000472if test "$have_long_long" = yes ; then
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000473AC_CHECK_SIZEOF(long long)
474fi
475
Barry Warsawbc7c7f92000-08-18 04:53:33 +0000476AC_MSG_CHECKING(for uintptr_t support)
477have_uintptr_t=no
478AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
479AC_MSG_RESULT($have_uintptr_t)
480if test "$have_uintptr_t" = yes ; then
481AC_CHECK_SIZEOF(uintptr_t)
482fi
483
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000484# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
485AC_MSG_CHECKING(size of off_t)
486AC_CACHE_VAL(ac_cv_sizeof_off_t,
487[AC_TRY_RUN([#include <stdio.h>
488#include <sys/types.h>
489main()
490{
491 FILE *f=fopen("conftestval", "w");
492 if (!f) exit(1);
493 fprintf(f, "%d\n", sizeof(off_t));
494 exit(0);
495}], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
496])
497AC_MSG_RESULT($ac_cv_sizeof_off_t)
498AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
499
500AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000501if test "$have_long_long" = yes -a \
502 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
503 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000504 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
505 AC_MSG_RESULT(yes)
506else
507 AC_MSG_RESULT(no)
508fi
509
Fred Drakea3f6e912000-06-29 20:44:47 +0000510# AC_CHECK_SIZEOF() doesn't include <time.h>.
511AC_MSG_CHECKING(size of time_t)
512AC_CACHE_VAL(ac_cv_sizeof_time_t,
513[AC_TRY_RUN([#include <stdio.h>
514#include <time.h>
515main()
516{
517 FILE *f=fopen("conftestval", "w");
518 if (!f) exit(1);
519 fprintf(f, "%d\n", sizeof(time_t));
520 exit(0);
521}], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
522])
523AC_MSG_RESULT($ac_cv_sizeof_time_t)
524AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
525
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000526
Trent Mick635f6fb2000-08-23 21:33:05 +0000527# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +0000528ac_save_cc="$CC"
529if test "$ac_cv_kpthread" = "yes"
530then CC="$CC -Kpthread"
531fi
Trent Mick635f6fb2000-08-23 21:33:05 +0000532AC_MSG_CHECKING(for pthread_t)
533have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +0000534AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +0000535AC_MSG_RESULT($have_pthread_t)
536if test "$have_pthread_t" = yes ; then
537 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
538 AC_MSG_CHECKING(size of pthread_t)
539 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
540 [AC_TRY_RUN([#include <stdio.h>
541 #include <pthread.h>
542 main()
543 {
544 FILE *f=fopen("conftestval", "w");
545 if (!f) exit(1);
546 fprintf(f, "%d\n", sizeof(pthread_t));
547 exit(0);
548 }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
549 ])
550 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
551 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
552fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +0000553CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +0000554
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000555AC_MSG_CHECKING(for --enable-toolbox-glue)
556AC_ARG_ENABLE(toolbox-glue,
557[ --enable-toolbox-glue disable/enable MacOSX glue code for extensions])
558
559if test -z "$enable_toolbox_glue"
560then
561 case $ac_sys_system/$ac_sys_release in
562 Darwin/*)
563 enable_toolbox_glue="yes";;
564 *)
565 enable_toolbox_glue="no";;
566 esac
567fi
568case "$enable_toolbox_glue" in
569yes)
570 extra_frameworks="-framework Carbon -framework Foundation"
571 extra_machdep_objs="Python/mactoolboxglue.o"
Jack Jansen591cbed2001-08-15 13:55:15 +0000572 extra_undefs="-u __dummy -u _PyMac_Error"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000573 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE)
574 ;;
575*)
576 extra_frameworks=""
577 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +0000578 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000579 ;;
580esac
581AC_MSG_RESULT($enable_toolbox_glue)
582
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000583AC_SUBST(LIBTOOL_CRUFT)
584case $ac_sys_system/$ac_sys_release in
Guido van Rossum5839e582000-10-09 19:52:35 +0000585 Darwin/*)
586 ns_undef_sym='_environ'
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000587 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym"
588 LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
589 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
590 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000591esac
592
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000593AC_MSG_CHECKING(for --enable-framework)
594if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000595then
Jack Jansenca06bc62001-08-03 15:32:23 +0000596 OPT="$OPT -fno-common -dynamic"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000597 # -U __environ is needed since bundles don't have access
598 # to crt0 when built but will always be linked against it
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000599 # -F. is needed to allow linking to the framework while
600 # in the build location.
601
602 LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-U,$ns_undef_sym"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000603 AC_DEFINE(WITH_NEXT_FRAMEWORK)
604 AC_MSG_RESULT(yes)
605else
606 AC_MSG_RESULT(no)
607fi
608
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000609AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000610case $ac_sys_system/$ac_sys_release in
611 Darwin/*)
612 AC_DEFINE(WITH_DYLD)
613 AC_MSG_RESULT(always on for Darwin)
614 ;;
615 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000616 AC_MSG_RESULT(no)
617 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000618esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000619
Guido van Rossumac405f61994-09-12 10:56:06 +0000620# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +0000621AC_SUBST(SO)
622AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000623AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000624AC_SUBST(CCSHARED)
625AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000626# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +0000627# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000628AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000629if test -z "$SO"
630then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000631 case $ac_sys_system in
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000632 hp*|HP*) SO=.sl;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000633 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000634 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000635 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000636fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000637AC_MSG_RESULT($SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000638# LDSHARED is the ld *command* used to create shared library
639# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000640# (Shared libraries in this instance are shared modules to be loaded into
641# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000642AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000643if test -z "$LDSHARED"
644then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000645 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000646 AIX*)
647 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
648 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
649 ;;
650 BeOS*)
651 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
652 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
653 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000654 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +0000655 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000656 SunOS/4*) LDSHARED="ld";;
Greg Ward57c9a6632000-05-26 12:22:54 +0000657 SunOS/5*)
658 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +0000659 then LDSHARED='$(CC) -shared'
Greg Ward57c9a6632000-05-26 12:22:54 +0000660 else LDSHARED="ld -G";
661 fi ;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000662 hp*|HP*) LDSHARED="ld -b";;
Guido van Rossum71001e41995-01-26 00:44:03 +0000663 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Guido van Rossum7d473291995-01-20 14:12:16 +0000664 DYNIX/ptx*) LDSHARED="ld -G";;
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000665 Darwin/*)
666 LDSHARED='$(CC) $(LDFLAGS) -bundle'
667 if test "$enable_framework" ; then
668 # Link against the framework. All externals should be defined.
669 LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
670 else
671 # No framework. Ignore undefined symbols, assuming they come from Python
672 LDSHARED="$LDSHARED -undefined suppress"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000673 fi ;;
Guido van Rossum81652ab1996-07-21 02:53:27 +0000674 Linux*) LDSHARED="gcc -shared";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000675 dgux*) LDSHARED="ld -G";;
Guido van Rossum458e7fa1999-09-17 15:40:40 +0000676 BSD/OS*/4*) LDSHARED="gcc -shared";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000677 OpenBSD*|NetBSD*|FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +0000678 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +0000679 then
680 LDSHARED="cc -shared ${LDFLAGS}"
681 else
682 LDSHARED="ld -Bshareable ${LDFLAGS}"
683 fi;;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000684 UnixWare*)
685 if test "$GCC" = "yes"
686 then LDSHARED="$(CC) -shared"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000687 else LDSHARED="$(CC) -G"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000688 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000689 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000690 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000691 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000692 *) LDSHARED="ld";;
693 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000694fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000695AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000696BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +0000697# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000698# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000699AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000700if test -z "$CCSHARED"
701then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000702 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +0000703 SunOS*) if test "$GCC" = yes;
704 then CCSHARED="-fPIC";
705 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +0000706 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +0000707 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +0000708 else CCSHARED="+z";
709 fi;;
Neil Schemenauer61c51152001-01-26 16:18:16 +0000710 Linux*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000711 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000712 FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000713 UnixWare*)
714 if test "$GCC" = "yes"
715 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000716 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000717 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000718 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000719 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000720 IRIX*/6*) case $CC in
721 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +0000722 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000723 esac;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000724 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000725 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000726fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000727AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000728# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000729# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000730AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000731if test -z "$LINKFORSHARED"
732then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000733 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000734 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000735 hp*|HP*)
Guido van Rossum304dd2d1997-10-20 23:10:56 +0000736 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000737 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum2d9feed1997-11-24 17:36:21 +0000738 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000739 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000740 Darwin/*)
741 # -u __dummy makes the linker aware of the objc runtime
742 # in System.framework; otherwise, __objcInit (referenced in
743 # crt1.o) gets erroneously defined as common, which breaks dynamic
744 # loading of any modules which reference it in System.framework.
745 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
746 # not used by the core itself but which needs to be in the core so
747 # that dynamically loaded extension modules have access to it.
Jack Jansen591cbed2001-08-15 13:55:15 +0000748 LINKFORSHARED="$extra_undefs -framework System"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000749 if test "$enable_framework"
750 then
751 LINKFORSHARED="$LINKFORSHARED -framework Python"
752 fi
753 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000754 UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Guido van Rossum300fda71996-08-19 21:58:16 +0000755 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +0000756 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000757 FreeBSD*|NetBSD*|OpenBSD*)
Guido van Rossumdf693651999-01-07 21:50:41 +0000758 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
759 then
760 LINKFORSHARED="-Wl,--export-dynamic"
761 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000762 SunOS/5*) case $CC in
763 *gcc*)
Guido van Rossum9c6ba9b2000-02-03 13:42:50 +0000764 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000765 then
766 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000767 fi;;
768 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000769 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000770fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000771AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000772
Neil Schemenauer61c51152001-01-26 16:18:16 +0000773AC_SUBST(CFLAGSFORSHARED)
774AC_MSG_CHECKING(CFLAGSFORSHARED)
775if test ! "$LIBRARY" = "$LDLIBRARY"
776then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +0000777 case $ac_sys_system in
778 CYGWIN*)
779 # Cygwin needs CCSHARED when building extension DLLs
780 # but not when building the interpreter DLL.
781 CFLAGSFORSHARED='';;
782 *)
783 CFLAGSFORSHARED='$(CCSHARED)'
784 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +0000785fi
786AC_MSG_RESULT($CFLAGSFORSHARED)
787
Guido van Rossum627b2d71993-12-24 10:39:16 +0000788# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000789AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
790AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000791
792# checks for system dependent C++ extensions support
793case "$ac_sys_system" in
794 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
795 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
796 [loadAndInit("", 0, "")],
797 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
798 AC_MSG_RESULT(yes)],
799 [AC_MSG_RESULT(no)]);;
800 *) ;;
801esac
802
Guido van Rossum70c7f481998-03-26 18:44:10 +0000803# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
804# However on SGI IRIX, these exist but are broken.
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000805# BeOS' sockets are stashed in libnet.
806case "$ac_sys_system" in
807IRIX*) ;;
Guido van Rossum2cb56601998-05-07 13:25:56 +0000808*)
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000809AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000810AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +0000811;;
812esac
813case "$ac_sys_system" in
814BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000815AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
816;;
817esac
Guido van Rossum70c7f481998-03-26 18:44:10 +0000818
Guido van Rossumc5a39031996-07-31 17:35:03 +0000819AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000820AC_ARG_WITH(libs,
821[ --with-libs='lib1 ...' link against additional libs], [
Guido van Rossumc5a39031996-07-31 17:35:03 +0000822AC_MSG_RESULT($withval)
823LIBS="$withval $LIBS"
824], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000825
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000826# Determine if signalmodule should be used.
827AC_SUBST(USE_SIGNAL_MODULE)
828AC_SUBST(SIGNAL_OBJS)
829AC_MSG_CHECKING(for --with-signal-module)
830AC_ARG_WITH(signal-module,
831[ --with-signal-module disable/enable signal module])
832
833if test -z "$with_signal_module"
834then with_signal_module="yes"
835fi
836AC_MSG_RESULT($with_signal_module)
837
838if test "${with_signal_module}" = "yes"; then
839 USE_SIGNAL_MODULE=""
840 SIGNAL_OBJS=""
841else
842 USE_SIGNAL_MODULE="#"
843 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
844fi
845
Guido van Rossum3d15bd82001-01-10 18:53:48 +0000846# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +0000847AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000848USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +0000849
Guido van Rossum54d93d41997-01-22 20:51:58 +0000850AC_MSG_CHECKING(for --with-dec-threads)
851AC_SUBST(LDLAST)
852AC_ARG_WITH(dec-threads,
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000853[ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
854AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +0000855LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +0000856if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +0000857 with_thread="$withval";
858fi],
859AC_MSG_RESULT(no))
860
861AC_MSG_CHECKING(for --with-threads)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000862AC_ARG_WITH(threads,
863[ --with(out)-threads[=DIRECTORY] disable/enable thread support])
Guido van Rossum54d93d41997-01-22 20:51:58 +0000864
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000865# --with-thread is deprecated, but check for it anyway
Barry Warsawa0f3c5c2000-06-30 16:39:35 +0000866AC_ARG_WITH(thread,
867[ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
868with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000869
870if test -z "$with_threads"
871then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000872fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000873AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +0000874
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000875if test "$with_threads" = "no"
876then
877 USE_THREAD_MODULE="#"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000878elif test "$ac_cv_kpthread" = "yes"
879then
880 CC="$CC -Kpthread"
881 AC_DEFINE(WITH_THREAD)
882 AC_DEFINE(_POSIX_THREADS)
883 LIBOBJS="$LIBOBJS thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000884else
Martin v. Löwis130fb172001-07-19 11:00:41 +0000885 if test ! -z "$with_threads" -a -d "$with_threads"
886 then LDFLAGS="$LDFLAGS -L$with_threads"
887 fi
888 if test ! -z "$withval" -a -d "$withval"
889 then LDFLAGS="$LDFLAGS -L$withval"
890 fi
891 AC_DEFINE(_REENTRANT)
892 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
893 AC_DEFINE(C_THREADS)
894 LIBOBJS="$LIBOBJS thread.o"],[
895 AC_MSG_CHECKING(for --with-pth)
896 AC_ARG_WITH(pth,
897 [ --with-pth use GNU pth threading libraries], [
898 AC_MSG_RESULT($withval)
899 AC_DEFINE(WITH_THREAD)
900 AC_DEFINE(HAVE_PTH)
901 LIBS="-lpth $LIBS"
902 LIBOBJS="$LIBOBJS thread.o"],[
903 AC_MSG_RESULT(no)
904 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000905 case $ac_sys_system in
906 Darwin*) ;;
907 *) AC_DEFINE(_POSIX_THREADS);;
908 esac
Martin v. Löwis130fb172001-07-19 11:00:41 +0000909 LIBS="-lpthread $LIBS"
910 LIBOBJS="$LIBOBJS thread.o"],[
911 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
912 case $ac_sys_system in
913 Darwin*) ;;
914 *) AC_DEFINE(_POSIX_THREADS);;
915 esac
916 LIBOBJS="$LIBOBJS thread.o"],[
917 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
918 AC_DEFINE(BEOS_THREADS)
919 LIBOBJS="$LIBOBJS thread.o"],[
920 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
921 AC_DEFINE(_POSIX_THREADS)
922 LIBS="$LIBS -lpthreads"
923 LIBOBJS="$LIBOBJS thread.o"], [
924 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
925 AC_DEFINE(_POSIX_THREADS)
926 LIBS="$LIBS -lc_r"
927 LIBOBJS="$LIBOBJS thread.o"], [
928 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
929 AC_DEFINE(_POSIX_THREADS)
930 LIBS="$LIBS -lthread"
931 LIBOBJS="$LIBOBJS thread.o"], [
932 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
933 AC_DEFINE(_POSIX_THREADS)
934 LIBS="$LIBS -lpthread"
935 LIBOBJS="$LIBOBJS thread.o"], [
936 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
937 AC_DEFINE(_POSIX_THREADS)
938 LIBS="$LIBS -lcma"
939 LIBOBJS="$LIBOBJS thread.o"],[
940 USE_THREAD_MODULE="#"])
941 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000942
Martin v. Löwis130fb172001-07-19 11:00:41 +0000943 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
944 LIBS="$LIBS -lmpc"
945 LIBOBJS="$LIBOBJS thread.o"
946 USE_THREAD_MODULE=""])
947 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
948 LIBS="$LIBS -lthread"
949 LIBOBJS="$LIBOBJS thread.o"
950 USE_THREAD_MODULE=""])
Jeremy Hylton1a2ca862000-10-16 16:59:12 +0000951
Martin v. Löwis130fb172001-07-19 11:00:41 +0000952 if test "$USE_THREAD_MODULE" != "#"
953 then
954 # If the above checks didn't disable threads, (at least) OSF1
955 # needs this '-threads' argument during linking.
956 case $ac_sys_system in
957 OSF1) LDLAST=-threads;;
958 esac
Jeremy Hylton1a2ca862000-10-16 16:59:12 +0000959 fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000960fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000961
Martin v. Löwisa2ac6022001-08-09 11:40:14 +0000962# Check for enable-ipv6
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +0000963AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +0000964AC_ARG_ENABLE(ipv6,
965[ --enable-ipv6 Enable ipv6 (with ipv4) support
966 --disable-ipv6 Disable ipv6 support],
967[ case "$enableval" in
968 no)
969 AC_MSG_RESULT(no)
970 ipv6=no
971 ;;
972 *) AC_MSG_RESULT(yes)
973 AC_DEFINE(ENABLE_IPV6)
974 ipv6=yes
975 ;;
976 esac ],
977
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +0000978[
979dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +0000980 AC_TRY_RUN([ /* AF_INET6 available check */
981#include <sys/types.h>
982#include <sys/socket.h>
983main()
984{
985 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
986 exit(1);
987 else
988 exit(0);
989}
990],
991 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +0000992 ipv6=yes,
993 AC_MSG_RESULT(no)
994 ipv6=no,
995 AC_MSG_RESULT(no)
996 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +0000997)
998
999if test "$ipv6" = "yes"; then
1000 AC_MSG_CHECKING(if RFC2553 API is available)
1001 AC_TRY_COMPILE([#include <sys/types.h>
1002#include <netinet/in.h>],
1003 [struct sockaddr_in6 x;
1004x.sin6_scope_id;],
1005 AC_MSG_RESULT(yes)
1006 ipv6=yes,
1007 AC_MSG_RESULT(no, IPv6 disabled)
1008 ipv6=no)
1009fi
1010
1011if test "$ipv6" = "yes"; then
1012 AC_DEFINE(ENABLE_IPV6)
1013fi
1014])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001015
1016ipv6type=unknown
1017ipv6lib=none
1018ipv6trylibc=no
1019
1020if test "$ipv6" = "yes"; then
1021 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00001022 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1023 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001024 case $i in
1025 inria)
1026 dnl http://www.kame.net/
1027 AC_EGREP_CPP(yes, [dnl
1028#include <netinet/in.h>
1029#ifdef IPV6_INRIA_VERSION
1030yes
1031#endif],
1032 [ipv6type=$i;
1033 OPT="-DINET6 $OPT"])
1034 ;;
1035 kame)
1036 dnl http://www.kame.net/
1037 AC_EGREP_CPP(yes, [dnl
1038#include <netinet/in.h>
1039#ifdef __KAME__
1040yes
1041#endif],
1042 [ipv6type=$i;
1043 ipv6lib=inet6
1044 ipv6libdir=/usr/local/v6/lib
1045 ipv6trylibc=yes
1046 OPT="-DINET6 $OPT"])
1047 ;;
1048 linux-glibc)
1049 dnl http://www.v6.linux.or.jp/
1050 AC_EGREP_CPP(yes, [dnl
1051#include <features.h>
1052#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1053yes
1054#endif],
1055 [ipv6type=$i;
1056 ipv6trylibc=yes
1057 OPT="-DINET6 $OPT"])
1058 ;;
1059 linux-inet6)
1060 dnl http://www.v6.linux.or.jp/
1061 if test -d /usr/inet6; then
1062 ipv6type=$i
1063 ipv6lib=inet6
1064 ipv6libdir=/usr/inet6/lib
1065 OPT="-DINET6 -I/usr/inet6/include $OPT"
1066 fi
1067 ;;
1068 solaris)
1069 if test -f /etc/netconfig; then
1070 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1071 ipv6type=$i
1072 ipv6trylibc=yes
1073 OPT="-DINET6 $OPT"
1074 fi
1075 fi
1076 ;;
1077 toshiba)
1078 AC_EGREP_CPP(yes, [dnl
1079#include <sys/param.h>
1080#ifdef _TOSHIBA_INET6
1081yes
1082#endif],
1083 [ipv6type=$i;
1084 ipv6lib=inet6;
1085 ipv6libdir=/usr/local/v6/lib;
1086 OPT="-DINET6 $OPT"])
1087 ;;
1088 v6d)
1089 AC_EGREP_CPP(yes, [dnl
1090#include </usr/local/v6/include/sys/v6config.h>
1091#ifdef __V6D__
1092yes
1093#endif],
1094 [ipv6type=$i;
1095 ipv6lib=v6;
1096 ipv6libdir=/usr/local/v6/lib;
1097 OPT="-I/usr/local/v6/include $OPT"])
1098 ;;
1099 zeta)
1100 AC_EGREP_CPP(yes, [dnl
1101#include <sys/param.h>
1102#ifdef _ZETA_MINAMI_INET6
1103yes
1104#endif],
1105 [ipv6type=$i;
1106 ipv6lib=inet6;
1107 ipv6libdir=/usr/local/v6/lib;
1108 OPT="-DINET6 $OPT"])
1109 ;;
1110 esac
1111 if test "$ipv6type" != "unknown"; then
1112 break
1113 fi
1114 done
1115 AC_MSG_RESULT($ipv6type)
1116fi
1117
1118if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1119 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1120 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1121 echo "using lib$ipv6lib"
1122 else
1123 if test $ipv6trylibc = "yes"; then
1124 echo "using libc"
1125 else
1126 echo 'Fatal: no $ipv6lib library found. cannot continue.'
1127 echo "You need to fetch lib$ipv6lib.a from appropriate"
1128 echo 'ipv6 kit and compile beforehand.'
1129 exit 1
1130 fi
1131 fi
1132fi
1133
Barry Warsawef82cd72000-06-30 16:21:01 +00001134# Check for GC support
Barry Warsawef82cd72000-06-30 16:21:01 +00001135AC_MSG_CHECKING(for --with-cycle-gc)
1136AC_ARG_WITH(cycle-gc,
1137[ --with(out)-cycle-gc disable/enable garbage collection])
1138
1139if test -z "$with_cycle_gc"
1140then with_cycle_gc="yes"
1141fi
Neil Schemenauer9c63e6d2001-08-29 23:44:38 +00001142if test "$with_cycle_gc" != "no"
Barry Warsawef82cd72000-06-30 16:21:01 +00001143then
Barry Warsawef82cd72000-06-30 16:21:01 +00001144 AC_DEFINE(WITH_CYCLE_GC)
1145fi
1146AC_MSG_RESULT($with_cycle_gc)
1147
Neil Schemenauera35c6882001-02-27 04:45:05 +00001148# Check for Python-specific malloc support
1149AC_MSG_CHECKING(for --with-pymalloc)
1150AC_ARG_WITH(pymalloc,
1151[ --with(out)-pymalloc disable/enable specialized mallocs], [
1152if test "$withval" != no
1153then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
1154else AC_MSG_RESULT(no)
1155fi],
1156[AC_MSG_RESULT(no)])
1157
Barry Warsawef82cd72000-06-30 16:21:01 +00001158# Check for --with-wctype-functions
1159AC_MSG_CHECKING(for --with-wctype-functions)
1160AC_ARG_WITH(wctype-functions,
1161[ --with-wctype-functions use wctype.h functions], [
1162if test "$withval" != no
1163then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
1164else AC_MSG_RESULT(no)
1165fi],
1166[AC_MSG_RESULT(no)])
1167
Guido van Rossum68242b51996-05-28 22:53:03 +00001168# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001169AC_SUBST(DLINCLDIR)
1170DLINCLDIR=/
1171
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001172AC_MSG_CHECKING(for --with-sgi-dl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001173AC_ARG_WITH(sgi-dl,
1174[ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001175AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001176AC_DEFINE(WITH_SGI_DL)
Guido van Rossume97ee181999-12-20 21:27:22 +00001177DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001178dldir=$withval
Guido van Rossum40951012000-10-07 16:21:27 +00001179if test ! -z "$dldir" -a -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001180then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001181else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1182fi
1183DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001184LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001185
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001186AC_MSG_CHECKING(for --with-dl-dld)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001187AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001188AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001189AC_DEFINE(WITH_DL_DLD)
Guido van Rossume97ee181999-12-20 21:27:22 +00001190DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001191dldir=`echo "$withval" | sed 's/,.*//'`
1192dlddir=`echo "$withval" | sed 's/.*,//'`
Barry Warsaw7d1219d2000-10-05 18:45:53 +00001193if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001194then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001195else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1196fi
1197DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001198LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +00001199
Guido van Rossume97ee181999-12-20 21:27:22 +00001200# the dlopen() function means we might want to use dynload_shlib.o. some
1201# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00001202AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00001203
1204# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1205# loading of modules.
1206AC_SUBST(DYNLOADFILE)
1207AC_MSG_CHECKING(DYNLOADFILE)
1208if test -z "$DYNLOADFILE"
1209then
1210 case $ac_sys_system/$ac_sys_release in
1211 AIX*) DYNLOADFILE="dynload_aix.o";;
1212 BeOS*) DYNLOADFILE="dynload_beos.o";;
1213 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001214 Darwin/*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00001215 *)
1216 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1217 # out any dynamic loading
1218 if test "$ac_cv_func_dlopen" = yes
1219 then DYNLOADFILE="dynload_shlib.o"
1220 else DYNLOADFILE="dynload_stub.o"
1221 fi
1222 ;;
1223 esac
1224fi
1225AC_MSG_RESULT($DYNLOADFILE)
1226if test "$DYNLOADFILE" != "dynload_stub.o"
1227then
1228 AC_DEFINE(HAVE_DYNAMIC_LOADING)
1229fi
1230
Jack Jansenc49e5b72001-06-19 15:00:23 +00001231# MACHDEP_OBJS can be set to platform-specific object files needed by Python
1232
1233AC_SUBST(MACHDEP_OBJS)
1234AC_MSG_CHECKING(MACHDEP_OBJS)
1235if test -z "$MACHDEP_OBJS"
1236then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001237 MACHDEP_OBJS=$extra_machdep_objs
1238else
1239 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00001240fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001241AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00001242
Guido van Rossum627b2d71993-12-24 10:39:16 +00001243# checks for library functions
Thomas Wouters3a584202000-08-05 23:28:51 +00001244AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
Fred Drake35a092f1999-12-13 16:23:35 +00001245 flock fork fsync fdatasync fpathconf ftime ftruncate \
Martin v. Löwisf95dd0a2001-08-15 17:14:33 +00001246 gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
Martin v. Löwis864e9ff2001-08-04 22:32:03 +00001247 hstrerror inet_pton kill link lstat mkfifo mktime mremap \
Andrew M. Kuchling5821b772000-08-25 01:14:08 +00001248 nice pathconf pause plock poll pthread_init \
Fred Drake35a092f1999-12-13 16:23:35 +00001249 putenv readlink \
Andrew M. Kuchling8d2f2b22000-07-13 01:26:58 +00001250 select setegid seteuid setgid \
Martin v. Löwis791bfda2001-07-24 06:33:08 +00001251 setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
Fred Drake35a092f1999-12-13 16:23:35 +00001252 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
Fred Drake89143df1999-12-09 22:03:25 +00001253 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Thomas Woutersc2c12dc2001-07-11 14:45:34 +00001254 truncate uname waitpid _getpty getpriority)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001255
Fred Drake8cef4cf2000-06-28 16:40:38 +00001256# check for openpty and forkpty
1257
1258AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1259AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1260
Guido van Rossumb8552162001-09-05 14:58:11 +00001261# Try defining symbols to enable large file support.
1262# The particular combination of symbols used here is known to work
1263# on Linux and Solaris [2.]7.
1264AC_MSG_CHECKING(for CFLAGS to enable large files)
1265OLD_CFLAGS="$CFLAGS"
1266CFLAGS="$CFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
1267AC_TRY_RUN([
1268#include <sys/types.h>
1269#include <stdio.h>
1270main() {
1271 FILE *fp;
1272 off_t seek = 0x80000000ul;
1273 off_t tell = 0;
1274 fp = fopen("conftestval", "wb");
1275 if (fp == NULL) {
1276 perror("conftestval");
1277 exit(1);
1278 }
1279 if (fseeko(fp, seek, 0) < 0)
1280 perror("fseeko");
1281 else
1282 tell = ftello(fp);
1283 fclose(fp);
1284 unlink("conftestval");
1285 if (tell == seek) {
1286 fprintf(stderr, "seek to 2**31 worked\n");
1287 exit(0);
1288 }
1289 else {
1290 exit(1);
1291 fprintf(stderr, "seek to 2**31 didn't work\n");
1292 }
1293}
1294],
1295AC_MSG_RESULT(yes)
1296AC_DEFINE(_LARGEFILE_SOURCE)
1297AC_DEFINE(_FILE_OFFSET_BITS,64),
1298AC_MSG_RESULT(no),
1299AC_MSG_RESULT(no (cross-compiling)))
1300CFLAGS="$OLD_CFLAGS"
1301
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001302# check for long file support functions
1303AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1304
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001305AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Thomas Wouters3a584202000-08-05 23:28:51 +00001306AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1307AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1308AC_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 +00001309
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001310AC_CHECK_FUNCS(getaddrinfo, [dnl
1311AC_MSG_CHECKING(getaddrinfo bug)
1312AC_TRY_RUN([
1313#include <sys/types.h>
1314#include <netdb.h>
1315#include <string.h>
1316#include <sys/socket.h>
1317#include <netinet/in.h>
1318
1319main()
1320{
1321 int passive, gaierr, inet4 = 0, inet6 = 0;
1322 struct addrinfo hints, *ai, *aitop;
1323 char straddr[INET6_ADDRSTRLEN], strport[16];
1324
1325 for (passive = 0; passive <= 1; passive++) {
1326 memset(&hints, 0, sizeof(hints));
1327 hints.ai_family = AF_UNSPEC;
1328 hints.ai_flags = passive ? AI_PASSIVE : 0;
1329 hints.ai_socktype = SOCK_STREAM;
1330 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1331 (void)gai_strerror(gaierr);
1332 goto bad;
1333 }
1334 for (ai = aitop; ai; ai = ai->ai_next) {
1335 if (ai->ai_addr == NULL ||
1336 ai->ai_addrlen == 0 ||
1337 getnameinfo(ai->ai_addr, ai->ai_addrlen,
1338 straddr, sizeof(straddr), strport, sizeof(strport),
1339 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1340 goto bad;
1341 }
1342 switch (ai->ai_family) {
1343 case AF_INET:
1344 if (strcmp(strport, "54321") != 0) {
1345 goto bad;
1346 }
1347 if (passive) {
1348 if (strcmp(straddr, "0.0.0.0") != 0) {
1349 goto bad;
1350 }
1351 } else {
1352 if (strcmp(straddr, "127.0.0.1") != 0) {
1353 goto bad;
1354 }
1355 }
1356 inet4++;
1357 break;
1358 case AF_INET6:
1359 if (strcmp(strport, "54321") != 0) {
1360 goto bad;
1361 }
1362 if (passive) {
1363 if (strcmp(straddr, "::") != 0) {
1364 goto bad;
1365 }
1366 } else {
1367 if (strcmp(straddr, "::1") != 0) {
1368 goto bad;
1369 }
1370 }
1371 inet6++;
1372 break;
1373 case AF_UNSPEC:
1374 goto bad;
1375 break;
1376 default:
1377 /* another family support? */
1378 break;
1379 }
1380 }
1381 }
1382
1383 if (!(inet4 == 0 || inet4 == 2))
1384 goto bad;
1385 if (!(inet6 == 0 || inet6 == 2))
1386 goto bad;
1387
1388 if (aitop)
1389 freeaddrinfo(aitop);
1390 exit(0);
1391
1392 bad:
1393 if (aitop)
1394 freeaddrinfo(aitop);
1395 exit(1);
1396}
1397],
1398AC_MSG_RESULT(good)
1399buggygetaddrinfo=no,
1400AC_MSG_RESULT(buggy)
1401buggygetaddrinfo=yes,
1402AC_MSG_RESULT(buggy)
1403buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
1404
1405if test "$buggygetaddrinfo" = "yes"; then
1406 if test "$ipv6" = "yes"; then
1407 echo 'Fatal: You must get working getaddrinfo() function.'
1408 echo ' or you can specify "--disable-ipv6"'.
1409 exit 1
1410 fi
1411fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00001412AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001413
Guido van Rossum627b2d71993-12-24 10:39:16 +00001414# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001415AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00001416AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001417AC_STRUCT_TIMEZONE
1418
1419AC_MSG_CHECKING(for time.h that defines altzone)
1420AC_CACHE_VAL(ac_cv_header_time_altzone,
1421[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1422 ac_cv_header_time_altzone=yes,
1423 ac_cv_header_time_altzone=no)])
1424AC_MSG_RESULT($ac_cv_header_time_altzone)
1425if test $ac_cv_header_time_altzone = yes; then
1426 AC_DEFINE(HAVE_ALTZONE)
1427fi
1428
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001429was_it_defined=no
1430AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001431AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001432#include <sys/types.h>
1433#include <sys/select.h>
1434#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001435], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1436AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001437
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001438AC_MSG_CHECKING(for addrinfo)
1439AC_CACHE_VAL(ac_cv_struct_addrinfo,
1440AC_TRY_COMPILE([
1441# include <netdb.h>],
1442 [struct addrinfo a],
1443 ac_cv_struct_addrinfo=yes,
1444 ac_cv_struct_addrinfo=no))
1445AC_MSG_RESULT($ac_cv_struct_addrinfo)
1446if test $ac_cv_struct_addrinfo = yes; then
1447 AC_DEFINE(HAVE_ADDRINFO)
1448fi
1449
1450AC_MSG_CHECKING(for sockaddr_storage)
1451AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1452AC_TRY_COMPILE([
1453# include <sys/types.h>
1454# include <sys/socket.h>],
1455 [struct sockaddr_storage s],
1456 ac_cv_struct_sockaddr_storage=yes,
1457 ac_cv_struct_sockaddr_storage=no))
1458AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1459if test $ac_cv_struct_sockaddr_storage = yes; then
1460 AC_DEFINE(HAVE_SOCKADDR_STORAGE)
1461fi
1462
Guido van Rossum627b2d71993-12-24 10:39:16 +00001463# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001464
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001465AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001466AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001467
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001468works=no
1469AC_MSG_CHECKING(for working volatile)
1470AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1471AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00001472
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001473works=no
1474AC_MSG_CHECKING(for working signed char)
1475AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1476AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001477
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001478have_prototypes=no
1479AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001480AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1481AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001482AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001483
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001484works=no
1485AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001486AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001487#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00001488int foo(int x, ...) {
1489 va_list va;
1490 va_start(va, x);
1491 va_arg(va, int);
1492 va_arg(va, char *);
1493 va_arg(va, double);
1494 return 0;
1495}
1496], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001497AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1498AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001499
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001500if test "$have_prototypes" = yes; then
1501bad_prototypes=no
1502AC_MSG_CHECKING(for bad exec* prototypes)
1503AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1504 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1505AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001506fi
1507
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001508# check if sockaddr has sa_len member
1509AC_MSG_CHECKING(if sockaddr has sa_len member)
1510AC_TRY_COMPILE([#include <sys/types.h>
1511#include <sys/socket.h>],
1512[struct sockaddr x;
1513x.sa_len = 0;],
1514 AC_MSG_RESULT(yes)
1515 AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
1516 AC_MSG_RESULT(no))
1517
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001518AC_MSG_CHECKING(for bad static forward)
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001519AC_CACHE_VAL(ac_cv_bad_static_forward,
1520[AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001521struct s { int a; int b; };
1522static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001523int foobar() {
1524 static int random;
1525 random = (int) &foo;
1526 return random;
1527}
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001528static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001529main() {
1530 exit(!((int)&foo == foobar()));
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001531}], ac_cv_bad_static_forward=no, ac_cv_bad_static_forward=yes)])
1532AC_MSG_RESULT($ac_cv_bad_static_forward)
1533if test "$ac_cv_bad_static_forward" = yes
1534then
1535 AC_DEFINE(BAD_STATIC_FORWARD)
1536fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001537
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001538va_list_is_array=no
1539AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001540AC_TRY_COMPILE([
1541#ifdef HAVE_STDARG_PROTOTYPES
1542#include <stdarg.h>
1543#else
1544#include <varargs.h>
1545#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001546], [va_list list1, list2; list1 = list2;], ,
1547AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1548AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001549
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001550# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1551AC_CHECK_FUNC(gethostbyname_r, [
1552 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1553 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1554 OLD_CFLAGS=$CFLAGS
1555 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1556 AC_TRY_COMPILE([
1557# include <netdb.h>
1558 ], [
1559 char *name;
1560 struct hostent *he, *res;
1561 char buffer[2048];
1562 int buflen = 2048;
1563 int h_errnop;
1564
1565 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1566 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001567 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001568 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1569 AC_MSG_RESULT(yes)
1570 ], [
1571 AC_MSG_RESULT(no)
1572 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1573 AC_TRY_COMPILE([
1574# include <netdb.h>
1575 ], [
1576 char *name;
1577 struct hostent *he;
1578 char buffer[2048];
1579 int buflen = 2048;
1580 int h_errnop;
1581
1582 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1583 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001584 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001585 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1586 AC_MSG_RESULT(yes)
1587 ], [
1588 AC_MSG_RESULT(no)
1589 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1590 AC_TRY_COMPILE([
1591# include <netdb.h>
1592 ], [
1593 char *name;
1594 struct hostent *he;
1595 struct hostent_data data;
1596
1597 (void) gethostbyname_r(name, he, &data);
1598 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001599 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001600 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1601 AC_MSG_RESULT(yes)
1602 ], [
1603 AC_MSG_RESULT(no)
1604 ])
1605 ])
1606 ])
1607 CFLAGS=$OLD_CFLAGS
1608], [
Thomas Wouters3a584202000-08-05 23:28:51 +00001609 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001610])
1611AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1612AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1613AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001614AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001615AC_SUBST(HAVE_GETHOSTBYNAME)
1616
Guido van Rossum627b2d71993-12-24 10:39:16 +00001617# checks for system services
1618# (none yet)
1619
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001620# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00001621AC_CHECK_FUNC(__fpu_control,
1622 [],
1623 [AC_CHECK_LIB(ieee, __fpu_control)
1624])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001625
Guido van Rossum93274221997-05-09 02:42:00 +00001626# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00001627AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001628AC_ARG_WITH(fpectl,
1629[ --with-fpectl enable SIGFPE catching], [
Guido van Rossum93274221997-05-09 02:42:00 +00001630if test "$withval" != no
1631then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1632else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00001633fi],
1634[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00001635
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001636# check for --with-libm=...
1637AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001638case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00001639Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001640BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001641*) LIBM=-lm
1642esac
Guido van Rossum93274221997-05-09 02:42:00 +00001643AC_MSG_CHECKING(for --with-libm=STRING)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001644AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001645if test "$withval" = no
1646then LIBM=
1647 AC_MSG_RESULT(force LIBM empty)
1648elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001649then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001650 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001651else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001652fi],
1653[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001654
1655# check for --with-libc=...
1656AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00001657AC_MSG_CHECKING(for --with-libc=STRING)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001658AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001659if test "$withval" = no
1660then LIBC=
1661 AC_MSG_RESULT(force LIBC empty)
1662elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001663then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001664 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001665else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001666fi],
1667[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001668
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001669# check for hypot() in math library
1670LIBS_SAVE=$LIBS
1671LIBS="$LIBS $LIBM"
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001672AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001673LIBS=$LIBS_SAVE
1674
Guido van Rossumad713701997-07-10 22:42:38 +00001675# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +00001676AC_MSG_CHECKING(what malloc(0) returns)
1677AC_CACHE_VAL(ac_cv_malloc_zero,
1678[AC_TRY_RUN([#include <stdio.h>
1679#ifdef HAVE_STDLIB
1680#include <stdlib.h>
1681#else
1682char *malloc(), *realloc();
1683int *free();
1684#endif
1685main() {
1686 char *p;
1687 p = malloc(0);
1688 if (p == NULL) exit(1);
1689 p = realloc(p, 0);
1690 if (p == NULL) exit(1);
1691 free(p);
1692 exit(0);
1693}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1694AC_MSG_RESULT($ac_cv_malloc_zero)
1695if test "$ac_cv_malloc_zero" = null
1696then
1697 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1698fi
1699
Guido van Rossumef2255b2000-03-10 22:30:29 +00001700# check for wchar.h
1701AC_CHECK_HEADER(wchar.h,
1702AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1703wchar_h="no"
1704)
1705
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001706# determine wchar_t size
1707if test "$wchar_h" = yes
1708then
1709 AC_CHECK_SIZEOF(wchar_t)
1710fi
1711
1712AC_MSG_CHECKING(what type to use for unicode)
1713AC_ARG_ENABLE(unicode,
1714[ --enable-unicode[=ucs2,ucs4] Enable Unicode strings (default is yes)],,enable_unicode=yes)
1715
1716if test $enable_unicode = yes
1717then
Martin v. Löwisfd917792001-06-27 20:22:04 +00001718 # Without any arguments, Py_UNICODE defaults to two-byte mode
1719 enable_unicode="ucs2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001720fi
1721
1722case "$enable_unicode" in
1723ucs2) unicode_size="2"
1724 AC_DEFINE(Py_UNICODE_SIZE,2)
1725 ;;
1726ucs4) unicode_size="4"
1727 AC_DEFINE(Py_UNICODE_SIZE,4)
1728 ;;
1729esac
1730
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001731AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001732if test "$enable_unicode" = "no"
1733then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001734 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001735 AC_MSG_RESULT(not used)
1736else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001737 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001738 AC_DEFINE(Py_USING_UNICODE)
1739 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
1740 then
1741 PY_UNICODE_TYPE="wchar_t"
1742 AC_DEFINE(HAVE_USABLE_WCHAR_T)
1743 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
1744 elif test "$ac_cv_sizeof_short" = "$unicode_size"
1745 then
1746 PY_UNICODE_TYPE="unsigned short"
1747 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
1748 elif test "$ac_cv_sizeof_long" = "$unicode_size"
1749 then
1750 PY_UNICODE_TYPE="unsigned long"
1751 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
1752 else
1753 PY_UNICODE_TYPE="no type found"
1754 fi
1755 AC_MSG_RESULT($PY_UNICODE_TYPE)
1756fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00001757
1758# check for endianness
1759AC_C_BIGENDIAN
1760
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001761# Check whether right shifting a negative integer extends the sign bit
1762# or fills with zeros (like the Cray J90, according to Tim Peters).
1763AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00001764AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001765AC_TRY_RUN([
1766int main()
1767{
Vladimir Marangozova6180282000-07-12 05:05:06 +00001768 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001769}
Vladimir Marangozova6180282000-07-12 05:05:06 +00001770], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1771AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1772if test "$ac_cv_rshift_extends_sign" = no
1773then
1774 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1775fi
1776
Guido van Rossumcadfaec2001-01-05 14:45:49 +00001777# check for getc_unlocked and related locking functions
1778AC_MSG_CHECKING(for getc_unlocked() and friends)
1779AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1780AC_TRY_LINK([#include <stdio.h>],[
1781 FILE *f = fopen("/dev/null", "r");
1782 flockfile(f);
1783 getc_unlocked(f);
1784 funlockfile(f);
1785], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1786AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1787if test "$ac_cv_have_getc_unlocked" = yes
1788then
1789 AC_DEFINE(HAVE_GETC_UNLOCKED)
1790fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001791
Guido van Rossum353ae582001-07-10 16:45:32 +00001792# check for readline 4.2
1793AC_CHECK_LIB(readline, rl_completion_matches,
1794 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
1795
Thomas Wouterse38b2f12001-07-11 22:35:31 +00001796AC_MSG_CHECKING(for broken nice())
1797AC_CACHE_VAL(ac_cv_broken_nice, [
1798AC_TRY_RUN([
1799int main()
1800{
1801 int val1 = nice(1);
1802 if (val1 != -1 && val1 == nice(2))
1803 exit(0);
1804 exit(1);
1805}
1806],ac_cv_broken_nice=yes, ac_cv_broken_nice=no)])
1807AC_MSG_RESULT($ac_cv_broken_nice)
1808if test "$ac_cv_broken_nice" = yes
1809then
1810 AC_DEFINE(HAVE_BROKEN_NICE)
1811fi
1812
Guido van Rossum95713eb2000-05-18 20:53:31 +00001813# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1814# Add sys/socket.h to confdefs.h
1815cat >> confdefs.h <<\EOF
1816#ifdef HAVE_SYS_SOCKET_H
1817#include <sys/socket.h>
1818#endif
1819EOF
1820AC_CHECK_TYPE(socklen_t, int)
1821
Neil Schemenauerf25cf6c2001-03-04 06:39:33 +00001822# Add Python/ prefix to LIBOBJS
1823libobjs=$LIBOBJS
1824LIBOBJS=
1825for obj in $libobjs; do
1826 LIBOBJS="$LIBOBJS Python/$obj"
1827done
1828
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001829#AC_MSG_CHECKING(for Modules/Setup)
1830#if test ! -f Modules/Setup ; then
1831# if test ! -d Modules ; then
1832# mkdir Modules
1833# fi
1834# cp "$srcdir/Modules/Setup.dist" Modules/Setup
1835# AC_MSG_RESULT(creating)
1836#else
1837# AC_MSG_RESULT(already exists)
1838#fi
1839
1840AC_SUBST(SRCDIRS)
Neil Schemenaueracbf9ef2001-02-27 02:15:14 +00001841SRCDIRS="Parser Grammar Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001842AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001843for dir in $SRCDIRS; do
1844 if test ! -d $dir; then
1845 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00001846 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001847done
1848AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00001849
Guido van Rossum627b2d71993-12-24 10:39:16 +00001850# generate output files
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001851AC_OUTPUT(Makefile.pre Modules/Setup.config)
Neil Schemenauer61c51152001-01-26 16:18:16 +00001852
1853echo "creating Setup"
1854if test ! -f Modules/Setup
1855then
1856 cp $srcdir/Modules/Setup.dist Modules/Setup
1857fi
1858
1859echo "creating Setup.local"
1860if test ! -f Modules/Setup.local
1861then
1862 echo "# Edit this file for local setup changes" >Modules/Setup.local
1863fi
1864
1865echo "creating Makefile"
1866$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1867 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00001868 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00001869mv config.c Modules