blob: 890aae2bd059a6013087a5eed7f592a0b4a57162 [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 Rossum6db412b2001-04-18 04:37:57 +00009VERSION=2.2
Guido van Rossum642b6781997-07-19 19:35:41 +000010
Neil Schemenauer4edbc2a2001-03-22 00:34:03 +000011# Arguments passed to configure.
12AC_SUBST(CONFIG_ARGS)
13CONFIG_ARGS="$ac_configure_args"
14
Guido van Rossum3dc0a512000-10-05 18:00:06 +000015# NEXTSTEP|MacOSX|Darwin stuff
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000016if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000017
18 AC_MSG_CHECKING(for --with-next-archs)
19 AC_ARG_WITH(next-archs,
Barry Warsawc0d24d8b2000-06-29 16:12:00 +000020 [ --with-next-archs='arch1 arch2 ..' build MAB binary], [
Guido van Rossum4b6b5791996-09-09 20:09:34 +000021 if test -n "$withval"; then
Guido van Rossum2bb4f551996-09-10 18:19:59 +000022 ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval`
23 # GCC does not currently support multi archs on the NeXT
24 with_gcc=no
Guido van Rossum4b6b5791996-09-09 20:09:34 +000025 fi
26 AC_MSG_RESULT($with_next_archs)
27 ], [AC_MSG_RESULT(none: using `arch`)])
28
29 if test -z "$MACHDEP"
30 then
Guido van Rossum3dc0a512000-10-05 18:00:06 +000031 ac_sys_system=`uname -s`
32 if test "$ac_sys_system" = "Darwin" ; then
33 ac_sys_release=`uname -r`
34 else
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000035 set X `hostinfo | egrep '(NeXT Mach|Kernel Release).*:' | \
Guido van Rossum3dc0a512000-10-05 18:00:06 +000036 sed -e 's/://' -e 's/\./_/'` && \
37 ac_sys_system=next && ac_sys_release=$4
38 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000039
Guido van Rossum3dc0a512000-10-05 18:00:06 +000040 MACHDEP="$ac_sys_system$ac_sys_release"
Guido van Rossumb418f891996-07-30 18:06:02 +000041 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000042fi
Guido van Rossumb418f891996-07-30 18:06:02 +000043
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000044AC_ARG_WITH(next-framework,
Guido van Rossum3dc0a512000-10-05 18:00:06 +000045[ --with-next-framework Build (OpenStep|Rhapsody|MacOSX|Darwin) framework],,)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +000046AC_ARG_WITH(dyld,
Guido van Rossum3dc0a512000-10-05 18:00:06 +000047[ --with-dyld Use (OpenStep|Rhapsody|MacOSX|Darwin) dynamic linker],,)
Guido van Rossum91922671997-10-09 20:24:13 +000048
Guido van Rossumb418f891996-07-30 18:06:02 +000049# Set name for machine-dependent library files
50AC_SUBST(MACHDEP)
51AC_MSG_CHECKING(MACHDEP)
52if test -z "$MACHDEP"
53then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000054 ac_sys_system=`uname -s`
Guido van Rossum2242f2f2001-04-11 20:58:20 +000055 if test "$ac_sys_system" = "AIX" -o \
56 "$ac_sys_system" = "Monterey64" -o \
57 "$ac_sys_system" = "UnixWare"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000058 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +000059 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +000060 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +000061 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000062 ac_md_system=`echo $ac_sys_system |
63 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
64 ac_md_release=`echo $ac_sys_release |
65 tr -d '[/ ]' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +000066 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +000067
Guido van Rossumbcd91e01997-03-20 20:46:29 +000068 case $MACHDEP in
Guido van Rossumb97ef171997-09-28 05:44:03 +000069 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +000070 esac
71fi
Guido van Rossum91922671997-10-09 20:24:13 +000072
73#
74# SGI compilers allow the specification of the both the ABI and the
75# ISA on the command line. Depending on the values of these switches,
76# different and often incompatable code will be generated.
77#
78# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
79# thus supply support for various ABI/ISA combinations. The MACHDEP
80# variable is also adjusted.
81#
82AC_SUBST(SGI_ABI)
83if test ! -z "$SGI_ABI"
84then
85 CC="cc $SGI_ABI"
86 LDFLAGS="$SGI_ABI $LDFLAGS"
87 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
88fi
Guido van Rossumb418f891996-07-30 18:06:02 +000089AC_MSG_RESULT($MACHDEP)
90
Guido van Rossum627b2d71993-12-24 10:39:16 +000091# checks for alternative programs
Guido van Rossum5739e7e1995-01-20 16:50:53 +000092AC_MSG_CHECKING(for --without-gcc)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +000093AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
Guido van Rossum433c8ad1994-08-01 12:07:07 +000094 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +000095 no) CC=cc
96 without_gcc=yes;;
97 yes) CC=gcc
98 without_gcc=no;;
99 *) CC=$withval
100 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000101 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000102 case $ac_sys_system in
Guido van Rossum55a214e1995-09-13 17:48:09 +0000103 OSF1) CC=cc
104 without_gcc=;;
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000105 AIX*) CC=cc_r
106 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000107 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000108 case $BE_HOST_CPU in
109 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000110 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000111 without_gcc=yes
Fred Drake5790be12000-10-09 17:06:13 +0000112 OPT="-O -D'DL_EXPORT(RTYPE)=__declspec(dllexport) RTYPE' -D'DL_IMPORT(RTYPE)=__declspec(dllexport) RTYPE' -export pragma"
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000113 CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000114 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000115 ;;
116 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000117 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000118 without_gcc=no
Fred Drake5790be12000-10-09 17:06:13 +0000119 OPT=-O
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000120 ;;
121 *)
Fred Drake5790be12000-10-09 17:06:13 +0000122 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000123 ;;
124 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000125 AR="\$(srcdir)/Modules/ar_beos"
126 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000127 ;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000128 Monterey*)
129 RANLIB=:
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000130 without_gcc=
131 ;;
132 UnixWare*)
133 RANLIB=:
134 without_gcc=
135 ;;
136 *)
137 without_gcc=no
138 ;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000139 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000140AC_MSG_RESULT($without_gcc)
141
Guido van Rossum27552902001-01-23 01:52:26 +0000142AC_SUBST(CXX)
Guido van Rossum95012191999-12-16 17:50:52 +0000143AC_SUBST(MAINOBJ)
Fred Drakea1a84e72001-03-06 05:52:16 +0000144MAINOBJ=python.o
Guido van Rossum95012191999-12-16 17:50:52 +0000145AC_MSG_CHECKING(for --with-cxx=<compiler>)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000146AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
Martin v. Löwis537970f2000-12-13 17:37:02 +0000147 check_cxx=no
Guido van Rossum95012191999-12-16 17:50:52 +0000148 case $withval in
149 no) CXX=
150 with_cxx=no;;
151 *) CXX=$withval
Fred Drakea1a84e72001-03-06 05:52:16 +0000152 MAINOBJ=ccpython.o
Guido van Rossum95012191999-12-16 17:50:52 +0000153 with_cxx=$withval;;
154 esac], [
155 with_cxx=no
Martin v. Löwis537970f2000-12-13 17:37:02 +0000156 check_cxx=yes
Guido van Rossum95012191999-12-16 17:50:52 +0000157])
158AC_MSG_RESULT($with_cxx)
Martin v. Löwis537970f2000-12-13 17:37:02 +0000159
160dnl The following fragment works similar to AC_PROG_CXX.
161dnl It does not fail if CXX is not found, and it is not executed if
162dnl --with-cxx was given.
163dnl Finally, it does not test whether CXX is g++.
164
165if test "$check_cxx" = "yes"
166then
167 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
168 if test "$CXX" = "notfound"
169 then
170 CXX=
171 else
172 AC_PROG_CXX_WORKS
173 fi
174fi
175
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000176# If the user switches compilers, we can't believe the cache
177if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
178then
179 AC_ERROR(cached CC is different -- throw away $cache_file
180(it is also a good idea to do 'make clean' before compiling))
181fi
182
Guido van Rossum627b2d71993-12-24 10:39:16 +0000183AC_PROG_CC
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000184AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000185AC_MSG_CHECKING(for --with-suffix)
186AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
187 case $withval in
188 no) EXEEXT=;;
189 yes) EXEEXT=.exe;;
190 *) EXEEXT=$withval;;
191 esac])
192AC_MSG_RESULT($EXEEXT)
Guido van Rossumfb842551997-08-06 23:42:07 +0000193
Guido van Rossumdd997f71998-10-07 19:58:26 +0000194case $MACHDEP in
195bsdos*)
196 case $CC in
197 gcc) CC="$CC -D_HAVE_BSDI";;
198 esac;;
199esac
200
Guido van Rossum84561611997-08-21 00:08:11 +0000201case $ac_sys_system in
202hp*|HP*)
203 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000204 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000205 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000206Monterey*)
207 case $CC in
208 cc) CC="$CC -Wl,-Bexport";;
209 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000210SunOS*)
211 # Some functions have a prototype only with that define, e.g. confstr
212 AC_DEFINE(__EXTENSIONS__)
213 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000214esac
215
Martin v. Löwise8964d42001-03-06 12:09:07 +0000216
Neil Schemenauer61c51152001-01-26 16:18:16 +0000217AC_SUBST(LIBRARY)
218AC_MSG_CHECKING(LIBRARY)
219if test -z "$LIBRARY"
220then
221 LIBRARY='libpython$(VERSION).a'
222fi
223AC_MSG_RESULT($LIBRARY)
224
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000225# LDLIBRARY is the name of the library to link against (as opposed to the
226# name of the library into which to insert object files). On systems
227# without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000228# the Makefiles). On Cygwin LDLIBRARY is the import library, DLLLIBRARY is the
229# shared (i.e., DLL) library.
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000230AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000231AC_SUBST(DLLLIBRARY)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000232LDLIBRARY="$LIBRARY"
Guido van Rossum27552902001-01-23 01:52:26 +0000233DLLLIBRARY=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000234
Guido van Rossumfb842551997-08-06 23:42:07 +0000235# LINKCC is the command that links the python executable -- default is $(CC).
Fred Drake5790be12000-10-09 17:06:13 +0000236# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000237# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000238AC_SUBST(LINKCC)
239AC_MSG_CHECKING(LINKCC)
240if test -z "$LINKCC"
241then
242 case $ac_sys_system in
243 AIX*)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000244 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000245 dgux*)
246 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000247 Monterey64*)
248 LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
Guido van Rossum25f93031997-08-18 16:00:04 +0000249 *) LINKCC="\$(PURIFY) \$(CC)";;
Guido van Rossumfb842551997-08-06 23:42:07 +0000250 esac
251fi
252AC_MSG_RESULT($LINKCC)
253
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000254AC_MSG_CHECKING(LDLIBRARY)
255
256# NeXT framework builds require that the 'ar' library be converted into
257# a bundle using libtool.
258if test "$with_next_framework"
259then
260 LDLIBRARY='libpython$(VERSION).dylib'
261fi
262
263# DG/UX requires some fancy ld contortions to produce a .so from an .a
Fred Drake5790be12000-10-09 17:06:13 +0000264case $MACHDEP in
265dguxR4)
266 LDLIBRARY='libpython$(VERSION).so'
267 OPT="$OPT -pic"
268 ;;
269beos*)
270 LDLIBRARY='libpython$(VERSION).so'
271 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000272cygwin*)
273 LDLIBRARY='libpython$(VERSION).dll.a'
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000274 DLLLIBRARY='libpython$(VERSION).dll'
Guido van Rossumaef734b2001-01-10 21:09:12 +0000275 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000276unixware*)
277 LDLIBRARY='libpython$(VERSION).so'
278 ;;
Fred Drake5790be12000-10-09 17:06:13 +0000279esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000280AC_MSG_RESULT($LDLIBRARY)
281
Guido van Rossum627b2d71993-12-24 10:39:16 +0000282AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000283AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000284AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000285
286case $MACHDEP in
287bsdos*)
288 # install -d does not work on BSDI
289 if test -z "$INSTALL"
290 then
291 INSTALL="${srcdir}/install-sh -c"
292 fi
293esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000294AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000295
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000296# Not every filesystem supports hard links
297AC_SUBST(LN)
298if test -z "$LN" ; then
299 case $ac_sys_system in
300 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000301 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000302 *) LN=ln;;
303 esac
304fi
305
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000306# Optimizer/debugger flags
Guido van Rossumb418f891996-07-30 18:06:02 +0000307AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000308if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000309then
Guido van Rossumb5875b61997-07-18 23:29:09 +0000310 case $GCC in
311 yes)
312 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000313 yes)
314 OPT="-g -O2 -Wall -Wstrict-prototypes";;
315 *)
316 OPT="-O2 -Wall -Wstrict-prototypes";;
Guido van Rossumb5875b61997-07-18 23:29:09 +0000317 esac
318 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000319 *)
320 case $ac_sys_system in
321 UnixWare*)
322 OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
323 *)
324 OPT="-O";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000325 esac
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000326 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000327fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000328
Trent Mick635f6fb2000-08-23 21:33:05 +0000329# The current (beta) Monterey compiler dies with optimizations
330case $ac_sys_system in
331Monterey*) OPT="";;
332esac
333
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000334if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000335then
336 OPT="$OPT $ac_arch_flags"
337fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000338# checks for UNIX variants that set C preprocessor variables
339AC_AIX
Guido van Rossum627b2d71993-12-24 10:39:16 +0000340AC_MINIX
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000341
Guido van Rossum91922671997-10-09 20:24:13 +0000342AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
343AC_CACHE_VAL(ac_cv_opt_olimit_ok,
344[ac_save_cc="$CC"
345CC="$CC -OPT:Olimit=0"
346AC_TRY_RUN([int main() { return 0; }],
347 ac_cv_opt_olimit_ok=yes,
348 ac_cv_opt_olimit_ok=no)
349CC="$ac_save_cc"])
350AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000351if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000352 case $ac_sys_system in
353 Darwin*) OPT="$OPT" ;;
354 *) OPT="$OPT -OPT:Olimit=0";;
355 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000356else
357 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
358 AC_CACHE_VAL(ac_cv_olimit_ok,
359 [ac_save_cc="$CC"
360 CC="$CC -Olimit 1500"
361 AC_TRY_RUN([int main() { return 0; }],
362 ac_cv_olimit_ok=yes,
363 ac_cv_olimit_ok=no)
364 CC="$ac_save_cc"])
365 AC_MSG_RESULT($ac_cv_olimit_ok)
366 if test $ac_cv_olimit_ok = yes; then
367 OPT="$OPT -Olimit 1500"
368 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000369fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000370
Fred Drakece81d592000-07-09 14:39:29 +0000371dnl # check for ANSI or K&R ("traditional") preprocessor
372dnl AC_MSG_CHECKING(for C preprocessor type)
373dnl AC_TRY_COMPILE([
374dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
375dnl int foo;
376dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
377dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
378dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +0000379
Guido van Rossum627b2d71993-12-24 10:39:16 +0000380# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000381AC_HEADER_STDC
Andrew M. Kuchling5821b772000-08-25 01:14:08 +0000382AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
Eric S. Raymond13603592001-01-16 15:01:26 +0000383signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
Fred Drake2ca5f3b2001-05-11 16:10:56 +0000384sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
Guido van Rossum95713eb2000-05-18 20:53:31 +0000385sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \
Fred Drakeae90f8d2000-09-15 03:38:12 +0000386sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
387ndbm.h db1/ndbm.h gdbm/ndbm.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000388AC_HEADER_DIRENT
Guido van Rossum627b2d71993-12-24 10:39:16 +0000389
390# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000391was_it_defined=no
392AC_MSG_CHECKING(for clock_t in time.h)
393AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
394AC_MSG_RESULT($was_it_defined)
395
Guido van Rossum300fda71996-08-19 21:58:16 +0000396# Add some code to confdefs.h so that the test for off_t works on SCO
397cat >> confdefs.h <<\EOF
398#if defined(SCO_DS)
399#undef _OFF_T
400#endif
401EOF
402
Guido van Rossumef2255b2000-03-10 22:30:29 +0000403# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000404AC_TYPE_MODE_T
405AC_TYPE_OFF_T
406AC_TYPE_PID_T
407AC_TYPE_SIGNAL
408AC_TYPE_SIZE_T
409AC_TYPE_UID_T
Guido van Rossum627b2d71993-12-24 10:39:16 +0000410
Guido van Rossumef2255b2000-03-10 22:30:29 +0000411# Sizes of various common basic types
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000412AC_CHECK_SIZEOF(int)
413AC_CHECK_SIZEOF(long)
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000414AC_CHECK_SIZEOF(void *)
Guido van Rossumef2255b2000-03-10 22:30:29 +0000415AC_CHECK_SIZEOF(char)
416AC_CHECK_SIZEOF(short)
417AC_CHECK_SIZEOF(float)
418AC_CHECK_SIZEOF(double)
Fred Drakea3f6e912000-06-29 20:44:47 +0000419AC_CHECK_SIZEOF(fpos_t)
Guido van Rossumac405f61994-09-12 10:56:06 +0000420
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000421AC_MSG_CHECKING(for long long support)
422have_long_long=no
423AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
424AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000425if test "$have_long_long" = yes ; then
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000426AC_CHECK_SIZEOF(long long)
427fi
428
Barry Warsawbc7c7f92000-08-18 04:53:33 +0000429AC_MSG_CHECKING(for uintptr_t support)
430have_uintptr_t=no
431AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
432AC_MSG_RESULT($have_uintptr_t)
433if test "$have_uintptr_t" = yes ; then
434AC_CHECK_SIZEOF(uintptr_t)
435fi
436
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000437# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
438AC_MSG_CHECKING(size of off_t)
439AC_CACHE_VAL(ac_cv_sizeof_off_t,
440[AC_TRY_RUN([#include <stdio.h>
441#include <sys/types.h>
442main()
443{
444 FILE *f=fopen("conftestval", "w");
445 if (!f) exit(1);
446 fprintf(f, "%d\n", sizeof(off_t));
447 exit(0);
448}], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
449])
450AC_MSG_RESULT($ac_cv_sizeof_off_t)
451AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
452
453AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000454if test "$have_long_long" = yes -a \
455 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
456 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000457 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
458 AC_MSG_RESULT(yes)
459else
460 AC_MSG_RESULT(no)
461fi
462
Fred Drakea3f6e912000-06-29 20:44:47 +0000463# AC_CHECK_SIZEOF() doesn't include <time.h>.
464AC_MSG_CHECKING(size of time_t)
465AC_CACHE_VAL(ac_cv_sizeof_time_t,
466[AC_TRY_RUN([#include <stdio.h>
467#include <time.h>
468main()
469{
470 FILE *f=fopen("conftestval", "w");
471 if (!f) exit(1);
472 fprintf(f, "%d\n", sizeof(time_t));
473 exit(0);
474}], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
475])
476AC_MSG_RESULT($ac_cv_sizeof_time_t)
477AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
478
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000479
Trent Mick635f6fb2000-08-23 21:33:05 +0000480# if have pthread_t then define SIZEOF_PTHREAD_T
481AC_MSG_CHECKING(for pthread_t)
482have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +0000483AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +0000484AC_MSG_RESULT($have_pthread_t)
485if test "$have_pthread_t" = yes ; then
486 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
487 AC_MSG_CHECKING(size of pthread_t)
488 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
489 [AC_TRY_RUN([#include <stdio.h>
490 #include <pthread.h>
491 main()
492 {
493 FILE *f=fopen("conftestval", "w");
494 if (!f) exit(1);
495 fprintf(f, "%d\n", sizeof(pthread_t));
496 exit(0);
497 }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
498 ])
499 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
500 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
501fi
502
503
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000504# Minor variations in building a framework between NextStep versions 4 and 5
505AC_SUBST(LIBTOOL_CRUFT)
506case $ac_sys_system/$ac_sys_release in
Guido van Rossum5839e582000-10-09 19:52:35 +0000507 Darwin/*)
508 ns_undef_sym='_environ'
509 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym" ;;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000510 next/4*)
511 ns_undef_sym='__environ'
512 LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
513 next/5*)
514 ns_undef_sym='_environ'
515 LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
516esac
517
518AC_MSG_CHECKING(for --with-next-framework)
519if test "$with_next_framework"
520then
521 OPT="$OPT -fno-common"
522 # -U __environ is needed since bundles don't have access
523 # to crt0 when built but will always be linked against it
524 LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
525 AC_DEFINE(WITH_NEXT_FRAMEWORK)
526 AC_MSG_RESULT(yes)
527else
528 AC_MSG_RESULT(no)
529fi
530
531AC_MSG_CHECKING(for --with-dyld)
532if test "$with_next_framework" -o "$with_dyld"
533then
534 if test "$with_dyld"
535 then
536 AC_MSG_RESULT(yes)
537 else
538 AC_MSG_RESULT(required for framework build)
539 fi
540 AC_DEFINE(WITH_DYLD)
541 ns_dyld='set'
542else
543 AC_MSG_RESULT(no)
544fi
545
Guido van Rossumac405f61994-09-12 10:56:06 +0000546# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +0000547AC_SUBST(SO)
548AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000549AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000550AC_SUBST(CCSHARED)
551AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000552# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +0000553# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000554AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000555if test -z "$SO"
556then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000557 case $ac_sys_system in
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000558 hp*|HP*) SO=.sl;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000559 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000560 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000561 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000562fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000563AC_MSG_RESULT($SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000564# LDSHARED is the ld *command* used to create shared library
565# -- "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 +0000566# (Shared libraries in this instance are shared modules to be loaded into
567# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000568AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000569if test -z "$LDSHARED"
570then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000571 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000572 AIX*)
573 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
574 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
575 ;;
576 BeOS*)
577 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
578 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
579 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000580 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +0000581 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000582 SunOS/4*) LDSHARED="ld";;
Greg Ward57c9a6632000-05-26 12:22:54 +0000583 SunOS/5*)
584 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +0000585 then LDSHARED='$(CC) -shared'
Greg Ward57c9a6632000-05-26 12:22:54 +0000586 else LDSHARED="ld -G";
587 fi ;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000588 hp*|HP*) LDSHARED="ld -b";;
Guido van Rossum71001e41995-01-26 00:44:03 +0000589 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Guido van Rossum7d473291995-01-20 14:12:16 +0000590 DYNIX/ptx*) LDSHARED="ld -G";;
Guido van Rossum3dc0a512000-10-05 18:00:06 +0000591 Darwin/*|next/*)
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000592 if test "$ns_dyld"
Guido van Rossumacb14c72001-01-10 21:41:16 +0000593 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined suppress'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000594 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
595 fi
Guido van Rossum3dc0a512000-10-05 18:00:06 +0000596 if test "$with_next_framework" ; then
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000597 LDSHARED="$LDSHARED \$(LDLIBRARY)"
598 fi ;;
Guido van Rossum81652ab1996-07-21 02:53:27 +0000599 Linux*) LDSHARED="gcc -shared";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000600 dgux*) LDSHARED="ld -G";;
Guido van Rossum458e7fa1999-09-17 15:40:40 +0000601 BSD/OS*/4*) LDSHARED="gcc -shared";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000602 OpenBSD*) LDSHARED="ld -Bshareable";;
Guido van Rossumdf693651999-01-07 21:50:41 +0000603 NetBSD*)
604 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
605 then
606 LDSHARED="cc -shared"
607 else
608 LDSHARED="ld -Bshareable"
609 fi;;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000610 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +0000611 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +0000612 then
613 LDSHARED="cc -shared ${LDFLAGS}"
614 else
615 LDSHARED="ld -Bshareable ${LDFLAGS}"
616 fi;;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000617 UnixWare*)
618 if test "$GCC" = "yes"
619 then LDSHARED="$(CC) -shared"
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000620 else LDSHARED="ld -G -dy -Bdynamic"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000621 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000622 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000623 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000624 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000625 *) LDSHARED="ld";;
626 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000627fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000628AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000629BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +0000630# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000631# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000632AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000633if test -z "$CCSHARED"
634then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000635 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +0000636 SunOS*) if test "$GCC" = yes;
637 then CCSHARED="-fPIC";
638 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +0000639 hp*|HP*) if test "$GCC" = yes;
640 then CCSHARED="-fpic";
641 else CCSHARED="+z";
642 fi;;
Neil Schemenauer61c51152001-01-26 16:18:16 +0000643 Linux*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000644 BSD/OS*/4*) CCSHARED="-fpic";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000645 OpenBSD*) CCSHARED="-fpic";;
646 FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000647 UnixWare*)
648 if test "$GCC" = "yes"
649 then CCSHARED="-fPIC"
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000650 else CCSHARED="-KPIC -G -dy -Bdynamic"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000651 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000652 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000653 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000654 IRIX*/6*) case $CC in
655 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +0000656 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000657 esac;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000658 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000659 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000660fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000661AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000662# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000663# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000664AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000665if test -z "$LINKFORSHARED"
666then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000667 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000668 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000669 hp*|HP*)
Guido van Rossum304dd2d1997-10-20 23:10:56 +0000670 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000671 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum2d9feed1997-11-24 17:36:21 +0000672 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000673 # -u libsys_s pulls in all symbols in libsys
674 next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
675 # -u __dummy makes the linker aware of the objc runtime
676 # in System.framework; otherwise, __objcInit (referenced in
677 # crt1.o) gets erroneously defined as common, which breaks dynamic
678 # loading of any modules which reference it in System.framework
679 next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
Guido van Rossumacb14c72001-01-10 21:41:16 +0000680 Darwin/*) LINKFORSHARED="-u __dummy -framework System -framework Foundation" ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000681 UnixWare*) LINKFORSHARED="-dy -Bdynamic -Wl,-Bexport";;
Guido van Rossum300fda71996-08-19 21:58:16 +0000682 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +0000683 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000684 FreeBSD*|NetBSD*)
Guido van Rossumdf693651999-01-07 21:50:41 +0000685 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
686 then
687 LINKFORSHARED="-Wl,--export-dynamic"
688 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000689 SunOS/5*) case $CC in
690 *gcc*)
Guido van Rossum9c6ba9b2000-02-03 13:42:50 +0000691 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000692 then
693 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000694 fi;;
695 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000696 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000697fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000698AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000699
Neil Schemenauer61c51152001-01-26 16:18:16 +0000700AC_SUBST(CFLAGSFORSHARED)
701AC_MSG_CHECKING(CFLAGSFORSHARED)
702if test ! "$LIBRARY" = "$LDLIBRARY"
703then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +0000704 case $ac_sys_system in
705 CYGWIN*)
706 # Cygwin needs CCSHARED when building extension DLLs
707 # but not when building the interpreter DLL.
708 CFLAGSFORSHARED='';;
709 *)
710 CFLAGSFORSHARED='$(CCSHARED)'
711 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +0000712fi
713AC_MSG_RESULT($CFLAGSFORSHARED)
714
Guido van Rossum627b2d71993-12-24 10:39:16 +0000715# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000716AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
717AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000718
Skip Montanarocb853262000-08-30 22:29:48 +0000719# Check for --with-pydebug
720AC_MSG_CHECKING(for --with-pydebug)
721AC_ARG_WITH(pydebug,
722[ --with-pydebug build with Py_DEBUG defined], [
723if test "$withval" != no
724then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes)
725else AC_MSG_RESULT(no)
726fi],
727[AC_MSG_RESULT(no)])
728
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000729# checks for system dependent C++ extensions support
730case "$ac_sys_system" in
731 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
732 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
733 [loadAndInit("", 0, "")],
734 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
735 AC_MSG_RESULT(yes)],
736 [AC_MSG_RESULT(no)]);;
737 *) ;;
738esac
739
Guido van Rossum70c7f481998-03-26 18:44:10 +0000740# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
741# However on SGI IRIX, these exist but are broken.
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000742# BeOS' sockets are stashed in libnet.
743case "$ac_sys_system" in
744IRIX*) ;;
Guido van Rossum2cb56601998-05-07 13:25:56 +0000745*)
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000746AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000747AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +0000748;;
749esac
750case "$ac_sys_system" in
751BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000752AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
753;;
754esac
Guido van Rossum70c7f481998-03-26 18:44:10 +0000755
Guido van Rossumc5a39031996-07-31 17:35:03 +0000756AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000757AC_ARG_WITH(libs,
758[ --with-libs='lib1 ...' link against additional libs], [
Guido van Rossumc5a39031996-07-31 17:35:03 +0000759AC_MSG_RESULT($withval)
760LIBS="$withval $LIBS"
761], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000762
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000763# Determine if signalmodule should be used.
764AC_SUBST(USE_SIGNAL_MODULE)
765AC_SUBST(SIGNAL_OBJS)
766AC_MSG_CHECKING(for --with-signal-module)
767AC_ARG_WITH(signal-module,
768[ --with-signal-module disable/enable signal module])
769
770if test -z "$with_signal_module"
771then with_signal_module="yes"
772fi
773AC_MSG_RESULT($with_signal_module)
774
775if test "${with_signal_module}" = "yes"; then
776 USE_SIGNAL_MODULE=""
777 SIGNAL_OBJS=""
778else
779 USE_SIGNAL_MODULE="#"
780 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
781fi
782
Guido van Rossum3d15bd82001-01-10 18:53:48 +0000783# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +0000784AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000785USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +0000786
Guido van Rossum54d93d41997-01-22 20:51:58 +0000787AC_MSG_CHECKING(for --with-dec-threads)
788AC_SUBST(LDLAST)
789AC_ARG_WITH(dec-threads,
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000790[ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
791AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +0000792LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +0000793if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +0000794 with_thread="$withval";
795fi],
796AC_MSG_RESULT(no))
797
798AC_MSG_CHECKING(for --with-threads)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000799AC_ARG_WITH(threads,
800[ --with(out)-threads[=DIRECTORY] disable/enable thread support])
Guido van Rossum54d93d41997-01-22 20:51:58 +0000801
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000802# --with-thread is deprecated, but check for it anyway
Barry Warsawa0f3c5c2000-06-30 16:39:35 +0000803AC_ARG_WITH(thread,
804[ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
805with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000806
807if test -z "$with_threads"
808then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000809fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000810AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +0000811
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000812if test "$with_threads" = "no"
813then
814 USE_THREAD_MODULE="#"
815else
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000816 if test "$ac_sys_system" = "UnixWare"
817 then
818 CC="${CC} -Kthread"
819 LIBOBJS="$LIBOBJS thread.o"
820 AC_DEFINE(WITH_THREAD)
821 AC_DEFINE(_POSIX_THREADS)
822 USE_THREAD_MODULE=""
823 else
824 if test ! -z "$with_threads" -a -d "$with_threads"
825 then LDFLAGS="$LDFLAGS -L$with_threads"
826 fi
827 if test ! -z "$withval" -a -d "$withval"
828 then LDFLAGS="$LDFLAGS -L$withval"
829 fi
830 AC_DEFINE(_REENTRANT)
831 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
832 AC_DEFINE(C_THREADS)
833 LIBOBJS="$LIBOBJS thread.o"],[
834 AC_MSG_CHECKING(for --with-pth)
835 AC_ARG_WITH(pth,
836 [ --with-pth use GNU pth threading libraries], [
837 AC_MSG_RESULT($withval)
838 AC_DEFINE(WITH_THREAD)
839 AC_DEFINE(HAVE_PTH)
840 LIBS="-lpth $LIBS"
841 LIBOBJS="$LIBOBJS thread.o"],[
842 AC_MSG_RESULT(no)
843 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
844 AC_DEFINE(_POSIX_THREADS)
845 LIBS="-lpthread $LIBS"
846 LIBOBJS="$LIBOBJS thread.o"],[
847 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
848 case $ac_sys_system in
849 Darwin*) ;;
850 *) AC_DEFINE(_POSIX_THREADS);;
851 esac
852 LIBOBJS="$LIBOBJS thread.o"],[
853 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
854 AC_DEFINE(BEOS_THREADS)
855 LIBOBJS="$LIBOBJS thread.o"],[
856 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
857 AC_DEFINE(_POSIX_THREADS)
858 LIBS="$LIBS -lpthreads"
859 LIBOBJS="$LIBOBJS thread.o"], [
860 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
861 AC_DEFINE(_POSIX_THREADS)
862 LIBS="$LIBS -lc_r"
863 LIBOBJS="$LIBOBJS thread.o"], [
864 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
865 AC_DEFINE(_POSIX_THREADS)
866 LIBS="$LIBS -lthread"
867 LIBOBJS="$LIBOBJS thread.o"], [
868 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
869 AC_DEFINE(_POSIX_THREADS)
870 LIBS="$LIBS -lpthread"
871 LIBOBJS="$LIBOBJS thread.o"], [
872 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
873 AC_DEFINE(_POSIX_THREADS)
874 LIBS="$LIBS -lcma"
875 LIBOBJS="$LIBOBJS thread.o"],[
876 USE_THREAD_MODULE="#"])
877 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000878
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000879 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
880 LIBS="$LIBS -lmpc"
881 LIBOBJS="$LIBOBJS thread.o"
882 USE_THREAD_MODULE=""])
883 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
884 LIBS="$LIBS -lthread"
885 LIBOBJS="$LIBOBJS thread.o"
886 USE_THREAD_MODULE=""])
Jeremy Hylton1a2ca862000-10-16 16:59:12 +0000887
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000888 if test "$USE_THREAD_MODULE" != "#"
889 then
890 # If the above checks didn't disable threads, (at least) OSF1
891 # needs this '-threads' argument during linking.
892 case $ac_sys_system in
893 OSF1) LDLAST=-threads;;
894 esac
895 fi
Jeremy Hylton1a2ca862000-10-16 16:59:12 +0000896 fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000897fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000898
Barry Warsawef82cd72000-06-30 16:21:01 +0000899# Check for GC support
900AC_SUBST(USE_GC_MODULE)
901USE_GC_MODULE=""
902AC_MSG_CHECKING(for --with-cycle-gc)
903AC_ARG_WITH(cycle-gc,
904[ --with(out)-cycle-gc disable/enable garbage collection])
905
906if test -z "$with_cycle_gc"
907then with_cycle_gc="yes"
908fi
909if test "$with_cycle_gc" = "no"
910then
911 USE_GC_MODULE="#"
912else
913 AC_DEFINE(WITH_CYCLE_GC)
914fi
915AC_MSG_RESULT($with_cycle_gc)
916
Neil Schemenauera35c6882001-02-27 04:45:05 +0000917# Check for Python-specific malloc support
918AC_MSG_CHECKING(for --with-pymalloc)
919AC_ARG_WITH(pymalloc,
920[ --with(out)-pymalloc disable/enable specialized mallocs], [
921if test "$withval" != no
922then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
923else AC_MSG_RESULT(no)
924fi],
925[AC_MSG_RESULT(no)])
926
Barry Warsawef82cd72000-06-30 16:21:01 +0000927# Check for --with-wctype-functions
928AC_MSG_CHECKING(for --with-wctype-functions)
929AC_ARG_WITH(wctype-functions,
930[ --with-wctype-functions use wctype.h functions], [
931if test "$withval" != no
932then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
933else AC_MSG_RESULT(no)
934fi],
935[AC_MSG_RESULT(no)])
936
Guido van Rossum68242b51996-05-28 22:53:03 +0000937# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000938AC_SUBST(DLINCLDIR)
939DLINCLDIR=/
940
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000941AC_MSG_CHECKING(for --with-sgi-dl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000942AC_ARG_WITH(sgi-dl,
943[ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000944AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000945AC_DEFINE(WITH_SGI_DL)
Guido van Rossume97ee181999-12-20 21:27:22 +0000946DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000947dldir=$withval
Guido van Rossum40951012000-10-07 16:21:27 +0000948if test ! -z "$dldir" -a -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +0000949then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000950else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
951fi
952DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000953LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000954
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000955AC_MSG_CHECKING(for --with-dl-dld)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000956AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000957AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000958AC_DEFINE(WITH_DL_DLD)
Guido van Rossume97ee181999-12-20 21:27:22 +0000959DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000960dldir=`echo "$withval" | sed 's/,.*//'`
961dlddir=`echo "$withval" | sed 's/.*,//'`
Barry Warsaw7d1219d2000-10-05 18:45:53 +0000962if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +0000963then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000964else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
965fi
966DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000967LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000968
Guido van Rossume97ee181999-12-20 21:27:22 +0000969# the dlopen() function means we might want to use dynload_shlib.o. some
970# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +0000971AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +0000972
973# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
974# loading of modules.
975AC_SUBST(DYNLOADFILE)
976AC_MSG_CHECKING(DYNLOADFILE)
977if test -z "$DYNLOADFILE"
978then
979 case $ac_sys_system/$ac_sys_release in
980 AIX*) DYNLOADFILE="dynload_aix.o";;
981 BeOS*) DYNLOADFILE="dynload_beos.o";;
982 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Guido van Rossum5839e582000-10-09 19:52:35 +0000983 Darwin/*|next/*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +0000984 *)
985 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
986 # out any dynamic loading
987 if test "$ac_cv_func_dlopen" = yes
988 then DYNLOADFILE="dynload_shlib.o"
989 else DYNLOADFILE="dynload_stub.o"
990 fi
991 ;;
992 esac
993fi
994AC_MSG_RESULT($DYNLOADFILE)
995if test "$DYNLOADFILE" != "dynload_stub.o"
996then
997 AC_DEFINE(HAVE_DYNAMIC_LOADING)
998fi
999
Guido van Rossum627b2d71993-12-24 10:39:16 +00001000# checks for library functions
Thomas Wouters3a584202000-08-05 23:28:51 +00001001AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
Fred Drake35a092f1999-12-13 16:23:35 +00001002 flock fork fsync fdatasync fpathconf ftime ftruncate \
Andrew M. Kuchlinga9586c72001-01-08 17:58:56 +00001003 getgroups getlogin getpeername getpid getpwent getwd \
Andrew M. Kuchling898527b2000-06-18 14:54:13 +00001004 kill link lstat mkfifo mktime mremap \
Andrew M. Kuchling5821b772000-08-25 01:14:08 +00001005 nice pathconf pause plock poll pthread_init \
Fred Drake35a092f1999-12-13 16:23:35 +00001006 putenv readlink \
Andrew M. Kuchling8d2f2b22000-07-13 01:26:58 +00001007 select setegid seteuid setgid \
Thomas Wouters3a584202000-08-05 23:28:51 +00001008 setlocale setregid setreuid setsid setpgid setuid setvbuf \
Fred Drake35a092f1999-12-13 16:23:35 +00001009 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
Fred Drake89143df1999-12-09 22:03:25 +00001010 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Thomas Wouters70c21a12000-07-14 14:28:33 +00001011 truncate uname waitpid _getpty)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001012
Fred Drake8cef4cf2000-06-28 16:40:38 +00001013# check for openpty and forkpty
1014
1015AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1016AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1017
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001018# check for long file support functions
1019AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1020
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001021AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Thomas Wouters3a584202000-08-05 23:28:51 +00001022AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1023AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1024AC_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 +00001025
1026# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001027AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00001028AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001029AC_STRUCT_TIMEZONE
1030
1031AC_MSG_CHECKING(for time.h that defines altzone)
1032AC_CACHE_VAL(ac_cv_header_time_altzone,
1033[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1034 ac_cv_header_time_altzone=yes,
1035 ac_cv_header_time_altzone=no)])
1036AC_MSG_RESULT($ac_cv_header_time_altzone)
1037if test $ac_cv_header_time_altzone = yes; then
1038 AC_DEFINE(HAVE_ALTZONE)
1039fi
1040
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001041was_it_defined=no
1042AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001043AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001044#include <sys/types.h>
1045#include <sys/select.h>
1046#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001047], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1048AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001049
1050# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001051
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001052AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001053AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001054
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001055works=no
1056AC_MSG_CHECKING(for working volatile)
1057AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1058AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00001059
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001060works=no
1061AC_MSG_CHECKING(for working signed char)
1062AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1063AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001064
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001065have_prototypes=no
1066AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001067AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1068AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001069AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001070
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001071works=no
1072AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001073AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001074#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00001075int foo(int x, ...) {
1076 va_list va;
1077 va_start(va, x);
1078 va_arg(va, int);
1079 va_arg(va, char *);
1080 va_arg(va, double);
1081 return 0;
1082}
1083], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001084AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1085AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001086
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001087if test "$have_prototypes" = yes; then
1088bad_prototypes=no
1089AC_MSG_CHECKING(for bad exec* prototypes)
1090AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1091 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1092AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001093fi
1094
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001095bad_forward=no
1096AC_MSG_CHECKING(for bad static forward)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001097AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001098struct s { int a; int b; };
1099static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001100int foobar() {
1101 static int random;
1102 random = (int) &foo;
1103 return random;
1104}
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001105static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001106main() {
1107 exit(!((int)&foo == foobar()));
1108}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001109], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
1110AC_MSG_RESULT($bad_forward)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001111
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001112va_list_is_array=no
1113AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001114AC_TRY_COMPILE([
1115#ifdef HAVE_STDARG_PROTOTYPES
1116#include <stdarg.h>
1117#else
1118#include <varargs.h>
1119#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001120], [va_list list1, list2; list1 = list2;], ,
1121AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1122AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001123
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001124# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1125AC_CHECK_FUNC(gethostbyname_r, [
1126 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1127 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1128 OLD_CFLAGS=$CFLAGS
1129 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1130 AC_TRY_COMPILE([
1131# include <netdb.h>
1132 ], [
1133 char *name;
1134 struct hostent *he, *res;
1135 char buffer[2048];
1136 int buflen = 2048;
1137 int h_errnop;
1138
1139 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1140 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001141 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001142 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1143 AC_MSG_RESULT(yes)
1144 ], [
1145 AC_MSG_RESULT(no)
1146 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1147 AC_TRY_COMPILE([
1148# include <netdb.h>
1149 ], [
1150 char *name;
1151 struct hostent *he;
1152 char buffer[2048];
1153 int buflen = 2048;
1154 int h_errnop;
1155
1156 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1157 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001158 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001159 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1160 AC_MSG_RESULT(yes)
1161 ], [
1162 AC_MSG_RESULT(no)
1163 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1164 AC_TRY_COMPILE([
1165# include <netdb.h>
1166 ], [
1167 char *name;
1168 struct hostent *he;
1169 struct hostent_data data;
1170
1171 (void) gethostbyname_r(name, he, &data);
1172 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001173 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001174 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1175 AC_MSG_RESULT(yes)
1176 ], [
1177 AC_MSG_RESULT(no)
1178 ])
1179 ])
1180 ])
1181 CFLAGS=$OLD_CFLAGS
1182], [
Thomas Wouters3a584202000-08-05 23:28:51 +00001183 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001184])
1185AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1186AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1187AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001188AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001189AC_SUBST(HAVE_GETHOSTBYNAME)
1190
Guido van Rossum627b2d71993-12-24 10:39:16 +00001191# checks for system services
1192# (none yet)
1193
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001194# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00001195AC_CHECK_FUNC(__fpu_control,
1196 [],
1197 [AC_CHECK_LIB(ieee, __fpu_control)
1198])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001199
Guido van Rossum93274221997-05-09 02:42:00 +00001200# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00001201AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001202AC_ARG_WITH(fpectl,
1203[ --with-fpectl enable SIGFPE catching], [
Guido van Rossum93274221997-05-09 02:42:00 +00001204if test "$withval" != no
1205then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1206else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00001207fi],
1208[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00001209
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001210# check for --with-libm=...
1211AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001212case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00001213Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001214next) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001215BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001216*) LIBM=-lm
1217esac
Guido van Rossum93274221997-05-09 02:42:00 +00001218AC_MSG_CHECKING(for --with-libm=STRING)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001219AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001220if test "$withval" = no
1221then LIBM=
1222 AC_MSG_RESULT(force LIBM empty)
1223elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001224then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001225 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001226else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001227fi],
1228[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001229
1230# check for --with-libc=...
1231AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00001232AC_MSG_CHECKING(for --with-libc=STRING)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001233AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001234if test "$withval" = no
1235then LIBC=
1236 AC_MSG_RESULT(force LIBC empty)
1237elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001238then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001239 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001240else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001241fi],
1242[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001243
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001244# check for hypot() in math library
1245LIBS_SAVE=$LIBS
1246LIBS="$LIBS $LIBM"
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001247AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001248LIBS=$LIBS_SAVE
1249
Guido van Rossumad713701997-07-10 22:42:38 +00001250# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +00001251AC_MSG_CHECKING(what malloc(0) returns)
1252AC_CACHE_VAL(ac_cv_malloc_zero,
1253[AC_TRY_RUN([#include <stdio.h>
1254#ifdef HAVE_STDLIB
1255#include <stdlib.h>
1256#else
1257char *malloc(), *realloc();
1258int *free();
1259#endif
1260main() {
1261 char *p;
1262 p = malloc(0);
1263 if (p == NULL) exit(1);
1264 p = realloc(p, 0);
1265 if (p == NULL) exit(1);
1266 free(p);
1267 exit(0);
1268}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1269AC_MSG_RESULT($ac_cv_malloc_zero)
1270if test "$ac_cv_malloc_zero" = null
1271then
1272 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1273fi
1274
Guido van Rossumef2255b2000-03-10 22:30:29 +00001275# check for wchar.h
1276AC_CHECK_HEADER(wchar.h,
1277AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1278wchar_h="no"
1279)
1280
1281# check for usable wchar_t
1282usable_wchar_t="unkown"
1283AC_MSG_CHECKING(for usable wchar_t)
1284AC_TRY_RUN([
1285#include "wchar.h"
1286#include "wctype.h"
1287main() {
1288 wchar_t s;
1289 if (sizeof(s) == 2)
1290 exit(0);
1291 else
1292 exit(1);
1293}
1294],
1295AC_DEFINE(HAVE_USABLE_WCHAR_T) usable_wchar_t="yes",
1296usable_wchar_t="no")
1297AC_MSG_RESULT($usable_wchar_t)
1298
1299# check for endianness
1300AC_C_BIGENDIAN
1301
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001302# Check whether right shifting a negative integer extends the sign bit
1303# or fills with zeros (like the Cray J90, according to Tim Peters).
1304AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00001305AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001306AC_TRY_RUN([
1307int main()
1308{
Vladimir Marangozova6180282000-07-12 05:05:06 +00001309 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001310}
Vladimir Marangozova6180282000-07-12 05:05:06 +00001311], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1312AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1313if test "$ac_cv_rshift_extends_sign" = no
1314then
1315 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1316fi
1317
Guido van Rossumcadfaec2001-01-05 14:45:49 +00001318# check for getc_unlocked and related locking functions
1319AC_MSG_CHECKING(for getc_unlocked() and friends)
1320AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1321AC_TRY_LINK([#include <stdio.h>],[
1322 FILE *f = fopen("/dev/null", "r");
1323 flockfile(f);
1324 getc_unlocked(f);
1325 funlockfile(f);
1326], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1327AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1328if test "$ac_cv_have_getc_unlocked" = yes
1329then
1330 AC_DEFINE(HAVE_GETC_UNLOCKED)
1331fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001332
Guido van Rossum95713eb2000-05-18 20:53:31 +00001333# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1334# Add sys/socket.h to confdefs.h
1335cat >> confdefs.h <<\EOF
1336#ifdef HAVE_SYS_SOCKET_H
1337#include <sys/socket.h>
1338#endif
1339EOF
1340AC_CHECK_TYPE(socklen_t, int)
1341
Neil Schemenauerf25cf6c2001-03-04 06:39:33 +00001342# Add Python/ prefix to LIBOBJS
1343libobjs=$LIBOBJS
1344LIBOBJS=
1345for obj in $libobjs; do
1346 LIBOBJS="$LIBOBJS Python/$obj"
1347done
1348
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001349#AC_MSG_CHECKING(for Modules/Setup)
1350#if test ! -f Modules/Setup ; then
1351# if test ! -d Modules ; then
1352# mkdir Modules
1353# fi
1354# cp "$srcdir/Modules/Setup.dist" Modules/Setup
1355# AC_MSG_RESULT(creating)
1356#else
1357# AC_MSG_RESULT(already exists)
1358#fi
1359
1360AC_SUBST(SRCDIRS)
Neil Schemenaueracbf9ef2001-02-27 02:15:14 +00001361SRCDIRS="Parser Grammar Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001362AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001363for dir in $SRCDIRS; do
1364 if test ! -d $dir; then
1365 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00001366 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001367done
1368AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00001369
Guido van Rossum627b2d71993-12-24 10:39:16 +00001370# generate output files
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001371AC_OUTPUT(Makefile.pre Modules/Setup.config)
Neil Schemenauer61c51152001-01-26 16:18:16 +00001372
1373echo "creating Setup"
1374if test ! -f Modules/Setup
1375then
1376 cp $srcdir/Modules/Setup.dist Modules/Setup
1377fi
1378
1379echo "creating Setup.local"
1380if test ! -f Modules/Setup.local
1381then
1382 echo "# Edit this file for local setup changes" >Modules/Setup.local
1383fi
1384
1385echo "creating Makefile"
1386$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1387 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00001388 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00001389mv config.c Modules