blob: 3e0248ac75b3ef162b1b7e74dbebb552743a43c4 [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`
Martin v. Löwis130fb172001-07-19 11:00:41 +000055 if test "$ac_sys_system" = "AIX" -o "$ac_sys_system" = "Monterey64"; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000056 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +000057 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +000058 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +000059 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000060 ac_md_system=`echo $ac_sys_system |
61 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
62 ac_md_release=`echo $ac_sys_release |
63 tr -d '[/ ]' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +000064 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +000065
Guido van Rossumbcd91e01997-03-20 20:46:29 +000066 case $MACHDEP in
Guido van Rossumb97ef171997-09-28 05:44:03 +000067 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +000068 esac
69fi
Guido van Rossum91922671997-10-09 20:24:13 +000070
71#
72# SGI compilers allow the specification of the both the ABI and the
73# ISA on the command line. Depending on the values of these switches,
74# different and often incompatable code will be generated.
75#
76# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
77# thus supply support for various ABI/ISA combinations. The MACHDEP
78# variable is also adjusted.
79#
80AC_SUBST(SGI_ABI)
81if test ! -z "$SGI_ABI"
82then
83 CC="cc $SGI_ABI"
84 LDFLAGS="$SGI_ABI $LDFLAGS"
85 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
86fi
Guido van Rossumb418f891996-07-30 18:06:02 +000087AC_MSG_RESULT($MACHDEP)
88
Guido van Rossum627b2d71993-12-24 10:39:16 +000089# checks for alternative programs
Guido van Rossum5739e7e1995-01-20 16:50:53 +000090AC_MSG_CHECKING(for --without-gcc)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +000091AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [
Guido van Rossum433c8ad1994-08-01 12:07:07 +000092 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +000093 no) CC=cc
94 without_gcc=yes;;
95 yes) CC=gcc
96 without_gcc=no;;
97 *) CC=$withval
98 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +000099 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000100 case $ac_sys_system in
Guido van Rossum55a214e1995-09-13 17:48:09 +0000101 OSF1) CC=cc
102 without_gcc=;;
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000103 AIX*) CC=cc_r
104 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000105 BeOS*)
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000106 case $BE_HOST_CPU in
107 ppc)
Fred Drake5790be12000-10-09 17:06:13 +0000108 CC=mwcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000109 without_gcc=yes
Fred Drake5790be12000-10-09 17:06:13 +0000110 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 +0000111 CCSHARED="-UDL_IMPORT -D'DL_IMPORT(RTYPE)=__declspec(dllimport) RTYPE'"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000112 LDFLAGS="$LDFLAGS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000113 ;;
114 x86)
Fred Drake5790be12000-10-09 17:06:13 +0000115 CC=gcc
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000116 without_gcc=no
Fred Drake5790be12000-10-09 17:06:13 +0000117 OPT=-O
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000118 ;;
119 *)
Fred Drake5790be12000-10-09 17:06:13 +0000120 AC_ERROR(Unknown BeOS platform \"$BE_HOST_CPU\")
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000121 ;;
122 esac
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000123 AR="\$(srcdir)/Modules/ar_beos"
124 RANLIB=:
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000125 ;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000126 Monterey*)
127 RANLIB=:
Martin v. Löwis130fb172001-07-19 11:00:41 +0000128 without_gcc=;;
129 *) without_gcc=no;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000130 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000131AC_MSG_RESULT($without_gcc)
132
Guido van Rossum27552902001-01-23 01:52:26 +0000133AC_SUBST(CXX)
Guido van Rossum95012191999-12-16 17:50:52 +0000134AC_SUBST(MAINOBJ)
Fred Drakea1a84e72001-03-06 05:52:16 +0000135MAINOBJ=python.o
Guido van Rossum95012191999-12-16 17:50:52 +0000136AC_MSG_CHECKING(for --with-cxx=<compiler>)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000137AC_ARG_WITH(cxx, [ --with-cxx=<compiler> enable C++ support],[
Martin v. Löwis537970f2000-12-13 17:37:02 +0000138 check_cxx=no
Guido van Rossum95012191999-12-16 17:50:52 +0000139 case $withval in
140 no) CXX=
141 with_cxx=no;;
142 *) CXX=$withval
Fred Drakea1a84e72001-03-06 05:52:16 +0000143 MAINOBJ=ccpython.o
Guido van Rossum95012191999-12-16 17:50:52 +0000144 with_cxx=$withval;;
145 esac], [
146 with_cxx=no
Martin v. Löwis537970f2000-12-13 17:37:02 +0000147 check_cxx=yes
Guido van Rossum95012191999-12-16 17:50:52 +0000148])
149AC_MSG_RESULT($with_cxx)
Martin v. Löwis537970f2000-12-13 17:37:02 +0000150
151dnl The following fragment works similar to AC_PROG_CXX.
152dnl It does not fail if CXX is not found, and it is not executed if
153dnl --with-cxx was given.
154dnl Finally, it does not test whether CXX is g++.
155
156if test "$check_cxx" = "yes"
157then
158 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++ cl, notfound)
159 if test "$CXX" = "notfound"
160 then
161 CXX=
162 else
163 AC_PROG_CXX_WORKS
164 fi
165fi
166
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000167# If the user switches compilers, we can't believe the cache
168if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
169then
170 AC_ERROR(cached CC is different -- throw away $cache_file
171(it is also a good idea to do 'make clean' before compiling))
172fi
173
Guido van Rossum627b2d71993-12-24 10:39:16 +0000174AC_PROG_CC
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000175AC_EXEEXT
Neil Schemenauer3ae1d0a2001-01-27 06:54:42 +0000176AC_MSG_CHECKING(for --with-suffix)
177AC_ARG_WITH(suffix, [ --with-suffix=.exe set executable suffix],[
178 case $withval in
179 no) EXEEXT=;;
180 yes) EXEEXT=.exe;;
181 *) EXEEXT=$withval;;
182 esac])
183AC_MSG_RESULT($EXEEXT)
Guido van Rossumfb842551997-08-06 23:42:07 +0000184
Guido van Rossumdd997f71998-10-07 19:58:26 +0000185case $MACHDEP in
186bsdos*)
187 case $CC in
188 gcc) CC="$CC -D_HAVE_BSDI";;
189 esac;;
190esac
191
Guido van Rossum84561611997-08-21 00:08:11 +0000192case $ac_sys_system in
193hp*|HP*)
194 case $CC in
Guido van Rossumcd5ff9f2000-09-22 16:15:54 +0000195 cc|*/cc) CC="$CC -Ae";;
Guido van Rossum84561611997-08-21 00:08:11 +0000196 esac;;
Trent Mick635f6fb2000-08-23 21:33:05 +0000197Monterey*)
198 case $CC in
199 cc) CC="$CC -Wl,-Bexport";;
200 esac;;
Martin v. Löwise8964d42001-03-06 12:09:07 +0000201SunOS*)
202 # Some functions have a prototype only with that define, e.g. confstr
203 AC_DEFINE(__EXTENSIONS__)
204 ;;
Guido van Rossum84561611997-08-21 00:08:11 +0000205esac
206
Martin v. Löwise8964d42001-03-06 12:09:07 +0000207
Neil Schemenauer61c51152001-01-26 16:18:16 +0000208AC_SUBST(LIBRARY)
209AC_MSG_CHECKING(LIBRARY)
210if test -z "$LIBRARY"
211then
212 LIBRARY='libpython$(VERSION).a'
213fi
214AC_MSG_RESULT($LIBRARY)
215
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000216# LDLIBRARY is the name of the library to link against (as opposed to the
217# name of the library into which to insert object files). On systems
218# without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
Guido van Rossumaef734b2001-01-10 21:09:12 +0000219# the Makefiles). On Cygwin LDLIBRARY is the import library, DLLLIBRARY is the
220# shared (i.e., DLL) library.
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000221AC_SUBST(LDLIBRARY)
Guido van Rossum27552902001-01-23 01:52:26 +0000222AC_SUBST(DLLLIBRARY)
Neil Schemenauer61c51152001-01-26 16:18:16 +0000223LDLIBRARY="$LIBRARY"
Guido van Rossum27552902001-01-23 01:52:26 +0000224DLLLIBRARY=''
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000225
Guido van Rossumfb842551997-08-06 23:42:07 +0000226# LINKCC is the command that links the python executable -- default is $(CC).
Fred Drake5790be12000-10-09 17:06:13 +0000227# This is altered for AIX in order to build the export list before
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000228# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000229AC_SUBST(LINKCC)
230AC_MSG_CHECKING(LINKCC)
231if test -z "$LINKCC"
232then
233 case $ac_sys_system in
234 AIX*)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000235 LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000236 dgux*)
237 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000238 Monterey64*)
239 LINKCC="\$(PURIFY) \$(CC) -L/usr/lib/ia64l64";;
Guido van Rossum25f93031997-08-18 16:00:04 +0000240 *) LINKCC="\$(PURIFY) \$(CC)";;
Guido van Rossumfb842551997-08-06 23:42:07 +0000241 esac
242fi
243AC_MSG_RESULT($LINKCC)
244
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000245AC_MSG_CHECKING(LDLIBRARY)
246
247# NeXT framework builds require that the 'ar' library be converted into
248# a bundle using libtool.
249if test "$with_next_framework"
250then
251 LDLIBRARY='libpython$(VERSION).dylib'
252fi
253
254# DG/UX requires some fancy ld contortions to produce a .so from an .a
Fred Drake5790be12000-10-09 17:06:13 +0000255case $MACHDEP in
256dguxR4)
257 LDLIBRARY='libpython$(VERSION).so'
258 OPT="$OPT -pic"
259 ;;
260beos*)
261 LDLIBRARY='libpython$(VERSION).so'
262 ;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000263cygwin*)
264 LDLIBRARY='libpython$(VERSION).dll.a'
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000265 DLLLIBRARY='libpython$(VERSION).dll'
Guido van Rossumaef734b2001-01-10 21:09:12 +0000266 ;;
Fred Drake5790be12000-10-09 17:06:13 +0000267esac
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000268AC_MSG_RESULT($LDLIBRARY)
269
Guido van Rossum627b2d71993-12-24 10:39:16 +0000270AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000271AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000272AC_CHECK_PROGS(AR, ar aal, ar)
Neil Schemenauera42c8272001-03-31 00:01:55 +0000273
274case $MACHDEP in
275bsdos*)
276 # install -d does not work on BSDI
277 if test -z "$INSTALL"
278 then
279 INSTALL="${srcdir}/install-sh -c"
280 fi
281esac
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000282AC_PROG_INSTALL
Guido van Rossumb418f891996-07-30 18:06:02 +0000283
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000284# Not every filesystem supports hard links
285AC_SUBST(LN)
286if test -z "$LN" ; then
287 case $ac_sys_system in
288 BeOS*) LN="ln -s";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000289 CYGWIN*) LN="ln -s";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000290 *) LN=ln;;
291 esac
292fi
293
Fred Drake9f715822001-07-11 06:27:00 +0000294# Check for --with-pydebug
295AC_MSG_CHECKING(for --with-pydebug)
296AC_ARG_WITH(pydebug,
297[ --with-pydebug build with Py_DEBUG defined], [
298if test "$withval" != no
299then AC_DEFINE(Py_DEBUG) AC_MSG_RESULT(yes); Py_DEBUG='true'
300else AC_MSG_RESULT(no); Py_DEBUG='false'
301fi],
302[AC_MSG_RESULT(no)])
303
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000304# Optimizer/debugger flags
Guido van Rossumb418f891996-07-30 18:06:02 +0000305AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000306if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000307then
Guido van Rossumb5875b61997-07-18 23:29:09 +0000308 case $GCC in
309 yes)
310 case $ac_cv_prog_cc_g in
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000311 yes)
Fred Drake9f715822001-07-11 06:27:00 +0000312 if test "$Py_DEBUG" = 'true' ; then
313 # Optimization messes up debuggers, so turn it off for
314 # debug builds.
315 OPT="-g -Wall -Wstrict-prototypes"
316 else
317 OPT="-g -O3 -Wall -Wstrict-prototypes"
318 fi;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000319 *)
Fred Drake9f715822001-07-11 06:27:00 +0000320 OPT="-O3 -Wall -Wstrict-prototypes";;
321 esac
322 ;;
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000323 *)
324 case $ac_sys_system in
325 UnixWare*)
326 OPT="-O -K pentium,host,inline,loop_unroll,alloca ";;
327 *)
328 OPT="-O";;
Guido van Rossumb418f891996-07-30 18:06:02 +0000329 esac
Guido van Rossum2242f2f2001-04-11 20:58:20 +0000330 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000331fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000332
Trent Mick635f6fb2000-08-23 21:33:05 +0000333# The current (beta) Monterey compiler dies with optimizations
334case $ac_sys_system in
335Monterey*) OPT="";;
336esac
337
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000338if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000339then
340 OPT="$OPT $ac_arch_flags"
341fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000342# checks for UNIX variants that set C preprocessor variables
343AC_AIX
Guido van Rossum627b2d71993-12-24 10:39:16 +0000344AC_MINIX
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000345
Guido van Rossum91922671997-10-09 20:24:13 +0000346AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
347AC_CACHE_VAL(ac_cv_opt_olimit_ok,
348[ac_save_cc="$CC"
349CC="$CC -OPT:Olimit=0"
350AC_TRY_RUN([int main() { return 0; }],
351 ac_cv_opt_olimit_ok=yes,
352 ac_cv_opt_olimit_ok=no)
353CC="$ac_save_cc"])
354AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000355if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum5839e582000-10-09 19:52:35 +0000356 case $ac_sys_system in
357 Darwin*) OPT="$OPT" ;;
358 *) OPT="$OPT -OPT:Olimit=0";;
359 esac
Guido van Rossumf8678121998-07-07 21:05:09 +0000360else
361 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
362 AC_CACHE_VAL(ac_cv_olimit_ok,
363 [ac_save_cc="$CC"
364 CC="$CC -Olimit 1500"
365 AC_TRY_RUN([int main() { return 0; }],
366 ac_cv_olimit_ok=yes,
367 ac_cv_olimit_ok=no)
368 CC="$ac_save_cc"])
369 AC_MSG_RESULT($ac_cv_olimit_ok)
370 if test $ac_cv_olimit_ok = yes; then
371 OPT="$OPT -Olimit 1500"
372 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000373fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000374
Martin v. Löwis01dfdb32001-06-23 16:30:13 +0000375# Check for enable-ipv6
Martin v. Löwisb9268662001-07-18 16:24:30 +0000376# XXX definition of ss_family disabled until author clarifies rationale.
377# DEFS="$DEFS -Dss_family=__ss_family -Dss_len=__ss_len"
Martin v. Löwis01dfdb32001-06-23 16:30:13 +0000378AC_MSG_CHECKING([whether to enable ipv6])
379AC_ARG_ENABLE(ipv6,
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +0000380[ --enable-ipv6 Enable ipv6 (with ipv4) support
381 --disable-ipv6 Disable ipv6 support],
Martin v. Löwis01dfdb32001-06-23 16:30:13 +0000382[ case "$enableval" in
383 no)
384 AC_MSG_RESULT(no)
385 ipv6=no
386 ;;
387 *) AC_MSG_RESULT(yes)
388 AC_DEFINE(ENABLE_IPV6)
389 ipv6=yes
390 ;;
391 esac ],
392
Fred Drake9f715822001-07-11 06:27:00 +0000393 AC_TRY_RUN([ /* AF_INET6 available check */
Martin v. Löwis01dfdb32001-06-23 16:30:13 +0000394#include <sys/types.h>
395#include <sys/socket.h>
396main()
397{
398 if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
399 exit(1);
400 else
401 exit(0);
402}
403],
404 AC_MSG_RESULT(yes)
405 AC_DEFINE(ENABLE_IPV6)
406 ipv6=yes,
407 AC_MSG_RESULT(no)
408 ipv6=no,
409 AC_MSG_RESULT(no)
410 ipv6=no
411))
412
413ipv6type=unknown
414ipv6lib=none
415ipv6trylibc=no
416
417if test "$ipv6" = "yes"; then
418 AC_MSG_CHECKING([ipv6 stack type])
419 for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
420 case $i in
421 inria)
422 dnl http://www.kame.net/
423 AC_EGREP_CPP(yes, [dnl
424#include <netinet/in.h>
425#ifdef IPV6_INRIA_VERSION
426yes
427#endif],
428 [ipv6type=$i;
429 OPT="-DINET6 $OPT"])
430 ;;
431 kame)
432 dnl http://www.kame.net/
433 AC_EGREP_CPP(yes, [dnl
434#include <netinet/in.h>
435#ifdef __KAME__
436yes
437#endif],
438 [ipv6type=$i;
439 ipv6lib=inet6
440 ipv6libdir=/usr/local/v6/lib
441 ipv6trylibc=yes
442 OPT="-DINET6 $OPT"])
443 ;;
444 linux-glibc)
445 dnl http://www.v6.linux.or.jp/
446 AC_EGREP_CPP(yes, [dnl
447#include <features.h>
448#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2))
449yes
450#endif],
451 [ipv6type=$i;
452 ipv6trylibc=yes
453 OPT="-DINET6 $OPT"])
454 ;;
455 linux-inet6)
456 dnl http://www.v6.linux.or.jp/
457 if test -d /usr/inet6; then
458 ipv6type=$i
459 ipv6lib=inet6
460 ipv6libdir=/usr/inet6/lib
461 OPT="-DINET6 -I/usr/inet6/include $OPT"
462 fi
463 ;;
464 toshiba)
465 AC_EGREP_CPP(yes, [dnl
466#include <sys/param.h>
467#ifdef _TOSHIBA_INET6
468yes
469#endif],
470 [ipv6type=$i;
471 ipv6lib=inet6;
472 ipv6libdir=/usr/local/v6/lib;
473 OPT="-DINET6 $OPT"])
474 ;;
475 v6d)
476 AC_EGREP_CPP(yes, [dnl
477#include </usr/local/v6/include/sys/v6config.h>
478#ifdef __V6D__
479yes
480#endif],
481 [ipv6type=$i;
482 ipv6lib=v6;
483 ipv6libdir=/usr/local/v6/lib;
484 OPT="-I/usr/local/v6/include $OPT"])
485 ;;
486 zeta)
487 AC_EGREP_CPP(yes, [dnl
488#include <sys/param.h>
489#ifdef _ZETA_MINAMI_INET6
490yes
491#endif],
492 [ipv6type=$i;
493 ipv6lib=inet6;
494 ipv6libdir=/usr/local/v6/lib;
495 OPT="-DINET6 $OPT"])
496 ;;
497 esac
498 if test "$ipv6type" != "unknown"; then
499 break
500 fi
501 done
502 AC_MSG_RESULT($ipv6type)
503fi
504
505if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
506 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
507 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
508 echo "using lib$ipv6lib"
509 else
510 if test $ipv6trylibc = "yes"; then
511 echo "using libc"
512 else
513 echo 'Fatal: no $ipv6lib library found. cannot continue.'
514 echo "You need to fetch lib$ipv6lib.a from appropriate"
515 echo 'ipv6 kit and compile beforehand.'
516 exit 1
517 fi
518 fi
519fi
520
Martin v. Löwis130fb172001-07-19 11:00:41 +0000521# -Kpthread, if available, provides the right #defines
522# and linker options to make pthread_create available
523AC_MSG_CHECKING(whether $CC accepts -Kpthread)
524AC_CACHE_VAL(ac_cv_kpthread,
525[ac_save_cc="$CC"
526CC="$CC -Kpthread"
527AC_TRY_LINK([#include <pthread.h>],[pthread_create(0,0,0,0)],
528 ac_cv_kpthread=yes,
529 ac_cv_kpthread=no)
530CC="$ac_save_cc"])
531
532# GCC does not reject -Kpthread as an illegal option, it merely complains that
533# it is unrecognized
534if test "$GCC" = "yes"
535then ac_cv_kpthread="no, we have gcc"
536fi
537AC_MSG_RESULT($ac_cv_kpthread)
538
Fred Drakece81d592000-07-09 14:39:29 +0000539dnl # check for ANSI or K&R ("traditional") preprocessor
540dnl AC_MSG_CHECKING(for C preprocessor type)
541dnl AC_TRY_COMPILE([
542dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
543dnl int foo;
544dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
545dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
546dnl AC_MSG_RESULT($cpp_type)
Guido van Rossum300fda71996-08-19 21:58:16 +0000547
Guido van Rossum627b2d71993-12-24 10:39:16 +0000548# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000549AC_HEADER_STDC
Andrew M. Kuchling5821b772000-08-25 01:14:08 +0000550AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h poll.h pthread.h \
Eric S. Raymond13603592001-01-16 15:01:26 +0000551signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
Fred Drake2ca5f3b2001-05-11 16:10:56 +0000552sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
Andrew M. Kuchling881fd902001-07-14 20:55:52 +0000553sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
Fred Drakeae90f8d2000-09-15 03:38:12 +0000554sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
Thomas Wouterse38b2f12001-07-11 22:35:31 +0000555ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000556AC_HEADER_DIRENT
Guido van Rossum627b2d71993-12-24 10:39:16 +0000557
558# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000559was_it_defined=no
560AC_MSG_CHECKING(for clock_t in time.h)
561AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
562AC_MSG_RESULT($was_it_defined)
563
Guido van Rossum300fda71996-08-19 21:58:16 +0000564# Add some code to confdefs.h so that the test for off_t works on SCO
565cat >> confdefs.h <<\EOF
566#if defined(SCO_DS)
567#undef _OFF_T
568#endif
569EOF
570
Guido van Rossumef2255b2000-03-10 22:30:29 +0000571# Type availability checks
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000572AC_TYPE_MODE_T
573AC_TYPE_OFF_T
574AC_TYPE_PID_T
575AC_TYPE_SIGNAL
576AC_TYPE_SIZE_T
577AC_TYPE_UID_T
Guido van Rossum627b2d71993-12-24 10:39:16 +0000578
Guido van Rossumef2255b2000-03-10 22:30:29 +0000579# Sizes of various common basic types
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000580AC_CHECK_SIZEOF(int)
581AC_CHECK_SIZEOF(long)
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000582AC_CHECK_SIZEOF(void *)
Guido van Rossumef2255b2000-03-10 22:30:29 +0000583AC_CHECK_SIZEOF(char)
584AC_CHECK_SIZEOF(short)
585AC_CHECK_SIZEOF(float)
586AC_CHECK_SIZEOF(double)
Fred Drakea3f6e912000-06-29 20:44:47 +0000587AC_CHECK_SIZEOF(fpos_t)
Guido van Rossumac405f61994-09-12 10:56:06 +0000588
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000589AC_MSG_CHECKING(for long long support)
590have_long_long=no
591AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
592AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000593if test "$have_long_long" = yes ; then
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000594AC_CHECK_SIZEOF(long long)
595fi
596
Barry Warsawbc7c7f92000-08-18 04:53:33 +0000597AC_MSG_CHECKING(for uintptr_t support)
598have_uintptr_t=no
599AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], AC_DEFINE(HAVE_UINTPTR_T) have_uintptr_t=yes)
600AC_MSG_RESULT($have_uintptr_t)
601if test "$have_uintptr_t" = yes ; then
602AC_CHECK_SIZEOF(uintptr_t)
603fi
604
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000605# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
606AC_MSG_CHECKING(size of off_t)
607AC_CACHE_VAL(ac_cv_sizeof_off_t,
608[AC_TRY_RUN([#include <stdio.h>
609#include <sys/types.h>
610main()
611{
612 FILE *f=fopen("conftestval", "w");
613 if (!f) exit(1);
614 fprintf(f, "%d\n", sizeof(off_t));
615 exit(0);
616}], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
617])
618AC_MSG_RESULT($ac_cv_sizeof_off_t)
619AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
620
621AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000622if test "$have_long_long" = yes -a \
623 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
624 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000625 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
626 AC_MSG_RESULT(yes)
627else
628 AC_MSG_RESULT(no)
629fi
630
Fred Drakea3f6e912000-06-29 20:44:47 +0000631# AC_CHECK_SIZEOF() doesn't include <time.h>.
632AC_MSG_CHECKING(size of time_t)
633AC_CACHE_VAL(ac_cv_sizeof_time_t,
634[AC_TRY_RUN([#include <stdio.h>
635#include <time.h>
636main()
637{
638 FILE *f=fopen("conftestval", "w");
639 if (!f) exit(1);
640 fprintf(f, "%d\n", sizeof(time_t));
641 exit(0);
642}], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0)
643])
644AC_MSG_RESULT($ac_cv_sizeof_time_t)
645AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t)
646
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000647
Trent Mick635f6fb2000-08-23 21:33:05 +0000648# if have pthread_t then define SIZEOF_PTHREAD_T
649AC_MSG_CHECKING(for pthread_t)
650have_pthread_t=no
Guido van Rossum12580492000-09-24 16:47:19 +0000651AC_TRY_COMPILE([#include <pthread.h>], [pthread_t x; x = *(pthread_t*)0;], have_pthread_t=yes)
Trent Mick635f6fb2000-08-23 21:33:05 +0000652AC_MSG_RESULT($have_pthread_t)
653if test "$have_pthread_t" = yes ; then
654 # AC_CHECK_SIZEOF() doesn't include <pthread.h>.
655 AC_MSG_CHECKING(size of pthread_t)
656 AC_CACHE_VAL(ac_cv_sizeof_pthread_t,
657 [AC_TRY_RUN([#include <stdio.h>
658 #include <pthread.h>
659 main()
660 {
661 FILE *f=fopen("conftestval", "w");
662 if (!f) exit(1);
663 fprintf(f, "%d\n", sizeof(pthread_t));
664 exit(0);
665 }], ac_cv_sizeof_pthread_t=`cat conftestval`, ac_cv_sizeof_pthread_t=0)
666 ])
667 AC_MSG_RESULT($ac_cv_sizeof_pthread_t)
668 AC_DEFINE_UNQUOTED(SIZEOF_PTHREAD_T, $ac_cv_sizeof_pthread_t)
669fi
670
671
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000672# Minor variations in building a framework between NextStep versions 4 and 5
673AC_SUBST(LIBTOOL_CRUFT)
674case $ac_sys_system/$ac_sys_release in
Guido van Rossum5839e582000-10-09 19:52:35 +0000675 Darwin/*)
676 ns_undef_sym='_environ'
677 LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym" ;;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000678 next/4*)
679 ns_undef_sym='__environ'
680 LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
681 next/5*)
682 ns_undef_sym='_environ'
683 LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
684esac
685
686AC_MSG_CHECKING(for --with-next-framework)
687if test "$with_next_framework"
688then
689 OPT="$OPT -fno-common"
690 # -U __environ is needed since bundles don't have access
691 # to crt0 when built but will always be linked against it
692 LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
693 AC_DEFINE(WITH_NEXT_FRAMEWORK)
694 AC_MSG_RESULT(yes)
695else
696 AC_MSG_RESULT(no)
697fi
698
699AC_MSG_CHECKING(for --with-dyld)
700if test "$with_next_framework" -o "$with_dyld"
701then
702 if test "$with_dyld"
703 then
704 AC_MSG_RESULT(yes)
705 else
706 AC_MSG_RESULT(required for framework build)
707 fi
708 AC_DEFINE(WITH_DYLD)
709 ns_dyld='set'
710else
711 AC_MSG_RESULT(no)
712fi
713
Guido van Rossumac405f61994-09-12 10:56:06 +0000714# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +0000715AC_SUBST(SO)
716AC_SUBST(LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000717AC_SUBST(BLDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000718AC_SUBST(CCSHARED)
719AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000720# SO is the extension of shared libraries `(including the dot!)
Guido van Rossumaef734b2001-01-10 21:09:12 +0000721# -- usually .so, .sl on HP-UX, .dll on Cygwin
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000722AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000723if test -z "$SO"
724then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000725 case $ac_sys_system in
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000726 hp*|HP*) SO=.sl;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000727 CYGWIN*) SO=.dll;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000728 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000729 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000730fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000731AC_MSG_RESULT($SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000732# LDSHARED is the ld *command* used to create shared library
733# -- "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 +0000734# (Shared libraries in this instance are shared modules to be loaded into
735# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000736AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000737if test -z "$LDSHARED"
738then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000739 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000740 AIX*)
741 BLDSHARED="\$(srcdir)/Modules/ld_so_aix \$(CC) -bI:Modules/python.exp"
742 LDSHARED="\$(BINLIBDEST)/ld_so_aix \$(CC) -bI:\$(BINLIBDEST)/python.exp"
743 ;;
744 BeOS*)
745 BLDSHARED="\$(srcdir)/Modules/ld_so_beos $LDLIBRARY"
746 LDSHARED="\$(BINLIBDEST)/ld_so_beos \$(LIBDIR)/$LDLIBRARY"
747 ;;
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000748 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +0000749 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000750 SunOS/4*) LDSHARED="ld";;
Greg Ward57c9a6632000-05-26 12:22:54 +0000751 SunOS/5*)
752 if test "$GCC" = "yes"
Neil Schemenauer95052722001-02-19 18:17:33 +0000753 then LDSHARED='$(CC) -shared'
Greg Ward57c9a6632000-05-26 12:22:54 +0000754 else LDSHARED="ld -G";
755 fi ;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000756 hp*|HP*) LDSHARED="ld -b";;
Guido van Rossum71001e41995-01-26 00:44:03 +0000757 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Guido van Rossum7d473291995-01-20 14:12:16 +0000758 DYNIX/ptx*) LDSHARED="ld -G";;
Guido van Rossum3dc0a512000-10-05 18:00:06 +0000759 Darwin/*|next/*)
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000760 if test "$ns_dyld"
Guido van Rossumacb14c72001-01-10 21:41:16 +0000761 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined suppress'
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000762 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
763 fi
Guido van Rossum3dc0a512000-10-05 18:00:06 +0000764 if test "$with_next_framework" ; then
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000765 LDSHARED="$LDSHARED \$(LDLIBRARY)"
766 fi ;;
Guido van Rossum81652ab1996-07-21 02:53:27 +0000767 Linux*) LDSHARED="gcc -shared";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000768 dgux*) LDSHARED="ld -G";;
Guido van Rossum458e7fa1999-09-17 15:40:40 +0000769 BSD/OS*/4*) LDSHARED="gcc -shared";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000770 OpenBSD*) LDSHARED="ld -Bshareable";;
Guido van Rossumdf693651999-01-07 21:50:41 +0000771 NetBSD*)
772 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
773 then
774 LDSHARED="cc -shared"
775 else
776 LDSHARED="ld -Bshareable"
777 fi;;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000778 FreeBSD*)
Jeremy Hylton4bcc7c52000-08-31 17:45:35 +0000779 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
Guido van Rossum0286ae82000-08-29 15:06:49 +0000780 then
781 LDSHARED="cc -shared ${LDFLAGS}"
782 else
783 LDSHARED="ld -Bshareable ${LDFLAGS}"
784 fi;;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000785 UnixWare*)
786 if test "$GCC" = "yes"
787 then LDSHARED="$(CC) -shared"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000788 else LDSHARED="$(CC) -G"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000789 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000790 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000791 Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000792 CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000793 *) LDSHARED="ld";;
794 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000795fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000796AC_MSG_RESULT($LDSHARED)
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000797BLDSHARED=${BLDSHARED-$LDSHARED}
Guido van Rossumac405f61994-09-12 10:56:06 +0000798# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000799# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000800AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000801if test -z "$CCSHARED"
802then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000803 case $ac_sys_system/$ac_sys_release in
Neil Schemenauer66252162001-02-19 04:47:42 +0000804 SunOS*) if test "$GCC" = yes;
805 then CCSHARED="-fPIC";
806 fi;;
Guido van Rossumaf07a441995-02-13 19:45:27 +0000807 hp*|HP*) if test "$GCC" = yes;
808 then CCSHARED="-fpic";
809 else CCSHARED="+z";
810 fi;;
Neil Schemenauer61c51152001-01-26 16:18:16 +0000811 Linux*) CCSHARED="-fPIC";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000812 BSD/OS*/4*) CCSHARED="-fpic";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000813 OpenBSD*) CCSHARED="-fpic";;
814 FreeBSD*|NetBSD*) CCSHARED="-fPIC";;
Martin v. Löwisbec19582001-03-21 15:57:54 +0000815 UnixWare*)
816 if test "$GCC" = "yes"
817 then CCSHARED="-fPIC"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000818 else CCSHARED="-KPIC"
Martin v. Löwisbec19582001-03-21 15:57:54 +0000819 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000820 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
Trent Mick635f6fb2000-08-23 21:33:05 +0000821 Monterey*) CCSHARED="-G";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000822 IRIX*/6*) case $CC in
823 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +0000824 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000825 esac;;
Guido van Rossumaef734b2001-01-10 21:09:12 +0000826 CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000827 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000828fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000829AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000830# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000831# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000832AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000833if test -z "$LINKFORSHARED"
834then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000835 case $ac_sys_system/$ac_sys_release in
Neil Schemenauerb3531b82001-02-16 04:09:05 +0000836 AIX*) LINKFORSHARED='-Wl,-bE:Modules/python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000837 hp*|HP*)
Guido van Rossum304dd2d1997-10-20 23:10:56 +0000838 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumf5957ea1999-10-05 21:59:33 +0000839 BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum2d9feed1997-11-24 17:36:21 +0000840 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000841 # -u libsys_s pulls in all symbols in libsys
842 next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
843 # -u __dummy makes the linker aware of the objc runtime
844 # in System.framework; otherwise, __objcInit (referenced in
845 # crt1.o) gets erroneously defined as common, which breaks dynamic
846 # loading of any modules which reference it in System.framework
847 next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
Jack Jansenc49e5b72001-06-19 15:00:23 +0000848 Darwin/*) LINKFORSHARED="-u __dummy -u _PyMac_Error -framework System -framework Foundation -framework Carbon" ;;
Martin v. Löwis130fb172001-07-19 11:00:41 +0000849 UnixWare*) LINKFORSHARED="-Wl,-Bexport";;
Guido van Rossum300fda71996-08-19 21:58:16 +0000850 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
Fred Drake02706f52000-09-25 15:08:46 +0000851 ReliantUNIX*) LINKFORSHARED="-W1 -Blargedynsym";;
Guido van Rossum0286ae82000-08-29 15:06:49 +0000852 FreeBSD*|NetBSD*)
Guido van Rossumdf693651999-01-07 21:50:41 +0000853 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
854 then
855 LINKFORSHARED="-Wl,--export-dynamic"
856 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000857 SunOS/5*) case $CC in
858 *gcc*)
Guido van Rossum9c6ba9b2000-02-03 13:42:50 +0000859 if $CC -Xlinker -V 2>&1 | grep BFD >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000860 then
861 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000862 fi;;
863 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000864 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000865fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000866AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000867
Neil Schemenauer61c51152001-01-26 16:18:16 +0000868AC_SUBST(CFLAGSFORSHARED)
869AC_MSG_CHECKING(CFLAGSFORSHARED)
870if test ! "$LIBRARY" = "$LDLIBRARY"
871then
Neil Schemenauerd9cf41c2001-01-27 21:39:17 +0000872 case $ac_sys_system in
873 CYGWIN*)
874 # Cygwin needs CCSHARED when building extension DLLs
875 # but not when building the interpreter DLL.
876 CFLAGSFORSHARED='';;
877 *)
878 CFLAGSFORSHARED='$(CCSHARED)'
879 esac
Neil Schemenauer61c51152001-01-26 16:18:16 +0000880fi
881AC_MSG_RESULT($CFLAGSFORSHARED)
882
Guido van Rossum627b2d71993-12-24 10:39:16 +0000883# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000884AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
885AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Guido van Rossum0eefa3f1999-11-16 15:57:37 +0000886
887# checks for system dependent C++ extensions support
888case "$ac_sys_system" in
889 AIX*) AC_MSG_CHECKING(for genuine AIX C++ extensions support)
890 AC_TRY_LINK([#include "/usr/lpp/xlC/include/load.h"],
891 [loadAndInit("", 0, "")],
892 [AC_DEFINE(AIX_GENUINE_CPLUSPLUS)
893 AC_MSG_RESULT(yes)],
894 [AC_MSG_RESULT(no)]);;
895 *) ;;
896esac
897
Guido van Rossum70c7f481998-03-26 18:44:10 +0000898# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
899# However on SGI IRIX, these exist but are broken.
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000900# BeOS' sockets are stashed in libnet.
901case "$ac_sys_system" in
902IRIX*) ;;
Guido van Rossum2cb56601998-05-07 13:25:56 +0000903*)
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000904AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000905AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Jeremy Hyltoncb25d5e2000-07-27 21:23:28 +0000906;;
907esac
908case "$ac_sys_system" in
909BeOS*)
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000910AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
911;;
912esac
Guido van Rossum70c7f481998-03-26 18:44:10 +0000913
Guido van Rossumc5a39031996-07-31 17:35:03 +0000914AC_MSG_CHECKING(for --with-libs)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000915AC_ARG_WITH(libs,
916[ --with-libs='lib1 ...' link against additional libs], [
Guido van Rossumc5a39031996-07-31 17:35:03 +0000917AC_MSG_RESULT($withval)
918LIBS="$withval $LIBS"
919], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000920
Neil Schemenauer55f0cf32001-01-24 17:24:33 +0000921# Determine if signalmodule should be used.
922AC_SUBST(USE_SIGNAL_MODULE)
923AC_SUBST(SIGNAL_OBJS)
924AC_MSG_CHECKING(for --with-signal-module)
925AC_ARG_WITH(signal-module,
926[ --with-signal-module disable/enable signal module])
927
928if test -z "$with_signal_module"
929then with_signal_module="yes"
930fi
931AC_MSG_RESULT($with_signal_module)
932
933if test "${with_signal_module}" = "yes"; then
934 USE_SIGNAL_MODULE=""
935 SIGNAL_OBJS=""
936else
937 USE_SIGNAL_MODULE="#"
938 SIGNAL_OBJS="Parser/intrcheck.o Python/sigcheck.o"
939fi
940
Guido van Rossum3d15bd82001-01-10 18:53:48 +0000941# This is used to generate Setup.config
Guido van Rossum009f7871997-12-04 00:51:42 +0000942AC_SUBST(USE_THREAD_MODULE)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000943USE_THREAD_MODULE=""
Guido van Rossum009f7871997-12-04 00:51:42 +0000944
Guido van Rossum54d93d41997-01-22 20:51:58 +0000945AC_MSG_CHECKING(for --with-dec-threads)
946AC_SUBST(LDLAST)
947AC_ARG_WITH(dec-threads,
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000948[ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [
949AC_MSG_RESULT($withval)
Guido van Rossum54d93d41997-01-22 20:51:58 +0000950LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +0000951if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +0000952 with_thread="$withval";
953fi],
954AC_MSG_RESULT(no))
955
956AC_MSG_CHECKING(for --with-threads)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000957AC_ARG_WITH(threads,
958[ --with(out)-threads[=DIRECTORY] disable/enable thread support])
Guido van Rossum54d93d41997-01-22 20:51:58 +0000959
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000960# --with-thread is deprecated, but check for it anyway
Barry Warsawa0f3c5c2000-06-30 16:39:35 +0000961AC_ARG_WITH(thread,
962[ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[
963with_threads=$with_thread])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000964
965if test -z "$with_threads"
966then with_threads="yes"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000967fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000968AC_MSG_RESULT($with_threads)
Guido van Rossum6400c261997-05-22 20:34:27 +0000969
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000970if test "$with_threads" = "no"
971then
972 USE_THREAD_MODULE="#"
Martin v. Löwis130fb172001-07-19 11:00:41 +0000973elif test "$ac_cv_kpthread" = "yes"
974then
975 CC="$CC -Kpthread"
976 AC_DEFINE(WITH_THREAD)
977 AC_DEFINE(_POSIX_THREADS)
978 LIBOBJS="$LIBOBJS thread.o"
Barry Warsawc0d24d8b2000-06-29 16:12:00 +0000979else
Martin v. Löwis130fb172001-07-19 11:00:41 +0000980 if test ! -z "$with_threads" -a -d "$with_threads"
981 then LDFLAGS="$LDFLAGS -L$with_threads"
982 fi
983 if test ! -z "$withval" -a -d "$withval"
984 then LDFLAGS="$LDFLAGS -L$withval"
985 fi
986 AC_DEFINE(_REENTRANT)
987 AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
988 AC_DEFINE(C_THREADS)
989 LIBOBJS="$LIBOBJS thread.o"],[
990 AC_MSG_CHECKING(for --with-pth)
991 AC_ARG_WITH(pth,
992 [ --with-pth use GNU pth threading libraries], [
993 AC_MSG_RESULT($withval)
994 AC_DEFINE(WITH_THREAD)
995 AC_DEFINE(HAVE_PTH)
996 LIBS="-lpth $LIBS"
997 LIBOBJS="$LIBOBJS thread.o"],[
998 AC_MSG_RESULT(no)
999 AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
1000 AC_DEFINE(_POSIX_THREADS)
1001 LIBS="-lpthread $LIBS"
1002 LIBOBJS="$LIBOBJS thread.o"],[
1003 AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
1004 case $ac_sys_system in
1005 Darwin*) ;;
1006 *) AC_DEFINE(_POSIX_THREADS);;
1007 esac
1008 LIBOBJS="$LIBOBJS thread.o"],[
1009 AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
1010 AC_DEFINE(BEOS_THREADS)
1011 LIBOBJS="$LIBOBJS thread.o"],[
1012 AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
1013 AC_DEFINE(_POSIX_THREADS)
1014 LIBS="$LIBS -lpthreads"
1015 LIBOBJS="$LIBOBJS thread.o"], [
1016 AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
1017 AC_DEFINE(_POSIX_THREADS)
1018 LIBS="$LIBS -lc_r"
1019 LIBOBJS="$LIBOBJS thread.o"], [
1020 AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
1021 AC_DEFINE(_POSIX_THREADS)
1022 LIBS="$LIBS -lthread"
1023 LIBOBJS="$LIBOBJS thread.o"], [
1024 AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
1025 AC_DEFINE(_POSIX_THREADS)
1026 LIBS="$LIBS -lpthread"
1027 LIBOBJS="$LIBOBJS thread.o"], [
1028 AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
1029 AC_DEFINE(_POSIX_THREADS)
1030 LIBS="$LIBS -lcma"
1031 LIBOBJS="$LIBOBJS thread.o"],[
1032 USE_THREAD_MODULE="#"])
1033 ])])])])])])])])])
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001034
Martin v. Löwis130fb172001-07-19 11:00:41 +00001035 AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
1036 LIBS="$LIBS -lmpc"
1037 LIBOBJS="$LIBOBJS thread.o"
1038 USE_THREAD_MODULE=""])
1039 AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
1040 LIBS="$LIBS -lthread"
1041 LIBOBJS="$LIBOBJS thread.o"
1042 USE_THREAD_MODULE=""])
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001043
Martin v. Löwis130fb172001-07-19 11:00:41 +00001044 if test "$USE_THREAD_MODULE" != "#"
1045 then
1046 # If the above checks didn't disable threads, (at least) OSF1
1047 # needs this '-threads' argument during linking.
1048 case $ac_sys_system in
1049 OSF1) LDLAST=-threads;;
1050 esac
Jeremy Hylton1a2ca862000-10-16 16:59:12 +00001051 fi
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001052fi
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001053
Barry Warsawef82cd72000-06-30 16:21:01 +00001054# Check for GC support
1055AC_SUBST(USE_GC_MODULE)
1056USE_GC_MODULE=""
1057AC_MSG_CHECKING(for --with-cycle-gc)
1058AC_ARG_WITH(cycle-gc,
1059[ --with(out)-cycle-gc disable/enable garbage collection])
1060
1061if test -z "$with_cycle_gc"
1062then with_cycle_gc="yes"
1063fi
1064if test "$with_cycle_gc" = "no"
1065then
1066 USE_GC_MODULE="#"
1067else
1068 AC_DEFINE(WITH_CYCLE_GC)
1069fi
1070AC_MSG_RESULT($with_cycle_gc)
1071
Neil Schemenauera35c6882001-02-27 04:45:05 +00001072# Check for Python-specific malloc support
1073AC_MSG_CHECKING(for --with-pymalloc)
1074AC_ARG_WITH(pymalloc,
1075[ --with(out)-pymalloc disable/enable specialized mallocs], [
1076if test "$withval" != no
1077then AC_DEFINE(WITH_PYMALLOC) AC_MSG_RESULT(yes)
1078else AC_MSG_RESULT(no)
1079fi],
1080[AC_MSG_RESULT(no)])
1081
Barry Warsawef82cd72000-06-30 16:21:01 +00001082# Check for --with-wctype-functions
1083AC_MSG_CHECKING(for --with-wctype-functions)
1084AC_ARG_WITH(wctype-functions,
1085[ --with-wctype-functions use wctype.h functions], [
1086if test "$withval" != no
1087then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes)
1088else AC_MSG_RESULT(no)
1089fi],
1090[AC_MSG_RESULT(no)])
1091
Guido van Rossum68242b51996-05-28 22:53:03 +00001092# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001093AC_SUBST(DLINCLDIR)
1094DLINCLDIR=/
1095
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001096AC_MSG_CHECKING(for --with-sgi-dl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001097AC_ARG_WITH(sgi-dl,
1098[ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001099AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001100AC_DEFINE(WITH_SGI_DL)
Guido van Rossume97ee181999-12-20 21:27:22 +00001101DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001102dldir=$withval
Guido van Rossum40951012000-10-07 16:21:27 +00001103if test ! -z "$dldir" -a -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001104then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001105else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
1106fi
1107DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001108LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001109
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001110AC_MSG_CHECKING(for --with-dl-dld)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001111AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001112AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001113AC_DEFINE(WITH_DL_DLD)
Guido van Rossume97ee181999-12-20 21:27:22 +00001114DYNLOADFILE="dynload_dl.o"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001115dldir=`echo "$withval" | sed 's/,.*//'`
1116dlddir=`echo "$withval" | sed 's/.*,//'`
Barry Warsaw7d1219d2000-10-05 18:45:53 +00001117if test ! -z "$dldir" -a -d "$dldir" -a ! -z "$dlddir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +00001118then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001119else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
1120fi
1121DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001122LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +00001123
Guido van Rossume97ee181999-12-20 21:27:22 +00001124# the dlopen() function means we might want to use dynload_shlib.o. some
1125# platforms, such as AIX, have dlopen(), but don't want to use it.
Thomas Wouters3a584202000-08-05 23:28:51 +00001126AC_CHECK_FUNCS(dlopen)
Guido van Rossume97ee181999-12-20 21:27:22 +00001127
1128# DYNLOADFILE specifies which dynload_*.o file we will use for dynamic
1129# loading of modules.
1130AC_SUBST(DYNLOADFILE)
1131AC_MSG_CHECKING(DYNLOADFILE)
1132if test -z "$DYNLOADFILE"
1133then
1134 case $ac_sys_system/$ac_sys_release in
1135 AIX*) DYNLOADFILE="dynload_aix.o";;
1136 BeOS*) DYNLOADFILE="dynload_beos.o";;
1137 hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Guido van Rossum5839e582000-10-09 19:52:35 +00001138 Darwin/*|next/*) DYNLOADFILE="dynload_next.o";;
Guido van Rossume97ee181999-12-20 21:27:22 +00001139 *)
1140 # use dynload_shlib.c and dlopen() if we have it; otherwise stub
1141 # out any dynamic loading
1142 if test "$ac_cv_func_dlopen" = yes
1143 then DYNLOADFILE="dynload_shlib.o"
1144 else DYNLOADFILE="dynload_stub.o"
1145 fi
1146 ;;
1147 esac
1148fi
1149AC_MSG_RESULT($DYNLOADFILE)
1150if test "$DYNLOADFILE" != "dynload_stub.o"
1151then
1152 AC_DEFINE(HAVE_DYNAMIC_LOADING)
1153fi
1154
Jack Jansenc49e5b72001-06-19 15:00:23 +00001155# MACHDEP_OBJS can be set to platform-specific object files needed by Python
1156
1157AC_SUBST(MACHDEP_OBJS)
1158AC_MSG_CHECKING(MACHDEP_OBJS)
1159if test -z "$MACHDEP_OBJS"
1160then
1161 case $ac_sys_system/$ac_sys_release in
1162 Darwin/*)
1163 MACHDEP_OBJS="Mac/Python/macglue.o"
1164 AC_DEFINE(USE_TOOLBOX_OBJECT_GLUE)
1165 ;;
1166 *) MACHDEP_OBJS="";;
1167 esac
1168fi
1169AC_MSG_RESULT($DYNLOADFILE)
1170
Guido van Rossum627b2d71993-12-24 10:39:16 +00001171# checks for library functions
Thomas Wouters3a584202000-08-05 23:28:51 +00001172AC_CHECK_FUNCS(alarm chown clock confstr ctermid ctermid_r execv \
Fred Drake35a092f1999-12-13 16:23:35 +00001173 flock fork fsync fdatasync fpathconf ftime ftruncate \
Andrew M. Kuchlinga9586c72001-01-08 17:58:56 +00001174 getgroups getlogin getpeername getpid getpwent getwd \
Martin v. Löwisb9ab1592001-06-24 21:18:26 +00001175 inet_pton kill link lstat mkfifo mktime mremap \
Andrew M. Kuchling5821b772000-08-25 01:14:08 +00001176 nice pathconf pause plock poll pthread_init \
Fred Drake35a092f1999-12-13 16:23:35 +00001177 putenv readlink \
Andrew M. Kuchling8d2f2b22000-07-13 01:26:58 +00001178 select setegid seteuid setgid \
Thomas Wouters3a584202000-08-05 23:28:51 +00001179 setlocale setregid setreuid setsid setpgid setuid setvbuf \
Fred Drake35a092f1999-12-13 16:23:35 +00001180 sigaction siginterrupt sigrelse strftime strptime symlink sysconf \
Fred Drake89143df1999-12-09 22:03:25 +00001181 tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \
Thomas Woutersc2c12dc2001-07-11 14:45:34 +00001182 truncate uname waitpid _getpty getpriority)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001183
Fred Drake8cef4cf2000-06-28 16:40:38 +00001184# check for openpty and forkpty
1185
1186AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"]))
1187AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"]))
1188
Guido van Rossum00f0f6e1999-01-06 18:52:29 +00001189# check for long file support functions
1190AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
1191
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001192AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Thomas Wouters3a584202000-08-05 23:28:51 +00001193AC_CHECK_FUNCS(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
1194AC_CHECK_FUNCS(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
1195AC_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 +00001196
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001197AC_CHECK_FUNCS(getaddrinfo, [dnl
1198AC_MSG_CHECKING(getaddrinfo bug)
1199AC_TRY_RUN([
1200#include <sys/types.h>
1201#include <netdb.h>
1202#include <string.h>
1203#include <sys/socket.h>
1204#include <netinet/in.h>
1205
1206main()
1207{
1208 int passive, gaierr, inet4 = 0, inet6 = 0;
1209 struct addrinfo hints, *ai, *aitop;
1210 char straddr[INET6_ADDRSTRLEN], strport[16];
1211
1212 for (passive = 0; passive <= 1; passive++) {
1213 memset(&hints, 0, sizeof(hints));
1214 hints.ai_family = AF_UNSPEC;
1215 hints.ai_flags = passive ? AI_PASSIVE : 0;
1216 hints.ai_socktype = SOCK_STREAM;
1217 if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
1218 (void)gai_strerror(gaierr);
1219 goto bad;
1220 }
1221 for (ai = aitop; ai; ai = ai->ai_next) {
1222 if (ai->ai_addr == NULL ||
1223 ai->ai_addrlen == 0 ||
1224 getnameinfo(ai->ai_addr, ai->ai_addrlen,
1225 straddr, sizeof(straddr), strport, sizeof(strport),
1226 NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
1227 goto bad;
1228 }
1229 switch (ai->ai_family) {
1230 case AF_INET:
1231 if (strcmp(strport, "54321") != 0) {
1232 goto bad;
1233 }
1234 if (passive) {
1235 if (strcmp(straddr, "0.0.0.0") != 0) {
1236 goto bad;
1237 }
1238 } else {
1239 if (strcmp(straddr, "127.0.0.1") != 0) {
1240 goto bad;
1241 }
1242 }
1243 inet4++;
1244 break;
1245 case AF_INET6:
1246 if (strcmp(strport, "54321") != 0) {
1247 goto bad;
1248 }
1249 if (passive) {
1250 if (strcmp(straddr, "::") != 0) {
1251 goto bad;
1252 }
1253 } else {
1254 if (strcmp(straddr, "::1") != 0) {
1255 goto bad;
1256 }
1257 }
1258 inet6++;
1259 break;
1260 case AF_UNSPEC:
1261 goto bad;
1262 break;
1263 default:
1264 /* another family support? */
1265 break;
1266 }
1267 }
1268 }
1269
1270 if (!(inet4 == 0 || inet4 == 2))
1271 goto bad;
1272 if (!(inet6 == 0 || inet6 == 2))
1273 goto bad;
1274
1275 if (aitop)
1276 freeaddrinfo(aitop);
1277 exit(0);
1278
1279 bad:
1280 if (aitop)
1281 freeaddrinfo(aitop);
1282 exit(1);
1283}
1284],
1285AC_MSG_RESULT(good)
1286buggygetaddrinfo=no,
1287AC_MSG_RESULT(buggy)
1288buggygetaddrinfo=yes,
1289AC_MSG_RESULT(buggy)
1290buggygetaddrinfo=yes)], [buggygetaddrinfo=yes])
1291
1292if test "$buggygetaddrinfo" = "yes"; then
1293 if test "$ipv6" = "yes"; then
1294 echo 'Fatal: You must get working getaddrinfo() function.'
1295 echo ' or you can specify "--disable-ipv6"'.
1296 exit 1
1297 fi
1298fi
1299AC_CHECK_FUNCS(getaddrinfo getnameinfo)
1300
Guido van Rossum627b2d71993-12-24 10:39:16 +00001301# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001302AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +00001303AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001304AC_STRUCT_TIMEZONE
1305
1306AC_MSG_CHECKING(for time.h that defines altzone)
1307AC_CACHE_VAL(ac_cv_header_time_altzone,
1308[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
1309 ac_cv_header_time_altzone=yes,
1310 ac_cv_header_time_altzone=no)])
1311AC_MSG_RESULT($ac_cv_header_time_altzone)
1312if test $ac_cv_header_time_altzone = yes; then
1313 AC_DEFINE(HAVE_ALTZONE)
1314fi
1315
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001316was_it_defined=no
1317AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001318AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001319#include <sys/types.h>
1320#include <sys/select.h>
1321#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001322], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
1323AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001324
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001325AC_MSG_CHECKING(for addrinfo)
1326AC_CACHE_VAL(ac_cv_struct_addrinfo,
1327AC_TRY_COMPILE([
1328# include <netdb.h>],
1329 [struct addrinfo a],
1330 ac_cv_struct_addrinfo=yes,
1331 ac_cv_struct_addrinfo=no))
1332AC_MSG_RESULT($ac_cv_struct_addrinfo)
1333if test $ac_cv_struct_addrinfo = yes; then
1334 AC_DEFINE(HAVE_ADDRINFO)
1335fi
1336
1337AC_MSG_CHECKING(for sockaddr_storage)
1338AC_CACHE_VAL(ac_cv_struct_sockaddr_storage,
1339AC_TRY_COMPILE([
1340# include <sys/types.h>
1341# include <sys/socket.h>],
1342 [struct sockaddr_storage s],
1343 ac_cv_struct_sockaddr_storage=yes,
1344 ac_cv_struct_sockaddr_storage=no))
1345AC_MSG_RESULT($ac_cv_struct_sockaddr_storage)
1346if test $ac_cv_struct_sockaddr_storage = yes; then
1347 AC_DEFINE(HAVE_SOCKADDR_STORAGE)
1348fi
1349
Guido van Rossum627b2d71993-12-24 10:39:16 +00001350# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001351
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001352AC_C_CHAR_UNSIGNED
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001353AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001354
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001355works=no
1356AC_MSG_CHECKING(for working volatile)
1357AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
1358AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +00001359
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001360works=no
1361AC_MSG_CHECKING(for working signed char)
1362AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
1363AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001364
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001365have_prototypes=no
1366AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001367AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
1368AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001369AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001370
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001371works=no
1372AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001373AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001374#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +00001375int foo(int x, ...) {
1376 va_list va;
1377 va_start(va, x);
1378 va_arg(va, int);
1379 va_arg(va, char *);
1380 va_arg(va, double);
1381 return 0;
1382}
1383], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001384AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
1385AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001386
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001387if test "$have_prototypes" = yes; then
1388bad_prototypes=no
1389AC_MSG_CHECKING(for bad exec* prototypes)
1390AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
1391 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
1392AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +00001393fi
1394
Martin v. Löwis01dfdb32001-06-23 16:30:13 +00001395# check if sockaddr has sa_len member
1396AC_MSG_CHECKING(if sockaddr has sa_len member)
1397AC_TRY_COMPILE([#include <sys/types.h>
1398#include <sys/socket.h>],
1399[struct sockaddr x;
1400x.sa_len = 0;],
1401 AC_MSG_RESULT(yes)
1402 AC_DEFINE(HAVE_SOCKADDR_SA_LEN),
1403 AC_MSG_RESULT(no))
1404
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001405bad_forward=no
1406AC_MSG_CHECKING(for bad static forward)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001407AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001408struct s { int a; int b; };
1409static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001410int foobar() {
1411 static int random;
1412 random = (int) &foo;
1413 return random;
1414}
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001415static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +00001416main() {
1417 exit(!((int)&foo == foobar()));
1418}
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001419], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
1420AC_MSG_RESULT($bad_forward)
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001421
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001422va_list_is_array=no
1423AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001424AC_TRY_COMPILE([
1425#ifdef HAVE_STDARG_PROTOTYPES
1426#include <stdarg.h>
1427#else
1428#include <varargs.h>
1429#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +00001430], [va_list list1, list2; list1 = list2;], ,
1431AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
1432AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001433
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001434# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
1435AC_CHECK_FUNC(gethostbyname_r, [
1436 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
1437 AC_MSG_CHECKING([gethostbyname_r with 6 args])
1438 OLD_CFLAGS=$CFLAGS
1439 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
1440 AC_TRY_COMPILE([
1441# include <netdb.h>
1442 ], [
1443 char *name;
1444 struct hostent *he, *res;
1445 char buffer[2048];
1446 int buflen = 2048;
1447 int h_errnop;
1448
1449 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
1450 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001451 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001452 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
1453 AC_MSG_RESULT(yes)
1454 ], [
1455 AC_MSG_RESULT(no)
1456 AC_MSG_CHECKING([gethostbyname_r with 5 args])
1457 AC_TRY_COMPILE([
1458# include <netdb.h>
1459 ], [
1460 char *name;
1461 struct hostent *he;
1462 char buffer[2048];
1463 int buflen = 2048;
1464 int h_errnop;
1465
1466 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
1467 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001468 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001469 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
1470 AC_MSG_RESULT(yes)
1471 ], [
1472 AC_MSG_RESULT(no)
1473 AC_MSG_CHECKING([gethostbyname_r with 3 args])
1474 AC_TRY_COMPILE([
1475# include <netdb.h>
1476 ], [
1477 char *name;
1478 struct hostent *he;
1479 struct hostent_data data;
1480
1481 (void) gethostbyname_r(name, he, &data);
1482 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001483 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001484 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
1485 AC_MSG_RESULT(yes)
1486 ], [
1487 AC_MSG_RESULT(no)
1488 ])
1489 ])
1490 ])
1491 CFLAGS=$OLD_CFLAGS
1492], [
Thomas Wouters3a584202000-08-05 23:28:51 +00001493 AC_CHECK_FUNCS(gethostbyname)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001494])
1495AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
1496AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
1497AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +00001498AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +00001499AC_SUBST(HAVE_GETHOSTBYNAME)
1500
Guido van Rossum627b2d71993-12-24 10:39:16 +00001501# checks for system services
1502# (none yet)
1503
Guido van Rossum76be6ed1995-01-02 18:33:54 +00001504# Linux requires this for correct f.p. operations
Jeremy Hyltonbe28f5b2000-07-27 21:03:04 +00001505AC_CHECK_FUNC(__fpu_control,
1506 [],
1507 [AC_CHECK_LIB(ieee, __fpu_control)
1508])
Guido van Rossum627b2d71993-12-24 10:39:16 +00001509
Guido van Rossum93274221997-05-09 02:42:00 +00001510# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +00001511AC_MSG_CHECKING(for --with-fpectl)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001512AC_ARG_WITH(fpectl,
1513[ --with-fpectl enable SIGFPE catching], [
Guido van Rossum93274221997-05-09 02:42:00 +00001514if test "$withval" != no
1515then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
1516else AC_MSG_RESULT(no)
Guido van Rossumef2255b2000-03-10 22:30:29 +00001517fi],
1518[AC_MSG_RESULT(no)])
Guido van Rossum93274221997-05-09 02:42:00 +00001519
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001520# check for --with-libm=...
1521AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001522case $ac_sys_system in
Guido van Rossum3dc0a512000-10-05 18:00:06 +00001523Darwin) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001524next) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +00001525BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +00001526*) LIBM=-lm
1527esac
Guido van Rossum93274221997-05-09 02:42:00 +00001528AC_MSG_CHECKING(for --with-libm=STRING)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001529AC_ARG_WITH(libm, [ --with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001530if test "$withval" = no
1531then LIBM=
1532 AC_MSG_RESULT(force LIBM empty)
1533elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001534then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001535 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001536else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001537fi],
1538[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001539
1540# check for --with-libc=...
1541AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +00001542AC_MSG_CHECKING(for --with-libc=STRING)
Barry Warsawc0d24d8b2000-06-29 16:12:00 +00001543AC_ARG_WITH(libc, [ --with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +00001544if test "$withval" = no
1545then LIBC=
1546 AC_MSG_RESULT(force LIBC empty)
1547elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001548then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +00001549 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001550else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +00001551fi],
1552[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +00001553
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001554# check for hypot() in math library
1555LIBS_SAVE=$LIBS
1556LIBS="$LIBS $LIBM"
Guido van Rossumf2f7eb31996-08-30 15:18:00 +00001557AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +00001558LIBS=$LIBS_SAVE
1559
Guido van Rossumad713701997-07-10 22:42:38 +00001560# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +00001561AC_MSG_CHECKING(what malloc(0) returns)
1562AC_CACHE_VAL(ac_cv_malloc_zero,
1563[AC_TRY_RUN([#include <stdio.h>
1564#ifdef HAVE_STDLIB
1565#include <stdlib.h>
1566#else
1567char *malloc(), *realloc();
1568int *free();
1569#endif
1570main() {
1571 char *p;
1572 p = malloc(0);
1573 if (p == NULL) exit(1);
1574 p = realloc(p, 0);
1575 if (p == NULL) exit(1);
1576 free(p);
1577 exit(0);
1578}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
1579AC_MSG_RESULT($ac_cv_malloc_zero)
1580if test "$ac_cv_malloc_zero" = null
1581then
1582 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
1583fi
1584
Guido van Rossumef2255b2000-03-10 22:30:29 +00001585# check for wchar.h
1586AC_CHECK_HEADER(wchar.h,
1587AC_DEFINE(HAVE_WCHAR_H) wchar_h="yes",
1588wchar_h="no"
1589)
1590
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001591# determine wchar_t size
1592if test "$wchar_h" = yes
1593then
1594 AC_CHECK_SIZEOF(wchar_t)
1595fi
1596
1597AC_MSG_CHECKING(what type to use for unicode)
1598AC_ARG_ENABLE(unicode,
1599[ --enable-unicode[=ucs2,ucs4] Enable Unicode strings (default is yes)],,enable_unicode=yes)
1600
1601if test $enable_unicode = yes
1602then
Martin v. Löwisfd917792001-06-27 20:22:04 +00001603 # Without any arguments, Py_UNICODE defaults to two-byte mode
1604 enable_unicode="ucs2"
Martin v. Löwis0ba70cc2001-06-26 22:22:37 +00001605fi
1606
1607case "$enable_unicode" in
1608ucs2) unicode_size="2"
1609 AC_DEFINE(Py_UNICODE_SIZE,2)
1610 ;;
1611ucs4) unicode_size="4"
1612 AC_DEFINE(Py_UNICODE_SIZE,4)
1613 ;;
1614esac
1615
1616if test "$enable_unicode" = "no"
1617then
1618 AC_MSG_RESULT(not used)
1619else
1620 AC_DEFINE(Py_USING_UNICODE)
1621 if test "$unicode_size" = "$ac_cv_sizeof_wchar_t"
1622 then
1623 PY_UNICODE_TYPE="wchar_t"
1624 AC_DEFINE(HAVE_USABLE_WCHAR_T)
1625 AC_DEFINE(PY_UNICODE_TYPE,wchar_t)
1626 elif test "$ac_cv_sizeof_short" = "$unicode_size"
1627 then
1628 PY_UNICODE_TYPE="unsigned short"
1629 AC_DEFINE(PY_UNICODE_TYPE,unsigned short)
1630 elif test "$ac_cv_sizeof_long" = "$unicode_size"
1631 then
1632 PY_UNICODE_TYPE="unsigned long"
1633 AC_DEFINE(PY_UNICODE_TYPE,unsigned long)
1634 else
1635 PY_UNICODE_TYPE="no type found"
1636 fi
1637 AC_MSG_RESULT($PY_UNICODE_TYPE)
1638fi
Guido van Rossumef2255b2000-03-10 22:30:29 +00001639
1640# check for endianness
1641AC_C_BIGENDIAN
1642
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001643# Check whether right shifting a negative integer extends the sign bit
1644# or fills with zeros (like the Cray J90, according to Tim Peters).
1645AC_MSG_CHECKING(whether right shift extends the sign bit)
Vladimir Marangozova6180282000-07-12 05:05:06 +00001646AC_CACHE_VAL(ac_cv_rshift_extends_sign, [
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001647AC_TRY_RUN([
1648int main()
1649{
Vladimir Marangozova6180282000-07-12 05:05:06 +00001650 exit(((-1)>>3 == -1) ? 0 : 1);
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001651}
Vladimir Marangozova6180282000-07-12 05:05:06 +00001652], ac_cv_rshift_extends_sign=yes, ac_cv_rshift_extends_sign=no)])
1653AC_MSG_RESULT($ac_cv_rshift_extends_sign)
1654if test "$ac_cv_rshift_extends_sign" = no
1655then
1656 AC_DEFINE(SIGNED_RIGHT_SHIFT_ZERO_FILLS)
1657fi
1658
Guido van Rossumcadfaec2001-01-05 14:45:49 +00001659# check for getc_unlocked and related locking functions
1660AC_MSG_CHECKING(for getc_unlocked() and friends)
1661AC_CACHE_VAL(ac_cv_have_getc_unlocked, [
1662AC_TRY_LINK([#include <stdio.h>],[
1663 FILE *f = fopen("/dev/null", "r");
1664 flockfile(f);
1665 getc_unlocked(f);
1666 funlockfile(f);
1667], ac_cv_have_getc_unlocked=yes, ac_cv_have_getc_unlocked=no)])
1668AC_MSG_RESULT($ac_cv_have_getc_unlocked)
1669if test "$ac_cv_have_getc_unlocked" = yes
1670then
1671 AC_DEFINE(HAVE_GETC_UNLOCKED)
1672fi
Vladimir Marangozov9a5a5d12000-07-12 03:02:16 +00001673
Guido van Rossum353ae582001-07-10 16:45:32 +00001674# check for readline 4.2
1675AC_CHECK_LIB(readline, rl_completion_matches,
1676 AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
1677
Thomas Wouterse38b2f12001-07-11 22:35:31 +00001678AC_MSG_CHECKING(for broken nice())
1679AC_CACHE_VAL(ac_cv_broken_nice, [
1680AC_TRY_RUN([
1681int main()
1682{
1683 int val1 = nice(1);
1684 if (val1 != -1 && val1 == nice(2))
1685 exit(0);
1686 exit(1);
1687}
1688],ac_cv_broken_nice=yes, ac_cv_broken_nice=no)])
1689AC_MSG_RESULT($ac_cv_broken_nice)
1690if test "$ac_cv_broken_nice" = yes
1691then
1692 AC_DEFINE(HAVE_BROKEN_NICE)
1693fi
1694
Guido van Rossum95713eb2000-05-18 20:53:31 +00001695# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
1696# Add sys/socket.h to confdefs.h
1697cat >> confdefs.h <<\EOF
1698#ifdef HAVE_SYS_SOCKET_H
1699#include <sys/socket.h>
1700#endif
1701EOF
1702AC_CHECK_TYPE(socklen_t, int)
1703
Neil Schemenauerf25cf6c2001-03-04 06:39:33 +00001704# Add Python/ prefix to LIBOBJS
1705libobjs=$LIBOBJS
1706LIBOBJS=
1707for obj in $libobjs; do
1708 LIBOBJS="$LIBOBJS Python/$obj"
1709done
1710
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001711#AC_MSG_CHECKING(for Modules/Setup)
1712#if test ! -f Modules/Setup ; then
1713# if test ! -d Modules ; then
1714# mkdir Modules
1715# fi
1716# cp "$srcdir/Modules/Setup.dist" Modules/Setup
1717# AC_MSG_RESULT(creating)
1718#else
1719# AC_MSG_RESULT(already exists)
1720#fi
1721
1722AC_SUBST(SRCDIRS)
Neil Schemenaueracbf9ef2001-02-27 02:15:14 +00001723SRCDIRS="Parser Grammar Objects Python Modules"
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001724AC_MSG_CHECKING(for build directories)
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001725for dir in $SRCDIRS; do
1726 if test ! -d $dir; then
1727 mkdir $dir
Fred Drake884d3ba2000-11-02 17:52:56 +00001728 fi
Neil Schemenauer55f0cf32001-01-24 17:24:33 +00001729done
1730AC_MSG_RESULT(done)
Fred Drake036144d2000-10-26 17:09:35 +00001731
Guido van Rossum627b2d71993-12-24 10:39:16 +00001732# generate output files
Andrew M. Kuchling8abedde2001-01-26 22:55:24 +00001733AC_OUTPUT(Makefile.pre Modules/Setup.config)
Neil Schemenauer61c51152001-01-26 16:18:16 +00001734
1735echo "creating Setup"
1736if test ! -f Modules/Setup
1737then
1738 cp $srcdir/Modules/Setup.dist Modules/Setup
1739fi
1740
1741echo "creating Setup.local"
1742if test ! -f Modules/Setup.local
1743then
1744 echo "# Edit this file for local setup changes" >Modules/Setup.local
1745fi
1746
1747echo "creating Makefile"
1748$SHELL $srcdir/Modules/makesetup -c $srcdir/Modules/config.c.in \
1749 -s Modules Modules/Setup.config \
Neil Schemenauerf8b71c52001-04-21 17:41:16 +00001750 Modules/Setup.local Modules/Setup
Neil Schemenauer66252162001-02-19 04:47:42 +00001751mv config.c Modules