blob: 666e2b720ab2793e241303b19e551a0b89c67a8c [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)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00005AC_CONFIG_HEADER(config.h)
Guido van Rossum627b2d71993-12-24 10:39:16 +00006
Guido van Rossum642b6781997-07-19 19:35:41 +00007# Set VERSION so we only need to edit in one place (i.e., here)
8AC_SUBST(VERSION)
Guido van Rossumb9a22a12000-06-30 02:48:53 +00009VERSION=2.0
Guido van Rossum642b6781997-07-19 19:35:41 +000010
Guido van Rossum3dc0a512000-10-05 18:00:06 +000011# NEXTSTEP|MacOSX|Darwin stuff
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000012if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000013
14 AC_MSG_CHECKING(for --with-next-archs)
15 AC_ARG_WITH(next-archs,
Barry Warsawc0d24d82000-06-29 16:12:00 +000016 [ --with-next-archs='arch1 arch2 ..' build MAB binary], [
Guido van Rossum4b6b5791996-09-09 20:09:34 +000017 if test -n "$withval"; then
Guido van Rossum2bb4f551996-09-10 18:19:59 +000018 ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval`
19 # GCC does not currently support multi archs on the NeXT
20 with_gcc=no
Guido van Rossum4b6b5791996-09-09 20:09:34 +000021 fi
22 AC_MSG_RESULT($with_next_archs)
23 ], [AC_MSG_RESULT(none: using `arch`)])
24
25 if test -z "$MACHDEP"
26 then
Guido van Rossum3dc0a512000-10-05 18:00:06 +000027 ac_sys_system=`uname -s`
28 if test "$ac_sys_system" = "Darwin" ; then
29 ac_sys_release=`uname -r`
30 else
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000031 set X `hostinfo | egrep '(NeXT Mach|Kernel Release).*:' | \
Guido van Rossum3dc0a512000-10-05 18:00:06 +000032 sed -e 's/://' -e 's/\./_/'` && \
33 ac_sys_system=next && ac_sys_release=$4
34 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000035
Guido van Rossum3dc0a512000-10-05 18:00:06 +000036 MACHDEP="$ac_sys_system$ac_sys_release"
Guido van Rossumb418f891996-07-30 18:06:02 +000037 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000038fi
Guido van Rossumb418f891996-07-30 18:06:02 +000039
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000040AC_ARG_WITH(next-framework,
Guido van Rossum3dc0a512000-10-05 18:00:06 +000041[ --with-next-framework Build (OpenStep|Rhapsody|MacOSX|Darwin) framework],,)
Barry Warsawc0d24d82000-06-29 16:12:00 +000042AC_ARG_WITH(dyld,
Guido van Rossum3dc0a512000-10-05 18:00:06 +000043[ --with-dyld Use (OpenStep|Rhapsody|MacOSX|Darwin) dynamic linker],,)
Guido van Rossum91922671997-10-09 20:24:13 +000044
Guido van Rossumb418f891996-07-30 18:06:02 +000045# Set name for machine-dependent library files
46AC_SUBST(MACHDEP)
47AC_MSG_CHECKING(MACHDEP)
48if test -z "$MACHDEP"
49then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000050 ac_sys_system=`uname -s`
Trent Mick635f6fb2000-08-23 21:33:05 +000051 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000052 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +000053 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +000054 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +000055 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000056 ac_md_system=`echo $ac_sys_system |
57 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
58 ac_md_release=`echo $ac_sys_release |
59 tr -d '[/ ]' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +000060 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +000061
Guido van Rossumbcd91e01997-03-20 20:46:29 +000062 case $MACHDEP in
Guido van Rossumb97ef171997-09-28 05:44:03 +000063 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +000064 esac
65fi
Guido van Rossum91922671997-10-09 20:24:13 +000066
67#
68# SGI compilers allow the specification of the both the ABI and the
69# ISA on the command line. Depending on the values of these switches,
70# different and often incompatable code will be generated.
71#
72# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
73# thus supply support for various ABI/ISA combinations. The MACHDEP
74# variable is also adjusted.
75#
76AC_SUBST(SGI_ABI)
77if test ! -z "$SGI_ABI"
78then
79 CC="cc $SGI_ABI"
80 LDFLAGS="$SGI_ABI $LDFLAGS"
81 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
82fi
Guido van Rossumb418f891996-07-30 18:06:02 +000083AC_MSG_RESULT($MACHDEP)
84
Guido van Rossum91922671997-10-09 20:24:13 +000085#
86# CCC is the command that compiles C++ programs
87#
88# Not all make programs have this predefined.
89#
Guido van Rossum95012191999-12-16 17:50:52 +000090#AC_SUBST(SET_CCC)
91#AC_MSG_CHECKING(CCC)
92#if test -z "$CCC"
93#then
94# case $ac_sys_system in
95# IRIX*) SET_CCC="CCC= CC ${SGI_ABI}";;
96# Linux*) SET_CCC="CCC= g++";;
97# *) SET_CCC=""
98# esac
99#else
100# SET_CCC="CCC= ${CCC}"
101#fi
102#AC_MSG_RESULT($SET_CCC)
Guido van Rossum91922671997-10-09 20:24:13 +0000103
104
Guido van Rossum627b2d71993-12-24 10:39:16 +0000105# checks for alternative programs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000106AC_MSG_CHECKING(for --without-gcc)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000107AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000108 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000109 no) CC=cc
110 without_gcc=yes;;
111 yes) CC=gcc
112 without_gcc=no;;
113 *) CC=$withval
114 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000115 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000116 case $ac_sys_system in
Guido van Rossum55a214e1995-09-13 17:48:09 +0000117 OSF1) CC=cc
118 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000119 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000120 case $BE_HOST_CPU in
121 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000122 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000123 without_gcc=yes
Fred Drake5790be12000-10-09 17:06:13 +0000124 OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
125 CCSHARED="UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000126 LDFLAGS="$LDFLAGS -nodup"
127
128 AR="$PWD/BeOS/ar-fake"
129 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000130 ;;
131 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000132 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000133 without_gcc=no
Fred Drake5790be12000-10-09 17:06:13 +0000134 OPT=-O
135 # Really should use srcdir instead of PWD
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000136 AR="$PWD/BeOS/ar-fake"
137 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000138 ;;
139 *)
Fred Drake5790be12000-10-09 17:06:13 +0000140 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000141 ;;
142 esac
143 ;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000144 Monterey*)
145 RANLIB=:
146 without_gcc=;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000147 *) without_gcc=no;;
148 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000149AC_MSG_RESULT($without_gcc)
150
Guido van Rossum95012191999-12-16 17:50:52 +0000151AC_SUBST(SET_CXX)
152AC_SUBST(MAINOBJ)
153MAINOBJ=python.o
154AC_MSG_CHECKING(for --with-cxx=<compiler>)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000155AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
Martin v. Löwis537970f2000-12-13 17:37:02 +0000156 check_cxx=no
Guido van Rossum95012191999-12-16 17:50:52 +0000157 case $withval in
158 no) CXX=
159 with_cxx=no;;
160 *) CXX=$withval
161 MAINOBJ=ccpython.o
162 with_cxx=$withval;;
163 esac], [
164 with_cxx=no
Martin v. Löwis537970f2000-12-13 17:37:02 +0000165 check_cxx=yes
Guido van Rossum95012191999-12-16 17:50:52 +0000166])
167AC_MSG_RESULT($with_cxx)
Martin v. Löwis537970f2000-12-13 17:37:02 +0000168
169dnl The following fragment works similar to AC_PROG_CXX.
170dnl It does not fail if CXX is not found, and it is not executed if
171dnl --with-cxx was given.
172dnl Finally, it does not test whether CXX is g++.
173
174if test "$check_cxx" = "yes"
175then
176 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
177 if test "$CXX" = "notfound"
178 then
179 CXX=
180 else
181 AC_PROG_CXX_WORKS
182 fi
183fi
184
Guido van Rossume1262332000-09-22 19:41:56 +0000185SET_CXX="CXX=$CXX"
Guido van Rossum95012191999-12-16 17:50:52 +0000186
Martin v. Löwis537970f2000-12-13 17:37:02 +0000187
Guido van Rossum95012191999-12-16 17:50:52 +0000188#AC_MSG_CHECKING(CCC)
189#if test -z "$CCC"
190#then
191# case $ac_sys_system in
192# IRIX*) SET_CCC="CCC= CC ${SGI_ABI}";;
193# Linux*) SET_CCC="CCC= g++";;
194# *) SET_CCC=""
195# esac
196#else
197# SET_CCC="CCC= ${CCC}"
198#fi
199#AC_MSG_RESULT($SET_CCC)
200
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000201# If the user switches compilers, we can't believe the cache
202if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
203then
204 AC_ERROR(cached CC is different -- throw away $cache_file
205(it is also a good idea to do 'make clean' before compiling))
206fi
207
Guido van Rossum627b2d71993-12-24 10:39:16 +0000208AC_PROG_CC
Guido van Rossumff555e32000-09-22 15:38:21 +0000209AC_SUBST(EXE)
210AC_MSG_CHECKING(for --with-suffix)
211AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
212 case $withval in
213 no) EXE=;;
214 yes) EXE=.exe;;
215 *) EXE=$withval;;
216 esac])
217AC_MSG_RESULT($EXE)
Guido van Rossumfb842551997-08-06 23:42:07 +0000218
Guido van Rossumdd997f71998-10-07 19:58:26 +0000219case $MACHDEP in
220bsdos*)
221 case $CC in
222 gcc) CC="$CC -D_HAVE_BSDI";;
223 esac;;
224esac
225
Guido van Rossum84561611997-08-21 00:08:11 +0000226case $ac_sys_system in
227hp*|HP*)
228 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000229 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000230 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000231Monterey*)
232 case $CC in
233 cc) CC="$CC -Wl,-Bexport";;
234 esac;;
Guido van Rossum84561611997-08-21 00:08:11 +0000235esac
236
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000237# LDLIBRARY is the name of the library to link against (as opposed to the
238# name of the library into which to insert object files). On systems
239# without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000240# the Makefiles). On Cygwin LDLIBRARY is the import library, DLLLIBRARY is the
241# shared (i.e., DLL) library.
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000242AC_SUBST(MAKE_LDLIBRARY)
243AC_SUBST(LDLIBRARY)
Guido van Rossumaef734b2001-01-10 21:09:12 +0000244AC_SUBST(SET_DLLLIBRARY)
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000245LDLIBRARY=''
Guido van Rossumaef734b2001-01-10 21:09:12 +0000246SET_DLLLIBRARY=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000247
Guido van Rossumfb842551997-08-06 23:42:07 +0000248# LINKCC is the command that links the python executable -- default is $(CC).
Fred Drake5790be12000-10-09 17:06:13 +0000249# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000250# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000251AC_SUBST(LINKCC)
252AC_MSG_CHECKING(LINKCC)
Guido van Rossum95012191999-12-16 17:50:52 +0000253if test -z "$LINKCC" -a ! -z "$CXX"
254then
255 LINKCC="$CXX"
256fi
Guido van Rossumfb842551997-08-06 23:42:07 +0000257if test -z "$LINKCC"
258then
259 case $ac_sys_system in
260 AIX*)
Guido van Rossum45140f91997-08-29 18:44:06 +0000261 LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000262 dgux*)
263 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000264 Monterey64*)
265 LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
Guido van Rossum25f93031997-08-18 16:00:04 +0000266 *) LINKCC="\$(PURIFY) \$(CC)";;
Guido van Rossumfb842551997-08-06 23:42:07 +0000267 esac
268fi
269AC_MSG_RESULT($LINKCC)
270
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000271AC_MSG_CHECKING(LDLIBRARY)
272
273# NeXT framework builds require that the 'ar' library be converted into
274# a bundle using libtool.
275if test "$with_next_framework"
276then
277 LDLIBRARY='libpython$(VERSION).dylib'
278fi
279
280# DG/UX requires some fancy ld contortions to produce a .so from an .a
Fred Drake5790be12000-10-09 17:06:13 +0000281case $MACHDEP in
282dguxR4)
283 LDLIBRARY='libpython$(VERSION).so'
284 OPT="$OPT -pic"
285 ;;
286beos*)
287 LDLIBRARY='libpython$(VERSION).so'
288 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000289cygwin*)
290 LDLIBRARY='libpython$(VERSION).dll.a'
291 SET_DLLLIBRARY='DLLLIBRARY= $(basename $(LDLIBRARY))'
292 ;;
Fred Drake5790be12000-10-09 17:06:13 +0000293esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000294AC_MSG_RESULT($LDLIBRARY)
295
296# If LDLIBRARY is different from LIBRARY, emit a rule to build it.
297if test -z "$LDLIBRARY"
298then
299 LDLIBRARY='libpython$(VERSION).a'
300 MAKE_LDLIBRARY="true"
301else
Guido van Rossumaef734b2001-01-10 21:09:12 +0000302 case $MACHDEP in
303 cygwin*) MAKE_LDLIBRARY='$(MAKE) -C Modules ../$(DLLLIBRARY)';;
304 *) MAKE_LDLIBRARY='$(MAKE) $(LDLIBRARY)';;
305 esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000306fi
307
Guido van Rossum627b2d71993-12-24 10:39:16 +0000308AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000309AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000310AC_CHECK_PROGS(AR, ar aal, ar)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000311AC_SUBST(INSTALL)
Guido van Rossum7d473291995-01-20 14:12:16 +0000312AC_SUBST(INSTALL_PROGRAM)
313AC_SUBST(INSTALL_DATA)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000314# Install just never works :-(
315if test -z "$INSTALL"
Guido van Rossum7d473291995-01-20 14:12:16 +0000316then
317 INSTALL=cp
318 INSTALL_PROGRAM=cp
319 INSTALL_DATA=cp
320else
321 INSTALL_PROGRAM="$INSTALL"
322 INSTALL_DATA="$INSTALL -m 644"
Guido van Rossum4e8af441994-08-19 15:33:54 +0000323fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000324
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000325# Not every filesystem supports hard links
326AC_SUBST(LN)
327if test -z "$LN" ; then
328 case $ac_sys_system in
329 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000330 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000331 *) LN=ln;;
332 esac
333fi
334
Guido van Rossum4e8af441994-08-19 15:33:54 +0000335# Optimizer/debugger flags passed between Makefiles
Guido van Rossumb418f891996-07-30 18:06:02 +0000336AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000337if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000338then
Guido van Rossumb5875b61997-07-18 23:29:09 +0000339 case $GCC in
340 yes)
341 case $ac_cv_prog_cc_g in
Greg Warda1c4da22000-11-07 15:44:21 +0000342 yes) OPT="-g -O2 -Wall -Wstrict-prototypes -fPIC";;
343 *) OPT="-O2 -Wall -Wstrict-prototypes -fPIC";;
Guido van Rossumb5875b61997-07-18 23:29:09 +0000344 esac
345 ;;
Guido van Rossumb418f891996-07-30 18:06:02 +0000346 *) OPT="-O";;
347 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000348fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000349
Trent Mick635f6fb2000-08-23 21:33:05 +0000350# The current (beta) Monterey compiler dies with optimizations
351case $ac_sys_system in
352Monterey*) OPT="";;
353esac
354
Guido van Rossumaef734b2001-01-10 21:09:12 +0000355# Cygwin does not need PIC compiler option so remove it to prevent warnings
356case $ac_sys_system in
357CYGWIN*) OPT="`echo $OPT | sed 's/ *-fPIC//'`";;
358esac
359
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000360if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000361then
362 OPT="$OPT $ac_arch_flags"
363fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000364# checks for UNIX variants that set C preprocessor variables
365AC_AIX
Guido van Rossum627b2d71993-12-24 10:39:16 +0000366AC_MINIX
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000367
Guido van Rossum91922671997-10-09 20:24:13 +0000368AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
369AC_CACHE_VAL(ac_cv_opt_olimit_ok,
370[ac_save_cc="$CC"
371CC="$CC -OPT:Olimit=0"
372AC_TRY_RUN([int main() { return 0; }],
373 ac_cv_opt_olimit_ok=yes,
374 ac_cv_opt_olimit_ok=no)
375CC="$ac_save_cc"])
376AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000377if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000378 case $ac_sys_system in
379 Darwin*) OPT="$OPT" ;;
380 *) OPT="$OPT -OPT:Olimit=0";;
381 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000382else
383 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
384 AC_CACHE_VAL(ac_cv_olimit_ok,
385 [ac_save_cc="$CC"
386 CC="$CC -Olimit 1500"
387 AC_TRY_RUN([int main() { return 0; }],
388 ac_cv_olimit_ok=yes,
389 ac_cv_olimit_ok=no)
390 CC="$ac_save_cc"])
391 AC_MSG_RESULT($ac_cv_olimit_ok)
392 if test $ac_cv_olimit_ok = yes; then
393 OPT="$OPT -Olimit 1500"
394 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000395fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000396
Fred Drakece81d592000-07-09 14:39:29 +0000397dnl # check for ANSI or K&R ("traditional") preprocessor
398dnl AC_MSG_CHECKING(for C preprocessor type)
399dnl AC_TRY_COMPILE([
400dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
401dnl int foo;
402dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
403dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
404dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +0000405
Guido van Rossum627b2d71993-12-24 10:39:16 +0000406# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000407AC_HEADER_STDC
Andrew M. Kuchling5821b772000-08-25 01:14:08 +0000408AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
Guido van Rossuma2ef3831996-06-26 19:45:23 +0000409signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
Fred Drakec9cb8472000-08-31 16:11:07 +0000410sys/audioio.h sys/file.h sys/lock.h db_185.h db.h \
Guido van Rossum95713eb2000-05-18 20:53:31 +0000411sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \
Fred Drakeae90f8d2000-09-15 03:38:12 +0000412sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
413ndbm.h db1/ndbm.h gdbm/ndbm.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000414AC_HEADER_DIRENT
Guido van Rossum627b2d71993-12-24 10:39:16 +0000415
416# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000417was_it_defined=no
418AC_MSG_CHECKING(for clock_t in time.h)
419AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
420AC_MSG_RESULT($was_it_defined)
421
Guido van Rossum300fda71996-08-19 21:58:16 +0000422# Add some code to confdefs.h so that the test for off_t works on SCO
423cat >> confdefs.h <<\EOF
424#if defined(SCO_DS)
425#undef _OFF_T
426#endif
427EOF
428
Guido van Rossumef2255b2000-03-10 22:30:29 +0000429# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000430AC_TYPE_MODE_T
431AC_TYPE_OFF_T
432AC_TYPE_PID_T
433AC_TYPE_SIGNAL
434AC_TYPE_SIZE_T
435AC_TYPE_UID_T
Guido van Rossum627b2d71993-12-24 10:39:16 +0000436
Guido van Rossumef2255b2000-03-10 22:30:29 +0000437# Sizes of various common basic types
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000438AC_CHECK_SIZEOF(int)
439AC_CHECK_SIZEOF(long)
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000440AC_CHECK_SIZEOF(void *)
Guido van Rossumef2255b2000-03-10 22:30:29 +0000441AC_CHECK_SIZEOF(char)
442AC_CHECK_SIZEOF(short)
443AC_CHECK_SIZEOF(float)
444AC_CHECK_SIZEOF(double)
Fred Drakea3f6e912000-06-29 20:44:47 +0000445AC_CHECK_SIZEOF(fpos_t)
Guido van Rossumac405f61994-09-12 10:56:06 +0000446
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000447AC_MSG_CHECKING(for long long support)
448have_long_long=no
449AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
450AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000451if test "$have_long_long" = yes ; then
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000452AC_CHECK_SIZEOF(long long)
453fi
454
Barry Warsawbc7c7f92000-08-18 04:53:33 +0000455AC_MSG_CHECKING(for uintptr_t support)
456have_uintptr_t=no
457AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
458AC_MSG_RESULT($have_uintptr_t)
459if test "$have_uintptr_t" = yes ; then
460AC_CHECK_SIZEOF(uintptr_t)
461fi
462
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000463# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
464AC_MSG_CHECKING(size of off_t)
465AC_CACHE_VAL(ac_cv_sizeof_off_t,
466[AC_TRY_RUN([#include <stdio.h>
467#include <sys/types.h>
468main()
469{
470 FILE *f=fopen("conftestval", "w");
471 if (!f) exit(1);
472 fprintf(f, "%d\n", sizeof(off_t));
473 exit(0);
474}], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
475])
476AC_MSG_RESULT($ac_cv_sizeof_off_t)
477AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
478
479AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000480if test "$have_long_long" = yes -a \
481 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
482 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000483 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
484 AC_MSG_RESULT(yes)
485else
486 AC_MSG_RESULT(no)
487fi
488
Fred Drakea3f6e912000-06-29 20:44:47 +0000489# AC_CHECK_SIZEOF() doesn't include <time.h>.
490AC_MSG_CHECKING(size of time_t)
491AC_CACHE_VAL(ac_cv_sizeof_time_t,
492[AC_TRY_RUN([#include <stdio.h>
493#include <time.h>
494main()
495{
496 FILE *f=fopen("conftestval", "w");
497 if (!f) exit(1);
498 fprintf(f, "%d\n", sizeof(time_t));
499 exit(0);
500}], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
501])
502AC_MSG_RESULT($ac_cv_sizeof_time_t)
503AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
504
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000505
Trent Mick635f6fb2000-08-23 21:33:05 +0000506# if have pthread_t then define SIZEOF_PTHREAD_T
507AC_MSG_CHECKING(for pthread_t)
508have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +0000509AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +0000510AC_MSG_RESULT($have_pthread_t)
511if test "$have_pthread_t" = yes ; then
512 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
513 AC_MSG_CHECKING(size of pthread_t)
514 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
515 [AC_TRY_RUN([#include <stdio.h>
516 #include <pthread.h>
517 main()
518 {
519 FILE *f=fopen("conftestval", "w");
520 if (!f) exit(1);
521 fprintf(f, "%d\n", sizeof(pthread_t));
522 exit(0);
523 }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
524 ])
525 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
526 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
527fi
528
529
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000530# Minor variations in building a framework between NextStep versions 4 and 5
531AC_SUBST(LIBTOOL_CRUFT)
532case $ac_sys_system/$ac_sys_release in
Guido van Rossum5839e582000-10-09 19:52:35 +0000533 Darwin/*)
534 ns_undef_sym='_environ'
535 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym" ;;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000536 next/4*)
537 ns_undef_sym='__environ'
538 LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
539 next/5*)
540 ns_undef_sym='_environ'
541 LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
542esac
543
544AC_MSG_CHECKING(for --with-next-framework)
545if test "$with_next_framework"
546then
547 OPT="$OPT -fno-common"
548 # -U __environ is needed since bundles don't have access
549 # to crt0 when built but will always be linked against it
550 LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
551 AC_DEFINE(WITH_NEXT_FRAMEWORK)
552 AC_MSG_RESULT(yes)
553else
554 AC_MSG_RESULT(no)
555fi
556
557AC_MSG_CHECKING(for --with-dyld)
558if test "$with_next_framework" -o "$with_dyld"
559then
560 if test "$with_dyld"
561 then
562 AC_MSG_RESULT(yes)
563 else
564 AC_MSG_RESULT(required for framework build)
565 fi
566 AC_DEFINE(WITH_DYLD)
567 ns_dyld='set'
568else
569 AC_MSG_RESULT(no)
570fi
571
Guido van Rossumac405f61994-09-12 10:56:06 +0000572# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +0000573AC_SUBST(SO)
574AC_SUBST(LDSHARED)
575AC_SUBST(CCSHARED)
576AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000577# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +0000578# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000579AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000580if test -z "$SO"
581then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000582 case $ac_sys_system in
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000583 hp*|HP*) SO=.sl;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000584 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000585 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000586 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000587fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000588AC_MSG_RESULT($SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000589# LDSHARED is the ld *command* used to create shared library
590# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000591# (Shared libraries in this instance are shared modules to be loaded into
592# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000593AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000594if test -z "$LDSHARED"
595then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000596 case $ac_sys_system/$ac_sys_release in
Guido van Rossum45140f91997-08-29 18:44:06 +0000597 AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000598 BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000599 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +0000600 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000601 SunOS/4*) LDSHARED="ld";;
Greg Ward57c9a662000-05-26 12:22:54 +0000602 SunOS/5*)
603 if test "$GCC" = "yes"
Greg Warda1c4da22000-11-07 15:44:21 +0000604 then LDSHARED='$(CC) -shared'
Greg Ward57c9a662000-05-26 12:22:54 +0000605 else LDSHARED="ld -G";
606 fi ;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000607 hp*|HP*) LDSHARED="ld -b";;
Guido van Rossum71001e41995-01-26 00:44:03 +0000608 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Guido van Rossum7d473291995-01-20 14:12:16 +0000609 DYNIX/ptx*) LDSHARED="ld -G";;
Guido van Rossum3dc0a512000-10-05 18:00:06 +0000610 Darwin/*|next/*)
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000611 if test "$ns_dyld"
Guido van Rossum5839e582000-10-09 19:52:35 +0000612 then
613 if test "$ac_sys_system" = Darwin
614 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined suppress'
615 else LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
616 fi
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000617 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
618 fi
Guido van Rossum3dc0a512000-10-05 18:00:06 +0000619 if test "$with_next_framework" ; then
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000620 LDSHARED="$LDSHARED \$(LDLIBRARY)"
621 fi ;;
Guido van Rossum81652ab1996-07-21 02:53:27 +0000622 Linux*) LDSHARED="gcc -shared";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000623 dgux*) LDSHARED="ld -G";;
Guido van Rossum458e7fa1999-09-17 15:40:40 +0000624 BSD/OS*/4*) LDSHARED="gcc -shared";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000625 OpenBSD*) LDSHARED="ld -Bshareable";;
Guido van Rossumdf693651999-01-07 21:50:41 +0000626 NetBSD*)
627 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
628 then
629 LDSHARED="cc -shared"
630 else
631 LDSHARED="ld -Bshareable"
632 fi;;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000633 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +0000634 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +0000635 then
636 LDSHARED="cc -shared ${LDFLAGS}"
637 else
638 LDSHARED="ld -Bshareable ${LDFLAGS}"
639 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000640 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000641 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000642 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000643 *) LDSHARED="ld";;
644 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000645fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000646AC_MSG_RESULT($LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000647# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000648# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000649AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000650if test -z "$CCSHARED"
651then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000652 case $ac_sys_system/$ac_sys_release in
Guido van Rossumaf07a441995-02-13 19:45:27 +0000653 hp*|HP*) if test "$GCC" = yes;
654 then CCSHARED="-fpic";
655 else CCSHARED="+z";
656 fi;;
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000657 Linux*) CCSHARED="-fpic";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000658 BSD/OS*/4*) CCSHARED="-fpic";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000659 OpenBSD*) CCSHARED="-fpic";;
660 FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
Guido van Rossum300fda71996-08-19 21:58:16 +0000661 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000662 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000663 IRIX*/6*) case $CC in
664 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +0000665 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000666 esac;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000667 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000668 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000669fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000670AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000671# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000672# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000673AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000674if test -z "$LINKFORSHARED"
675then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000676 case $ac_sys_system/$ac_sys_release in
Guido van Rossum69f65801998-03-03 21:47:00 +0000677 AIX*) LINKFORSHARED='-Wl,-bE:python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000678 hp*|HP*)
Guido van Rossum304dd2d1997-10-20 23:10:56 +0000679 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000680 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum2d9feed1997-11-24 17:36:21 +0000681 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000682 # -u libsys_s pulls in all symbols in libsys
683 next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
684 # -u __dummy makes the linker aware of the objc runtime
685 # in System.framework; otherwise, __objcInit (referenced in
686 # crt1.o) gets erroneously defined as common, which breaks dynamic
687 # loading of any modules which reference it in System.framework
688 next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
Guido van Rossum5839e582000-10-09 19:52:35 +0000689 Darwin/*) LINKFORSHARED="-framework System" ;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000690 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +0000691 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000692 FreeBSD*|NetBSD*)
Guido van Rossumdf693651999-01-07 21:50:41 +0000693 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
694 then
695 LINKFORSHARED="-Wl,--export-dynamic"
696 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000697 SunOS/5*) case $CC in
698 *gcc*)
Guido van Rossum9c6ba9b2000-02-03 13:42:50 +0000699 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000700 then
701 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000702 fi;;
703 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000704 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000705fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000706AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000707
Guido van Rossum627b2d71993-12-24 10:39:16 +0000708# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000709AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
710AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000711
Skip Montanarocb853262000-08-30 22:29:48 +0000712# Check for --with-pydebug
713AC_MSG_CHECKING(for --with-pydebug)
714AC_ARG_WITH(pydebug,
715[ --with-pydebug build with Py_DEBUG defined], [
716if test "$withval" != no
717then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes)
718else AC_MSG_RESULT(no)
719fi],
720[AC_MSG_RESULT(no)])
721
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000722# checks for system dependent C++ extensions support
723case "$ac_sys_system" in
724 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
725 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
726 [loadAndInit("", 0, "")],
727 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
728 AC_MSG_RESULT(yes)],
729 [AC_MSG_RESULT(no)]);;
730 *) ;;
731esac
732
Guido van Rossum70c7f481998-03-26 18:44:10 +0000733# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
734# However on SGI IRIX, these exist but are broken.
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000735# BeOS' sockets are stashed in libnet.
736case "$ac_sys_system" in
737IRIX*) ;;
Guido van Rossum2cb56601998-05-07 13:25:56 +0000738*)
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000739AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000740AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +0000741;;
742esac
743case "$ac_sys_system" in
744BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000745AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
746;;
747esac
Guido van Rossum70c7f481998-03-26 18:44:10 +0000748
Guido van Rossumc5a39031996-07-31 17:35:03 +0000749AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000750AC_ARG_WITH(libs,
751[ --with-libs='lib1 ...' link against additional libs], [
Guido van Rossumc5a39031996-07-31 17:35:03 +0000752AC_MSG_RESULT($withval)
753LIBS="$withval $LIBS"
754], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000755
Guido van Rossum3d15bd82001-01-10 18:53:48 +0000756# This is used to generate Setup.config
757AC_SUBST(USE_NCURSES_MODULE)
758AC_CHECK_LIB(ncurses, initscr,
759 [USE_NCURSES_MODULE=""],
760 [USE_NCURSES_MODULE="#"],
761 -ltermcap)
762
763# This is used to generate Setup.config
764AC_SUBST(USE_READLINE_MODULE)
765AC_CHECK_LIB(readline, readline,
766 [USE_READLINE_MODULE=""],
767 [USE_READLINE_MODULE="#"],
768 -ltermcap)
769
770# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +0000771AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000772USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +0000773
Guido van Rossum54d93d41997-01-22 20:51:58 +0000774AC_MSG_CHECKING(for --with-dec-threads)
775AC_SUBST(LDLAST)
776AC_ARG_WITH(dec-threads,
Barry Warsawc0d24d82000-06-29 16:12:00 +0000777[ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
778AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +0000779LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +0000780if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +0000781 with_thread="$withval";
782fi],
783AC_MSG_RESULT(no))
784
785AC_MSG_CHECKING(for --with-threads)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000786AC_ARG_WITH(threads,
787[ --with(out)-threads[=DIRECTORY] disable/enable thread support])
Guido van Rossum54d93d41997-01-22 20:51:58 +0000788
Barry Warsawc0d24d82000-06-29 16:12:00 +0000789# --with-thread is deprecated, but check for it anyway
Barry Warsawa0f3c5c2000-06-30 16:39:35 +0000790AC_ARG_WITH(thread,
791[ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
792with_threads=$with_thread])
Barry Warsawc0d24d82000-06-29 16:12:00 +0000793
794if test -z "$with_threads"
795then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000796fi
Barry Warsawc0d24d82000-06-29 16:12:00 +0000797AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +0000798
Barry Warsawc0d24d82000-06-29 16:12:00 +0000799if test "$with_threads" = "no"
800then
801 USE_THREAD_MODULE="#"
802else
Guido van Rossum40951012000-10-07 16:21:27 +0000803 if test ! -z "$with_threads" -a -d "$with_threads"
Barry Warsawc0d24d82000-06-29 16:12:00 +0000804 then LDFLAGS="$LDFLAGS -L$with_threads"
805 fi
Guido van Rossum40951012000-10-07 16:21:27 +0000806 if test ! -z "$withval" -a -d "$withval"
Barry Warsawc0d24d82000-06-29 16:12:00 +0000807 then LDFLAGS="$LDFLAGS -L$withval"
808 fi
809 AC_DEFINE(_REENTRANT)
810 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
811 AC_DEFINE(C_THREADS)
812 LIBOBJS="$LIBOBJS thread.o"],[
Guido van Rossum9e8181b2000-09-19 00:46:46 +0000813 AC_MSG_CHECKING(for --with-pth)
814 AC_ARG_WITH(pth,
815 [ --with-pth use GNU pth threading libraries], [
816 AC_MSG_RESULT($withval)
817 AC_DEFINE(WITH_THREAD)
818 AC_DEFINE(HAVE_PTH)
819 LIBS="-lpth $LIBS"
820 LIBOBJS="$LIBOBJS thread.o"],[
821 AC_MSG_RESULT(no)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000822 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
823 AC_DEFINE(_POSIX_THREADS)
824 LIBS="-lpthread $LIBS"
825 LIBOBJS="$LIBOBJS thread.o"],[
826 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Guido van Rossum5839e582000-10-09 19:52:35 +0000827 case $ac_sys_system in
828 Darwin*) ;;
829 *) AC_DEFINE(_POSIX_THREADS);;
830 esac
Barry Warsawc0d24d82000-06-29 16:12:00 +0000831 LIBOBJS="$LIBOBJS thread.o"],[
832 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
833 AC_DEFINE(BEOS_THREADS)
834 LIBOBJS="$LIBOBJS thread.o"],[
835 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
836 AC_DEFINE(_POSIX_THREADS)
837 LIBS="$LIBS -lpthreads"
838 LIBOBJS="$LIBOBJS thread.o"], [
839 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
840 AC_DEFINE(_POSIX_THREADS)
841 LIBS="$LIBS -lc_r"
842 LIBOBJS="$LIBOBJS thread.o"], [
843 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
844 AC_DEFINE(_POSIX_THREADS)
845 LIBS="$LIBS -lthread"
846 LIBOBJS="$LIBOBJS thread.o"], [
Guido van Rossum8d6e8af2000-10-30 17:45:07 +0000847 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
848 AC_DEFINE(_POSIX_THREADS)
849 LIBS="$LIBS -lpthread"
850 LIBOBJS="$LIBOBJS thread.o"], [
Barry Warsawc0d24d82000-06-29 16:12:00 +0000851 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
852 AC_DEFINE(_POSIX_THREADS)
853 LIBS="$LIBS -lcma"
Thomas Wouters0db2b2b2000-08-26 11:33:43 +0000854 LIBOBJS="$LIBOBJS thread.o"],[
855 USE_THREAD_MODULE="#"])
Guido van Rossum8d6e8af2000-10-30 17:45:07 +0000856 ])])])])])])])])])
Barry Warsawc0d24d82000-06-29 16:12:00 +0000857
858 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
859 LIBS="$LIBS -lmpc"
Thomas Wouters0db2b2b2000-08-26 11:33:43 +0000860 LIBOBJS="$LIBOBJS thread.o"
861 USE_THREAD_MODULE=""])
Barry Warsawc0d24d82000-06-29 16:12:00 +0000862 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
863 LIBS="$LIBS -lthread"
Thomas Wouters0db2b2b2000-08-26 11:33:43 +0000864 LIBOBJS="$LIBOBJS thread.o"
865 USE_THREAD_MODULE=""])
Jeremy Hylton1a2ca862000-10-16 16:59:12 +0000866
867 if test "$USE_THREAD_MODULE" != "#"
868 then
869 # If the above checks didn't disable threads, (at least) OSF1
870 # needs this '-threads' argument during linking.
871 case $ac_sys_system in
872 OSF1) LDLAST=-threads;;
873 esac
874 fi
Barry Warsawc0d24d82000-06-29 16:12:00 +0000875fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000876
Barry Warsawef82cd72000-06-30 16:21:01 +0000877# Check for GC support
878AC_SUBST(USE_GC_MODULE)
879USE_GC_MODULE=""
880AC_MSG_CHECKING(for --with-cycle-gc)
881AC_ARG_WITH(cycle-gc,
882[ --with(out)-cycle-gc disable/enable garbage collection])
883
884if test -z "$with_cycle_gc"
885then with_cycle_gc="yes"
886fi
887if test "$with_cycle_gc" = "no"
888then
889 USE_GC_MODULE="#"
890else
891 AC_DEFINE(WITH_CYCLE_GC)
892fi
893AC_MSG_RESULT($with_cycle_gc)
894
Fred Drakec9cb8472000-08-31 16:11:07 +0000895# Check for LIBDB support
896# either --with-libdb or, in its absence, the presence of db.h
897AC_SUBST(USE_BSDDB_MODULE)
898USE_BSDDB_MODULE=""
899AC_MSG_CHECKING(for --with-libdb)
900AC_ARG_WITH(libdb,
901[ --with(out)-libdb disable/enable bsddb module])
902
Skip Montanarob89f41e2000-09-04 04:06:05 +0000903# enabled by default, but db.h must be found
904if test "$ac_cv_header_db_h" = "yes"
905then
906 if test "$with_libdb" != "no"
907 then with_libdb="yes"
908 fi
909else
Fred Drake5790be12000-10-09 17:06:13 +0000910 # make sure user knows why bsddb support wasn't enabled even
Skip Montanarob89f41e2000-09-04 04:06:05 +0000911 # though s/he requested it
912 if test "$with_libdb" = "yes"
913 then echo $ac_n "(requested, but db.h was not found) $ac_c"
914 fi
915 with_libdb="no"
Fred Drakec9cb8472000-08-31 16:11:07 +0000916fi
Skip Montanarob89f41e2000-09-04 04:06:05 +0000917
Fred Drakec9cb8472000-08-31 16:11:07 +0000918if test "$with_libdb" = "no"
919then
920 USE_BSDDB_MODULE="#"
921else
922 AC_DEFINE(WITH_LIBDB)
923fi
924AC_MSG_RESULT($with_libdb)
925
Skip Montanaroed33c9a2000-09-08 02:17:15 +0000926if test "$with_libdb" = "yes"
927then
928 # check for libdb; BSD systems have the DB routines in libc --tg
929 AC_SUBST(HAVE_LIBDB)
Martin v. Löwis05a65d62000-09-24 19:40:25 +0000930 # If dbopen is not in libc, then checking whether it is in libdb
931 # is difficult: db_185.h may #define it as __db185_open
932 # Instead, we just trust it is in libdb; linking will fail if it
933 # is not.
934 AC_CHECK_FUNC(dbopen, [HAVE_LIBDB=], [HAVE_LIBDB=-ldb])
Skip Montanaroed33c9a2000-09-08 02:17:15 +0000935fi
936
Barry Warsawef82cd72000-06-30 16:21:01 +0000937# Check for --with-wctype-functions
938AC_MSG_CHECKING(for --with-wctype-functions)
939AC_ARG_WITH(wctype-functions,
940[ --with-wctype-functions use wctype.h functions], [
941if test "$withval" != no
942then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
943else AC_MSG_RESULT(no)
944fi],
945[AC_MSG_RESULT(no)])
946
Guido van Rossum68242b51996-05-28 22:53:03 +0000947# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000948AC_SUBST(DLINCLDIR)
949DLINCLDIR=/
950
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000951AC_MSG_CHECKING(for --with-sgi-dl)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000952AC_ARG_WITH(sgi-dl,
953[ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000954AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000955AC_DEFINE(WITH_SGI_DL)
Guido van Rossume97ee181999-12-20 21:27:22 +0000956DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000957dldir=$withval
Guido van Rossum40951012000-10-07 16:21:27 +0000958if test ! -z "$dldir" -a -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +0000959then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000960else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
961fi
962DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000963LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000964
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000965AC_MSG_CHECKING(for --with-dl-dld)
Barry Warsawc0d24d82000-06-29 16:12:00 +0000966AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000967AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000968AC_DEFINE(WITH_DL_DLD)
Guido van Rossume97ee181999-12-20 21:27:22 +0000969DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000970dldir=`echo "$withval" | sed 's/,.*//'`
971dlddir=`echo "$withval" | sed 's/.*,//'`
Barry Warsaw7d1219d2000-10-05 18:45:53 +0000972if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +0000973then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000974else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
975fi
976DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000977LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000978
Guido van Rossume97ee181999-12-20 21:27:22 +0000979# the dlopen() function means we might want to use dynload_shlib.o. some
980# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +0000981AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +0000982
983# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
984# loading of modules.
985AC_SUBST(DYNLOADFILE)
986AC_MSG_CHECKING(DYNLOADFILE)
987if test -z "$DYNLOADFILE"
988then
989 case $ac_sys_system/$ac_sys_release in
990 AIX*) DYNLOADFILE="dynload_aix.o";;
991 BeOS*) DYNLOADFILE="dynload_beos.o";;
992 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Guido van Rossum5839e582000-10-09 19:52:35 +0000993 Darwin/*|next/*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +0000994 *)
995 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
996 # out any dynamic loading
997 if test "$ac_cv_func_dlopen" = yes
998 then DYNLOADFILE="dynload_shlib.o"
999 else DYNLOADFILE="dynload_stub.o"
1000 fi
1001 ;;
1002 esac
1003fi
1004AC_MSG_RESULT($DYNLOADFILE)
1005if test "$DYNLOADFILE" != "dynload_stub.o"
1006then
1007 AC_DEFINE(HAVE_DYNAMIC_LOADING)
1008fi
1009
Guido van Rossum627b2d71993-12-24 10:39:16 +00001010# checks for library functions
Thomas Wouters3a584202000-08-05 23:28:51 +00001011AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
Fred Drake35a092f1999-12-13 16:23:35 +00001012 flock fork fsync fdatasync fpathconf ftime ftruncate \
Andrew M. Kuchlinga9586c72001-01-08 17:58:56 +00001013 getgroups getlogin getpeername getpid getpwent getwd \
Andrew M. Kuchling898527b2000-06-18 14:54:13 +00001014 kill link lstat mkfifo mktime mremap \
Andrew M. Kuchling5821b772000-08-25 01:14:08 +00001015 nice pathconf pause plock poll pthread_init \
Fred Drake35a092f1999-12-13 16:23:35 +00001016 putenv readlink \
Andrew M. Kuchling8d2f2b22000-07-13 01:26:58 +00001017 select setegid seteuid setgid \
Thomas Wouters3a584202000-08-05 23:28:51 +00001018 setlocale setregid setreuid setsid setpgid setuid setvbuf \
Fred Drake35a092f1999-12-13 16:23:35 +00001019 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
Fred Drake89143df1999-12-09 22:03:25 +00001020 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Thomas Wouters70c21a12000-07-14 14:28:33 +00001021 truncate uname waitpid _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001022
Fred Drake8cef4cf2000-06-28 16:40:38 +00001023# check for openpty and forkpty
1024
1025AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1026AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1027
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001028# check for long file support functions
1029AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1030
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001031AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Thomas Wouters3a584202000-08-05 23:28:51 +00001032AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1033AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1034AC_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 +00001035
1036# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001037AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00001038AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001039AC_STRUCT_TIMEZONE
1040
1041AC_MSG_CHECKING(for time.h that defines altzone)
1042AC_CACHE_VAL(ac_cv_header_time_altzone,
1043[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1044 ac_cv_header_time_altzone=yes,
1045 ac_cv_header_time_altzone=no)])
1046AC_MSG_RESULT($ac_cv_header_time_altzone)
1047if test $ac_cv_header_time_altzone = yes; then
1048 AC_DEFINE(HAVE_ALTZONE)
1049fi
1050
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001051was_it_defined=no
1052AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001053AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001054#include <sys/types.h>
1055#include <sys/select.h>
1056#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001057], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1058AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001059
1060# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001061
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001062AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001063AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001064
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001065works=no
1066AC_MSG_CHECKING(for working volatile)
1067AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1068AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00001069
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001070works=no
1071AC_MSG_CHECKING(for working signed char)
1072AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1073AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001074
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001075have_prototypes=no
1076AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001077AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1078AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001079AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001080
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001081works=no
1082AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001083AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001084#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00001085int foo(int x, ...) {
1086 va_list va;
1087 va_start(va, x);
1088 va_arg(va, int);
1089 va_arg(va, char *);
1090 va_arg(va, double);
1091 return 0;
1092}
1093], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001094AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1095AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001096
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001097if test "$have_prototypes" = yes; then
1098bad_prototypes=no
1099AC_MSG_CHECKING(for bad exec* prototypes)
1100AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1101 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1102AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001103fi
1104
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001105bad_forward=no
1106AC_MSG_CHECKING(for bad static forward)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001107AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001108struct s { int a; int b; };
1109static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001110int foobar() {
1111 static int random;
1112 random = (int) &foo;
1113 return random;
1114}
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001115static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001116main() {
1117 exit(!((int)&foo == foobar()));
1118}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001119], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
1120AC_MSG_RESULT($bad_forward)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001121
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001122va_list_is_array=no
1123AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001124AC_TRY_COMPILE([
1125#ifdef HAVE_STDARG_PROTOTYPES
1126#include <stdarg.h>
1127#else
1128#include <varargs.h>
1129#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001130], [va_list list1, list2; list1 = list2;], ,
1131AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1132AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001133
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001134# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1135AC_CHECK_FUNC(gethostbyname_r, [
1136 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1137 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1138 OLD_CFLAGS=$CFLAGS
1139 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1140 AC_TRY_COMPILE([
1141# include <netdb.h>
1142 ], [
1143 char *name;
1144 struct hostent *he, *res;
1145 char buffer[2048];
1146 int buflen = 2048;
1147 int h_errnop;
1148
1149 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1150 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001151 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001152 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1153 AC_MSG_RESULT(yes)
1154 ], [
1155 AC_MSG_RESULT(no)
1156 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1157 AC_TRY_COMPILE([
1158# include <netdb.h>
1159 ], [
1160 char *name;
1161 struct hostent *he;
1162 char buffer[2048];
1163 int buflen = 2048;
1164 int h_errnop;
1165
1166 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1167 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001168 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001169 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1170 AC_MSG_RESULT(yes)
1171 ], [
1172 AC_MSG_RESULT(no)
1173 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1174 AC_TRY_COMPILE([
1175# include <netdb.h>
1176 ], [
1177 char *name;
1178 struct hostent *he;
1179 struct hostent_data data;
1180
1181 (void) gethostbyname_r(name, he, &data);
1182 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001183 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001184 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1185 AC_MSG_RESULT(yes)
1186 ], [
1187 AC_MSG_RESULT(no)
1188 ])
1189 ])
1190 ])
1191 CFLAGS=$OLD_CFLAGS
1192], [
Thomas Wouters3a584202000-08-05 23:28:51 +00001193 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001194])
1195AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1196AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1197AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001198AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001199AC_SUBST(HAVE_GETHOSTBYNAME)
1200
Guido van Rossum627b2d71993-12-24 10:39:16 +00001201# checks for system services
1202# (none yet)
1203
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001204# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00001205AC_CHECK_FUNC(__fpu_control,
1206 [],
1207 [AC_CHECK_LIB(ieee, __fpu_control)
1208])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001209
Guido van Rossum93274221997-05-09 02:42:00 +00001210# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00001211AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001212AC_ARG_WITH(fpectl,
1213[ --with-fpectl enable SIGFPE catching], [
Guido van Rossum93274221997-05-09 02:42:00 +00001214if test "$withval" != no
1215then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1216else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00001217fi],
1218[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00001219
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001220# check for --with-libm=...
1221AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001222case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00001223Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001224next) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001225BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001226*) LIBM=-lm
1227esac
Guido van Rossum93274221997-05-09 02:42:00 +00001228AC_MSG_CHECKING(for --with-libm=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001229AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001230if test "$withval" = no
1231then LIBM=
1232 AC_MSG_RESULT(force LIBM empty)
1233elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001234then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001235 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001236else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001237fi],
1238[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001239
1240# check for --with-libc=...
1241AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00001242AC_MSG_CHECKING(for --with-libc=STRING)
Barry Warsawc0d24d82000-06-29 16:12:00 +00001243AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001244if test "$withval" = no
1245then LIBC=
1246 AC_MSG_RESULT(force LIBC empty)
1247elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001248then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001249 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001250else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001251fi],
1252[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001253
Guido van Rossum4c3f57c2001-01-10 20:40:46 +00001254# check for --with-check-import-case
1255AC_ARG_WITH(check-import-case,
1256[ --with-check-import-case enable imported module name case checking],,)
1257AC_MSG_CHECKING(for --with-check-import-case)
1258if test "$with_check_import_case"
1259then
1260 AC_DEFINE(CHECK_IMPORT_CASE)
1261 AC_MSG_RESULT(yes)
1262else
1263 AC_MSG_RESULT(no)
1264fi
1265
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001266# check for hypot() in math library
1267LIBS_SAVE=$LIBS
1268LIBS="$LIBS $LIBM"
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001269AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001270LIBS=$LIBS_SAVE
1271
Guido van Rossumad713701997-07-10 22:42:38 +00001272# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +00001273AC_MSG_CHECKING(what malloc(0) returns)
1274AC_CACHE_VAL(ac_cv_malloc_zero,
1275[AC_TRY_RUN([#include <stdio.h>
1276#ifdef HAVE_STDLIB
1277#include <stdlib.h>
1278#else
1279char *malloc(), *realloc();
1280int *free();
1281#endif
1282main() {
1283 char *p;
1284 p = malloc(0);
1285 if (p == NULL) exit(1);
1286 p = realloc(p, 0);
1287 if (p == NULL) exit(1);
1288 free(p);
1289 exit(0);
1290}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1291AC_MSG_RESULT($ac_cv_malloc_zero)
1292if test "$ac_cv_malloc_zero" = null
1293then
1294 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1295fi
1296
Guido van Rossumef2255b2000-03-10 22:30:29 +00001297# check for wchar.h
1298AC_CHECK_HEADER(wchar.h,
1299AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1300wchar_h="no"
1301)
1302
1303# check for usable wchar_t
1304usable_wchar_t="unkown"
1305AC_MSG_CHECKING(for usable wchar_t)
1306AC_TRY_RUN([
1307#include "wchar.h"
1308#include "wctype.h"
1309main() {
1310 wchar_t s;
1311 if (sizeof(s) == 2)
1312 exit(0);
1313 else
1314 exit(1);
1315}
1316],
1317AC_DEFINE(HAVE_USABLE_WCHAR_T) usable_wchar_t="yes",
1318usable_wchar_t="no")
1319AC_MSG_RESULT($usable_wchar_t)
1320
1321# check for endianness
1322AC_C_BIGENDIAN
1323
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001324# Check whether right shifting a negative integer extends the sign bit
1325# or fills with zeros (like the Cray J90, according to Tim Peters).
1326AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00001327AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001328AC_TRY_RUN([
1329int main()
1330{
Vladimir Marangozova6180282000-07-12 05:05:06 +00001331 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001332}
Vladimir Marangozova6180282000-07-12 05:05:06 +00001333], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1334AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1335if test "$ac_cv_rshift_extends_sign" = no
1336then
1337 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1338fi
1339
Guido van Rossumcadfaec2001-01-05 14:45:49 +00001340# check for getc_unlocked and related locking functions
1341AC_MSG_CHECKING(for getc_unlocked() and friends)
1342AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1343AC_TRY_LINK([#include <stdio.h>],[
1344 FILE *f = fopen("/dev/null", "r");
1345 flockfile(f);
1346 getc_unlocked(f);
1347 funlockfile(f);
1348], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1349AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1350if test "$ac_cv_have_getc_unlocked" = yes
1351then
1352 AC_DEFINE(HAVE_GETC_UNLOCKED)
1353fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001354
Guido van Rossum95713eb2000-05-18 20:53:31 +00001355# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1356# Add sys/socket.h to confdefs.h
1357cat >> confdefs.h <<\EOF
1358#ifdef HAVE_SYS_SOCKET_H
1359#include <sys/socket.h>
1360#endif
1361EOF
1362AC_CHECK_TYPE(socklen_t, int)
1363
Fred Drake036144d2000-10-26 17:09:35 +00001364AC_MSG_CHECKING(for Modules/Setup)
1365if test ! -f Modules/Setup ; then
Fred Drake884d3ba2000-11-02 17:52:56 +00001366 if test ! -d Modules ; then
1367 mkdir Modules
1368 fi
Fred Drake036144d2000-10-26 17:09:35 +00001369 cp "$srcdir/Modules/Setup.dist" Modules/Setup
1370 AC_MSG_RESULT(creating)
1371else
1372 AC_MSG_RESULT(already exists)
1373fi
1374
Guido van Rossum627b2d71993-12-24 10:39:16 +00001375# generate output files
Guido van Rossumb418f891996-07-30 18:06:02 +00001376AC_OUTPUT(Makefile \
1377 Objects/Makefile \
1378 Parser/Makefile \
Sjoerd Mullender59bb0802000-08-17 11:38:18 +00001379 Grammar/Makefile \
Guido van Rossumb418f891996-07-30 18:06:02 +00001380 Python/Makefile \
Guido van Rossum009f7871997-12-04 00:51:42 +00001381 Modules/Makefile.pre \
Barry Warsawef82cd72000-06-30 16:21:01 +00001382 Modules/Setup.config)