blob: 09a33cf94394955abfd2e9cf5a9e8e0c09f9a710 [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
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001053AC_SUBST(THREADOBJ)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001054if test "$with_threads" = "no"
1055then
1056 USE_THREAD_MODULE="#"
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001057elif test "$ac_cv_pthread_is_default" = yes
1058then
1059 AC_DEFINE(WITH_THREAD)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001060 # Defining _REENTRANT on system with POSIX threads should not hurt.
1061 AC_DEFINE(_REENTRANT)
1062 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001063 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001064elif test "$ac_cv_kpthread" = "yes"
1065then
1066 CC="$CC -Kpthread"
1067 AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001068 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001069 THREADOBJ="Python/thread.o"
Barry Warsawc0d24d82000-06-29 16:12:00 +00001070else
Martin v. Löwis130fb172001-07-19 11:00:41 +00001071 if test ! -z "$with_threads" -a -d "$with_threads"
1072 then LDFLAGS="$LDFLAGS -L$with_threads"
1073 fi
1074 if test ! -z "$withval" -a -d "$withval"
1075 then LDFLAGS="$LDFLAGS -L$withval"
1076 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001077
1078 # According to the POSIX spec, a pthreads implementation must
1079 # define _POSIX_THREADS in unistd.h. Some apparently don't (which ones?)
1080 AC_MSG_CHECKING(for _POSIX_THREADS in unistd.h)
1081 AC_EGREP_CPP(yes,
1082 [#include <unistd.h>
1083 #ifdef _POSIX_THREADS
1084 yes
1085 #endif
1086 ], unistd_defines_pthreads=yes, unistd_defines_pthreads=no)
1087 AC_MSG_RESULT($unistd_defines_pthreads)
1088
Martin v. Löwis130fb172001-07-19 11:00:41 +00001089 AC_DEFINE(_REENTRANT)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001090 AC_CHECK_HEADER(cthreads.h, [AC_DEFINE(WITH_THREAD)
1091 AC_DEFINE(C_THREADS)
1092 AC_DEFINE(HURD_C_THREADS)
1093 LIBS="$LIBS -lthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001094 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001095 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
1096 AC_DEFINE(C_THREADS)
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001097 AC_DEFINE(MACH_C_THREADS)
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001098 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001099 AC_MSG_CHECKING(for --with-pth)
1100 AC_ARG_WITH(pth,
1101 [ --with-pth use GNU pth threading libraries], [
1102 AC_MSG_RESULT($withval)
1103 AC_DEFINE(WITH_THREAD)
1104 AC_DEFINE(HAVE_PTH)
1105 LIBS="-lpth $LIBS"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001106 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001107 AC_MSG_RESULT(no)
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001108
1109 # Just looking for pthread_create in libpthread is not enough:
1110 # on HP/UX, pthread.h renames pthread_create to a different symbol name.
1111 # So we really have to include pthread.h, and then link.
1112 _libs=$LIBS
1113 LIBS="$LIBS -lpthread"
1114 AC_MSG_CHECKING([for pthread_create in -lpthread])
1115 AC_TRY_LINK([#include <pthread.h>
1116
1117void * start_routine (void *arg) { exit (0); }], [
1118pthread_create (NULL, NULL, start_routine, NULL)], [
1119 AC_MSG_RESULT(yes)
1120 AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001121 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001122 THREADOBJ="Python/thread.o"],[
Martin v. Löwis8158b5a2001-10-08 13:17:28 +00001123 LIBS=$_libs
Martin v. Löwis130fb172001-07-19 11:00:41 +00001124 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001125 posix_threads=yes
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001126 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001127 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1128 AC_DEFINE(BEOS_THREADS)
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001129 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001130 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001131 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001132 LIBS="$LIBS -lpthreads"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001133 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001134 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001135 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001136 LIBS="$LIBS -lc_r"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001137 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001138 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001139 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001140 LIBS="$LIBS -lthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001141 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001142 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001143 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001144 LIBS="$LIBS -lpthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001145 THREADOBJ="Python/thread.o"], [
Martin v. Löwis130fb172001-07-19 11:00:41 +00001146 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001147 posix_threads=yes
Martin v. Löwis130fb172001-07-19 11:00:41 +00001148 LIBS="$LIBS -lcma"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001149 THREADOBJ="Python/thread.o"],[
Martin v. Löwis130fb172001-07-19 11:00:41 +00001150 USE_THREAD_MODULE="#"])
Martin v. Löwisa6e97582002-01-01 18:41:33 +00001151 ])])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +00001152
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001153 if test "$posix_threads" = "yes"; then
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001154 if test "$unistd_defines_pthreads" = "no"; then
1155 AC_DEFINE(_POSIX_THREADS)
1156 fi
1157
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001158 AC_MSG_CHECKING(if PTHREAD_SCOPE_SYSTEM is supported)
1159 AC_CACHE_VAL(ac_cv_pthread_system_supported,
1160 [AC_TRY_RUN([#include <pthread.h>
1161 void *foo(void *parm) {
1162 return NULL;
1163 }
1164 main() {
1165 pthread_attr_t attr;
Martin v. Löwisa82d3472002-02-24 16:05:05 +00001166 pthread_t id;
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001167 if (pthread_attr_init(&attr)) exit(-1);
1168 if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) exit(-1);
Martin v. Löwisa82d3472002-02-24 16:05:05 +00001169 if (pthread_create(&id, &attr, foo, NULL)) exit(-1);
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001170 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001171 }],
1172 ac_cv_pthread_system_supported=yes,
1173 ac_cv_pthread_system_supported=no,
1174 ac_cv_pthread_system_supported=no)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001175 ])
1176 AC_MSG_RESULT($ac_cv_pthread_system_supported)
1177 if test "$ac_cv_pthread_system_supported" = "yes"; then
1178 AC_DEFINE(PTHREAD_SYSTEM_SCHED_SUPPORTED)
1179 fi
Martin v. Löwis69c0ff32001-10-15 14:34:42 +00001180 AC_CHECK_FUNCS(pthread_sigmask)
Guido van Rossumd0b69ec2001-09-10 14:10:54 +00001181 fi
1182
Martin v. Löwis130fb172001-07-19 11:00:41 +00001183 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1184 LIBS="$LIBS -lmpc"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001185 THREADOBJ="Python/thread.o"
Martin v. Löwis130fb172001-07-19 11:00:41 +00001186 USE_THREAD_MODULE=""])
Martin v. Löwis3d2b5492002-03-15 13:48:21 +00001187
1188 if test $posix_threads != "yes"; then
1189 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1190 LIBS="$LIBS -lthread"
Martin v. Löwis2d7e2642002-04-05 16:50:53 +00001191 THREADOBJ="Python/thread.o"
Martin v. Löwis3d2b5492002-03-15 13:48:21 +00001192 USE_THREAD_MODULE=""])
1193 fi
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001194
Martin v. Löwis130fb172001-07-19 11:00:41 +00001195 if test "$USE_THREAD_MODULE" != "#"
1196 then
1197 # If the above checks didn't disable threads, (at least) OSF1
1198 # needs this '-threads' argument during linking.
1199 case $ac_sys_system in
1200 OSF1) LDLAST=-threads;;
1201 esac
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001202 fi
Barry Warsawc0d24d82000-06-29 16:12:00 +00001203fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001204
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001205# Check for enable-ipv6
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001206AC_MSG_CHECKING([if --enable-ipv6 is specified])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001207AC_ARG_ENABLE(ipv6,
1208[ --enable-ipv6 Enable ipv6 (with ipv4) support
1209 --disable-ipv6 Disable ipv6 support],
1210[ case "$enableval" in
1211 no)
1212 AC_MSG_RESULT(no)
1213 ipv6=no
1214 ;;
1215 *) AC_MSG_RESULT(yes)
1216 AC_DEFINE(ENABLE_IPV6)
1217 ipv6=yes
1218 ;;
1219 esac ],
1220
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001221[
1222dnl the check does not work on cross compilation case...
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001223 AC_TRY_RUN([ /* AF_INET6 available check */
1224#include <sys/types.h>
1225#include <sys/socket.h>
1226main()
1227{
1228 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
1229 exit(1);
1230 else
1231 exit(0);
1232}
1233],
1234 AC_MSG_RESULT(yes)
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001235 ipv6=yes,
1236 AC_MSG_RESULT(no)
1237 ipv6=no,
1238 AC_MSG_RESULT(no)
1239 ipv6=no
Martin v. Löwisa5f8bb52001-09-05 08:22:34 +00001240)
1241
1242if test "$ipv6" = "yes"; then
1243 AC_MSG_CHECKING(if RFC2553 API is available)
1244 AC_TRY_COMPILE([#include <sys/types.h>
1245#include <netinet/in.h>],
1246 [struct sockaddr_in6 x;
1247x.sin6_scope_id;],
1248 AC_MSG_RESULT(yes)
1249 ipv6=yes,
1250 AC_MSG_RESULT(no, IPv6 disabled)
1251 ipv6=no)
1252fi
1253
1254if test "$ipv6" = "yes"; then
1255 AC_DEFINE(ENABLE_IPV6)
1256fi
1257])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001258
1259ipv6type=unknown
1260ipv6lib=none
1261ipv6trylibc=no
1262
1263if test "$ipv6" = "yes"; then
1264 AC_MSG_CHECKING([ipv6 stack type])
Guido van Rossumb8552162001-09-05 14:58:11 +00001265 for i in inria kame linux-glibc linux-inet6 solaris toshiba v6d zeta;
1266 do
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001267 case $i in
1268 inria)
1269 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001270 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001271#include <netinet/in.h>
1272#ifdef IPV6_INRIA_VERSION
1273yes
1274#endif],
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001275 [ipv6type=$i])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001276 ;;
1277 kame)
1278 dnl http://www.kame.net/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001279 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001280#include <netinet/in.h>
1281#ifdef __KAME__
1282yes
1283#endif],
1284 [ipv6type=$i;
1285 ipv6lib=inet6
1286 ipv6libdir=/usr/local/v6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001287 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001288 ;;
1289 linux-glibc)
1290 dnl http://www.v6.linux.or.jp/
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001291 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001292#include <features.h>
1293#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
1294yes
1295#endif],
1296 [ipv6type=$i;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001297 ipv6trylibc=yes])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001298 ;;
1299 linux-inet6)
1300 dnl http://www.v6.linux.or.jp/
1301 if test -d /usr/inet6; then
1302 ipv6type=$i
1303 ipv6lib=inet6
1304 ipv6libdir=/usr/inet6/lib
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001305 OPT="-I/usr/inet6/include $OPT"
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001306 fi
1307 ;;
1308 solaris)
1309 if test -f /etc/netconfig; then
1310 if /usr/xpg4/bin/grep -q tcp6 /etc/netconfig; then
1311 ipv6type=$i
1312 ipv6trylibc=yes
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001313 fi
1314 fi
1315 ;;
1316 toshiba)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001317 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001318#include <sys/param.h>
1319#ifdef _TOSHIBA_INET6
1320yes
1321#endif],
1322 [ipv6type=$i;
1323 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001324 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001325 ;;
1326 v6d)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001327 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001328#include </usr/local/v6/include/sys/v6config.h>
1329#ifdef __V6D__
1330yes
1331#endif],
1332 [ipv6type=$i;
1333 ipv6lib=v6;
1334 ipv6libdir=/usr/local/v6/lib;
1335 OPT="-I/usr/local/v6/include $OPT"])
1336 ;;
1337 zeta)
Martin v. Löwisa5f73f92001-10-15 08:06:29 +00001338 AC_EGREP_CPP(yes, [
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001339#include <sys/param.h>
1340#ifdef _ZETA_MINAMI_INET6
1341yes
1342#endif],
1343 [ipv6type=$i;
1344 ipv6lib=inet6;
Martin v. Löwis44ddbde2001-12-02 10:15:37 +00001345 ipv6libdir=/usr/local/v6/lib])
Martin v. Löwisa2ac6022001-08-09 11:40:14 +00001346 ;;
1347 esac
1348 if test "$ipv6type" != "unknown"; then
1349 break
1350 fi
1351 done
1352 AC_MSG_RESULT($ipv6type)
1353fi
1354
1355if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
1356 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
1357 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
1358 echo "using lib$ipv6lib"
1359 else
1360 if test $ipv6trylibc = "yes"; then
1361 echo "using libc"
1362 else
1363 echo 'Fatal: no $ipv6lib library found. cannot continue.'
1364 echo "You need to fetch lib$ipv6lib.a from appropriate"
1365 echo 'ipv6 kit and compile beforehand.'
1366 exit 1
1367 fi
1368 fi
1369fi
1370
Barry Warsawef82cd72000-06-30 16:21:01 +00001371# Check for GC support
Barry Warsawef82cd72000-06-30 16:21:01 +00001372AC_MSG_CHECKING(for --with-cycle-gc)
1373AC_ARG_WITH(cycle-gc,
1374[ --with(out)-cycle-gc disable/enable garbage collection])
1375
1376if test -z "$with_cycle_gc"
1377then with_cycle_gc="yes"
1378fi
Neil Schemenauer9c63e6d2001-08-29 23:44:38 +00001379if test "$with_cycle_gc" != "no"
Barry Warsawef82cd72000-06-30 16:21:01 +00001380then
Barry Warsawef82cd72000-06-30 16:21:01 +00001381 AC_DEFINE(WITH_CYCLE_GC)
1382fi
1383AC_MSG_RESULT($with_cycle_gc)
1384
Neil Schemenauera35c6882001-02-27 04:45:05 +00001385# Check for Python-specific malloc support
1386AC_MSG_CHECKING(for --with-pymalloc)
1387AC_ARG_WITH(pymalloc,
Neil Schemenauer16c22972002-03-22 15:34:49 +00001388[ --with(out)-pymalloc disable/enable specialized mallocs])
1389
1390if test -z "$with_pymalloc"
1391then with_pymalloc="yes"
1392fi
1393if test "$with_pymalloc" != "no"
1394then
1395 AC_DEFINE(WITH_PYMALLOC)
1396fi
1397AC_MSG_RESULT($with_pymalloc)
Neil Schemenauera35c6882001-02-27 04:45:05 +00001398
Barry Warsawef82cd72000-06-30 16:21:01 +00001399# Check for --with-wctype-functions
1400AC_MSG_CHECKING(for --with-wctype-functions)
1401AC_ARG_WITH(wctype-functions,
1402[ --with-wctype-functions use wctype.h functions], [
1403if test "$withval" != no
1404then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
1405else AC_MSG_RESULT(no)
1406fi],
1407[AC_MSG_RESULT(no)])
1408
Guido van Rossum68242b51996-05-28 22:53:03 +00001409# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001410AC_SUBST(DLINCLDIR)
Guido van Rossum98935bf2001-09-05 19:13:16 +00001411DLINCLDIR=.
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001412
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001413AC_MSG_CHECKING(for --with-sgi-dl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001414AC_ARG_WITH(sgi-dl,
1415[ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001416AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001417AC_DEFINE(WITH_SGI_DL)
Guido van Rossume97ee181999-12-20 21:27:22 +00001418DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001419dldir=$withval
Guido van Rossum40951012000-10-07 16:21:27 +00001420if test ! -z "$dldir" -a -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001421then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001422else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1423fi
1424DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001425LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001426
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001427AC_MSG_CHECKING(for --with-dl-dld)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001428AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001429AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001430AC_DEFINE(WITH_DL_DLD)
Guido van Rossume97ee181999-12-20 21:27:22 +00001431DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001432dldir=`echo "$withval" | sed 's/,.*//'`
1433dlddir=`echo "$withval" | sed 's/.*,//'`
Barry Warsaw7d1219d2000-10-05 18:45:53 +00001434if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001435then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001436else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1437fi
1438DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001439LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +00001440
Guido van Rossume97ee181999-12-20 21:27:22 +00001441# the dlopen() function means we might want to use dynload_shlib.o. some
1442# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00001443AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00001444
1445# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1446# loading of modules.
1447AC_SUBST(DYNLOADFILE)
1448AC_MSG_CHECKING(DYNLOADFILE)
1449if test -z "$DYNLOADFILE"
1450then
1451 case $ac_sys_system/$ac_sys_release in
1452 AIX*) DYNLOADFILE="dynload_aix.o";;
1453 BeOS*) DYNLOADFILE="dynload_beos.o";;
1454 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001455 Darwin/*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00001456 *)
1457 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1458 # out any dynamic loading
1459 if test "$ac_cv_func_dlopen" = yes
1460 then DYNLOADFILE="dynload_shlib.o"
1461 else DYNLOADFILE="dynload_stub.o"
1462 fi
1463 ;;
1464 esac
1465fi
1466AC_MSG_RESULT($DYNLOADFILE)
1467if test "$DYNLOADFILE" != "dynload_stub.o"
1468then
1469 AC_DEFINE(HAVE_DYNAMIC_LOADING)
1470fi
1471
Jack Jansenc49e5b72001-06-19 15:00:23 +00001472# MACHDEP_OBJS can be set to platform-specific object files needed by Python
1473
1474AC_SUBST(MACHDEP_OBJS)
1475AC_MSG_CHECKING(MACHDEP_OBJS)
1476if test -z "$MACHDEP_OBJS"
1477then
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001478 MACHDEP_OBJS=$extra_machdep_objs
1479else
1480 MACHDEP_OBJS="$MACHDEP_OBJS $extra_machdep_objs"
Jack Jansenc49e5b72001-06-19 15:00:23 +00001481fi
Jack Jansenb6e9cad2001-08-15 01:26:28 +00001482AC_MSG_RESULT(MACHDEP_OBJS)
Jack Jansenc49e5b72001-06-19 15:00:23 +00001483
Guido van Rossum627b2d71993-12-24 10:39:16 +00001484# checks for library functions
Martin v. Löwis244edc82001-10-04 22:44:26 +00001485AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \
Fred Drake35a092f1999-12-13 16:23:35 +00001486 flock fork fsync fdatasync fpathconf ftime ftruncate \
Martin v. Löwisf95dd0a2001-08-15 17:14:33 +00001487 gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
Martin v. Löwisb2c92f42002-02-16 23:35:41 +00001488 hstrerror inet_pton kill killpg link lstat mkfifo mktime mremap \
Andrew M. Kuchling5821b772000-08-25 01:14:08 +00001489 nice pathconf pause plock poll pthread_init \
Fred Drake35a092f1999-12-13 16:23:35 +00001490 putenv readlink \
Martin v. Löwis61c5edf2001-10-18 04:06:00 +00001491 select setegid seteuid setgid setgroups \
Martin v. Löwis791bfda2001-07-24 06:33:08 +00001492 setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \
Fred Drake35a092f1999-12-13 16:23:35 +00001493 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
Fred Drake89143df1999-12-09 22:03:25 +00001494 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Guido van Rossumc524d952001-10-19 01:31:59 +00001495 truncate uname unsetenv waitpid _getpty getpriority)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001496
Fred Drake8cef4cf2000-06-28 16:40:38 +00001497# check for openpty and forkpty
1498
1499AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1500AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1501
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001502# check for long file support functions
1503AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1504
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001505AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Thomas Wouters3a584202000-08-05 23:28:51 +00001506AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1507AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1508AC_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 +00001509
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001510
1511# On OSF/1 V5.1, getaddrinfo is available, but a define
1512# for [no]getaddrinfo in netdb.h.
1513AC_MSG_CHECKING(for getaddrinfo)
1514AC_TRY_LINK([
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00001515#include <sys/types.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001516#include <sys/socket.h>
1517#include <netdb.h>
Martin v. Löwisc010b6d2001-11-09 17:50:52 +00001518#include <stdio.h>
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001519],[
1520getaddrinfo(NULL, NULL, NULL, NULL);
1521], [
1522AC_MSG_RESULT(yes)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001523AC_MSG_CHECKING(getaddrinfo bug)
1524AC_TRY_RUN([
1525#include <sys/types.h>
1526#include <netdb.h>
1527#include <string.h>
1528#include <sys/socket.h>
1529#include <netinet/in.h>
1530
1531main()
1532{
1533 int passive, gaierr, inet4 = 0, inet6 = 0;
1534 struct addrinfo hints, *ai, *aitop;
1535 char straddr[INET6_ADDRSTRLEN], strport[16];
1536
1537 for (passive = 0; passive <= 1; passive++) {
1538 memset(&hints, 0, sizeof(hints));
1539 hints.ai_family = AF_UNSPEC;
1540 hints.ai_flags = passive ? AI_PASSIVE : 0;
1541 hints.ai_socktype = SOCK_STREAM;
1542 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1543 (void)gai_strerror(gaierr);
1544 goto bad;
1545 }
1546 for (ai = aitop; ai; ai = ai->ai_next) {
1547 if (ai->ai_addr == NULL ||
1548 ai->ai_addrlen == 0 ||
1549 getnameinfo(ai->ai_addr, ai->ai_addrlen,
1550 straddr, sizeof(straddr), strport, sizeof(strport),
1551 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1552 goto bad;
1553 }
1554 switch (ai->ai_family) {
1555 case AF_INET:
1556 if (strcmp(strport, "54321") != 0) {
1557 goto bad;
1558 }
1559 if (passive) {
1560 if (strcmp(straddr, "0.0.0.0") != 0) {
1561 goto bad;
1562 }
1563 } else {
1564 if (strcmp(straddr, "127.0.0.1") != 0) {
1565 goto bad;
1566 }
1567 }
1568 inet4++;
1569 break;
1570 case AF_INET6:
1571 if (strcmp(strport, "54321") != 0) {
1572 goto bad;
1573 }
1574 if (passive) {
1575 if (strcmp(straddr, "::") != 0) {
1576 goto bad;
1577 }
1578 } else {
1579 if (strcmp(straddr, "::1") != 0) {
1580 goto bad;
1581 }
1582 }
1583 inet6++;
1584 break;
1585 case AF_UNSPEC:
1586 goto bad;
1587 break;
1588 default:
1589 /* another family support? */
1590 break;
1591 }
1592 }
1593 }
1594
1595 if (!(inet4 == 0 || inet4 == 2))
1596 goto bad;
1597 if (!(inet6 == 0 || inet6 == 2))
1598 goto bad;
1599
1600 if (aitop)
1601 freeaddrinfo(aitop);
1602 exit(0);
1603
1604 bad:
1605 if (aitop)
1606 freeaddrinfo(aitop);
1607 exit(1);
1608}
1609],
1610AC_MSG_RESULT(good)
1611buggygetaddrinfo=no,
1612AC_MSG_RESULT(buggy)
1613buggygetaddrinfo=yes,
1614AC_MSG_RESULT(buggy)
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001615buggygetaddrinfo=yes)], [
1616AC_MSG_RESULT(no)
1617buggygetaddrinfo=yes
1618])
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001619
1620if test "$buggygetaddrinfo" = "yes"; then
1621 if test "$ipv6" = "yes"; then
1622 echo 'Fatal: You must get working getaddrinfo() function.'
1623 echo ' or you can specify "--disable-ipv6"'.
1624 exit 1
1625 fi
Martin v. Löwis861a65b2001-10-24 14:36:00 +00001626else
1627 AC_DEFINE(HAVE_GETADDRINFO)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001628fi
Thomas Woutersb0db85a2001-08-08 10:39:03 +00001629AC_CHECK_FUNCS(getnameinfo)
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001630
Guido van Rossum627b2d71993-12-24 10:39:16 +00001631# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001632AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00001633AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001634AC_STRUCT_TIMEZONE
Guido van Rossum98bf58f2001-10-18 20:34:25 +00001635AC_STRUCT_ST_RDEV
1636AC_STRUCT_ST_BLKSIZE
1637AC_STRUCT_ST_BLOCKS
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001638
1639AC_MSG_CHECKING(for time.h that defines altzone)
1640AC_CACHE_VAL(ac_cv_header_time_altzone,
1641[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1642 ac_cv_header_time_altzone=yes,
1643 ac_cv_header_time_altzone=no)])
1644AC_MSG_RESULT($ac_cv_header_time_altzone)
1645if test $ac_cv_header_time_altzone = yes; then
1646 AC_DEFINE(HAVE_ALTZONE)
1647fi
1648
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001649was_it_defined=no
1650AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001651AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001652#include <sys/types.h>
1653#include <sys/select.h>
1654#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001655], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1656AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001657
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001658AC_MSG_CHECKING(for addrinfo)
1659AC_CACHE_VAL(ac_cv_struct_addrinfo,
1660AC_TRY_COMPILE([
1661# include <netdb.h>],
1662 [struct addrinfo a],
1663 ac_cv_struct_addrinfo=yes,
1664 ac_cv_struct_addrinfo=no))
1665AC_MSG_RESULT($ac_cv_struct_addrinfo)
1666if test $ac_cv_struct_addrinfo = yes; then
1667 AC_DEFINE(HAVE_ADDRINFO)
1668fi
1669
1670AC_MSG_CHECKING(for sockaddr_storage)
1671AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1672AC_TRY_COMPILE([
1673# include <sys/types.h>
1674# include <sys/socket.h>],
1675 [struct sockaddr_storage s],
1676 ac_cv_struct_sockaddr_storage=yes,
1677 ac_cv_struct_sockaddr_storage=no))
1678AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1679if test $ac_cv_struct_sockaddr_storage = yes; then
1680 AC_DEFINE(HAVE_SOCKADDR_STORAGE)
1681fi
1682
Guido van Rossum627b2d71993-12-24 10:39:16 +00001683# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001684
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001685AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001686AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001687
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001688works=no
1689AC_MSG_CHECKING(for working volatile)
1690AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1691AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00001692
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001693works=no
1694AC_MSG_CHECKING(for working signed char)
1695AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1696AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001697
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001698have_prototypes=no
1699AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001700AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1701AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001702AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001703
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001704works=no
1705AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001706AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001707#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00001708int foo(int x, ...) {
1709 va_list va;
1710 va_start(va, x);
1711 va_arg(va, int);
1712 va_arg(va, char *);
1713 va_arg(va, double);
1714 return 0;
1715}
1716], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001717AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1718AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001719
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001720if test "$have_prototypes" = yes; then
1721bad_prototypes=no
1722AC_MSG_CHECKING(for bad exec* prototypes)
1723AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1724 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1725AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001726fi
1727
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001728# check if sockaddr has sa_len member
1729AC_MSG_CHECKING(if sockaddr has sa_len member)
1730AC_TRY_COMPILE([#include <sys/types.h>
1731#include <sys/socket.h>],
1732[struct sockaddr x;
1733x.sa_len = 0;],
1734 AC_MSG_RESULT(yes)
1735 AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
1736 AC_MSG_RESULT(no))
1737
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001738AC_MSG_CHECKING(for bad static forward)
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001739AC_CACHE_VAL(ac_cv_bad_static_forward,
1740[AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001741struct s { int a; int b; };
1742static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001743int foobar() {
1744 static int random;
1745 random = (int) &foo;
1746 return random;
1747}
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001748static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001749main() {
1750 exit(!((int)&foo == foobar()));
Guido van Rossum3065c942001-09-17 04:03:14 +00001751}],
1752ac_cv_bad_static_forward=no,
1753ac_cv_bad_static_forward=yes,
1754ac_cv_bad_static_forward=no)])
Martin v. Löwis1d5ecb72001-08-09 10:29:44 +00001755AC_MSG_RESULT($ac_cv_bad_static_forward)
1756if test "$ac_cv_bad_static_forward" = yes
1757then
1758 AC_DEFINE(BAD_STATIC_FORWARD)
1759fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001760
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001761va_list_is_array=no
1762AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001763AC_TRY_COMPILE([
1764#ifdef HAVE_STDARG_PROTOTYPES
1765#include <stdarg.h>
1766#else
1767#include <varargs.h>
1768#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001769], [va_list list1, list2; list1 = list2;], ,
1770AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1771AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001772
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001773# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1774AC_CHECK_FUNC(gethostbyname_r, [
1775 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1776 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1777 OLD_CFLAGS=$CFLAGS
1778 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1779 AC_TRY_COMPILE([
1780# include <netdb.h>
1781 ], [
1782 char *name;
1783 struct hostent *he, *res;
1784 char buffer[2048];
1785 int buflen = 2048;
1786 int h_errnop;
1787
1788 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1789 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001790 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001791 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1792 AC_MSG_RESULT(yes)
1793 ], [
1794 AC_MSG_RESULT(no)
1795 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1796 AC_TRY_COMPILE([
1797# include <netdb.h>
1798 ], [
1799 char *name;
1800 struct hostent *he;
1801 char buffer[2048];
1802 int buflen = 2048;
1803 int h_errnop;
1804
1805 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1806 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001807 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001808 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1809 AC_MSG_RESULT(yes)
1810 ], [
1811 AC_MSG_RESULT(no)
1812 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1813 AC_TRY_COMPILE([
1814# include <netdb.h>
1815 ], [
1816 char *name;
1817 struct hostent *he;
1818 struct hostent_data data;
1819
1820 (void) gethostbyname_r(name, he, &data);
1821 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001822 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001823 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1824 AC_MSG_RESULT(yes)
1825 ], [
1826 AC_MSG_RESULT(no)
1827 ])
1828 ])
1829 ])
1830 CFLAGS=$OLD_CFLAGS
1831], [
Thomas Wouters3a584202000-08-05 23:28:51 +00001832 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001833])
1834AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1835AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1836AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001837AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001838AC_SUBST(HAVE_GETHOSTBYNAME)
1839
Guido van Rossum627b2d71993-12-24 10:39:16 +00001840# checks for system services
1841# (none yet)
1842
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001843# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00001844AC_CHECK_FUNC(__fpu_control,
1845 [],
1846 [AC_CHECK_LIB(ieee, __fpu_control)
1847])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001848
Guido van Rossum93274221997-05-09 02:42:00 +00001849# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00001850AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001851AC_ARG_WITH(fpectl,
1852[ --with-fpectl enable SIGFPE catching], [
Guido van Rossum93274221997-05-09 02:42:00 +00001853if test "$withval" != no
1854then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1855else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00001856fi],
1857[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00001858
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001859# check for --with-libm=...
1860AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001861case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00001862Darwin) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001863BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001864*) LIBM=-lm
1865esac
Guido van Rossum93274221997-05-09 02:42:00 +00001866AC_MSG_CHECKING(for --with-libm=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001867AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001868if test "$withval" = no
1869then LIBM=
1870 AC_MSG_RESULT(force LIBM empty)
1871elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001872then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001873 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001874else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001875fi],
1876[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001877
1878# check for --with-libc=...
1879AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00001880AC_MSG_CHECKING(for --with-libc=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001881AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001882if test "$withval" = no
1883then LIBC=
1884 AC_MSG_RESULT(force LIBC empty)
1885elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001886then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001887 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001888else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001889fi],
1890[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001891
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001892# check for hypot() in math library
1893LIBS_SAVE=$LIBS
1894LIBS="$LIBS $LIBM"
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001895AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001896LIBS=$LIBS_SAVE
1897
Guido van Rossumad713701997-07-10 22:42:38 +00001898# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +00001899AC_MSG_CHECKING(what malloc(0) returns)
1900AC_CACHE_VAL(ac_cv_malloc_zero,
1901[AC_TRY_RUN([#include <stdio.h>
1902#ifdef HAVE_STDLIB
1903#include <stdlib.h>
1904#else
1905char *malloc(), *realloc();
1906int *free();
1907#endif
1908main() {
1909 char *p;
1910 p = malloc(0);
1911 if (p == NULL) exit(1);
1912 p = realloc(p, 0);
1913 if (p == NULL) exit(1);
1914 free(p);
1915 exit(0);
Guido van Rossum3065c942001-09-17 04:03:14 +00001916}],
1917ac_cv_malloc_zero=nonnull,
1918ac_cv_malloc_zero=null,
1919ac_cv_malloc_zero=nonnull)]) # XXX arm cross-compile?
Guido van Rossumad713701997-07-10 22:42:38 +00001920AC_MSG_RESULT($ac_cv_malloc_zero)
1921if test "$ac_cv_malloc_zero" = null
1922then
1923 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1924fi
1925
Guido van Rossumef2255b2000-03-10 22:30:29 +00001926# check for wchar.h
1927AC_CHECK_HEADER(wchar.h,
1928AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1929wchar_h="no"
1930)
1931
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001932# determine wchar_t size
1933if test "$wchar_h" = yes
1934then
Guido van Rossum67b26592001-10-20 14:21:45 +00001935 AC_CHECK_SIZEOF(wchar_t, 4, [#include <wchar.h>])
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001936fi
1937
1938AC_MSG_CHECKING(what type to use for unicode)
1939AC_ARG_ENABLE(unicode,
1940[ --enable-unicode[=ucs2,ucs4] Enable Unicode strings (default is yes)],,enable_unicode=yes)
1941
1942if test $enable_unicode = yes
1943then
Martin v. Löwisfd917792001-06-27 20:22:04 +00001944 # Without any arguments, Py_UNICODE defaults to two-byte mode
1945 enable_unicode="ucs2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001946fi
1947
1948case "$enable_unicode" in
1949ucs2) unicode_size="2"
1950 AC_DEFINE(Py_UNICODE_SIZE,2)
1951 ;;
1952ucs4) unicode_size="4"
1953 AC_DEFINE(Py_UNICODE_SIZE,4)
1954 ;;
1955esac
1956
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001957AC_SUBST(UNICODE_OBJS)
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001958if test "$enable_unicode" = "no"
1959then
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001960 UNICODE_OBJS=""
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001961 AC_MSG_RESULT(not used)
1962else
Martin v. Löwis339d0f72001-08-17 18:39:25 +00001963 UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001964 AC_DEFINE(Py_USING_UNICODE)
1965 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
1966 then
1967 PY_UNICODE_TYPE="wchar_t"
1968 AC_DEFINE(HAVE_USABLE_WCHAR_T)
1969 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
1970 elif test "$ac_cv_sizeof_short" = "$unicode_size"
1971 then
1972 PY_UNICODE_TYPE="unsigned short"
1973 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
1974 elif test "$ac_cv_sizeof_long" = "$unicode_size"
1975 then
1976 PY_UNICODE_TYPE="unsigned long"
1977 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
1978 else
1979 PY_UNICODE_TYPE="no type found"
1980 fi
1981 AC_MSG_RESULT($PY_UNICODE_TYPE)
1982fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00001983
1984# check for endianness
1985AC_C_BIGENDIAN
1986
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001987# Check whether right shifting a negative integer extends the sign bit
1988# or fills with zeros (like the Cray J90, according to Tim Peters).
1989AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00001990AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001991AC_TRY_RUN([
1992int main()
1993{
Vladimir Marangozova6180282000-07-12 05:05:06 +00001994 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001995}
Guido van Rossum3065c942001-09-17 04:03:14 +00001996],
1997ac_cv_rshift_extends_sign=yes,
1998ac_cv_rshift_extends_sign=no,
1999ac_cv_rshift_extends_sign=yes)])
Vladimir Marangozova6180282000-07-12 05:05:06 +00002000AC_MSG_RESULT($ac_cv_rshift_extends_sign)
2001if test "$ac_cv_rshift_extends_sign" = no
2002then
2003 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
2004fi
2005
Guido van Rossumcadfaec2001-01-05 14:45:49 +00002006# check for getc_unlocked and related locking functions
2007AC_MSG_CHECKING(for getc_unlocked() and friends)
2008AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
2009AC_TRY_LINK([#include <stdio.h>],[
2010 FILE *f = fopen("/dev/null", "r");
2011 flockfile(f);
2012 getc_unlocked(f);
2013 funlockfile(f);
2014], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
2015AC_MSG_RESULT($ac_cv_have_getc_unlocked)
2016if test "$ac_cv_have_getc_unlocked" = yes
2017then
2018 AC_DEFINE(HAVE_GETC_UNLOCKED)
2019fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00002020
Martin v. Löwis0daad592001-09-30 21:09:59 +00002021# check for readline 4.0
2022AC_CHECK_LIB(readline, rl_pre_input_hook,
2023 AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK), , -ltermcap)
2024
Guido van Rossum353ae582001-07-10 16:45:32 +00002025# check for readline 4.2
2026AC_CHECK_LIB(readline, rl_completion_matches,
2027 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
2028
Thomas Wouterse38b2f12001-07-11 22:35:31 +00002029AC_MSG_CHECKING(for broken nice())
2030AC_CACHE_VAL(ac_cv_broken_nice, [
2031AC_TRY_RUN([
2032int main()
2033{
2034 int val1 = nice(1);
2035 if (val1 != -1 && val1 == nice(2))
2036 exit(0);
2037 exit(1);
2038}
Guido van Rossum3065c942001-09-17 04:03:14 +00002039],
2040ac_cv_broken_nice=yes,
2041ac_cv_broken_nice=no,
2042ac_cv_broken_nice=no)])
Thomas Wouterse38b2f12001-07-11 22:35:31 +00002043AC_MSG_RESULT($ac_cv_broken_nice)
2044if test "$ac_cv_broken_nice" = yes
2045then
2046 AC_DEFINE(HAVE_BROKEN_NICE)
2047fi
2048
Martin v. Löwiseb9b1032001-10-24 17:10:49 +00002049# On HP/UX 11.0, mvwdelch is a block with a return statement
2050AC_MSG_CHECKING(whether mvwdelch is an expression)
2051AC_CACHE_VAL(ac_cv_mvwdelch_is_expression,
2052AC_TRY_COMPILE([#include <curses.h>], [
2053 int rtn;
2054 rtn = mvwdelch(0,0,0);
2055], ac_cv_mvwdelch_is_expression=yes,
2056 ac_cv_mvwdelch_is_expression=no,
2057 ac_cv_mvwdelch_is_expression=yes))
2058AC_MSG_RESULT($ac_cv_mvwdelch_is_expression)
2059
2060if test "$ac_cv_mvwdelch_is_expression" = yes
2061then
2062 AC_DEFINE(MVWDELCH_IS_EXPRESSION)
2063fi
2064
2065AC_MSG_CHECKING(whether WINDOW has _flags)
2066AC_CACHE_VAL(ac_cv_window_has_flags,
2067AC_TRY_COMPILE([#include <curses.h>], [
2068 WINDOW *w;
2069 w->_flags = 0;
2070], ac_cv_window_has_flags=yes,
2071 ac_cv_window_has_flags=no,
2072 ac_cv_window_has_flags=no))
2073AC_MSG_RESULT($ac_cv_window_has_flags)
2074
2075
2076if test "$ac_cv_window_has_flags" = yes
2077then
2078 AC_DEFINE(WINDOW_HAS_FLAGS)
2079fi
2080
Guido van Rossum95713eb2000-05-18 20:53:31 +00002081# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
2082# Add sys/socket.h to confdefs.h
2083cat >> confdefs.h <<\EOF
2084#ifdef HAVE_SYS_SOCKET_H
2085#include <sys/socket.h>
2086#endif
2087EOF
2088AC_CHECK_TYPE(socklen_t, int)
2089
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002090#AC_MSG_CHECKING(for Modules/Setup)
2091#if test ! -f Modules/Setup ; then
2092# if test ! -d Modules ; then
2093# mkdir Modules
2094# fi
2095# cp "$srcdir/Modules/Setup.dist" Modules/Setup
2096# AC_MSG_RESULT(creating)
2097#else
2098# AC_MSG_RESULT(already exists)
2099#fi
2100
Martin v. Löwis06f15bb2001-12-02 13:02:32 +00002101AC_SUBST(THREADHEADERS)
2102
2103for h in `(cd $srcdir;echo Python/thread_*.h)`
2104do
2105 THREADHEADERS="$THREADHEADERS \$(srcdir)/$h"
2106done
2107
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002108AC_SUBST(SRCDIRS)
Neil Schemenaueracbf9ef2001-02-27 02:15:14 +00002109SRCDIRS="Parser Grammar Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00002110AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002111for dir in $SRCDIRS; do
2112 if test ! -d $dir; then
2113 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00002114 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00002115done
2116AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00002117
Guido van Rossum627b2d71993-12-24 10:39:16 +00002118# generate output files
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00002119AC_OUTPUT(Makefile.pre Modules/Setup.config)
Neil Schemenauer61c51152001-01-26 16:18:16 +00002120
2121echo "creating Setup"
2122if test ! -f Modules/Setup
2123then
2124 cp $srcdir/Modules/Setup.dist Modules/Setup
2125fi
2126
2127echo "creating Setup.local"
2128if test ! -f Modules/Setup.local
2129then
2130 echo "# Edit this file for local setup changes" >Modules/Setup.local
2131fi
2132
2133echo "creating Makefile"
2134$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
2135 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00002136 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00002137mv config.c Modules