blob: cdf10aff4dc158ce34f17a7cc020acca4f037fd0 [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)
9VERSION=1.5
10
Guido van Rossumb418f891996-07-30 18:06:02 +000011# NEXTSTEP stuff
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000012if test -f /usr/lib/NextStep/software_version -o -f /System/Library/CoreServices/software_version ; then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000013
14 AC_MSG_CHECKING(for --with-next-archs)
15 AC_ARG_WITH(next-archs,
16 [--with-next-archs='arch1 arch2 ..' build MAB binary], [
17 if test -n "$withval"; then
Guido van Rossum2bb4f551996-09-10 18:19:59 +000018 ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval`
19 # GCC does not currently support multi archs on the NeXT
20 with_gcc=no
Guido van Rossum4b6b5791996-09-09 20:09:34 +000021 fi
22 AC_MSG_RESULT($with_next_archs)
23 ], [AC_MSG_RESULT(none: using `arch`)])
24
25 if test -z "$MACHDEP"
26 then
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000027 set X `hostinfo | egrep '(NeXT Mach|Kernel Release).*:' | \
Guido van Rossum4b6b5791996-09-09 20:09:34 +000028 sed -e 's/://' -e 's/\./_/'` && \
29 ac_sys_system=next && ac_sys_release=$4
30
Guido van Rossumb97ef171997-09-28 05:44:03 +000031 MACHDEP="$ac_sys_system$ac_sys_release"
Guido van Rossumb418f891996-07-30 18:06:02 +000032 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000033fi
Guido van Rossumb418f891996-07-30 18:06:02 +000034
Guido van Rossum54ecc3d1999-01-27 17:53:11 +000035AC_ARG_WITH(next-framework,
36[--with-next-framework Build (OpenStep|Rhapsody|MacOS10) framework],,)
37AC_ARG_WITH(dyld,
38[--with-dyld Use (OpenStep|Rhapsody|MacOS10) dynamic linker],,)
Guido van Rossum91922671997-10-09 20:24:13 +000039
Guido van Rossumb418f891996-07-30 18:06:02 +000040# Set name for machine-dependent library files
41AC_SUBST(MACHDEP)
42AC_MSG_CHECKING(MACHDEP)
43if test -z "$MACHDEP"
44then
Guido van Rossum4b6b5791996-09-09 20:09:34 +000045 ac_sys_system=`uname -s`
46 if test "$ac_sys_system" = "AIX" ; then
47 ac_sys_release=`uname -v`
Guido van Rossumb418f891996-07-30 18:06:02 +000048 else
Guido van Rossum4b6b5791996-09-09 20:09:34 +000049 ac_sys_release=`uname -r`
Guido van Rossumb418f891996-07-30 18:06:02 +000050 fi
Guido van Rossum4b6b5791996-09-09 20:09:34 +000051 ac_md_system=`echo $ac_sys_system |
52 tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
53 ac_md_release=`echo $ac_sys_release |
54 tr -d '[/ ]' | sed 's/\..*//'`
Guido van Rossumb97ef171997-09-28 05:44:03 +000055 MACHDEP="$ac_md_system$ac_md_release"
Guido van Rossum4b6b5791996-09-09 20:09:34 +000056
Guido van Rossumbcd91e01997-03-20 20:46:29 +000057 case $MACHDEP in
Guido van Rossumb97ef171997-09-28 05:44:03 +000058 '') MACHDEP="unknown";;
Guido van Rossumb418f891996-07-30 18:06:02 +000059 esac
60fi
Guido van Rossum91922671997-10-09 20:24:13 +000061
62#
63# SGI compilers allow the specification of the both the ABI and the
64# ISA on the command line. Depending on the values of these switches,
65# different and often incompatable code will be generated.
66#
67# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
68# thus supply support for various ABI/ISA combinations. The MACHDEP
69# variable is also adjusted.
70#
71AC_SUBST(SGI_ABI)
72if test ! -z "$SGI_ABI"
73then
74 CC="cc $SGI_ABI"
75 LDFLAGS="$SGI_ABI $LDFLAGS"
76 MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
77fi
Guido van Rossumb418f891996-07-30 18:06:02 +000078AC_MSG_RESULT($MACHDEP)
79
Guido van Rossum91922671997-10-09 20:24:13 +000080#
81# CCC is the command that compiles C++ programs
82#
83# Not all make programs have this predefined.
84#
85AC_SUBST(SET_CCC)
86AC_MSG_CHECKING(CCC)
87if test -z "$CCC"
88then
89 case $ac_sys_system in
90 IRIX*) SET_CCC="CCC= CC ${SGI_ABI}";;
Guido van Rossumfb4533c1998-10-02 14:39:42 +000091 Linux*) SET_CCC="CCC= g++";;
Guido van Rossum91922671997-10-09 20:24:13 +000092 *) SET_CCC=""
93 esac
94else
95 SET_CCC="CCC= ${CCC}"
96fi
97AC_MSG_RESULT($SET_CCC)
98
99
Guido van Rossum627b2d71993-12-24 10:39:16 +0000100# checks for alternative programs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000101AC_MSG_CHECKING(for --without-gcc)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000102AC_ARG_WITH(gcc, [--without-gcc never use gcc], [
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000103 case $withval in
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000104 no) CC=cc
105 without_gcc=yes;;
106 yes) CC=gcc
107 without_gcc=no;;
108 *) CC=$withval
109 without_gcc=$withval;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000110 esac], [
Guido van Rossumb418f891996-07-30 18:06:02 +0000111 case $ac_sys_system in
Guido van Rossum55a214e1995-09-13 17:48:09 +0000112 OSF1) CC=cc
113 without_gcc=;;
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000114 BeOS*)
115 # Dunno if it's a good idea to get this over with all at once, or
116 # to handle it in with the other goodies.
117 MACHDEP=beos
118
119 case $BE_HOST_CPU in
120 ppc)
Guido van Rossum81376801999-04-06 15:50:51 +0000121 CC="mwcc -I$PWD/BeOS -nodup"
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000122 without_gcc=yes
Guido van Rossum6b9da451999-03-24 17:48:12 +0000123 case `uname -r` in
124 4.0*) OPT="-DUSE_DL_EXPORT -O7 -opt schedule604 -export pragma" ;;
125 *) OPT="-DUSE_DL_EXPORT -O2 -proc 604e -export pragma" ;;
126 esac
Guido van Rossum7a5f4201999-01-12 20:30:23 +0000127 CCSHARED=-UUSE_DL_EXPORT
128 LDFLAGS="$LDFLAGS -nodup"
129
130 AR="$PWD/BeOS/ar-fake"
131 RANLIB=:
132
133 AC_DEFINE(DL_EXPORT_HEADER,"dl_export.h")
134 ;;
135 x86)
136 CC="gcc -I$PWD/BeOS"
137 without_gcc=no
138 OPT="-DUSE_DL_EXPORT -O3 -mpentiumpro"
139 CCSHARED=-UUSE_DL_EXPORT
140
141 AR="$PWD/BeOS/ar-fake"
142 RANLIB=:
143
144 AC_DEFINE(DL_EXPORT_HEADER,"dl_export.h")
145 ;;
146 *)
147 AC_ERROR(Your BeOS system isn't PowerPC or x86... neat, but this won't work...)
148 ;;
149 esac
150 ;;
Guido van Rossum55a214e1995-09-13 17:48:09 +0000151 *) without_gcc=no;;
152 esac])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000153AC_MSG_RESULT($without_gcc)
154
Guido van Rossum03ad99f1995-03-09 14:09:54 +0000155# If the user switches compilers, we can't believe the cache
156if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
157then
158 AC_ERROR(cached CC is different -- throw away $cache_file
159(it is also a good idea to do 'make clean' before compiling))
160fi
161
Guido van Rossum627b2d71993-12-24 10:39:16 +0000162AC_PROG_CC
Guido van Rossumfb842551997-08-06 23:42:07 +0000163
Guido van Rossumdd997f71998-10-07 19:58:26 +0000164case $MACHDEP in
165bsdos*)
166 case $CC in
167 gcc) CC="$CC -D_HAVE_BSDI";;
168 esac;;
169esac
170
Guido van Rossum84561611997-08-21 00:08:11 +0000171case $ac_sys_system in
172hp*|HP*)
173 case $CC in
174 cc|*/cc) CC="$CC -Aa -D_HPUX_SOURCE";;
175 esac;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000176BeOS*)
177 case $CC in
178 cc) CC=cc;;
179 esac;;
Guido van Rossum84561611997-08-21 00:08:11 +0000180esac
181
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000182# LDLIBRARY is the name of the library to link against (as opposed to the
183# name of the library into which to insert object files). On systems
184# without shared libraries, LDLIBRARY is the same as LIBRARY (defined in
185# the Makefiles).
186AC_SUBST(MAKE_LDLIBRARY)
187AC_SUBST(LDLIBRARY)
188LDLIBRARY=''
189
Guido van Rossumfb842551997-08-06 23:42:07 +0000190# LINKCC is the command that links the python executable -- default is $(CC).
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000191# This is altered for AIX and BeOS in order to build the export list before
192# linking.
Guido van Rossumfb842551997-08-06 23:42:07 +0000193AC_SUBST(LINKCC)
194AC_MSG_CHECKING(LINKCC)
195if test -z "$LINKCC"
196then
197 case $ac_sys_system in
198 AIX*)
Guido van Rossum45140f91997-08-29 18:44:06 +0000199 LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000200 BeOS*)
Guido van Rossum2666a151998-12-17 18:07:35 +0000201 LINKCC="\$(srcdir)/../BeOS/linkcc \$(LIBRARY) \$(PURIFY) \$(CC) \$(OPT)"
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000202 LDLIBRARY='libpython$(VERSION).so';;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000203 dgux*)
204 LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
Guido van Rossum25f93031997-08-18 16:00:04 +0000205 *) LINKCC="\$(PURIFY) \$(CC)";;
Guido van Rossumfb842551997-08-06 23:42:07 +0000206 esac
207fi
208AC_MSG_RESULT($LINKCC)
209
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000210AC_MSG_CHECKING(LDLIBRARY)
211
212# NeXT framework builds require that the 'ar' library be converted into
213# a bundle using libtool.
214if test "$with_next_framework"
215then
216 LDLIBRARY='libpython$(VERSION).dylib'
217fi
218
219# DG/UX requires some fancy ld contortions to produce a .so from an .a
220if test "$MACHDEP" = "dguxR4"
221then
222 LDLIBRARY='libpython$(VERSION).so'
223 OPT="$OPT -pic"
224fi
225AC_MSG_RESULT($LDLIBRARY)
226
227# If LDLIBRARY is different from LIBRARY, emit a rule to build it.
228if test -z "$LDLIBRARY"
229then
230 LDLIBRARY='libpython$(VERSION).a'
231 MAKE_LDLIBRARY="true"
232else
233 MAKE_LDLIBRARY='$(MAKE) $(LDLIBRARY)'
234fi
235
Guido van Rossum627b2d71993-12-24 10:39:16 +0000236AC_PROG_RANLIB
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000237AC_SUBST(AR)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000238AC_CHECK_PROGS(AR, ar aal, ar)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000239AC_SUBST(INSTALL)
Guido van Rossum7d473291995-01-20 14:12:16 +0000240AC_SUBST(INSTALL_PROGRAM)
241AC_SUBST(INSTALL_DATA)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000242# Install just never works :-(
243if test -z "$INSTALL"
Guido van Rossum7d473291995-01-20 14:12:16 +0000244then
245 INSTALL=cp
246 INSTALL_PROGRAM=cp
247 INSTALL_DATA=cp
248else
249 INSTALL_PROGRAM="$INSTALL"
250 INSTALL_DATA="$INSTALL -m 644"
Guido van Rossum4e8af441994-08-19 15:33:54 +0000251fi
Guido van Rossumb418f891996-07-30 18:06:02 +0000252
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000253# Not every filesystem supports hard links
254AC_SUBST(LN)
255if test -z "$LN" ; then
256 case $ac_sys_system in
257 BeOS*) LN="ln -s";;
258 *) LN=ln;;
259 esac
260fi
261
Guido van Rossum4e8af441994-08-19 15:33:54 +0000262# Optimizer/debugger flags passed between Makefiles
Guido van Rossumb418f891996-07-30 18:06:02 +0000263AC_SUBST(OPT)
Guido van Rossum4e8af441994-08-19 15:33:54 +0000264if test -z "$OPT"
Guido van Rossumb418f891996-07-30 18:06:02 +0000265then
Guido van Rossumb5875b61997-07-18 23:29:09 +0000266 case $GCC in
267 yes)
268 case $ac_cv_prog_cc_g in
269 yes) OPT="-g -O2";;
270 *) OPT="-O2";;
271 esac
272 ;;
Guido van Rossumb418f891996-07-30 18:06:02 +0000273 *) OPT="-O";;
274 esac
Guido van Rossum4e8af441994-08-19 15:33:54 +0000275fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000276
Guido van Rossum6f2260e1996-09-09 16:21:03 +0000277if test "$ac_arch_flags"
Guido van Rossumc5a39031996-07-31 17:35:03 +0000278then
279 OPT="$OPT $ac_arch_flags"
280fi
Guido van Rossum627b2d71993-12-24 10:39:16 +0000281# checks for UNIX variants that set C preprocessor variables
282AC_AIX
Guido van Rossum627b2d71993-12-24 10:39:16 +0000283AC_MINIX
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000284
Guido van Rossum91922671997-10-09 20:24:13 +0000285AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
286AC_CACHE_VAL(ac_cv_opt_olimit_ok,
287[ac_save_cc="$CC"
288CC="$CC -OPT:Olimit=0"
289AC_TRY_RUN([int main() { return 0; }],
290 ac_cv_opt_olimit_ok=yes,
291 ac_cv_opt_olimit_ok=no)
292CC="$ac_save_cc"])
293AC_MSG_RESULT($ac_cv_opt_olimit_ok)
Guido van Rossum2efa34b1997-10-23 17:43:11 +0000294if test $ac_cv_opt_olimit_ok = yes; then
Guido van Rossum304dd2d1997-10-20 23:10:56 +0000295 OPT="$OPT -OPT:Olimit=0"
Guido van Rossumf8678121998-07-07 21:05:09 +0000296else
297 AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
298 AC_CACHE_VAL(ac_cv_olimit_ok,
299 [ac_save_cc="$CC"
300 CC="$CC -Olimit 1500"
301 AC_TRY_RUN([int main() { return 0; }],
302 ac_cv_olimit_ok=yes,
303 ac_cv_olimit_ok=no)
304 CC="$ac_save_cc"])
305 AC_MSG_RESULT($ac_cv_olimit_ok)
306 if test $ac_cv_olimit_ok = yes; then
307 OPT="$OPT -Olimit 1500"
308 fi
Guido van Rossum201afe51997-05-14 21:14:44 +0000309fi
Guido van Rossumf8678121998-07-07 21:05:09 +0000310
Guido van Rossum300fda71996-08-19 21:58:16 +0000311# check for ANSI or K&R ("traditional") preprocessor
312AC_MSG_CHECKING(for C preprocessor type)
313AC_TRY_COMPILE([
314#define spam(name, doc) {#name, &name, #name "() -- " doc}
315int foo;
316struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
317], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
318AC_MSG_RESULT($cpp_type)
319
Guido van Rossum627b2d71993-12-24 10:39:16 +0000320# checks for header files
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000321AC_HEADER_STDC
Guido van Rossum96013151997-10-08 22:47:52 +0000322AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h pthread.h \
Guido van Rossuma2ef3831996-06-26 19:45:23 +0000323signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000324sys/audioio.h sys/file.h sys/lock.h \
325sys/param.h sys/select.h sys/time.h sys/times.h \
Guido van Rossuma2ef3831996-06-26 19:45:23 +0000326sys/un.h sys/utsname.h sys/wait.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000327AC_HEADER_DIRENT
Guido van Rossum627b2d71993-12-24 10:39:16 +0000328
329# checks for typedefs
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000330was_it_defined=no
331AC_MSG_CHECKING(for clock_t in time.h)
332AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
333AC_MSG_RESULT($was_it_defined)
334
Guido van Rossum300fda71996-08-19 21:58:16 +0000335# Add some code to confdefs.h so that the test for off_t works on SCO
336cat >> confdefs.h <<\EOF
337#if defined(SCO_DS)
338#undef _OFF_T
339#endif
340EOF
341
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000342AC_TYPE_MODE_T
343AC_TYPE_OFF_T
344AC_TYPE_PID_T
345AC_TYPE_SIGNAL
346AC_TYPE_SIZE_T
347AC_TYPE_UID_T
Guido van Rossum627b2d71993-12-24 10:39:16 +0000348
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000349AC_CHECK_SIZEOF(int)
350AC_CHECK_SIZEOF(long)
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000351AC_CHECK_SIZEOF(void *)
Guido van Rossumac405f61994-09-12 10:56:06 +0000352
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000353AC_MSG_CHECKING(for long long support)
354have_long_long=no
355AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
356AC_MSG_RESULT($have_long_long)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000357if test "$have_long_long" = yes ; then
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000358AC_CHECK_SIZEOF(long long)
359fi
360
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000361# Hmph. AC_CHECK_SIZEOF() doesn't include <sys/types.h>.
362AC_MSG_CHECKING(size of off_t)
363AC_CACHE_VAL(ac_cv_sizeof_off_t,
364[AC_TRY_RUN([#include <stdio.h>
365#include <sys/types.h>
366main()
367{
368 FILE *f=fopen("conftestval", "w");
369 if (!f) exit(1);
370 fprintf(f, "%d\n", sizeof(off_t));
371 exit(0);
372}], ac_cv_sizeof_off_t=`cat conftestval`, ac_cv_sizeof_off_t=0)
373])
374AC_MSG_RESULT($ac_cv_sizeof_off_t)
375AC_DEFINE_UNQUOTED(SIZEOF_OFF_T, $ac_cv_sizeof_off_t)
376
377AC_MSG_CHECKING(whether to enable large file support)
Guido van Rossum8bc1dfd1999-04-10 16:01:48 +0000378if test "$have_long_long" = yes -a \
379 "$ac_cv_sizeof_off_t" -gt "$ac_cv_sizeof_long" -a \
380 "$ac_cv_sizeof_long_long" -ge "$ac_cv_sizeof_off_t"; then
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000381 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
382 AC_MSG_RESULT(yes)
383else
384 AC_MSG_RESULT(no)
385fi
386
387
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000388# Minor variations in building a framework between NextStep versions 4 and 5
389AC_SUBST(LIBTOOL_CRUFT)
390case $ac_sys_system/$ac_sys_release in
391 next/4*)
392 ns_undef_sym='__environ'
393 LIBTOOL_CRUFT="-U $ns_undef_sym" ;;
394 next/5*)
395 ns_undef_sym='_environ'
396 LIBTOOL_CRUFT="-lcc_dynamic -U $ns_undef_sym" ;;
397esac
398
399AC_MSG_CHECKING(for --with-next-framework)
400if test "$with_next_framework"
401then
402 OPT="$OPT -fno-common"
403 # -U __environ is needed since bundles don't have access
404 # to crt0 when built but will always be linked against it
405 LDFLAGS="$LDFLAGS -Wl,-U,$ns_undef_sym"
406 AC_DEFINE(WITH_NEXT_FRAMEWORK)
407 AC_MSG_RESULT(yes)
408else
409 AC_MSG_RESULT(no)
410fi
411
412AC_MSG_CHECKING(for --with-dyld)
413if test "$with_next_framework" -o "$with_dyld"
414then
415 if test "$with_dyld"
416 then
417 AC_MSG_RESULT(yes)
418 else
419 AC_MSG_RESULT(required for framework build)
420 fi
421 AC_DEFINE(WITH_DYLD)
422 ns_dyld='set'
423else
424 AC_MSG_RESULT(no)
425fi
426
Guido van Rossumac405f61994-09-12 10:56:06 +0000427# Set info about shared libraries.
Guido van Rossumac405f61994-09-12 10:56:06 +0000428AC_SUBST(SO)
429AC_SUBST(LDSHARED)
430AC_SUBST(CCSHARED)
431AC_SUBST(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000432# SO is the extension of shared libraries `(including the dot!)
433# -- usually .so, .sl on HP-UX
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000434AC_MSG_CHECKING(SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000435if test -z "$SO"
436then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000437 case $ac_sys_system in
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000438 hp*|HP*) SO=.sl;;
439 *) SO=.so;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000440 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000441fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000442AC_MSG_RESULT($SO)
Guido van Rossumac405f61994-09-12 10:56:06 +0000443# LDSHARED is the ld *command* used to create shared library
444# -- "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 +0000445# (Shared libraries in this instance are shared modules to be loaded into
446# Python, as opposed to building Python itself as a shared library.)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000447AC_MSG_CHECKING(LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000448if test -z "$LDSHARED"
449then
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000450 case $ac_sys_system/$ac_sys_release in
Guido van Rossum45140f91997-08-29 18:44:06 +0000451 AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000452 BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000453 IRIX/5*) LDSHARED="ld -shared";;
Guido van Rossum91922671997-10-09 20:24:13 +0000454 IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000455 SunOS/4*) LDSHARED="ld";;
456 SunOS/5*) LDSHARED="ld -G";;
457 hp*|HP*) LDSHARED="ld -b";;
Guido van Rossum71001e41995-01-26 00:44:03 +0000458 OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
Guido van Rossum7d473291995-01-20 14:12:16 +0000459 DYNIX/ptx*) LDSHARED="ld -G";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000460 next/*)
461 if test "$ns_dyld"
462 then LDSHARED='$(CC) $(LDFLAGS) -bundle -prebind'
463 else LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';
464 fi
465 if test "$with_next_framework" ; then
466 LDSHARED="$LDSHARED \$(LDLIBRARY)"
467 fi ;;
Guido van Rossum81652ab1996-07-21 02:53:27 +0000468 Linux*) LDSHARED="gcc -shared";;
Guido van Rossum3c4bb801997-12-18 23:55:32 +0000469 dgux*) LDSHARED="ld -G";;
Guido van Rossumeeb63fd1999-04-21 17:03:13 +0000470 FreeBSD*/[34]*) LDSHARED="gcc -shared";;
Guido van Rossumdf693651999-01-07 21:50:41 +0000471 FreeBSD*|OpenBSD*) LDSHARED="ld -Bshareable";;
472 NetBSD*)
473 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
474 then
475 LDSHARED="cc -shared"
476 else
477 LDSHARED="ld -Bshareable"
478 fi;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000479 SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
Guido van Rossumac405f61994-09-12 10:56:06 +0000480 *) LDSHARED="ld";;
481 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000482fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000483AC_MSG_RESULT($LDSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000484# CCSHARED are the C *flags* used to create objects to go into a shared
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000485# library (module) -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000486AC_MSG_CHECKING(CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000487if test -z "$CCSHARED"
488then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000489 case $ac_sys_system/$ac_sys_release in
Guido van Rossumaf07a441995-02-13 19:45:27 +0000490 hp*|HP*) if test "$GCC" = yes;
491 then CCSHARED="-fpic";
492 else CCSHARED="+z";
493 fi;;
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000494 Linux*) CCSHARED="-fpic";;
Guido van Rossumdf693651999-01-07 21:50:41 +0000495 FreeBSD*|OpenBSD*) CCSHARED="-fpic";;
496 NetBSD*) CCSHARED="-fPIC";;
Guido van Rossum300fda71996-08-19 21:58:16 +0000497 SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000498 IRIX*/6*) case $CC in
499 *gcc*) CCSHARED="-shared";;
Guido van Rossumee21f411998-04-20 18:51:54 +0000500 *) CCSHARED="";;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000501 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000502 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000503fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000504AC_MSG_RESULT($CCSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000505# LINKFORSHARED are the flags passed to the $(CC) command that links
Guido van Rossumb65a48e1995-06-14 18:21:23 +0000506# the python executable -- this is only needed for a few systems
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000507AC_MSG_CHECKING(LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000508if test -z "$LINKFORSHARED"
509then
Guido van Rossum6100aaf1997-04-29 21:48:51 +0000510 case $ac_sys_system/$ac_sys_release in
Guido van Rossum69f65801998-03-03 21:47:00 +0000511 AIX*) LINKFORSHARED='-Wl,-bE:python.exp -lld';;
Guido van Rossum5dab3d81996-12-06 21:18:18 +0000512 hp*|HP*)
Guido van Rossum304dd2d1997-10-20 23:10:56 +0000513 LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
Guido van Rossumeeb63fd1999-04-21 17:03:13 +0000514 FreeBSD/[34]*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum2d9feed1997-11-24 17:36:21 +0000515 Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum54ecc3d1999-01-27 17:53:11 +0000516 # -u libsys_s pulls in all symbols in libsys
517 next/2*|next/3*) LINKFORSHARED="-u libsys_s";;
518 # -u __dummy makes the linker aware of the objc runtime
519 # in System.framework; otherwise, __objcInit (referenced in
520 # crt1.o) gets erroneously defined as common, which breaks dynamic
521 # loading of any modules which reference it in System.framework
522 next/4*|next/5*) LINKFORSHARED="-u __dummy -framework System" ;;
Guido van Rossum300fda71996-08-19 21:58:16 +0000523 SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
Guido van Rossumdf693651999-01-07 21:50:41 +0000524 NetBSD*)
525 if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
526 then
527 LINKFORSHARED="-Wl,--export-dynamic"
528 fi;;
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000529 SunOS/5*) case $CC in
530 *gcc*)
531 if $CC -Xlinker -V 2>/dev/null | grep BFD >/dev/null
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000532 then
533 LINKFORSHARED="-Xlinker --export-dynamic"
Guido van Rossum2b5ca001998-03-05 15:41:09 +0000534 fi;;
535 esac;;
Guido van Rossumac405f61994-09-12 10:56:06 +0000536 esac
Guido van Rossumac405f61994-09-12 10:56:06 +0000537fi
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000538AC_MSG_RESULT($LINKFORSHARED)
Guido van Rossumac405f61994-09-12 10:56:06 +0000539
Guido van Rossum627b2d71993-12-24 10:39:16 +0000540# checks for libraries
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000541AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
542AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
Guido van Rossum70c7f481998-03-26 18:44:10 +0000543# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
544# However on SGI IRIX, these exist but are broken.
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000545# BeOS' sockets are stashed in libnet.
546case "$ac_sys_system" in
547IRIX*) ;;
Guido van Rossum2cb56601998-05-07 13:25:56 +0000548*)
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000549AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
Guido van Rossumf618d2c1995-01-17 16:36:13 +0000550AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000551AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
552;;
553esac
Guido van Rossum70c7f481998-03-26 18:44:10 +0000554
Guido van Rossumc5a39031996-07-31 17:35:03 +0000555AC_MSG_CHECKING(for --with-libs)
556AC_ARG_WITH(libs, [--with-libs='lib1 ...' link against additional libs], [
557AC_MSG_RESULT($withval)
558LIBS="$withval $LIBS"
559], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000560
Guido van Rossum8c4ed9a1996-12-31 22:34:17 +0000561AC_MSG_CHECKING(for --with(out)-readline)
Guido van Rossum8c4ed9a1996-12-31 22:34:17 +0000562AC_ARG_WITH(readline,
Guido van Rossum3c7c6781997-08-05 21:47:42 +0000563[--with(out)-readline obsolete, edit Modules/Setup instead],
564[AC_MSG_RESULT($withval)
565AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)],
566[AC_MSG_RESULT(not specified.)])
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000567
Guido van Rossum009f7871997-12-04 00:51:42 +0000568AC_SUBST(USE_THREAD_MODULE)
569USE_THREAD_MODULE="#"
570
Guido van Rossum54d93d41997-01-22 20:51:58 +0000571AC_MSG_CHECKING(for --with-dec-threads)
572AC_SUBST(LDLAST)
573AC_ARG_WITH(dec-threads,
574[--with-dec-threads use DEC Alpha/OSF1 thread-safe libraries],
575[AC_MSG_RESULT($withval)
576LDLAST=-threads
Guido van Rossumf78abae1997-01-21 22:02:36 +0000577if test "${with_thread+set}" != set; then
Guido van Rossum54d93d41997-01-22 20:51:58 +0000578 with_thread="$withval";
579fi],
580AC_MSG_RESULT(no))
581
582AC_MSG_CHECKING(for --with-threads)
583AC_ARG_WITH(threads, [--with-threads alias for --with-thread],
584[AC_MSG_RESULT($withval)
585if test "${with_thread+set}" != set; then
586 with_thread="$withval";
587fi],
588AC_MSG_RESULT(no))
589
590AC_MSG_CHECKING(for --with-thread)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000591AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [
Guido van Rossum009f7871997-12-04 00:51:42 +0000592USE_THREAD_MODULE=
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000593AC_MSG_RESULT($withval)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000594if test -d "$withval"
Guido van Rossum300fda71996-08-19 21:58:16 +0000595then LDFLAGS="$LDFLAGS -L$withval"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000596fi
Guido van Rossum9caf77a1996-08-01 00:52:26 +0000597AC_DEFINE(_REENTRANT)
Guido van Rossumb418f891996-07-30 18:06:02 +0000598AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
599AC_DEFINE(C_THREADS)
600LIBOBJS="$LIBOBJS thread.o"],[
Guido van Rossum2666a151998-12-17 18:07:35 +0000601AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD)
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000602AC_DEFINE(_POSIX_THREADS)
603LIBOBJS="$LIBOBJS thread.o"],[
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000604AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
605AC_DEFINE(BEOS_THREADS)
606LIBOBJS="$LIBOBJS thread.o"],[
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000607AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000608AC_DEFINE(_POSIX_THREADS)
609LIBS="$LIBS -lpthreads"
Guido van Rossuma2ef3831996-06-26 19:45:23 +0000610LIBOBJS="$LIBOBJS thread.o"], [
611AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
612AC_DEFINE(_POSIX_THREADS)
613LIBS="$LIBS -lpthread"
Guido van Rossum6400c261997-05-22 20:34:27 +0000614LIBOBJS="$LIBOBJS thread.o"], [
Guido van Rossum49545951997-12-02 19:28:29 +0000615AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
616AC_DEFINE(_POSIX_THREADS)
617LIBS="$LIBS -lc_r"
618LIBOBJS="$LIBOBJS thread.o"], [
Guido van Rossum6400c261997-05-22 20:34:27 +0000619AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
620AC_DEFINE(_POSIX_THREADS)
621LIBS="$LIBS -lthread"
Guido van Rossumb93a8621998-05-07 13:27:32 +0000622LIBOBJS="$LIBOBJS thread.o"], [
623AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
624AC_DEFINE(_POSIX_THREADS)
625LIBS="$LIBS -lcma"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000626LIBOBJS="$LIBOBJS thread.o"])
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000627])])])])])])])
Guido van Rossum6400c261997-05-22 20:34:27 +0000628
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000629AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000630LIBS="$LIBS -lmpc"
631LIBOBJS="$LIBOBJS thread.o"])
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000632AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000633LIBS="$LIBS -lthread"
634LIBOBJS="$LIBOBJS thread.o"])
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000635], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000636
Guido van Rossum68242b51996-05-28 22:53:03 +0000637# -I${DLINCLDIR} is added to the compile rule for importdl.o
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000638AC_SUBST(DLINCLDIR)
639DLINCLDIR=/
640
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000641AC_MSG_CHECKING(for --with-sgi-dl)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000642AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000643AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000644AC_DEFINE(WITH_SGI_DL)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000645dldir=$withval
646if test -d "$dldir"
Guido van Rossum300fda71996-08-19 21:58:16 +0000647then LDFLAGS="$LDFLAGS -L$dldir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000648else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
649fi
650DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000651LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000652
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000653AC_MSG_CHECKING(for --with-dl-dld)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000654AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000655AC_MSG_RESULT($withval)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000656AC_DEFINE(WITH_DL_DLD)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000657dldir=`echo "$withval" | sed 's/,.*//'`
658dlddir=`echo "$withval" | sed 's/.*,//'`
659if test -d "$dldir" -a -d "$dlddir"
Guido van Rossum300fda71996-08-19 21:58:16 +0000660then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000661else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
662fi
663DLINCLDIR=${dldir}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000664LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum627b2d71993-12-24 10:39:16 +0000665
666# checks for library functions
Guido van Rossumdf693651999-01-07 21:50:41 +0000667AC_CHECK_FUNCS(alarm chown clock dlopen execv flock fork \
668 fsync fdatasync ftime ftruncate \
Guido van Rossuma96f0ba1999-03-22 21:49:51 +0000669 getpeername getpgrp getpid getpwent gettimeofday getwd \
Guido van Rossumfb4533c1998-10-02 14:39:42 +0000670 kill link lstat mkfifo mktime nice pause plock pthread_init putenv readlink \
Guido van Rossum96013151997-10-08 22:47:52 +0000671 select setgid setlocale setuid setsid setpgid setpgrp setvbuf \
Guido van Rossum8f4ceb11997-12-18 23:42:19 +0000672 sigaction siginterrupt sigrelse strftime strptime symlink \
Guido van Rossum08d6be41998-06-11 15:19:05 +0000673 tcgetpgrp tcsetpgrp timegm times truncate uname waitpid)
Guido van Rossum00f0f6e1999-01-06 18:52:29 +0000674
675# check for long file support functions
676AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
677
Guido van Rossumf2f7eb31996-08-30 15:18:00 +0000678AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000679AC_CHECK_FUNC(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
680AC_CHECK_FUNC(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
681AC_CHECK_FUNC(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 +0000682
683# checks for structures
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000684AC_HEADER_TIME
Guido van Rossum627b2d71993-12-24 10:39:16 +0000685AC_STRUCT_TM
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000686AC_STRUCT_TIMEZONE
687
688AC_MSG_CHECKING(for time.h that defines altzone)
689AC_CACHE_VAL(ac_cv_header_time_altzone,
690[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
691 ac_cv_header_time_altzone=yes,
692 ac_cv_header_time_altzone=no)])
693AC_MSG_RESULT($ac_cv_header_time_altzone)
694if test $ac_cv_header_time_altzone = yes; then
695 AC_DEFINE(HAVE_ALTZONE)
696fi
697
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000698was_it_defined=no
699AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000700AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000701#include <sys/types.h>
702#include <sys/select.h>
703#include <sys/time.h>
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000704], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
705AC_MSG_RESULT($was_it_defined)
Guido van Rossum627b2d71993-12-24 10:39:16 +0000706
707# checks for compiler characteristics
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000708
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000709AC_C_CHAR_UNSIGNED
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000710
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000711AC_C_CONST
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000712
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000713works=no
714AC_MSG_CHECKING(for working volatile)
715AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
716AC_MSG_RESULT($works)
Guido van Rossumdabb11b1994-10-11 15:04:27 +0000717
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000718works=no
719AC_MSG_CHECKING(for working signed char)
720AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
721AC_MSG_RESULT($works)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000722
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000723have_prototypes=no
724AC_MSG_CHECKING(for prototypes)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000725AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
726AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000727AC_MSG_RESULT($have_prototypes)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000728
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000729works=no
730AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000731AC_TRY_COMPILE([
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000732#include <stdarg.h>
Guido van Rossum3f13e481996-08-30 20:58:11 +0000733int foo(int x, ...) {
734 va_list va;
735 va_start(va, x);
736 va_arg(va, int);
737 va_arg(va, char *);
738 va_arg(va, double);
739 return 0;
740}
741], [return foo(10, "", 3.14);],
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000742AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
743AC_MSG_RESULT($works)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000744
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000745if test "$have_prototypes" = yes; then
746bad_prototypes=no
747AC_MSG_CHECKING(for bad exec* prototypes)
748AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
749 AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
750AC_MSG_RESULT($bad_prototypes)
Guido van Rossum627b2d71993-12-24 10:39:16 +0000751fi
752
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000753bad_forward=no
754AC_MSG_CHECKING(for bad static forward)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000755AC_TRY_RUN([
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000756struct s { int a; int b; };
757static struct s foo;
Guido van Rossum5dee5e71994-11-10 23:06:54 +0000758int foobar() {
759 static int random;
760 random = (int) &foo;
761 return random;
762}
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000763static struct s foo = { 1, 2 };
Guido van Rossum5dee5e71994-11-10 23:06:54 +0000764main() {
765 exit(!((int)&foo == foobar()));
766}
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000767], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
768AC_MSG_RESULT($bad_forward)
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000769
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000770va_list_is_array=no
771AC_MSG_CHECKING(whether va_list is an array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000772AC_TRY_COMPILE([
773#ifdef HAVE_STDARG_PROTOTYPES
774#include <stdarg.h>
775#else
776#include <varargs.h>
777#endif
Guido van Rossum5739e7e1995-01-20 16:50:53 +0000778], [va_list list1, list2; list1 = list2;], ,
779AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
780AC_MSG_RESULT($va_list_is_array)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000781
Guido van Rossuma96f0ba1999-03-22 21:49:51 +0000782# sigh -- gethostbyname_r is a mess; it can have 3, 5 or 6 arguments :-(
783AC_CHECK_FUNC(gethostbyname_r, [
784 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
785 AC_MSG_CHECKING([gethostbyname_r with 6 args])
786 OLD_CFLAGS=$CFLAGS
787 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
788 AC_TRY_COMPILE([
789# include <netdb.h>
790 ], [
791 char *name;
792 struct hostent *he, *res;
793 char buffer[2048];
794 int buflen = 2048;
795 int h_errnop;
796
797 (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
798 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +0000799 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +0000800 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG)
801 AC_MSG_RESULT(yes)
802 ], [
803 AC_MSG_RESULT(no)
804 AC_MSG_CHECKING([gethostbyname_r with 5 args])
805 AC_TRY_COMPILE([
806# include <netdb.h>
807 ], [
808 char *name;
809 struct hostent *he;
810 char buffer[2048];
811 int buflen = 2048;
812 int h_errnop;
813
814 (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
815 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +0000816 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +0000817 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG)
818 AC_MSG_RESULT(yes)
819 ], [
820 AC_MSG_RESULT(no)
821 AC_MSG_CHECKING([gethostbyname_r with 3 args])
822 AC_TRY_COMPILE([
823# include <netdb.h>
824 ], [
825 char *name;
826 struct hostent *he;
827 struct hostent_data data;
828
829 (void) gethostbyname_r(name, he, &data);
830 ], [
Guido van Rossum8db7d8b1999-03-23 16:40:33 +0000831 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +0000832 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG)
833 AC_MSG_RESULT(yes)
834 ], [
835 AC_MSG_RESULT(no)
836 ])
837 ])
838 ])
839 CFLAGS=$OLD_CFLAGS
840], [
841 AC_CHECK_FUNC(gethostbyname, AC_DEFINE(HAVE_GETHOSTBYNAME))
842])
843AC_SUBST(HAVE_GETHOSTBYNAME_R_6_ARG)
844AC_SUBST(HAVE_GETHOSTBYNAME_R_5_ARG)
845AC_SUBST(HAVE_GETHOSTBYNAME_R_3_ARG)
Guido van Rossum8db7d8b1999-03-23 16:40:33 +0000846AC_SUBST(HAVE_GETHOSTBYNAME_R)
Guido van Rossuma96f0ba1999-03-22 21:49:51 +0000847AC_SUBST(HAVE_GETHOSTBYNAME)
848
Guido van Rossum627b2d71993-12-24 10:39:16 +0000849# checks for system services
850# (none yet)
851
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000852# Linux requires this for correct f.p. operations
853AC_CHECK_LIB(ieee, __fpu_control)
Guido van Rossum627b2d71993-12-24 10:39:16 +0000854
Guido van Rossum93274221997-05-09 02:42:00 +0000855# Check for --with-fpectl
Guido van Rossum93274221997-05-09 02:42:00 +0000856AC_MSG_CHECKING(for --with-fpectl)
857AC_ARG_WITH(fpectl, [--with-fpectl enable SIGFPE catching], [
858if test "$withval" != no
859then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
860else AC_MSG_RESULT(no)
861fi])
862
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000863# check for --with-libm=...
864AC_SUBST(LIBM)
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000865case $ac_sys_system in
866next) ;;
Guido van Rossumec95c7b1998-08-04 17:59:56 +0000867BeOS) ;;
Guido van Rossum4b6b5791996-09-09 20:09:34 +0000868*) LIBM=-lm
869esac
Guido van Rossum93274221997-05-09 02:42:00 +0000870AC_MSG_CHECKING(for --with-libm=STRING)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000871AC_ARG_WITH(libm, [--with-libm=STRING math library], [
Guido van Rossum93274221997-05-09 02:42:00 +0000872if test "$withval" = no
873then LIBM=
874 AC_MSG_RESULT(force LIBM empty)
875elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000876then LIBM=$withval
Guido van Rossum93274221997-05-09 02:42:00 +0000877 AC_MSG_RESULT(set LIBM=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000878else AC_ERROR(proper usage is --with-libm=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +0000879fi],
880[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000881
882# check for --with-libc=...
883AC_SUBST(LIBC)
Guido van Rossum93274221997-05-09 02:42:00 +0000884AC_MSG_CHECKING(for --with-libc=STRING)
Guido van Rossum76be6ed1995-01-02 18:33:54 +0000885AC_ARG_WITH(libc, [--with-libc=STRING C library], [
Guido van Rossum93274221997-05-09 02:42:00 +0000886if test "$withval" = no
887then LIBC=
888 AC_MSG_RESULT(force LIBC empty)
889elif test "$withval" != yes
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000890then LIBC=$withval
Guido van Rossum93274221997-05-09 02:42:00 +0000891 AC_MSG_RESULT(set LIBC=\"$withval\")
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000892else AC_ERROR(proper usage is --with-libc=STRING)
Guido van Rossum93274221997-05-09 02:42:00 +0000893fi],
894[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
Guido van Rossum433c8ad1994-08-01 12:07:07 +0000895
Guido van Rossumaf5b83e1995-01-04 19:02:35 +0000896# check for hypot() in math library
897LIBS_SAVE=$LIBS
898LIBS="$LIBS $LIBM"
899AC_CHECK_FUNCS(hypot)
Guido van Rossumf2f7eb31996-08-30 15:18:00 +0000900AC_REPLACE_FUNCS(hypot)
Guido van Rossumaf5b83e1995-01-04 19:02:35 +0000901LIBS=$LIBS_SAVE
902
Guido van Rossum7d473291995-01-20 14:12:16 +0000903# check for getopt
904AC_MSG_CHECKING(for genuine getopt)
905AC_CACHE_VAL(ac_cv_func_getopt,
906[AC_TRY_RUN([#include <stdio.h>
907extern int optind, opterr, getopt();
908extern char* optarg;
909int main() {
910 char* av[] = { "testprog", "parameter", "-fFlag", NULL };
911 opterr = 0;
912 if (getopt(3, av, "f:") == 'f') { exit(1); }
913 exit(0);
914}], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
915AC_MSG_RESULT($ac_cv_func_getopt)
916test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
917AC_SUBST(LIBOBJS)dnl
918
Guido van Rossumad713701997-07-10 22:42:38 +0000919# check whether malloc(0) returns NULL or not
Guido van Rossumad713701997-07-10 22:42:38 +0000920AC_MSG_CHECKING(what malloc(0) returns)
921AC_CACHE_VAL(ac_cv_malloc_zero,
922[AC_TRY_RUN([#include <stdio.h>
923#ifdef HAVE_STDLIB
924#include <stdlib.h>
925#else
926char *malloc(), *realloc();
927int *free();
928#endif
929main() {
930 char *p;
931 p = malloc(0);
932 if (p == NULL) exit(1);
933 p = realloc(p, 0);
934 if (p == NULL) exit(1);
935 free(p);
936 exit(0);
937}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
938AC_MSG_RESULT($ac_cv_malloc_zero)
939if test "$ac_cv_malloc_zero" = null
940then
941 AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
942fi
943
Guido van Rossum627b2d71993-12-24 10:39:16 +0000944# generate output files
Guido van Rossumb418f891996-07-30 18:06:02 +0000945AC_OUTPUT(Makefile \
946 Objects/Makefile \
947 Parser/Makefile \
948 Python/Makefile \
Guido van Rossum009f7871997-12-04 00:51:42 +0000949 Modules/Makefile.pre \
950 Modules/Setup.thread)