blob: 10b5e89d11a3717f14b3262d0189385982b55b7a [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)
Andrew M. Kuchling54a39412002-02-11 16:30:54 +00009VERSION=2.3
Guido van Rossum642b6781997-07-19 19:35:41 +000010
Martin v. Löwis1142de32002-03-29 16:28:31 +000011AC_SUBST(SOVERSION)
12SOVERSION=1.0
13
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000014# Arguments passed to configure.
15AC_SUBST(CONFIG_ARGS)
16CONFIG_ARGS="$ac_configure_args"
17
Guido van Rossum4b6b5791996-09-09 20:09:34 +000018
Jack Jansenb6e9cad2001-08-15 01:26:28 +000019AC_ARG_ENABLE(framework,
20[ --enable-framework[=INSTALLDIR] Build (MacOSX|Darwin) framework],[
Jack Jansenb6e9cad2001-08-15 01:26:28 +000021 case $enableval in
22 yes)
23 enableval=/Library/Frameworks
Jack Jansen127e56e2001-09-11 14:41:54 +000024 esac
25 case $enableval in
26 no)
27 PYTHONFRAMEWORK=
28 PYTHONFRAMEWORKDIR=no-framework
29 PYTHONFRAMEWORKPREFIX=
30 PYTHONFRAMEWORKINSTALLDIR=
31 enable_framework=
Jack Jansenb6e9cad2001-08-15 01:26:28 +000032 ;;
33 *)
Jack Jansen127e56e2001-09-11 14:41:54 +000034 PYTHONFRAMEWORK=Python
35 PYTHONFRAMEWORKDIR=Python.framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +000036 PYTHONFRAMEWORKPREFIX=$enableval
Jack Jansen127e56e2001-09-11 14:41:54 +000037 PYTHONFRAMEWORKINSTALLDIR=$PYTHONFRAMEWORKPREFIX/$PYTHONFRAMEWORKDIR
38 prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION
Jack Jansenb6e9cad2001-08-15 01:26:28 +000039 esac
Jack Jansenb6e9cad2001-08-15 01:26:28 +000040 ],[
41 PYTHONFRAMEWORK=
Jack Jansen127e56e2001-09-11 14:41:54 +000042 PYTHONFRAMEWORKDIR=no-framework
Jack Jansenb6e9cad2001-08-15 01:26:28 +000043 PYTHONFRAMEWORKPREFIX=
44 PYTHONFRAMEWORKINSTALLDIR=
45 enable_framework=
46])
47AC_SUBST(PYTHONFRAMEWORK)
48AC_SUBST(PYTHONFRAMEWORKDIR)
49AC_SUBST(PYTHONFRAMEWORKPREFIX)
50AC_SUBST(PYTHONFRAMEWORKINSTALLDIR)
Guido van Rossum4b6b5791996-09-09 20:09:34 +000051
Jack Jansenb6e9cad2001-08-15 01:26:28 +000052##AC_ARG_WITH(dyld,
53##[ --with-dyld Use (OpenStep|Rhapsody) dynamic linker],,)
54##
Guido van Rossumb418f891996-07-30 18:06:02 +000055# Set name for machine-dependent library files
56AC_SUBST(MACHDEP)
57AC_MSG_CHECKING(MACHDEP)
58if test -z "$MACHDEP"
59then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000060 ac_sys_system=`uname -s`
Martin v. Löwis130fb172001-07-19 11:00:41 +000061 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000062 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +000063 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +000064 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +000065 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000066 ac_md_system=`echo $ac_sys_system |
67 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
68 ac_md_release=`echo $ac_sys_release |
Guido van Rossum67b26592001-10-20 14:21:45 +000069 tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +000070 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +000071
Guido van Rossumbcd91e01997-03-20 20:46:29 +000072 case $MACHDEP in
Andrew M. Kuchling5a3e4cb2001-07-20 19:29:04 +000073 cygwin*) MACHDEP="cygwin";;
Jack Jansen8a97f4a2001-12-05 23:27:32 +000074 darwin*) MACHDEP="darwin";;
Guido van Rossumb97ef171997-09-28 05:44:03 +000075 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +000076 esac
77fi
Guido van Rossum91922671997-10-09 20:24:13 +000078
79#
80# SGI compilers allow the specification of the both the ABI and the
81# ISA on the command line. Depending on the values of these switches,
82# different and often incompatable code will be generated.
83#
84# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
85# thus supply support for various ABI/ISA combinations. The MACHDEP
86# variable is also adjusted.
87#
88AC_SUBST(SGI_ABI)
89if test ! -z "$SGI_ABI"
90then
91 CC="cc $SGI_ABI"
92 LDFLAGS="$SGI_ABI $LDFLAGS"
93 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
94fi
Guido van Rossumb418f891996-07-30 18:06:02 +000095AC_MSG_RESULT($MACHDEP)
96
Guido van Rossum627b2d71993-12-24 10:39:16 +000097# checks for alternative programs
Guido van Rossum5739e7e1995-01-20 16:50:53 +000098AC_MSG_CHECKING(for --without-gcc)
Barry Warsawc0d24d82000-06-29 16:12:00 +000099AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000100 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000101 no) CC=cc
102 without_gcc=yes;;
103 yes) CC=gcc
104 without_gcc=no;;
105 *) CC=$withval
106 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000107 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000108 case $ac_sys_system in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000109 AIX*) CC=cc_r
110 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000111 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000112 case $BE_HOST_CPU in
113 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000114 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000115 without_gcc=yes
Fred Drake5790be12000-10-09 17:06:13 +0000116 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 +0000117 CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000118 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000119 ;;
120 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000121 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000122 without_gcc=no
Fred Drake5790be12000-10-09 17:06:13 +0000123 OPT=-O
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000124 ;;
125 *)
Fred Drake5790be12000-10-09 17:06:13 +0000126 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000127 ;;
128 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000129 AR="\$(srcdir)/Modules/ar_beos"
130 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000131 ;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000132 Monterey*)
133 RANLIB=:
Martin v. Löwis130fb172001-07-19 11:00:41 +0000134 without_gcc=;;
135 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000136 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000137AC_MSG_RESULT($without_gcc)
138
Guido van Rossum27552902001-01-23 01:52:26 +0000139AC_SUBST(CXX)
Guido van Rossum95012191999-12-16 17:50:52 +0000140AC_SUBST(MAINOBJ)
Fred Drakea1a84e72001-03-06 05:52:16 +0000141MAINOBJ=python.o
Guido van Rossum95012191999-12-16 17:50:52 +0000142AC_MSG_CHECKING(for --with-cxx=<compiler>)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000143AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
Martin v. Löwis537970f2000-12-13 17:37:02 +0000144 check_cxx=no
Guido van Rossum95012191999-12-16 17:50:52 +0000145 case $withval in
146 no) CXX=
147 with_cxx=no;;
148 *) CXX=$withval
Fred Drakea1a84e72001-03-06 05:52:16 +0000149 MAINOBJ=ccpython.o
Guido van Rossum95012191999-12-16 17:50:52 +0000150 with_cxx=$withval;;
151 esac], [
152 with_cxx=no
Martin v. Löwis537970f2000-12-13 17:37:02 +0000153 check_cxx=yes
Guido van Rossum95012191999-12-16 17:50:52 +0000154])
155AC_MSG_RESULT($with_cxx)
Martin v. Löwis537970f2000-12-13 17:37:02 +0000156
Michael W. Hudson54241132001-12-07 15:38:26 +0000157if test "$with_cxx" = "yes"
158then
159 AC_ERROR(must supply a compiler when using --with-cxx)
160fi
161
Martin v. Löwis537970f2000-12-13 17:37:02 +0000162dnl The following fragment works similar to AC_PROG_CXX.
163dnl It does not fail if CXX is not found, and it is not executed if
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000164dnl --without-cxx was given.
Martin v. Löwis537970f2000-12-13 17:37:02 +0000165dnl Finally, it does not test whether CXX is g++.
166
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000167dnl Autoconf 2.5x does not have AC_PROG_CXX_WORKS anymore
168ifdef([AC_PROG_CXX_WORKS],[],
169 [AC_DEFUN([AC_PROG_CXX_WORKS],
170 [AC_LANG_PUSH(C++)dnl
171 _AC_COMPILER_EXEEXT
172 AC_LANG_POP()
173 ]
174)])
175
Martin v. Löwis537970f2000-12-13 17:37:02 +0000176if test "$check_cxx" = "yes"
177then
178 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
179 if test "$CXX" = "notfound"
180 then
181 CXX=
182 else
183 AC_PROG_CXX_WORKS
184 fi
185fi
186
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000187# If the user switches compilers, we can't believe the cache
188if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
189then
190 AC_ERROR(cached CC is different -- throw away $cache_file
191(it is also a good idea to do 'make clean' before compiling))
192fi
193
Guido van Rossum627b2d71993-12-24 10:39:16 +0000194AC_PROG_CC
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +0000195
196# checks for UNIX variants that set C preprocessor variables
197AC_AIX
198AC_MINIX
199
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000200AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000201AC_MSG_CHECKING(for --with-suffix)
202AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
203 case $withval in
204 no) EXEEXT=;;
205 yes) EXEEXT=.exe;;
206 *) EXEEXT=$withval;;
207 esac])
208AC_MSG_RESULT($EXEEXT)
Jack Jansen1999ef42001-12-06 21:47:20 +0000209
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000210# Test whether we're running on a non-case-sensitive system, in which
211# case we give a warning if no ext is given
Jack Jansen1999ef42001-12-06 21:47:20 +0000212AC_SUBST(BUILDEXEEXT)
213AC_MSG_CHECKING(for case-insensitive build directory)
214if test -d "python"
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000215then
Jack Jansen1999ef42001-12-06 21:47:20 +0000216 AC_MSG_RESULT(yes)
217 BUILDEXEEXT=.exe
218else
219 AC_MSG_RESULT(no)
Jack Jansendd19cf82001-12-06 22:36:17 +0000220 BUILDEXEEXT=$EXEEXT
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000221fi
Guido van Rossumfb842551997-08-06 23:42:07 +0000222
Guido van Rossumdd997f71998-10-07 19:58:26 +0000223case $MACHDEP in
224bsdos*)
225 case $CC in
226 gcc) CC="$CC -D_HAVE_BSDI";;
227 esac;;
228esac
229
Guido van Rossum84561611997-08-21 00:08:11 +0000230case $ac_sys_system in
231hp*|HP*)
232 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000233 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000234 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000235Monterey*)
236 case $CC in
237 cc) CC="$CC -Wl,-Bexport";;
238 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000239SunOS*)
240 # Some functions have a prototype only with that define, e.g. confstr
241 AC_DEFINE(__EXTENSIONS__)
242 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000243esac
244
Martin v. Löwise8964d42001-03-06 12:09:07 +0000245
Neil Schemenauer61c51152001-01-26 16:18:16 +0000246AC_SUBST(LIBRARY)
247AC_MSG_CHECKING(LIBRARY)
248if test -z "$LIBRARY"
249then
250 LIBRARY='libpython$(VERSION).a'
251fi
252AC_MSG_RESULT($LIBRARY)
253
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000254# LDLIBRARY is the name of the library to link against (as opposed to the
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000255# name of the library into which to insert object files). BLDLIBRARY is also
256# the library to link against, usually. On Mac OS X frameworks, BLDLIBRARY
257# is blank as the main program is not linked directly against LDLIBRARY.
258# LDLIBRARYDIR is the path to LDLIBRARY, which is made in a subdirectory. On
259# systems without shared libraries, LDLIBRARY is the same as LIBRARY
260# (defined in the Makefiles). On Cygwin LDLIBRARY is the import library,
261# DLLLIBRARY is the shared (i.e., DLL) library.
262#
Martin v. Löwis1142de32002-03-29 16:28:31 +0000263# RUNSHARED is used to run shared python without installed libraries
264#
265# INSTSONAME is the name of the shared library that will be use to install
266# on the system - some systems like version suffix, others don't
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000267AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000268AC_SUBST(DLLLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000269AC_SUBST(BLDLIBRARY)
270AC_SUBST(LDLIBRARYDIR)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000271AC_SUBST(INSTSONAME)
272AC_SUBST(RUNSHARED)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000273LDLIBRARY="$LIBRARY"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000274BLDLIBRARY='$(LDLIBRARY)'
Martin v. Löwis1142de32002-03-29 16:28:31 +0000275INSTSONMAE='$(LDLIBRARY)'
Guido van Rossum27552902001-01-23 01:52:26 +0000276DLLLIBRARY=''
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000277LDLIBRARYDIR=''
Martin v. Löwis1142de32002-03-29 16:28:31 +0000278RUNSHARED=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000279
Guido van Rossumfb842551997-08-06 23:42:07 +0000280# LINKCC is the command that links the python executable -- default is $(CC).
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000281# If CXX is set, and if it is needed to link a main function that was
282# compiled with CXX, LINKCC is CXX instead. Always using CXX is undesirable:
283# python might then depend on the C++ runtime
Fred Drake5790be12000-10-09 17:06:13 +0000284# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000285# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000286AC_SUBST(LINKCC)
287AC_MSG_CHECKING(LINKCC)
288if test -z "$LINKCC"
289then
Martin v. Löwisb7da67a2001-10-18 15:35:38 +0000290 if test -z "$CXX"; then
291 LINKCC="\$(PURIFY) \$(CC)"
292 else
293 echo 'int main(){return 0;}' > conftest.$ac_ext
294 $CXX -c conftest.$ac_ext 2>&5
295 if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \
296 && test -s conftest$ac_exeext && ./conftest$ac_exeext
297 then
298 LINKCC="\$(PURIFY) \$(CC)"
299 else
300 LINKCC="\$(PURIFY) \$(CXX)"
301 fi
302 rm -fr conftest*
303 fi
Guido van Rossumfb842551997-08-06 23:42:07 +0000304 case $ac_sys_system in
305 AIX*)
Jeremy Hylton90d10062002-03-08 21:43:51 +0000306 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000307 dgux*)
Martin v. Löwis4e732dc2002-03-19 15:15:32 +0000308 LINKCC="LD_RUN_PATH=$libdir $LINKCC";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000309 Monterey64*)
Martin v. Löwis4e732dc2002-03-19 15:15:32 +0000310 LINKCC="$LINKCC -L/usr/lib/ia64l64";;
Guido van Rossumfb842551997-08-06 23:42:07 +0000311 esac
312fi
313AC_MSG_RESULT($LINKCC)
314
Martin v. Löwis1142de32002-03-29 16:28:31 +0000315AC_MSG_CHECKING(for --enable-shared)
316AC_ARG_ENABLE(shared,
317[ --enable-shared disable/enable building shared python library])
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000318
Martin v. Löwis1142de32002-03-29 16:28:31 +0000319if test -z "$enable_shared"
320then
321 enable_shared="no"
322fi
323AC_MSG_RESULT($enable_shared)
324
325
326AC_MSG_CHECKING(LDLIBRARY)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000327
Guido van Rossumb8552162001-09-05 14:58:11 +0000328# MacOSX framework builds need more magic. LDLIBRARY is the dynamic
329# library that we build, but we do not want to link against it (we
330# will find it with a -framework option). For this reason there is an
331# extra variable BLDLIBRARY against which Python and the extension
332# modules are linked, BLDLIBRARY. This is normally the same as
333# LDLIBRARY, but empty for MacOSX framework builds.
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000334if test "$enable_framework"
335then
336 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
337 LDLIBRARYDIR='$(PYTHONFRAMEWORKDIR)'
338 BLDLIBRARY=''
339else
340 BLDLIBRARY='$(LDLIBRARY)'
341fi
342
Martin v. Löwis1142de32002-03-29 16:28:31 +0000343# Other platforms follow
344if test $enable_shared = "yes"; then
345 case $ac_sys_system in
346 BeOS*)
347 LDLIBRARY='libpython$(VERSION).so'
348 ;;
349 CYGWIN*)
350 LDLIBRARY='libpython$(VERSION).dll.a'
351 DLLLIBRARY='libpython$(VERSION).dll'
352 ;;
353 SunOS*)
354 LDLIBRARY='libpython$(VERSION).so'
355 BLDLIBRARY='-Wl,-rpath,$(LIBDIR) -L. -lpython$(VERSION)'
356 RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
357 ;;
358 Linux*)
359 LDLIBRARY='libpython$(VERSION).so'
360 BLDLIBRARY='-L. -lpython$(VERSION)'
361 RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
362 INSTSONAME="$LDLIBRARY".$SOVERSION
363 ;;
364 hp*|HP*)
365 LDLIBRARY='libpython$(VERSION).sl'
366 BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(VERSION)'
367 RUNSHARED=SHLIB_PATH=`pwd`:$SHLIB_PATH
368 ;;
369 OSF*)
370 LDLIBRARY='libpython$(VERSION).so'
371 BLDLIBRARY='-rpath $(LIBDIR) -L. -lpython$(VERSION)'
372 RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
373 ;;
374 esac
375 # DG/UX requires some fancy ld contortions to produce a .so from an .a
376 case $MACHDEP in
377 dguxR4)
378 LDLIBRARY='libpython$(VERSION).so'
379 OPT="$OPT -pic"
380 ;;
381 esac
382fi
383
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000384AC_MSG_RESULT($LDLIBRARY)
385
Guido van Rossum627b2d71993-12-24 10:39:16 +0000386AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000387AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000388AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000389
390case $MACHDEP in
Neil Schemenaueraf5567f2001-10-21 22:32:04 +0000391bsdos*|hp*|HP*)
392 # install -d does not work on BSDI or HP-UX
Neil Schemenauera42c8272001-03-31 00:01:55 +0000393 if test -z "$INSTALL"
394 then
395 INSTALL="${srcdir}/install-sh -c"
396 fi
397esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000398AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000399
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000400# Not every filesystem supports hard links
401AC_SUBST(LN)
402if test -z "$LN" ; then
403 case $ac_sys_system in
404 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000405 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000406 *) LN=ln;;
407 esac
408fi
409
Fred Drake9f715822001-07-11 06:27:00 +0000410# Check for --with-pydebug
411AC_MSG_CHECKING(for --with-pydebug)
412AC_ARG_WITH(pydebug,
413[ --with-pydebug build with Py_DEBUG defined], [
414if test "$withval" != no
415then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes); Py_DEBUG='true'
416else AC_MSG_RESULT(no); Py_DEBUG='false'
417fi],
418[AC_MSG_RESULT(no)])
419
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000420# Optimizer/debugger flags
Guido van Rossumb418f891996-07-30 18:06:02 +0000421AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000422if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000423then
Guido van Rossumb5875b61997-07-18 23:29:09 +0000424 case $GCC in
425 yes)
426 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000427 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000428 if test "$Py_DEBUG" = 'true' ; then
429 # Optimization messes up debuggers, so turn it off for
430 # debug builds.
431 OPT="-g -Wall -Wstrict-prototypes"
432 else
433 OPT="-g -O3 -Wall -Wstrict-prototypes"
434 fi;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000435 *)
Fred Drake9f715822001-07-11 06:27:00 +0000436 OPT="-O3 -Wall -Wstrict-prototypes";;
437 esac
438 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000439 *)
440 case $ac_sys_system in
Martin v. Löwis25ae43b2001-10-07 08:39:18 +0000441 OpenUNIX*|UnixWare*)
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000442 OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
443 *)
444 OPT="-O";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000445 esac
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000446 esac
Jack Jansenca06bc62001-08-03 15:32:23 +0000447 case $ac_sys_system in
448 Darwin*)
Jack Jansen524a0982002-03-12 15:25:52 +0000449 OPT="$OPT -Wno-long-double -no-cpp-precomp";;
Jack Jansenca06bc62001-08-03 15:32:23 +0000450 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000451fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000452
Fred Drakee1ceaa02001-12-04 20:55:47 +0000453if test "$Py_DEBUG" = 'true'; then
454 :
455else
456 OPT="-DNDEBUG $OPT"
457fi
458
Trent Mick635f6fb2000-08-23 21:33:05 +0000459# The current (beta) Monterey compiler dies with optimizations
460case $ac_sys_system in
461Monterey*) OPT="";;
462esac
463
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000464if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000465then
466 OPT="$OPT $ac_arch_flags"
467fi
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000468
Guido van Rossum91922671997-10-09 20:24:13 +0000469AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
470AC_CACHE_VAL(ac_cv_opt_olimit_ok,
471[ac_save_cc="$CC"
472CC="$CC -OPT:Olimit=0"
473AC_TRY_RUN([int main() { return 0; }],
474 ac_cv_opt_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +0000475 ac_cv_opt_olimit_ok=no,
Guido van Rossum91922671997-10-09 20:24:13 +0000476 ac_cv_opt_olimit_ok=no)
477CC="$ac_save_cc"])
478AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000479if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000480 case $ac_sys_system in
481 Darwin*) OPT="$OPT" ;;
482 *) OPT="$OPT -OPT:Olimit=0";;
483 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000484else
485 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
486 AC_CACHE_VAL(ac_cv_olimit_ok,
487 [ac_save_cc="$CC"
488 CC="$CC -Olimit 1500"
489 AC_TRY_RUN([int main() { return 0; }],
490 ac_cv_olimit_ok=yes,
Guido van Rossum3065c942001-09-17 04:03:14 +0000491 ac_cv_olimit_ok=no,
Guido van Rossumf8678121998-07-07 21:05:09 +0000492 ac_cv_olimit_ok=no)
493 CC="$ac_save_cc"])
494 AC_MSG_RESULT($ac_cv_olimit_ok)
495 if test $ac_cv_olimit_ok = yes; then
496 OPT="$OPT -Olimit 1500"
497 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000498fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000499
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000500# On some compilers, pthreads are available without further options
501# (e.g. MacOS X). On some of these systems, the compiler will not
502# complain if unaccepted options are passed (e.g. gcc on Mac OS X).
503# So we have to see first whether pthreads are available without
504# options before we can check whether -Kpthread improves anything.
505AC_MSG_CHECKING(whether pthreads are available without options)
506AC_CACHE_VAL(ac_cv_pthread_is_default,
507[AC_TRY_RUN([
508#include <pthread.h>
509
510void* routine(void* p){return NULL;}
511
512int main(){
513 pthread_t p;
514 if(pthread_create(&p,NULL,routine,NULL)!=0)
515 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +0000516 (void)pthread_detach(p);
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000517 return 0;
518}
519],
520 ac_cv_pthread_is_default=yes,
521 ac_cv_pthread_is_default=no,
522 ac_cv_pthread_is_default=no)
523])
524AC_MSG_RESULT($ac_cv_pthread_is_default)
525
526
527if test $ac_cv_pthread_is_default = yes
528then
529 ac_cv_kpthread=no
530else
Martin v. Löwis130fb172001-07-19 11:00:41 +0000531# -Kpthread, if available, provides the right #defines
532# and linker options to make pthread_create available
Martin v. Löwis260aecc2001-10-07 08:14:41 +0000533# Some compilers won't report that they do not support -Kpthread,
534# so we need to run a program to see whether it really made the
535# function available.
Martin v. Löwis130fb172001-07-19 11:00:41 +0000536AC_MSG_CHECKING(whether $CC accepts -Kpthread)
537AC_CACHE_VAL(ac_cv_kpthread,
538[ac_save_cc="$CC"
539CC="$CC -Kpthread"
Martin v. Löwis260aecc2001-10-07 08:14:41 +0000540AC_TRY_RUN([
541#include <pthread.h>
542
543void* routine(void* p){return NULL;}
544
545int main(){
546 pthread_t p;
547 if(pthread_create(&p,NULL,routine,NULL)!=0)
548 return 1;
Jack Jansen4f8d0542002-03-08 13:43:01 +0000549 (void)pthread_detach(p);
Martin v. Löwis260aecc2001-10-07 08:14:41 +0000550 return 0;
551}
552],
Martin v. Löwis130fb172001-07-19 11:00:41 +0000553 ac_cv_kpthread=yes,
Martin v. Löwis260aecc2001-10-07 08:14:41 +0000554 ac_cv_kpthread=no,
Martin v. Löwis130fb172001-07-19 11:00:41 +0000555 ac_cv_kpthread=no)
556CC="$ac_save_cc"])
Martin v. Löwis130fb172001-07-19 11:00:41 +0000557AC_MSG_RESULT($ac_cv_kpthread)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +0000558fi
Martin v. Löwis130fb172001-07-19 11:00:41 +0000559
Fred Drakece81d592000-07-09 14:39:29 +0000560dnl # check for ANSI or K&R ("traditional") preprocessor
561dnl AC_MSG_CHECKING(for C preprocessor type)
562dnl AC_TRY_COMPILE([
563dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
564dnl int foo;
565dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
566dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
567dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +0000568
Guido van Rossum627b2d71993-12-24 10:39:16 +0000569# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000570AC_HEADER_STDC
Martin v. Löwis2e64c342002-03-27 18:49:02 +0000571AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h \
572libintl.h locale.h ncurses.h poll.h pthread.h \
Eric S. Raymond13603592001-01-16 15:01:26 +0000573signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
Fred Drake2ca5f3b2001-05-11 16:10:56 +0000574sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
Andrew M. Kuchling881fd902001-07-14 20:55:52 +0000575sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
Martin v. Löwis69532332001-10-13 09:12:41 +0000576sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
Martin v. Löwis1ba3fd52001-08-10 20:29:40 +0000577ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000578AC_HEADER_DIRENT
Guido van Rossum627b2d71993-12-24 10:39:16 +0000579
580# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000581was_it_defined=no
582AC_MSG_CHECKING(for clock_t in time.h)
583AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
584AC_MSG_RESULT($was_it_defined)
585
Guido van Rossum810cc512001-09-09 23:51:39 +0000586# Two defines needed to enable largefile support on various platforms
587# These may affect some typedefs
588AC_DEFINE(_LARGEFILE_SOURCE)
589AC_DEFINE(_FILE_OFFSET_BITS, 64)
590
Guido van Rossum300fda71996-08-19 21:58:16 +0000591# Add some code to confdefs.h so that the test for off_t works on SCO
592cat >> confdefs.h <<\EOF
593#if defined(SCO_DS)
594#undef _OFF_T
595#endif
596EOF
597
Guido van Rossumef2255b2000-03-10 22:30:29 +0000598# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000599AC_TYPE_MODE_T
600AC_TYPE_OFF_T
601AC_TYPE_PID_T
602AC_TYPE_SIGNAL
603AC_TYPE_SIZE_T
604AC_TYPE_UID_T
Guido van Rossum627b2d71993-12-24 10:39:16 +0000605
Guido van Rossumef2255b2000-03-10 22:30:29 +0000606# Sizes of various common basic types
Guido van Rossum3065c942001-09-17 04:03:14 +0000607AC_CHECK_SIZEOF(int, 4)
608AC_CHECK_SIZEOF(long, 4)
609AC_CHECK_SIZEOF(void *, 4)
610AC_CHECK_SIZEOF(char, 1)
611AC_CHECK_SIZEOF(short, 2)
612AC_CHECK_SIZEOF(float, 4)
613AC_CHECK_SIZEOF(double, 8)
614AC_CHECK_SIZEOF(fpos_t, 4)
Guido van Rossumac405f61994-09-12 10:56:06 +0000615
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000616AC_MSG_CHECKING(for long long support)
617have_long_long=no
618AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
619AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000620if test "$have_long_long" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +0000621AC_CHECK_SIZEOF(long long, 8)
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000622fi
623
Barry Warsawbc7c7f92000-08-18 04:53:33 +0000624AC_MSG_CHECKING(for uintptr_t support)
625have_uintptr_t=no
626AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
627AC_MSG_RESULT($have_uintptr_t)
628if test "$have_uintptr_t" = yes ; then
Guido van Rossum3065c942001-09-17 04:03:14 +0000629AC_CHECK_SIZEOF(uintptr_t, 4)
Barry Warsawbc7c7f92000-08-18 04:53:33 +0000630fi
631
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000632# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
633AC_MSG_CHECKING(size of off_t)
634AC_CACHE_VAL(ac_cv_sizeof_off_t,
635[AC_TRY_RUN([#include <stdio.h>
636#include <sys/types.h>
637main()
638{
639 FILE *f=fopen("conftestval", "w");
640 if (!f) exit(1);
641 fprintf(f, "%d\n", sizeof(off_t));
642 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +0000643}],
644ac_cv_sizeof_off_t=`cat conftestval`,
645ac_cv_sizeof_off_t=0,
646ac_cv_sizeof_off_t=4)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000647])
648AC_MSG_RESULT($ac_cv_sizeof_off_t)
649AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
650
651AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000652if test "$have_long_long" = yes -a \
653 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
654 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000655 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
656 AC_MSG_RESULT(yes)
657else
658 AC_MSG_RESULT(no)
659fi
660
Fred Drakea3f6e912000-06-29 20:44:47 +0000661# AC_CHECK_SIZEOF() doesn't include <time.h>.
662AC_MSG_CHECKING(size of time_t)
663AC_CACHE_VAL(ac_cv_sizeof_time_t,
664[AC_TRY_RUN([#include <stdio.h>
665#include <time.h>
666main()
667{
668 FILE *f=fopen("conftestval", "w");
669 if (!f) exit(1);
670 fprintf(f, "%d\n", sizeof(time_t));
671 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +0000672}],
673ac_cv_sizeof_time_t=`cat conftestval`,
674ac_cv_sizeof_time_t=0,
675ac_cv_sizeof_time_t=4)
Fred Drakea3f6e912000-06-29 20:44:47 +0000676])
677AC_MSG_RESULT($ac_cv_sizeof_time_t)
678AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
679
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000680
Trent Mick635f6fb2000-08-23 21:33:05 +0000681# if have pthread_t then define SIZEOF_PTHREAD_T
Martin v. Löwis123cbd22001-07-19 14:21:10 +0000682ac_save_cc="$CC"
683if test "$ac_cv_kpthread" = "yes"
684then CC="$CC -Kpthread"
685fi
Trent Mick635f6fb2000-08-23 21:33:05 +0000686AC_MSG_CHECKING(for pthread_t)
687have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +0000688AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +0000689AC_MSG_RESULT($have_pthread_t)
690if test "$have_pthread_t" = yes ; then
691 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
692 AC_MSG_CHECKING(size of pthread_t)
693 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
694 [AC_TRY_RUN([#include <stdio.h>
695 #include <pthread.h>
696 main()
697 {
698 FILE *f=fopen("conftestval", "w");
699 if (!f) exit(1);
700 fprintf(f, "%d\n", sizeof(pthread_t));
701 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +0000702 }],
703 ac_cv_sizeof_pthread_t=`cat conftestval`,
704 ac_cv_sizeof_pthread_t=0,
705 ac_cv_sizeof_pthread_t=4)
Trent Mick635f6fb2000-08-23 21:33:05 +0000706 ])
707 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
708 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
709fi
Martin v. Löwis123cbd22001-07-19 14:21:10 +0000710CC="$ac_save_cc"
Trent Mick635f6fb2000-08-23 21:33:05 +0000711
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000712AC_MSG_CHECKING(for --enable-toolbox-glue)
713AC_ARG_ENABLE(toolbox-glue,
714[ --enable-toolbox-glue disable/enable MacOSX glue code for extensions])
715
716if test -z "$enable_toolbox_glue"
717then
718 case $ac_sys_system/$ac_sys_release in
719 Darwin/*)
720 enable_toolbox_glue="yes";;
721 *)
722 enable_toolbox_glue="no";;
723 esac
724fi
725case "$enable_toolbox_glue" in
726yes)
Jack Jansen666b1e72001-10-31 12:11:48 +0000727 extra_frameworks="-framework CoreServices -framework Foundation"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000728 extra_machdep_objs="Python/mactoolboxglue.o"
Jack Jansen591cbed2001-08-15 13:55:15 +0000729 extra_undefs="-u __dummy -u _PyMac_Error"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000730 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE)
731 ;;
732*)
733 extra_frameworks=""
734 extra_machdep_objs=""
Jack Jansen591cbed2001-08-15 13:55:15 +0000735 extra_undefs=""
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000736 ;;
737esac
738AC_MSG_RESULT($enable_toolbox_glue)
739
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000740AC_SUBST(LIBTOOL_CRUFT)
741case $ac_sys_system/$ac_sys_release in
Jack Jansen418c3b12001-11-14 10:59:57 +0000742 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +0000743 ns_undef_sym='_environ'
Jack Jansen418c3b12001-11-14 10:59:57 +0000744 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym"
745 LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
Jack Jansena3891ea2001-09-07 14:25:12 +0000746 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
747 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum5839e582000-10-09 19:52:35 +0000748 Darwin/*)
749 ns_undef_sym='_environ'
Jack Jansen418c3b12001-11-14 10:59:57 +0000750 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -flat_namespace -U $ns_undef_sym"
751 LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000752 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
753 LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000754esac
755
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000756AC_MSG_CHECKING(for --enable-framework)
757if test "$enable_framework"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000758then
Jack Jansenca06bc62001-08-03 15:32:23 +0000759 OPT="$OPT -fno-common -dynamic"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000760 # -U __environ is needed since bundles don't have access
761 # to crt0 when built but will always be linked against it
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000762 # -F. is needed to allow linking to the framework while
763 # in the build location.
764
Jack Jansena3891ea2001-09-07 14:25:12 +0000765 case $ac_sys_system/$ac_sys_release in
Jack Jansen418c3b12001-11-14 10:59:57 +0000766 Darwin/1.3*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-U,$ns_undef_sym";;
767 Darwin/*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-flat_namespace,-U,$ns_undef_sym";;
Jack Jansena3891ea2001-09-07 14:25:12 +0000768 esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000769 AC_DEFINE(WITH_NEXT_FRAMEWORK)
770 AC_MSG_RESULT(yes)
771else
772 AC_MSG_RESULT(no)
773fi
774
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000775AC_MSG_CHECKING(for dyld)
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000776case $ac_sys_system/$ac_sys_release in
777 Darwin/*)
778 AC_DEFINE(WITH_DYLD)
779 AC_MSG_RESULT(always on for Darwin)
780 ;;
781 *)
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000782 AC_MSG_RESULT(no)
783 ;;
Jack Jansen9a66b6d2001-08-08 13:56:14 +0000784esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000785
Guido van Rossumac405f61994-09-12 10:56:06 +0000786# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +0000787AC_SUBST(SO)
788AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000789AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000790AC_SUBST(CCSHARED)
791AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000792# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +0000793# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000794AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000795if test -z "$SO"
796then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000797 case $ac_sys_system in
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000798 hp*|HP*) SO=.sl;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000799 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000800 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000801 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000802fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000803AC_MSG_RESULT($SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000804# LDSHARED is the ld *command* used to create shared library
Martin v. Löwis5b718fc2001-09-10 15:34:42 +0000805# -- "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 +0000806# (Shared libraries in this instance are shared modules to be loaded into
807# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000808AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000809if test -z "$LDSHARED"
810then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000811 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000812 AIX*)
813 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
Guido van Rossumce608b02001-09-28 15:59:38 +0000814 LDSHARED="\$(BINLIBDEST)/config/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/config/python.exp"
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000815 ;;
816 BeOS*)
817 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
Guido van Rossumce608b02001-09-28 15:59:38 +0000818 LDSHARED="\$(BINLIBDEST)/config/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000819 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000820 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +0000821 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000822 SunOS/4*) LDSHARED="ld";;
Greg Ward57c9a662000-05-26 12:22:54 +0000823 SunOS/5*)
824 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +0000825 then LDSHARED='$(CC) -shared'
Martin v. Löwis5b718fc2001-09-10 15:34:42 +0000826 else LDSHARED="$(CC) -G";
Greg Ward57c9a662000-05-26 12:22:54 +0000827 fi ;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000828 hp*|HP*) LDSHARED="ld -b";;
Guido van Rossum71001e41995-01-26 00:44:03 +0000829 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Guido van Rossum7d473291995-01-20 14:12:16 +0000830 DYNIX/ptx*) LDSHARED="ld -G";;
Jack Jansen418c3b12001-11-14 10:59:57 +0000831 Darwin/1.3*)
Jack Jansena3891ea2001-09-07 14:25:12 +0000832 LDSHARED='$(CC) $(LDFLAGS) -bundle'
833 if test "$enable_framework" ; then
834 # Link against the framework. All externals should be defined.
835 LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
836 else
837 # No framework. Ignore undefined symbols, assuming they come from Python
Jack Jansen418c3b12001-11-14 10:59:57 +0000838 LDSHARED="$LDSHARED -undefined suppress"
Jack Jansena3891ea2001-09-07 14:25:12 +0000839 fi ;;
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000840 Darwin/*)
841 LDSHARED='$(CC) $(LDFLAGS) -bundle'
842 if test "$enable_framework" ; then
843 # Link against the framework. All externals should be defined.
844 LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)'
845 else
Michael W. Hudson0c46c0c2002-03-07 09:58:56 +0000846 # No framework, use the Python app as bundle-loader
847 BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
848 LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/$(PYTHON)'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000849 fi ;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +0000850 Linux*|GNU*) LDSHARED="gcc -shared";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000851 dgux*) LDSHARED="ld -G";;
Guido van Rossum458e7fa1999-09-17 15:40:40 +0000852 BSD/OS*/4*) LDSHARED="gcc -shared";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000853 OpenBSD*|NetBSD*|FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +0000854 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +0000855 then
856 LDSHARED="cc -shared ${LDFLAGS}"
857 else
858 LDSHARED="ld -Bshareable ${LDFLAGS}"
859 fi;;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +0000860 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +0000861 if test "$GCC" = "yes"
862 then LDSHARED="$(CC) -shared"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000863 else LDSHARED="$(CC) -G"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000864 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000865 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000866 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000867 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000868 *) LDSHARED="ld";;
869 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000870fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000871AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000872BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +0000873# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000874# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000875AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000876if test -z "$CCSHARED"
877then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000878 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +0000879 SunOS*) if test "$GCC" = yes;
880 then CCSHARED="-fPIC";
881 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +0000882 hp*|HP*) if test "$GCC" = yes;
Martin v. Löwis703ad702001-09-05 08:36:52 +0000883 then CCSHARED="-fPIC";
Guido van Rossumaf07a441995-02-13 19:45:27 +0000884 else CCSHARED="+z";
885 fi;;
Martin v. Löwisa6e97582002-01-01 18:41:33 +0000886 Linux*|GNU*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000887 BSD/OS*/4*) CCSHARED="-fpic";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000888 FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fPIC";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +0000889 OpenUNIX*|UnixWare*)
Martin v. Löwisbec19582001-03-21 15:57:54 +0000890 if test "$GCC" = "yes"
891 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000892 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000893 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000894 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000895 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000896 IRIX*/6*) case $CC in
897 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +0000898 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000899 esac;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000900 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000901 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000902fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000903AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000904# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000905# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000906AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000907if test -z "$LINKFORSHARED"
908then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000909 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000910 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000911 hp*|HP*)
Martin v. Löwis1142de32002-03-29 16:28:31 +0000912 LINKFORSHARED="-Wl,-E -Wl,+s";;
913# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000914 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Martin v. Löwisa6e97582002-01-01 18:41:33 +0000915 Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000916 # -u libsys_s pulls in all symbols in libsys
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000917 Darwin/*)
918 # -u __dummy makes the linker aware of the objc runtime
919 # in System.framework; otherwise, __objcInit (referenced in
920 # crt1.o) gets erroneously defined as common, which breaks dynamic
921 # loading of any modules which reference it in System.framework.
922 # -u _PyMac_Error is needed to pull in the mac toolbox glue, which is
923 # not used by the core itself but which needs to be in the core so
924 # that dynamically loaded extension modules have access to it.
Jack Jansen591cbed2001-08-15 13:55:15 +0000925 LINKFORSHARED="$extra_undefs -framework System"
Jack Jansenb6e9cad2001-08-15 01:26:28 +0000926 if test "$enable_framework"
927 then
928 LINKFORSHARED="$LINKFORSHARED -framework Python"
929 fi
930 LINKFORSHARED="$LINKFORSHARED $extra_frameworks";;
Martin v. Löwis25ae43b2001-10-07 08:39:18 +0000931 OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Guido van Rossum300fda71996-08-19 21:58:16 +0000932 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +0000933 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Martin v. Löwis36546db2001-09-05 14:24:43 +0000934 FreeBSD*|NetBSD*|OpenBSD*)
Guido van Rossumdf693651999-01-07 21:50:41 +0000935 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
936 then
937 LINKFORSHARED="-Wl,--export-dynamic"
938 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000939 SunOS/5*) case $CC in
940 *gcc*)
Guido van Rossum9c6ba9b2000-02-03 13:42:50 +0000941 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000942 then
943 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000944 fi;;
945 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000946 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000947fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000948AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000949
Neil Schemenauer61c51152001-01-26 16:18:16 +0000950AC_SUBST(CFLAGSFORSHARED)
951AC_MSG_CHECKING(CFLAGSFORSHARED)
952if test ! "$LIBRARY" = "$LDLIBRARY"
953then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +0000954 case $ac_sys_system in
955 CYGWIN*)
956 # Cygwin needs CCSHARED when building extension DLLs
957 # but not when building the interpreter DLL.
958 CFLAGSFORSHARED='';;
959 *)
960 CFLAGSFORSHARED='$(CCSHARED)'
961 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +0000962fi
963AC_MSG_RESULT($CFLAGSFORSHARED)
964
Guido van Rossum627b2d71993-12-24 10:39:16 +0000965# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000966AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
967AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Martin v. Löwis41933dd2002-03-21 15:10:58 +0000968AC_CHECK_LIB(rt, sem_init) # 'Real Time' functions on Solaris
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000969
970# checks for system dependent C++ extensions support
971case "$ac_sys_system" in
972 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
973 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
974 [loadAndInit("", 0, "")],
975 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
976 AC_MSG_RESULT(yes)],
977 [AC_MSG_RESULT(no)]);;
978 *) ;;
979esac
980
Guido van Rossum70c7f481998-03-26 18:44:10 +0000981# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
982# However on SGI IRIX, these exist but are broken.
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000983# BeOS' sockets are stashed in libnet.
984case "$ac_sys_system" in
985IRIX*) ;;
Guido van Rossum2cb56601998-05-07 13:25:56 +0000986*)
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000987AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000988AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +0000989;;
990esac
991case "$ac_sys_system" in
992BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000993AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
994;;
995esac
Guido van Rossum70c7f481998-03-26 18:44:10 +0000996
Guido van Rossumc5a39031996-07-31 17:35:03 +0000997AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000998AC_ARG_WITH(libs,
999[ --with-libs='lib1 ...' link against additional libs], [
Guido van Rossumc5a39031996-07-31 17:35:03 +00001000AC_MSG_RESULT($withval)
1001LIBS="$withval $LIBS"
1002], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +00001003
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001004# Determine if signalmodule should be used.
1005AC_SUBST(USE_SIGNAL_MODULE)
1006AC_SUBST(SIGNAL_OBJS)
1007AC_MSG_CHECKING(for --with-signal-module)
1008AC_ARG_WITH(signal-module,
1009[ --with-signal-module disable/enable signal module])
1010
1011if test -z "$with_signal_module"
1012then with_signal_module="yes"
1013fi
1014AC_MSG_RESULT($with_signal_module)
1015
1016if test "${with_signal_module}" = "yes"; then
1017 USE_SIGNAL_MODULE=""
1018 SIGNAL_OBJS=""
1019else
1020 USE_SIGNAL_MODULE="#"
1021 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
1022fi
1023
Guido van Rossum3d15bd82001-01-10 18:53:48 +00001024# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +00001025AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001026USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +00001027
Guido van Rossum54d93d41997-01-22 20:51:58 +00001028AC_MSG_CHECKING(for --with-dec-threads)
1029AC_SUBST(LDLAST)
1030AC_ARG_WITH(dec-threads,
Barry Warsawc0d24d82000-06-29 16:12:00 +00001031[ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
1032AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +00001033LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +00001034if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +00001035 with_thread="$withval";
1036fi],
1037AC_MSG_RESULT(no))
1038
1039AC_MSG_CHECKING(for --with-threads)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001040AC_ARG_WITH(threads,
1041[ --with(out)-threads[=DIRECTORY] disable/enable thread support])
Guido van Rossum54d93d41997-01-22 20:51:58 +00001042
Barry Warsawc0d24d82000-06-29 16:12:00 +00001043# --with-thread is deprecated, but check for it anyway
Barry Warsawa0f3c5c2000-06-30 16:39:35 +00001044AC_ARG_WITH(thread,
1045[ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
1046with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +00001047
1048if test -z "$with_threads"
1049then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001050fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00001051AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +00001052
Barry Warsawc0d24d82000-06-29 16:12:00 +00001053if test "$with_threads" = "no"
1054then
1055 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001056elif test "$ac_cv_pthread_is_default" = yes
1057then
1058 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001059 # Defining _REENTRANT on system with POSIX threads should not hurt.
1060 AC_DEFINE(_REENTRANT)
1061 posix_threads=yes
1062 LIBOBJS="$LIBOBJS thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001063elif test "$ac_cv_kpthread" = "yes"
1064then
1065 CC="$CC -Kpthread"
1066 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001067 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001068 LIBOBJS="$LIBOBJS thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00001069else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001070 if test ! -z "$with_threads" -a -d "$with_threads"
1071 then LDFLAGS="$LDFLAGS -L$with_threads"
1072 fi
1073 if test ! -z "$withval" -a -d "$withval"
1074 then LDFLAGS="$LDFLAGS -L$withval"
1075 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001076
1077 # According to the POSIX spec, a pthreads implementation must
1078 # define _POSIX_THREADS in unistd.h. Some apparently don't (which ones?)
1079 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1080 AC_EGREP_CPP(yes,
1081 [#include <unistd.h>
1082 #ifdef _POSIX_THREADS
1083 yes
1084 #endif
1085 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1086 AC_MSG_RESULT($unistd_defines_pthreads)
1087
Martin v. Löwis130fb172001-07-19 11:00:41 +00001088 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001089 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1090 AC_DEFINE(C_THREADS)
1091 AC_DEFINE(HURD_C_THREADS)
1092 LIBS="$LIBS -lthreads"
1093 LIBOBJS="$LIBOBJS thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001094 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1095 AC_DEFINE(C_THREADS)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001096 AC_DEFINE(MACH_C_THREADS)
Martin v. Löwis130fb172001-07-19 11:00:41 +00001097 LIBOBJS="$LIBOBJS thread.o"],[
1098 AC_MSG_CHECKING(for --with-pth)
1099 AC_ARG_WITH(pth,
1100 [ --with-pth use GNU pth threading libraries], [
1101 AC_MSG_RESULT($withval)
1102 AC_DEFINE(WITH_THREAD)
1103 AC_DEFINE(HAVE_PTH)
1104 LIBS="-lpth $LIBS"
1105 LIBOBJS="$LIBOBJS thread.o"],[
1106 AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001107
1108 # Just looking for pthread_create in libpthread is not enough:
1109 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1110 # So we really have to include pthread.h, and then link.
1111 _libs=$LIBS
1112 LIBS="$LIBS -lpthread"
1113 AC_MSG_CHECKING([for pthread_create in -lpthread])
1114 AC_TRY_LINK([#include <pthread.h>
1115
1116void * start_routine (void *arg) { exit (0); }], [
1117pthread_create (NULL, NULL, start_routine, NULL)], [
1118 AC_MSG_RESULT(yes)
1119 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001120 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001121 LIBOBJS="$LIBOBJS thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001122 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00001123 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001124 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001125 LIBOBJS="$LIBOBJS thread.o"],[
1126 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1127 AC_DEFINE(BEOS_THREADS)
1128 LIBOBJS="$LIBOBJS thread.o"],[
1129 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001130 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001131 LIBS="$LIBS -lpthreads"
1132 LIBOBJS="$LIBOBJS thread.o"], [
1133 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001134 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001135 LIBS="$LIBS -lc_r"
1136 LIBOBJS="$LIBOBJS thread.o"], [
1137 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001138 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001139 LIBS="$LIBS -lthread"
1140 LIBOBJS="$LIBOBJS thread.o"], [
1141 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001142 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001143 LIBS="$LIBS -lpthread"
1144 LIBOBJS="$LIBOBJS thread.o"], [
1145 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001146 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001147 LIBS="$LIBS -lcma"
1148 LIBOBJS="$LIBOBJS thread.o"],[
1149 USE_THREAD_MODULE="#"])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001150 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00001151
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001152 if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001153 if test "$unistd_defines_pthreads" = "no"; then
1154 AC_DEFINE(_POSIX_THREADS)
1155 fi
1156
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001157 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
1158 AC_CACHE_VAL(ac_cv_pthread_system_supported,
1159 [AC_TRY_RUN([#include <pthread.h>
1160 void *foo(void *parm) {
1161 return NULL;
1162 }
1163 main() {
1164 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00001165 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001166 if (pthread_attr_init(&attr)) exit(-1);
1167 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00001168 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001169 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001170 }],
1171 ac_cv_pthread_system_supported=yes,
1172 ac_cv_pthread_system_supported=no,
1173 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001174 ])
1175 AC_MSG_RESULT($ac_cv_pthread_system_supported)
1176 if test "$ac_cv_pthread_system_supported" = "yes"; then
1177 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED)
1178 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001179 AC_CHECK_FUNCS(pthread_sigmask)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001180 fi
1181
Martin v. Löwis130fb172001-07-19 11:00:41 +00001182 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1183 LIBS="$LIBS -lmpc"
1184 LIBOBJS="$LIBOBJS thread.o"
1185 USE_THREAD_MODULE=""])
Martin v. Löwis3d2b5492002-03-15 13:48:21 +00001186
1187 if test $posix_threads != "yes"; then
1188 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1189 LIBS="$LIBS -lthread"
1190 LIBOBJS="$LIBOBJS thread.o"
1191 USE_THREAD_MODULE=""])
1192 fi
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001193
Martin v. Löwis130fb172001-07-19 11:00:41 +00001194 if test "$USE_THREAD_MODULE" != "#"
1195 then
1196 # If the above checks didn't disable threads, (at least) OSF1
1197 # needs this '-threads' argument during linking.
1198 case $ac_sys_system in
1199 OSF1) LDLAST=-threads;;
1200 esac
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001201 fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00001202fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001203
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001204# Check for enable-ipv6
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001205AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001206AC_ARG_ENABLE(ipv6,
1207[ --enable-ipv6 Enable ipv6 (with ipv4) support
1208 --disable-ipv6 Disable ipv6 support],
1209[ case "$enableval" in
1210 no)
1211 AC_MSG_RESULT(no)
1212 ipv6=no
1213 ;;
1214 *) AC_MSG_RESULT(yes)
1215 AC_DEFINE(ENABLE_IPV6)
1216 ipv6=yes
1217 ;;
1218 esac ],
1219
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001220[
1221dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001222 AC_TRY_RUN([ /* AF_INET6 available check */
1223#include <sys/types.h>
1224#include <sys/socket.h>
1225main()
1226{
1227 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1228 exit(1);
1229 else
1230 exit(0);
1231}
1232],
1233 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001234 ipv6=yes,
1235 AC_MSG_RESULT(no)
1236 ipv6=no,
1237 AC_MSG_RESULT(no)
1238 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001239)
1240
1241if test "$ipv6" = "yes"; then
1242 AC_MSG_CHECKING(if RFC2553 API is available)
1243 AC_TRY_COMPILE([#include <sys/types.h>
1244#include <netinet/in.h>],
1245 [struct sockaddr_in6 x;
1246x.sin6_scope_id;],
1247 AC_MSG_RESULT(yes)
1248 ipv6=yes,
1249 AC_MSG_RESULT(no, IPv6 disabled)
1250 ipv6=no)
1251fi
1252
1253if test "$ipv6" = "yes"; then
1254 AC_DEFINE(ENABLE_IPV6)
1255fi
1256])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001257
1258ipv6type=unknown
1259ipv6lib=none
1260ipv6trylibc=no
1261
1262if test "$ipv6" = "yes"; then
1263 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00001264 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1265 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001266 case $i in
1267 inria)
1268 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001269 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001270#include <netinet/in.h>
1271#ifdef IPV6_INRIA_VERSION
1272yes
1273#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001274 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001275 ;;
1276 kame)
1277 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001278 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001279#include <netinet/in.h>
1280#ifdef __KAME__
1281yes
1282#endif],
1283 [ipv6type=$i;
1284 ipv6lib=inet6
1285 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001286 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001287 ;;
1288 linux-glibc)
1289 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001290 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001291#include <features.h>
1292#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1293yes
1294#endif],
1295 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001296 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001297 ;;
1298 linux-inet6)
1299 dnl http://www.v6.linux.or.jp/
1300 if test -d /usr/inet6; then
1301 ipv6type=$i
1302 ipv6lib=inet6
1303 ipv6libdir=/usr/inet6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001304 OPT="-I/usr/inet6/include $OPT"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001305 fi
1306 ;;
1307 solaris)
1308 if test -f /etc/netconfig; then
1309 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1310 ipv6type=$i
1311 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001312 fi
1313 fi
1314 ;;
1315 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001316 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001317#include <sys/param.h>
1318#ifdef _TOSHIBA_INET6
1319yes
1320#endif],
1321 [ipv6type=$i;
1322 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001323 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001324 ;;
1325 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001326 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001327#include </usr/local/v6/include/sys/v6config.h>
1328#ifdef __V6D__
1329yes
1330#endif],
1331 [ipv6type=$i;
1332 ipv6lib=v6;
1333 ipv6libdir=/usr/local/v6/lib;
1334 OPT="-I/usr/local/v6/include $OPT"])
1335 ;;
1336 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001337 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001338#include <sys/param.h>
1339#ifdef _ZETA_MINAMI_INET6
1340yes
1341#endif],
1342 [ipv6type=$i;
1343 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001344 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001345 ;;
1346 esac
1347 if test "$ipv6type" != "unknown"; then
1348 break
1349 fi
1350 done
1351 AC_MSG_RESULT($ipv6type)
1352fi
1353
1354if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1355 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1356 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1357 echo "using lib$ipv6lib"
1358 else
1359 if test $ipv6trylibc = "yes"; then
1360 echo "using libc"
1361 else
1362 echo 'Fatal: no $ipv6lib library found. cannot continue.'
1363 echo "You need to fetch lib$ipv6lib.a from appropriate"
1364 echo 'ipv6 kit and compile beforehand.'
1365 exit 1
1366 fi
1367 fi
1368fi
1369
Barry Warsawef82cd72000-06-30 16:21:01 +00001370# Check for GC support
Barry Warsawef82cd72000-06-30 16:21:01 +00001371AC_MSG_CHECKING(for --with-cycle-gc)
1372AC_ARG_WITH(cycle-gc,
1373[ --with(out)-cycle-gc disable/enable garbage collection])
1374
1375if test -z "$with_cycle_gc"
1376then with_cycle_gc="yes"
1377fi
Neil Schemenauer9c63e6d2001-08-29 23:44:38 +00001378if test "$with_cycle_gc" != "no"
Barry Warsawef82cd72000-06-30 16:21:01 +00001379then
Barry Warsawef82cd72000-06-30 16:21:01 +00001380 AC_DEFINE(WITH_CYCLE_GC)
1381fi
1382AC_MSG_RESULT($with_cycle_gc)
1383
Neil Schemenauera35c6882001-02-27 04:45:05 +00001384# Check for Python-specific malloc support
1385AC_MSG_CHECKING(for --with-pymalloc)
1386AC_ARG_WITH(pymalloc,
Neil Schemenauer16c22972002-03-22 15:34:49 +00001387[ --with(out)-pymalloc disable/enable specialized mallocs])
1388
1389if test -z "$with_pymalloc"
1390then with_pymalloc="yes"
1391fi
1392if test "$with_pymalloc" != "no"
1393then
1394 AC_DEFINE(WITH_PYMALLOC)
1395fi
1396AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00001397
Barry Warsawef82cd72000-06-30 16:21:01 +00001398# Check for --with-wctype-functions
1399AC_MSG_CHECKING(for --with-wctype-functions)
1400AC_ARG_WITH(wctype-functions,
1401[ --with-wctype-functions use wctype.h functions], [
1402if test "$withval" != no
1403then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
1404else AC_MSG_RESULT(no)
1405fi],
1406[AC_MSG_RESULT(no)])
1407
Guido van Rossum68242b51996-05-28 22:53:03 +00001408# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001409AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00001410DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001411
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001412AC_MSG_CHECKING(for --with-sgi-dl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001413AC_ARG_WITH(sgi-dl,
1414[ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001415AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001416AC_DEFINE(WITH_SGI_DL)
Guido van Rossume97ee181999-12-20 21:27:22 +00001417DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001418dldir=$withval
Guido van Rossum40951012000-10-07 16:21:27 +00001419if test ! -z "$dldir" -a -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001420then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001421else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1422fi
1423DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001424LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001425
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001426AC_MSG_CHECKING(for --with-dl-dld)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001427AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001428AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001429AC_DEFINE(WITH_DL_DLD)
Guido van Rossume97ee181999-12-20 21:27:22 +00001430DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001431dldir=`echo "$withval" | sed 's/,.*//'`
1432dlddir=`echo "$withval" | sed 's/.*,//'`
Barry Warsaw7d1219d2000-10-05 18:45:53 +00001433if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001434then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001435else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1436fi
1437DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001438LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +00001439
Guido van Rossume97ee181999-12-20 21:27:22 +00001440# the dlopen() function means we might want to use dynload_shlib.o. some
1441# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00001442AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00001443
1444# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1445# loading of modules.
1446AC_SUBST(DYNLOADFILE)
1447AC_MSG_CHECKING(DYNLOADFILE)
1448if test -z "$DYNLOADFILE"
1449then
1450 case $ac_sys_system/$ac_sys_release in
1451 AIX*) DYNLOADFILE="dynload_aix.o";;
1452 BeOS*) DYNLOADFILE="dynload_beos.o";;
1453 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001454 Darwin/*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00001455 *)
1456 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1457 # out any dynamic loading
1458 if test "$ac_cv_func_dlopen" = yes
1459 then DYNLOADFILE="dynload_shlib.o"
1460 else DYNLOADFILE="dynload_stub.o"
1461 fi
1462 ;;
1463 esac
1464fi
1465AC_MSG_RESULT($DYNLOADFILE)
1466if test "$DYNLOADFILE" != "dynload_stub.o"
1467then
1468 AC_DEFINE(HAVE_DYNAMIC_LOADING)
1469fi
1470
Jack Jansenc49e5b72001-06-19 15:00:23 +00001471# MACHDEP_OBJS can be set to platform-specific object files needed by Python
1472
1473AC_SUBST(MACHDEP_OBJS)
1474AC_MSG_CHECKING(MACHDEP_OBJS)
1475if test -z "$MACHDEP_OBJS"
1476then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001477 MACHDEP_OBJS=$extra_machdep_objs
1478else
1479 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00001480fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001481AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00001482
Guido van Rossum627b2d71993-12-24 10:39:16 +00001483# checks for library functions
Martin v. Löwis244edc82001-10-04 22:44:26 +00001484AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \
Fred Drake35a092f1999-12-13 16:23:35 +00001485 flock fork fsync fdatasync fpathconf ftime ftruncate \
Martin v. Löwisf95dd0a2001-08-15 17:14:33 +00001486 gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
Martin v. Löwisb2c92f42002-02-16 23:35:41 +00001487 hstrerror inet_pton kill killpg link lstat mkfifo mktime mremap \
Andrew M. Kuchling5821b772000-08-25 01:14:08 +00001488 nice pathconf pause plock poll pthread_init \
Fred Drake35a092f1999-12-13 16:23:35 +00001489 putenv readlink \
Martin v. Löwis61c5edf2001-10-18 04:06:00 +00001490 select setegid seteuid setgid setgroups \
Martin v. Löwis791bfda2001-07-24 06:33:08 +00001491 setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
Fred Drake35a092f1999-12-13 16:23:35 +00001492 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
Fred Drake89143df1999-12-09 22:03:25 +00001493 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Guido van Rossumc524d952001-10-19 01:31:59 +00001494 truncate uname unsetenv waitpid _getpty getpriority)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001495
Fred Drake8cef4cf2000-06-28 16:40:38 +00001496# check for openpty and forkpty
1497
1498AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1499AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1500
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001501# check for long file support functions
1502AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1503
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001504AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Thomas Wouters3a584202000-08-05 23:28:51 +00001505AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1506AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1507AC_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 +00001508
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001509
1510# On OSF/1 V5.1, getaddrinfo is available, but a define
1511# for [no]getaddrinfo in netdb.h.
1512AC_MSG_CHECKING(for getaddrinfo)
1513AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00001514#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001515#include <sys/socket.h>
1516#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00001517#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001518],[
1519getaddrinfo(NULL, NULL, NULL, NULL);
1520], [
1521AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001522AC_MSG_CHECKING(getaddrinfo bug)
1523AC_TRY_RUN([
1524#include <sys/types.h>
1525#include <netdb.h>
1526#include <string.h>
1527#include <sys/socket.h>
1528#include <netinet/in.h>
1529
1530main()
1531{
1532 int passive, gaierr, inet4 = 0, inet6 = 0;
1533 struct addrinfo hints, *ai, *aitop;
1534 char straddr[INET6_ADDRSTRLEN], strport[16];
1535
1536 for (passive = 0; passive <= 1; passive++) {
1537 memset(&hints, 0, sizeof(hints));
1538 hints.ai_family = AF_UNSPEC;
1539 hints.ai_flags = passive ? AI_PASSIVE : 0;
1540 hints.ai_socktype = SOCK_STREAM;
1541 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1542 (void)gai_strerror(gaierr);
1543 goto bad;
1544 }
1545 for (ai = aitop; ai; ai = ai->ai_next) {
1546 if (ai->ai_addr == NULL ||
1547 ai->ai_addrlen == 0 ||
1548 getnameinfo(ai->ai_addr, ai->ai_addrlen,
1549 straddr, sizeof(straddr), strport, sizeof(strport),
1550 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1551 goto bad;
1552 }
1553 switch (ai->ai_family) {
1554 case AF_INET:
1555 if (strcmp(strport, "54321") != 0) {
1556 goto bad;
1557 }
1558 if (passive) {
1559 if (strcmp(straddr, "0.0.0.0") != 0) {
1560 goto bad;
1561 }
1562 } else {
1563 if (strcmp(straddr, "127.0.0.1") != 0) {
1564 goto bad;
1565 }
1566 }
1567 inet4++;
1568 break;
1569 case AF_INET6:
1570 if (strcmp(strport, "54321") != 0) {
1571 goto bad;
1572 }
1573 if (passive) {
1574 if (strcmp(straddr, "::") != 0) {
1575 goto bad;
1576 }
1577 } else {
1578 if (strcmp(straddr, "::1") != 0) {
1579 goto bad;
1580 }
1581 }
1582 inet6++;
1583 break;
1584 case AF_UNSPEC:
1585 goto bad;
1586 break;
1587 default:
1588 /* another family support? */
1589 break;
1590 }
1591 }
1592 }
1593
1594 if (!(inet4 == 0 || inet4 == 2))
1595 goto bad;
1596 if (!(inet6 == 0 || inet6 == 2))
1597 goto bad;
1598
1599 if (aitop)
1600 freeaddrinfo(aitop);
1601 exit(0);
1602
1603 bad:
1604 if (aitop)
1605 freeaddrinfo(aitop);
1606 exit(1);
1607}
1608],
1609AC_MSG_RESULT(good)
1610buggygetaddrinfo=no,
1611AC_MSG_RESULT(buggy)
1612buggygetaddrinfo=yes,
1613AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001614buggygetaddrinfo=yes)], [
1615AC_MSG_RESULT(no)
1616buggygetaddrinfo=yes
1617])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001618
1619if test "$buggygetaddrinfo" = "yes"; then
1620 if test "$ipv6" = "yes"; then
1621 echo 'Fatal: You must get working getaddrinfo() function.'
1622 echo ' or you can specify "--disable-ipv6"'.
1623 exit 1
1624 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001625else
1626 AC_DEFINE(HAVE_GETADDRINFO)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001627fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00001628AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001629
Guido van Rossum627b2d71993-12-24 10:39:16 +00001630# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001631AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00001632AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001633AC_STRUCT_TIMEZONE
Guido van Rossum98bf58f2001-10-18 20:34:25 +00001634AC_STRUCT_ST_RDEV
1635AC_STRUCT_ST_BLKSIZE
1636AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001637
1638AC_MSG_CHECKING(for time.h that defines altzone)
1639AC_CACHE_VAL(ac_cv_header_time_altzone,
1640[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1641 ac_cv_header_time_altzone=yes,
1642 ac_cv_header_time_altzone=no)])
1643AC_MSG_RESULT($ac_cv_header_time_altzone)
1644if test $ac_cv_header_time_altzone = yes; then
1645 AC_DEFINE(HAVE_ALTZONE)
1646fi
1647
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001648was_it_defined=no
1649AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001650AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001651#include <sys/types.h>
1652#include <sys/select.h>
1653#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001654], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1655AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001656
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001657AC_MSG_CHECKING(for addrinfo)
1658AC_CACHE_VAL(ac_cv_struct_addrinfo,
1659AC_TRY_COMPILE([
1660# include <netdb.h>],
1661 [struct addrinfo a],
1662 ac_cv_struct_addrinfo=yes,
1663 ac_cv_struct_addrinfo=no))
1664AC_MSG_RESULT($ac_cv_struct_addrinfo)
1665if test $ac_cv_struct_addrinfo = yes; then
1666 AC_DEFINE(HAVE_ADDRINFO)
1667fi
1668
1669AC_MSG_CHECKING(for sockaddr_storage)
1670AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1671AC_TRY_COMPILE([
1672# include <sys/types.h>
1673# include <sys/socket.h>],
1674 [struct sockaddr_storage s],
1675 ac_cv_struct_sockaddr_storage=yes,
1676 ac_cv_struct_sockaddr_storage=no))
1677AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1678if test $ac_cv_struct_sockaddr_storage = yes; then
1679 AC_DEFINE(HAVE_SOCKADDR_STORAGE)
1680fi
1681
Guido van Rossum627b2d71993-12-24 10:39:16 +00001682# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001683
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001684AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001685AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001686
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001687works=no
1688AC_MSG_CHECKING(for working volatile)
1689AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1690AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00001691
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001692works=no
1693AC_MSG_CHECKING(for working signed char)
1694AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1695AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001696
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001697have_prototypes=no
1698AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001699AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1700AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001701AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001702
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001703works=no
1704AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001705AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001706#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00001707int foo(int x, ...) {
1708 va_list va;
1709 va_start(va, x);
1710 va_arg(va, int);
1711 va_arg(va, char *);
1712 va_arg(va, double);
1713 return 0;
1714}
1715], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001716AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1717AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001718
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001719if test "$have_prototypes" = yes; then
1720bad_prototypes=no
1721AC_MSG_CHECKING(for bad exec* prototypes)
1722AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1723 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1724AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001725fi
1726
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001727# check if sockaddr has sa_len member
1728AC_MSG_CHECKING(if sockaddr has sa_len member)
1729AC_TRY_COMPILE([#include <sys/types.h>
1730#include <sys/socket.h>],
1731[struct sockaddr x;
1732x.sa_len = 0;],
1733 AC_MSG_RESULT(yes)
1734 AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
1735 AC_MSG_RESULT(no))
1736
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001737AC_MSG_CHECKING(for bad static forward)
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001738AC_CACHE_VAL(ac_cv_bad_static_forward,
1739[AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001740struct s { int a; int b; };
1741static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001742int foobar() {
1743 static int random;
1744 random = (int) &foo;
1745 return random;
1746}
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001747static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001748main() {
1749 exit(!((int)&foo == foobar()));
Guido van Rossum3065c942001-09-17 04:03:14 +00001750}],
1751ac_cv_bad_static_forward=no,
1752ac_cv_bad_static_forward=yes,
1753ac_cv_bad_static_forward=no)])
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001754AC_MSG_RESULT($ac_cv_bad_static_forward)
1755if test "$ac_cv_bad_static_forward" = yes
1756then
1757 AC_DEFINE(BAD_STATIC_FORWARD)
1758fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001759
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001760va_list_is_array=no
1761AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001762AC_TRY_COMPILE([
1763#ifdef HAVE_STDARG_PROTOTYPES
1764#include <stdarg.h>
1765#else
1766#include <varargs.h>
1767#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001768], [va_list list1, list2; list1 = list2;], ,
1769AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1770AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001771
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001772# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1773AC_CHECK_FUNC(gethostbyname_r, [
1774 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1775 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1776 OLD_CFLAGS=$CFLAGS
1777 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1778 AC_TRY_COMPILE([
1779# include <netdb.h>
1780 ], [
1781 char *name;
1782 struct hostent *he, *res;
1783 char buffer[2048];
1784 int buflen = 2048;
1785 int h_errnop;
1786
1787 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1788 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001789 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001790 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1791 AC_MSG_RESULT(yes)
1792 ], [
1793 AC_MSG_RESULT(no)
1794 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1795 AC_TRY_COMPILE([
1796# include <netdb.h>
1797 ], [
1798 char *name;
1799 struct hostent *he;
1800 char buffer[2048];
1801 int buflen = 2048;
1802 int h_errnop;
1803
1804 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1805 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001806 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001807 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1808 AC_MSG_RESULT(yes)
1809 ], [
1810 AC_MSG_RESULT(no)
1811 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1812 AC_TRY_COMPILE([
1813# include <netdb.h>
1814 ], [
1815 char *name;
1816 struct hostent *he;
1817 struct hostent_data data;
1818
1819 (void) gethostbyname_r(name, he, &data);
1820 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001821 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001822 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1823 AC_MSG_RESULT(yes)
1824 ], [
1825 AC_MSG_RESULT(no)
1826 ])
1827 ])
1828 ])
1829 CFLAGS=$OLD_CFLAGS
1830], [
Thomas Wouters3a584202000-08-05 23:28:51 +00001831 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001832])
1833AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1834AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1835AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001836AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001837AC_SUBST(HAVE_GETHOSTBYNAME)
1838
Guido van Rossum627b2d71993-12-24 10:39:16 +00001839# checks for system services
1840# (none yet)
1841
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001842# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00001843AC_CHECK_FUNC(__fpu_control,
1844 [],
1845 [AC_CHECK_LIB(ieee, __fpu_control)
1846])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001847
Guido van Rossum93274221997-05-09 02:42:00 +00001848# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00001849AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001850AC_ARG_WITH(fpectl,
1851[ --with-fpectl enable SIGFPE catching], [
Guido van Rossum93274221997-05-09 02:42:00 +00001852if test "$withval" != no
1853then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1854else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00001855fi],
1856[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00001857
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001858# check for --with-libm=...
1859AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001860case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00001861Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001862BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001863*) LIBM=-lm
1864esac
Guido van Rossum93274221997-05-09 02:42:00 +00001865AC_MSG_CHECKING(for --with-libm=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001866AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001867if test "$withval" = no
1868then LIBM=
1869 AC_MSG_RESULT(force LIBM empty)
1870elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001871then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001872 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001873else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001874fi],
1875[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001876
1877# check for --with-libc=...
1878AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00001879AC_MSG_CHECKING(for --with-libc=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001880AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001881if test "$withval" = no
1882then LIBC=
1883 AC_MSG_RESULT(force LIBC empty)
1884elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001885then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001886 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001887else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001888fi],
1889[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001890
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001891# check for hypot() in math library
1892LIBS_SAVE=$LIBS
1893LIBS="$LIBS $LIBM"
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001894AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001895LIBS=$LIBS_SAVE
1896
Guido van Rossumad713701997-07-10 22:42:38 +00001897# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +00001898AC_MSG_CHECKING(what malloc(0) returns)
1899AC_CACHE_VAL(ac_cv_malloc_zero,
1900[AC_TRY_RUN([#include <stdio.h>
1901#ifdef HAVE_STDLIB
1902#include <stdlib.h>
1903#else
1904char *malloc(), *realloc();
1905int *free();
1906#endif
1907main() {
1908 char *p;
1909 p = malloc(0);
1910 if (p == NULL) exit(1);
1911 p = realloc(p, 0);
1912 if (p == NULL) exit(1);
1913 free(p);
1914 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001915}],
1916ac_cv_malloc_zero=nonnull,
1917ac_cv_malloc_zero=null,
1918ac_cv_malloc_zero=nonnull)]) # XXX arm cross-compile?
Guido van Rossumad713701997-07-10 22:42:38 +00001919AC_MSG_RESULT($ac_cv_malloc_zero)
1920if test "$ac_cv_malloc_zero" = null
1921then
1922 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1923fi
1924
Guido van Rossumef2255b2000-03-10 22:30:29 +00001925# check for wchar.h
1926AC_CHECK_HEADER(wchar.h,
1927AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1928wchar_h="no"
1929)
1930
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001931# determine wchar_t size
1932if test "$wchar_h" = yes
1933then
Guido van Rossum67b26592001-10-20 14:21:45 +00001934 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001935fi
1936
1937AC_MSG_CHECKING(what type to use for unicode)
1938AC_ARG_ENABLE(unicode,
1939[ --enable-unicode[=ucs2,ucs4] Enable Unicode strings (default is yes)],,enable_unicode=yes)
1940
1941if test $enable_unicode = yes
1942then
Martin v. Löwisfd917792001-06-27 20:22:04 +00001943 # Without any arguments, Py_UNICODE defaults to two-byte mode
1944 enable_unicode="ucs2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001945fi
1946
1947case "$enable_unicode" in
1948ucs2) unicode_size="2"
1949 AC_DEFINE(Py_UNICODE_SIZE,2)
1950 ;;
1951ucs4) unicode_size="4"
1952 AC_DEFINE(Py_UNICODE_SIZE,4)
1953 ;;
1954esac
1955
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001956AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001957if test "$enable_unicode" = "no"
1958then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001959 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001960 AC_MSG_RESULT(not used)
1961else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001962 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001963 AC_DEFINE(Py_USING_UNICODE)
1964 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
1965 then
1966 PY_UNICODE_TYPE="wchar_t"
1967 AC_DEFINE(HAVE_USABLE_WCHAR_T)
1968 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
1969 elif test "$ac_cv_sizeof_short" = "$unicode_size"
1970 then
1971 PY_UNICODE_TYPE="unsigned short"
1972 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
1973 elif test "$ac_cv_sizeof_long" = "$unicode_size"
1974 then
1975 PY_UNICODE_TYPE="unsigned long"
1976 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
1977 else
1978 PY_UNICODE_TYPE="no type found"
1979 fi
1980 AC_MSG_RESULT($PY_UNICODE_TYPE)
1981fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00001982
1983# check for endianness
1984AC_C_BIGENDIAN
1985
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001986# Check whether right shifting a negative integer extends the sign bit
1987# or fills with zeros (like the Cray J90, according to Tim Peters).
1988AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00001989AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001990AC_TRY_RUN([
1991int main()
1992{
Vladimir Marangozova6180282000-07-12 05:05:06 +00001993 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001994}
Guido van Rossum3065c942001-09-17 04:03:14 +00001995],
1996ac_cv_rshift_extends_sign=yes,
1997ac_cv_rshift_extends_sign=no,
1998ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00001999AC_MSG_RESULT($ac_cv_rshift_extends_sign)
2000if test "$ac_cv_rshift_extends_sign" = no
2001then
2002 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
2003fi
2004
Guido van Rossumcadfaec2001-01-05 14:45:49 +00002005# check for getc_unlocked and related locking functions
2006AC_MSG_CHECKING(for getc_unlocked() and friends)
2007AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
2008AC_TRY_LINK([#include <stdio.h>],[
2009 FILE *f = fopen("/dev/null", "r");
2010 flockfile(f);
2011 getc_unlocked(f);
2012 funlockfile(f);
2013], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
2014AC_MSG_RESULT($ac_cv_have_getc_unlocked)
2015if test "$ac_cv_have_getc_unlocked" = yes
2016then
2017 AC_DEFINE(HAVE_GETC_UNLOCKED)
2018fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00002019
Martin v. Löwis0daad592001-09-30 21:09:59 +00002020# check for readline 4.0
2021AC_CHECK_LIB(readline, rl_pre_input_hook,
2022 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK), , -ltermcap)
2023
Guido van Rossum353ae582001-07-10 16:45:32 +00002024# check for readline 4.2
2025AC_CHECK_LIB(readline, rl_completion_matches,
2026 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
2027
Thomas Wouterse38b2f12001-07-11 22:35:31 +00002028AC_MSG_CHECKING(for broken nice())
2029AC_CACHE_VAL(ac_cv_broken_nice, [
2030AC_TRY_RUN([
2031int main()
2032{
2033 int val1 = nice(1);
2034 if (val1 != -1 && val1 == nice(2))
2035 exit(0);
2036 exit(1);
2037}
Guido van Rossum3065c942001-09-17 04:03:14 +00002038],
2039ac_cv_broken_nice=yes,
2040ac_cv_broken_nice=no,
2041ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00002042AC_MSG_RESULT($ac_cv_broken_nice)
2043if test "$ac_cv_broken_nice" = yes
2044then
2045 AC_DEFINE(HAVE_BROKEN_NICE)
2046fi
2047
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00002048# On HP/UX 11.0, mvwdelch is a block with a return statement
2049AC_MSG_CHECKING(whether mvwdelch is an expression)
2050AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
2051AC_TRY_COMPILE([#include <curses.h>], [
2052 int rtn;
2053 rtn = mvwdelch(0,0,0);
2054], ac_cv_mvwdelch_is_expression=yes,
2055 ac_cv_mvwdelch_is_expression=no,
2056 ac_cv_mvwdelch_is_expression=yes))
2057AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
2058
2059if test "$ac_cv_mvwdelch_is_expression" = yes
2060then
2061 AC_DEFINE(MVWDELCH_IS_EXPRESSION)
2062fi
2063
2064AC_MSG_CHECKING(whether WINDOW has _flags)
2065AC_CACHE_VAL(ac_cv_window_has_flags,
2066AC_TRY_COMPILE([#include <curses.h>], [
2067 WINDOW *w;
2068 w->_flags = 0;
2069], ac_cv_window_has_flags=yes,
2070 ac_cv_window_has_flags=no,
2071 ac_cv_window_has_flags=no))
2072AC_MSG_RESULT($ac_cv_window_has_flags)
2073
2074
2075if test "$ac_cv_window_has_flags" = yes
2076then
2077 AC_DEFINE(WINDOW_HAS_FLAGS)
2078fi
2079
Guido van Rossum95713eb2000-05-18 20:53:31 +00002080# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
2081# Add sys/socket.h to confdefs.h
2082cat >> confdefs.h <<\EOF
2083#ifdef HAVE_SYS_SOCKET_H
2084#include <sys/socket.h>
2085#endif
2086EOF
2087AC_CHECK_TYPE(socklen_t, int)
2088
Neil Schemenauerf25cf6c2001-03-04 06:39:33 +00002089# Add Python/ prefix to LIBOBJS
2090libobjs=$LIBOBJS
2091LIBOBJS=
2092for obj in $libobjs; do
2093 LIBOBJS="$LIBOBJS Python/$obj"
2094done
2095
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002096#AC_MSG_CHECKING(for Modules/Setup)
2097#if test ! -f Modules/Setup ; then
2098# if test ! -d Modules ; then
2099# mkdir Modules
2100# fi
2101# cp "$srcdir/Modules/Setup.dist" Modules/Setup
2102# AC_MSG_RESULT(creating)
2103#else
2104# AC_MSG_RESULT(already exists)
2105#fi
2106
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00002107AC_SUBST(THREADHEADERS)
2108
2109for h in `(cd $srcdir;echo Python/thread_*.h)`
2110do
2111 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
2112done
2113
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002114AC_SUBST(SRCDIRS)
Neil Schemenaueracbf9ef2001-02-27 02:15:14 +00002115SRCDIRS="Parser Grammar Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00002116AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002117for dir in $SRCDIRS; do
2118 if test ! -d $dir; then
2119 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00002120 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002121done
2122AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00002123
Guido van Rossum627b2d71993-12-24 10:39:16 +00002124# generate output files
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00002125AC_OUTPUT(Makefile.pre Modules/Setup.config)
Neil Schemenauer61c51152001-01-26 16:18:16 +00002126
2127echo "creating Setup"
2128if test ! -f Modules/Setup
2129then
2130 cp $srcdir/Modules/Setup.dist Modules/Setup
2131fi
2132
2133echo "creating Setup.local"
2134if test ! -f Modules/Setup.local
2135then
2136 echo "# Edit this file for local setup changes" >Modules/Setup.local
2137fi
2138
2139echo "creating Makefile"
2140$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
2141 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00002142 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00002143mv config.c Modules