configure.in 19 KB
Newer Older
1 2 3
dnl Process this file with autoconf 2.0 or later to make a configure script.
AC_REVISION($Revision$)
AC_PREREQ(2.0)
Guido van Rossum's avatar
Guido van Rossum committed
4
AC_INIT(Include/object.h)
5
AC_CONFIG_HEADER(config.h)
Guido van Rossum's avatar
Guido van Rossum committed
6

7 8 9 10
# Set VERSION so we only need to edit in one place (i.e., here)
AC_SUBST(VERSION)
VERSION=1.5

11
# NEXTSTEP stuff
12 13 14 15 16 17
if test -f /usr/lib/NextStep/software_version; then

	AC_MSG_CHECKING(for --with-next-archs)
	AC_ARG_WITH(next-archs,
	 [--with-next-archs='arch1 arch2 ..'   build MAB binary], [
		if test -n "$withval"; then
Guido van Rossum's avatar
Guido van Rossum committed
18 19 20
		    ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval`
		    # GCC does not currently support multi archs on the NeXT
		    with_gcc=no
21 22 23 24 25 26 27 28 29 30
		fi
		AC_MSG_RESULT($with_next_archs)
	], [AC_MSG_RESULT(none: using `arch`)])
	
	if test -z "$MACHDEP"
	then
		set X `hostinfo | grep 'NeXT Mach.*:' | \
 			sed -e 's/://' -e 's/\./_/'` && \
			ac_sys_system=next && ac_sys_release=$4

31
		MACHDEP="$ac_sys_system$ac_sys_release"
32
	fi
33
fi
34

35

36 37 38 39 40
# Set name for machine-dependent library files
AC_SUBST(MACHDEP)
AC_MSG_CHECKING(MACHDEP)
if test -z "$MACHDEP"
then
41 42 43
	ac_sys_system=`uname -s`
	if test "$ac_sys_system" = "AIX" ; then
		ac_sys_release=`uname -v`
44
	else
45
		ac_sys_release=`uname -r`
46
	fi
47 48 49 50
	ac_md_system=`echo $ac_sys_system |
			   tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
	ac_md_release=`echo $ac_sys_release |
			   tr -d '[/ ]' | sed 's/\..*//'`
51
	MACHDEP="$ac_md_system$ac_md_release"
52

53
	case $MACHDEP in
54
	'')	MACHDEP="unknown";;
55 56
	esac
fi
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

#
# SGI compilers allow the specification of the both the ABI and the
# ISA on the command line.  Depending on the values of these switches,
# different and often incompatable code will be generated.
#
# The SGI_ABI variable can be used to modify the CC and LDFLAGS and
# thus supply support for various ABI/ISA combinations.  The MACHDEP
# variable is also adjusted.
#
AC_SUBST(SGI_ABI)
if test ! -z "$SGI_ABI"
then
        CC="cc $SGI_ABI"
        LDFLAGS="$SGI_ABI $LDFLAGS"
        MACHDEP=`echo "${MACHDEP}${SGI_ABI}" | sed 's/ *//g'`
fi
74 75
AC_MSG_RESULT($MACHDEP)

76 77 78 79 80 81 82 83 84 85 86
#
# CCC is the command that compiles C++ programs
#
# Not all make programs have this predefined.
#
AC_SUBST(SET_CCC)
AC_MSG_CHECKING(CCC)
if test -z "$CCC"
then
	case $ac_sys_system in
	IRIX*)	SET_CCC="CCC= CC ${SGI_ABI}";;
87
	Linux*) SET_CCC="CCC= g++";;
88 89 90 91 92 93 94 95
	*)	SET_CCC=""
	esac
else
        SET_CCC="CCC= ${CCC}"
fi
AC_MSG_RESULT($SET_CCC)


Guido van Rossum's avatar
Guido van Rossum committed
96
# checks for alternative programs
97
AC_MSG_CHECKING(for --without-gcc)
98
AC_ARG_WITH(gcc, [--without-gcc             never use gcc], [
99
	case $withval in
100 101 102 103 104 105
	no)	CC=cc
		without_gcc=yes;;
	yes)	CC=gcc
		without_gcc=no;;
	*)	CC=$withval
		without_gcc=$withval;;
106
	esac], [
107
	case $ac_sys_system in
108 109
	OSF1)	CC=cc
		without_gcc=;;
110 111
	BeOS*)	CC=cc
		without_gcc=;;
112 113
	*)	without_gcc=no;;
	esac])
114 115
AC_MSG_RESULT($without_gcc)

116 117 118 119 120 121 122
# If the user switches compilers, we can't believe the cache
if test ! -z "$ac_cv_prog_CC" -a ! -z "$CC" -a "$CC" != "$ac_cv_prog_CC"
then
  AC_ERROR(cached CC is different -- throw away $cache_file
(it is also a good idea to do 'make clean' before compiling))
fi

Guido van Rossum's avatar
Guido van Rossum committed
123
AC_PROG_CC
124

125 126 127 128 129 130 131
case $MACHDEP in
bsdos*)
    case $CC in
    gcc) CC="$CC -D_HAVE_BSDI";;
    esac;;
esac

132 133 134 135 136
case $ac_sys_system in
hp*|HP*)
    case $CC in
    cc|*/cc) CC="$CC -Aa -D_HPUX_SOURCE";;
    esac;;
137 138 139 140
BeOS*)
	case $CC in
	cc) CC=cc;;
	esac;;
141 142
esac

143
# LINKCC is the command that links the python executable -- default is $(CC).
144 145
# This is altered for AIX and BeOS in order to build the export list before 
# linking.
146 147 148 149 150 151
AC_SUBST(LINKCC)
AC_MSG_CHECKING(LINKCC)
if test -z "$LINKCC"
then
	case $ac_sys_system in
	AIX*)
152
	   LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
153 154 155
	BeOS*)
	   LINKCC="\$(srcdir)/../BeOS/linkcc \$(LIBRARY) \$(PURIFY) \$(CC) -nodup \$(OPT)"
	   REALLIBRARY='libpython$(VERSION).so';;
156 157
	dgux*)
	   LINKCC="LD_RUN_PATH=$libdir \$(PURIFY) \$(CC)";;
158
	*) LINKCC="\$(PURIFY) \$(CC)";;
159 160 161 162
	esac
fi
AC_MSG_RESULT($LINKCC)

Guido van Rossum's avatar
Guido van Rossum committed
163
AC_PROG_RANLIB
164
AC_SUBST(AR)
165
AC_CHECK_PROGS(AR, ar aal, ar)
166
AC_SUBST(INSTALL)
167 168
AC_SUBST(INSTALL_PROGRAM)
AC_SUBST(INSTALL_DATA)
169
AC_SUBST(REALLIBRARY)
170 171
# Install just never works :-(
if test -z "$INSTALL"
172 173 174 175 176 177 178
then
	INSTALL=cp
	INSTALL_PROGRAM=cp
	INSTALL_DATA=cp
else
	INSTALL_PROGRAM="$INSTALL"
	INSTALL_DATA="$INSTALL -m 644"
179
fi
180

181 182 183 184 185 186 187 188 189
# Not every filesystem supports hard links
AC_SUBST(LN)
if test -z "$LN" ; then
	case $ac_sys_system in
		BeOS*) LN="ln -s";;
		*) LN=ln;;
	esac
fi

190
# Optimizer/debugger flags passed between Makefiles
191
AC_SUBST(OPT)
192
if test -z "$OPT"
193
then
194 195 196 197 198 199 200
	case $GCC in
	yes)
		case $ac_cv_prog_cc_g in
		yes)	OPT="-g -O2";;
		*)	OPT="-O2";;
		esac
		;;
201 202
	*)	OPT="-O";;
	esac
203
fi
Guido van Rossum's avatar
Guido van Rossum committed
204

205
if test "$ac_arch_flags"
Guido van Rossum's avatar
Guido van Rossum committed
206 207 208
then
	OPT="$OPT $ac_arch_flags"
fi
Guido van Rossum's avatar
Guido van Rossum committed
209 210 211
# checks for UNIX variants that set C preprocessor variables
AC_AIX
AC_MINIX
212

213 214 215 216 217 218 219 220 221
AC_MSG_CHECKING(whether $CC accepts -OPT:Olimit=0)
AC_CACHE_VAL(ac_cv_opt_olimit_ok,
[ac_save_cc="$CC"
CC="$CC -OPT:Olimit=0"
AC_TRY_RUN([int main() { return 0; }],
  ac_cv_opt_olimit_ok=yes,
  ac_cv_opt_olimit_ok=no)
CC="$ac_save_cc"])
AC_MSG_RESULT($ac_cv_opt_olimit_ok)
222
if test $ac_cv_opt_olimit_ok = yes; then
223
  OPT="$OPT -OPT:Olimit=0"
224 225 226 227 228 229 230 231 232 233 234 235 236
else
  AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
  AC_CACHE_VAL(ac_cv_olimit_ok,
  [ac_save_cc="$CC"
  CC="$CC -Olimit 1500"
  AC_TRY_RUN([int main() { return 0; }],
    ac_cv_olimit_ok=yes,
    ac_cv_olimit_ok=no)
  CC="$ac_save_cc"])
  AC_MSG_RESULT($ac_cv_olimit_ok)
  if test $ac_cv_olimit_ok = yes; then
    OPT="$OPT -Olimit 1500"
  fi
237
fi
238 239 240 241

AC_SUBST(DGUX_IS_BROKEN)
if test "$MACHDEP" != "dguxR4"
then
242
  REALLIBRARY='libpython$(VERSION).a'
243
  DGUX_IS_BROKEN="true"
244 245 246
else
  REALLIBRARY='libpython$(VERSION).so'
  OPT="$OPT -pic"
247
  DGUX_IS_BROKEN="make $REALLIBRARY"
248
fi
249

Guido van Rossum's avatar
Guido van Rossum committed
250 251 252 253 254 255 256 257 258
# check for ANSI or K&R ("traditional") preprocessor
AC_MSG_CHECKING(for C preprocessor type)
AC_TRY_COMPILE([
#define spam(name, doc) {#name, &name, #name "() -- " doc}
int foo;
struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
AC_MSG_RESULT($cpp_type)

Guido van Rossum's avatar
Guido van Rossum committed
259
# checks for header files
260
AC_HEADER_STDC
261
AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h pthread.h \
262
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
Guido van Rossum's avatar
Guido van Rossum committed
263 264
sys/audioio.h sys/file.h sys/lock.h \
sys/param.h sys/select.h sys/time.h sys/times.h \
265
sys/un.h sys/utsname.h sys/wait.h)
266
AC_HEADER_DIRENT
Guido van Rossum's avatar
Guido van Rossum committed
267 268

# checks for typedefs
269 270 271 272 273
was_it_defined=no
AC_MSG_CHECKING(for clock_t in time.h)
AC_EGREP_HEADER(clock_t, time.h, was_it_defined=yes, AC_DEFINE(clock_t, long))
AC_MSG_RESULT($was_it_defined)

Guido van Rossum's avatar
Guido van Rossum committed
274 275 276 277 278 279 280
# Add some code to confdefs.h so that the test for off_t works on SCO
cat >> confdefs.h <<\EOF
#if defined(SCO_DS)
#undef _OFF_T
#endif
EOF

281 282 283 284 285 286
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_UID_T
Guido van Rossum's avatar
Guido van Rossum committed
287

Guido van Rossum's avatar
Guido van Rossum committed
288 289
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
290
AC_CHECK_SIZEOF(void *)
291

292 293 294 295 296 297 298 299
AC_MSG_CHECKING(for long long support)
have_long_long=no
AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG) have_long_long=yes)
AC_MSG_RESULT($have_long_long)
if test $have_long_long = yes ; then
AC_CHECK_SIZEOF(long long)
fi

300 301 302 303 304 305 306
# Set info about shared libraries.
AC_SUBST(SO)
AC_SUBST(LDSHARED)
AC_SUBST(CCSHARED)
AC_SUBST(LINKFORSHARED)
# SO is the extension of shared libraries `(including the dot!)
# -- usually .so, .sl on HP-UX
307
AC_MSG_CHECKING(SO)
308 309
if test -z "$SO"
then
310
	case $ac_sys_system in
311 312
	hp*|HP*)   SO=.sl;;
	*)	   SO=.so;;
313 314
	esac
fi
315
AC_MSG_RESULT($SO)
316 317
# LDSHARED is the ld *command* used to create shared library
# -- "ld" on SunOS 4.x.x, "ld -G" on SunOS 5.x, "ld -shared" on IRIX 5
318
AC_MSG_CHECKING(LDSHARED)
319 320
if test -z "$LDSHARED"
then
321
	case $ac_sys_system/$ac_sys_release in
322
	AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
323
	BeOS*) LDSHARED="\$(srcdir)/../BeOS/linkmodule -L.. -lpython\$(VERSION)";;
324
	IRIX/5*) LDSHARED="ld -shared";;
325
	IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
326 327 328
	SunOS/4*) LDSHARED="ld";;
	SunOS/5*) LDSHARED="ld -G";;
	hp*|HP*) LDSHARED="ld -b";;
329
	OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
330
	DYNIX/ptx*) LDSHARED="ld -G";;
331
	next/*) LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';;
332
	Linux*) LDSHARED="gcc -shared";;
333
	dgux*) LDSHARED="ld -G";;
334
	FreeBSD*|NetBSD*|OpenBSD*) LDSHARED="ld -Bshareable";;
Guido van Rossum's avatar
Guido van Rossum committed
335
	SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
336 337 338
	*)	LDSHARED="ld";;
	esac
fi
339
AC_MSG_RESULT($LDSHARED)
340
# CCSHARED are the C *flags* used to create objects to go into a shared
341
# library -- this is only needed for a few systems
342
AC_MSG_CHECKING(CCSHARED)
343 344
if test -z "$CCSHARED"
then
345
	case $ac_sys_system/$ac_sys_release in
Guido van Rossum's avatar
Guido van Rossum committed
346 347 348 349
	hp*|HP*) if test "$GCC" = yes;
		 then CCSHARED="-fpic";
		 else CCSHARED="+z";
		 fi;;
350
	Linux*) CCSHARED="-fpic";;
351
	FreeBSD*|NetBSD*|OpenBSD*) CCSHARED="-fpic";;
Guido van Rossum's avatar
Guido van Rossum committed
352
	SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
353 354
	IRIX*/6*)  case $CC in
		   *gcc*) CCSHARED="-shared";;
355
		   *) CCSHARED="";;
356
		   esac;;
357 358
	esac
fi
359
AC_MSG_RESULT($CCSHARED)
360
# LINKFORSHARED are the flags passed to the $(CC) command that links
361
# the python executable -- this is only needed for a few systems
362
AC_MSG_CHECKING(LINKFORSHARED)
363 364
if test -z "$LINKFORSHARED"
then
365
	case $ac_sys_system/$ac_sys_release in
366
	AIX*)	LINKFORSHARED='-Wl,-bE:python.exp -lld';;
Guido van Rossum's avatar
Guido van Rossum committed
367
	hp*|HP*)
368
	    LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
369
	Linux*) LINKFORSHARED="-Xlinker -export-dynamic";;
Guido van Rossum's avatar
Guido van Rossum committed
370
	next/*) LINKFORSHARED="-u libsys_s";;
Guido van Rossum's avatar
Guido van Rossum committed
371
	SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
372 373 374
	SunOS/5*) case $CC in
		  *gcc*)
		    if $CC -Xlinker -V 2>/dev/null | grep BFD >/dev/null
375 376
		    then
			LINKFORSHARED="-Xlinker --export-dynamic"
377 378
		    fi;;
		  esac;;
379 380
	esac
fi
381
AC_MSG_RESULT($LINKFORSHARED)
382

Guido van Rossum's avatar
Guido van Rossum committed
383
# checks for libraries
384 385
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
386
AC_CHECK_LIB(m, pow)		# Std math lib -- assume needed if it exists
387 388
# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
# However on SGI IRIX, these exist but are broken.
389 390 391
# BeOS' sockets are stashed in libnet.
case "$ac_sys_system" in
IRIX*) ;;
392
*)
393 394
AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
395 396 397
AC_CHECK_LIB(net, socket, [LIBS="-lnet $LIBS"], [], $LIBS) # BeOS
;;
esac
398

Guido van Rossum's avatar
Guido van Rossum committed
399 400 401 402 403
AC_MSG_CHECKING(for --with-libs)
AC_ARG_WITH(libs, [--with-libs='lib1 ...'    link against additional libs], [
AC_MSG_RESULT($withval)
LIBS="$withval $LIBS"
], AC_MSG_RESULT(no))
404

405 406
AC_MSG_CHECKING(for --with(out)-readline)
AC_ARG_WITH(readline,
407 408 409 410
[--with(out)-readline      obsolete, edit Modules/Setup instead],
[AC_MSG_RESULT($withval)
AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)],
[AC_MSG_RESULT(not specified.)])
Guido van Rossum's avatar
Guido van Rossum committed
411

412 413 414
AC_SUBST(USE_THREAD_MODULE)
USE_THREAD_MODULE="#"

415 416 417 418 419 420
AC_MSG_CHECKING(for --with-dec-threads)
AC_SUBST(LDLAST)
AC_ARG_WITH(dec-threads,
[--with-dec-threads        use DEC Alpha/OSF1 thread-safe libraries],
[AC_MSG_RESULT($withval)
LDLAST=-threads
421
if test "${with_thread+set}" != set; then
422 423 424 425 426 427 428 429 430 431 432 433 434
   with_thread="$withval";
fi],
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for --with-threads)
AC_ARG_WITH(threads, [--with-threads            alias for --with-thread],
[AC_MSG_RESULT($withval)
if test "${with_thread+set}" != set; then
   with_thread="$withval";
fi],
AC_MSG_RESULT(no))

AC_MSG_CHECKING(for --with-thread)
435
AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [
436
USE_THREAD_MODULE=
437
AC_MSG_RESULT($withval)
438
if test -d "$withval"
Guido van Rossum's avatar
Guido van Rossum committed
439
then LDFLAGS="$LDFLAGS -L$withval"
Guido van Rossum's avatar
Guido van Rossum committed
440
fi
441
AC_DEFINE(_REENTRANT)
442 443 444
AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(C_THREADS)
LIBOBJS="$LIBOBJS thread.o"],[
445 446 447
AC_CHECK_FUNC(pthread_create, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
LIBOBJS="$LIBOBJS thread.o"],[
448 449 450
AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(BEOS_THREADS)
LIBOBJS="$LIBOBJS thread.o"],[
451
AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
452 453
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lpthreads"
454 455 456 457
LIBOBJS="$LIBOBJS thread.o"], [
AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lpthread"
458
LIBOBJS="$LIBOBJS thread.o"], [
459 460 461 462
AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lc_r"
LIBOBJS="$LIBOBJS thread.o"], [
463 464 465
AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lthread"
Guido van Rossum's avatar
Guido van Rossum committed
466 467 468 469
LIBOBJS="$LIBOBJS thread.o"], [
AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lcma"
470
LIBOBJS="$LIBOBJS thread.o"])
471
])])])])])])])
472

473
AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
474 475
LIBS="$LIBS -lmpc"
LIBOBJS="$LIBOBJS thread.o"])
476
AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
477 478
LIBS="$LIBS -lthread"
LIBOBJS="$LIBOBJS thread.o"])
479
], AC_MSG_RESULT(no))
480

481
# -I${DLINCLDIR} is added to the compile rule for importdl.o
482 483
AC_SUBST(DLINCLDIR)
DLINCLDIR=/
Guido van Rossum's avatar
Guido van Rossum committed
484

485
AC_MSG_CHECKING(for --with-sgi-dl)
486
AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY   IRIX 4 dynamic linking], [
487
AC_MSG_RESULT($withval)
488
AC_DEFINE(WITH_SGI_DL)
489 490
dldir=$withval
if test -d "$dldir"
Guido van Rossum's avatar
Guido van Rossum committed
491
then LDFLAGS="$LDFLAGS -L$dldir"
492
else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
Guido van Rossum's avatar
Guido van Rossum committed
493
fi
494
DLINCLDIR=${dldir}
495
LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
496

497
AC_MSG_CHECKING(for --with-dl-dld)
498
AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR  GNU dynamic linking], [
499
AC_MSG_RESULT($withval)
500
AC_DEFINE(WITH_DL_DLD)
501 502 503
dldir=`echo "$withval" | sed 's/,.*//'`
dlddir=`echo "$withval" | sed 's/.*,//'`
if test -d "$dldir" -a -d "$dlddir"
Guido van Rossum's avatar
Guido van Rossum committed
504
then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
505 506 507
else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
fi
DLINCLDIR=${dldir}
508
LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum's avatar
Guido van Rossum committed
509 510

# checks for library functions
511 512
AC_CHECK_FUNCS(alarm chown clock dlopen execv flock fork ftime ftruncate \
 gethostname_r getpeername getpgrp getpid getpwent gettimeofday getwd \
513
 kill link lstat mkfifo mktime nice pause plock pthread_init putenv readlink \
514
 select setgid setlocale setuid setsid setpgid setpgrp setvbuf \
515
 sigaction siginterrupt sigrelse strftime strptime symlink \
516
 tcgetpgrp tcsetpgrp timegm times truncate uname waitpid)
517
AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
518 519 520
AC_CHECK_FUNC(getpgrp, AC_TRY_COMPILE([#include <unistd.h>], [getpgrp(0);], AC_DEFINE(GETPGRP_HAVE_ARG)))
AC_CHECK_FUNC(setpgrp, AC_TRY_COMPILE([#include <unistd.h>], [setpgrp(0,0);], AC_DEFINE(SETPGRP_HAVE_ARG)))
AC_CHECK_FUNC(gettimeofday, AC_TRY_COMPILE([#include <sys/time.h>], [gettimeofday((struct timeval*)0,(struct timezone*)0);], ,AC_DEFINE(GETTIMEOFDAY_NO_TZ)))
Guido van Rossum's avatar
Guido van Rossum committed
521 522

# checks for structures
523
AC_HEADER_TIME
Guido van Rossum's avatar
Guido van Rossum committed
524
AC_STRUCT_TM
525 526 527 528 529 530 531 532 533 534 535 536
AC_STRUCT_TIMEZONE

AC_MSG_CHECKING(for time.h that defines altzone)
AC_CACHE_VAL(ac_cv_header_time_altzone,
[AC_TRY_COMPILE([#include <time.h>], [return altzone;],
  ac_cv_header_time_altzone=yes,
  ac_cv_header_time_altzone=no)])
AC_MSG_RESULT($ac_cv_header_time_altzone)
if test $ac_cv_header_time_altzone = yes; then
  AC_DEFINE(HAVE_ALTZONE)
fi

537 538
was_it_defined=no
AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
539
AC_TRY_COMPILE([
540 541 542
#include <sys/types.h>
#include <sys/select.h>
#include <sys/time.h>
543 544
], [;], [AC_DEFINE(SYS_SELECT_WITH_SYS_TIME) was_it_defined=yes])
AC_MSG_RESULT($was_it_defined)
Guido van Rossum's avatar
Guido van Rossum committed
545 546

# checks for compiler characteristics
547

548
AC_C_CHAR_UNSIGNED
549

550
AC_C_CONST
551

552 553 554 555
works=no
AC_MSG_CHECKING(for working volatile)
AC_TRY_COMPILE([],[volatile int x; x = 0;], works=yes, AC_DEFINE(volatile, []))
AC_MSG_RESULT($works)
Guido van Rossum's avatar
Guido van Rossum committed
556

557 558 559 560
works=no
AC_MSG_CHECKING(for working signed char)
AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
AC_MSG_RESULT($works)
561

562 563
have_prototypes=no
AC_MSG_CHECKING(for prototypes)
564 565
AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
566
AC_MSG_RESULT($have_prototypes)
567

568 569
works=no
AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
570
AC_TRY_COMPILE([
571
#include <stdarg.h>
572 573 574 575 576 577 578 579 580
int foo(int x, ...) {
	va_list va;
	va_start(va, x);
	va_arg(va, int);
	va_arg(va, char *);
	va_arg(va, double);
	return 0;
}
], [return foo(10, "", 3.14);],
581 582
AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
AC_MSG_RESULT($works)
583

584 585 586 587 588 589
if test "$have_prototypes" = yes; then
bad_prototypes=no
AC_MSG_CHECKING(for bad exec* prototypes)
AC_TRY_COMPILE([#include <unistd.h>], [char **t;execve("@",t,t);], ,
	AC_DEFINE(BAD_EXEC_PROTOTYPES) bad_prototypes=yes)
AC_MSG_RESULT($bad_prototypes)
Guido van Rossum's avatar
Guido van Rossum committed
590 591
fi

592 593
bad_forward=no
AC_MSG_CHECKING(for bad static forward)
594
AC_TRY_RUN([
595 596
struct s { int a; int b; };
static struct s foo;
Guido van Rossum's avatar
Guido van Rossum committed
597 598 599 600 601
int foobar() {
 static int random;
 random = (int) &foo;
 return random;
}
602
static struct s foo = { 1, 2 };
Guido van Rossum's avatar
Guido van Rossum committed
603 604 605
main() {
 exit(!((int)&foo == foobar()));
}
606 607
], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
AC_MSG_RESULT($bad_forward)
608

609 610
va_list_is_array=no
AC_MSG_CHECKING(whether va_list is an array)
611 612 613 614 615 616
AC_TRY_COMPILE([
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
#else
#include <varargs.h>
#endif
617 618 619
], [va_list list1, list2; list1 = list2;], , 
AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
AC_MSG_RESULT($va_list_is_array)
620

Guido van Rossum's avatar
Guido van Rossum committed
621 622 623
# checks for system services
# (none yet)

624 625
# Linux requires this for correct f.p. operations
AC_CHECK_LIB(ieee, __fpu_control)
Guido van Rossum's avatar
Guido van Rossum committed
626

627 628 629 630 631 632 633 634
# Check for --with-fpectl
AC_MSG_CHECKING(for --with-fpectl)
AC_ARG_WITH(fpectl, [--with-fpectl             enable SIGFPE catching], [
if test "$withval" != no
then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes)
else AC_MSG_RESULT(no)
fi])

635 636
# check for --with-libm=...
AC_SUBST(LIBM)
637 638
case $ac_sys_system in
next) ;;
639
BeOS) ;;
640 641
*) LIBM=-lm
esac
642
AC_MSG_CHECKING(for --with-libm=STRING)
643
AC_ARG_WITH(libm, [--with-libm=STRING        math library], [
644 645 646 647
if test "$withval" = no
then LIBM=
     AC_MSG_RESULT(force LIBM empty)
elif test "$withval" != yes
648
then LIBM=$withval
649
     AC_MSG_RESULT(set LIBM=\"$withval\")
650
else AC_ERROR(proper usage is --with-libm=STRING)
651 652
fi],
[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
653 654 655

# check for --with-libc=...
AC_SUBST(LIBC)
656
AC_MSG_CHECKING(for --with-libc=STRING)
657
AC_ARG_WITH(libc, [--with-libc=STRING        C library], [
658 659 660 661
if test "$withval" = no
then LIBC=
     AC_MSG_RESULT(force LIBC empty)
elif test "$withval" != yes
662
then LIBC=$withval
663
     AC_MSG_RESULT(set LIBC=\"$withval\")
664
else AC_ERROR(proper usage is --with-libc=STRING)
665 666
fi],
[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
667

668 669 670 671
# check for hypot() in math library
LIBS_SAVE=$LIBS
LIBS="$LIBS $LIBM"
AC_CHECK_FUNCS(hypot)
672
AC_REPLACE_FUNCS(hypot)
673 674
LIBS=$LIBS_SAVE

675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
# check for getopt
AC_MSG_CHECKING(for genuine getopt)
AC_CACHE_VAL(ac_cv_func_getopt,
[AC_TRY_RUN([#include <stdio.h>
extern int optind, opterr, getopt();
extern char* optarg;
int main() {
	char* av[] = { "testprog", "parameter", "-fFlag", NULL };
	opterr = 0;
	if (getopt(3, av, "f:") == 'f') { exit(1); }
	exit(0);
}], ac_cv_func_getopt=yes, ac_cv_func_getopt=no, ac_cv_func_getopt=no)])dnl
AC_MSG_RESULT($ac_cv_func_getopt)
test $ac_cv_func_getopt = no && LIBOBJS="$LIBOBJS getopt.o"
AC_SUBST(LIBOBJS)dnl

691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
# check whether malloc(0) returns NULL or not
AC_MSG_CHECKING(what malloc(0) returns)
AC_CACHE_VAL(ac_cv_malloc_zero,
[AC_TRY_RUN([#include <stdio.h>
#ifdef HAVE_STDLIB
#include <stdlib.h>
#else
char *malloc(), *realloc();
int *free();
#endif
main() {
	char *p;
	p = malloc(0);
	if (p == NULL) exit(1);
	p = realloc(p, 0);
	if (p == NULL) exit(1);
	free(p);
	exit(0);
}], ac_cv_malloc_zero=nonnull, ac_cv_malloc_zero=null)])
AC_MSG_RESULT($ac_cv_malloc_zero)
if test "$ac_cv_malloc_zero" = null
then
  AC_DEFINE(MALLOC_ZERO_RETURNS_NULL)
fi

Guido van Rossum's avatar
Guido van Rossum committed
716
# generate output files
717 718 719 720
AC_OUTPUT(Makefile \
 Objects/Makefile \
 Parser/Makefile \
 Python/Makefile \
721 722
 Modules/Makefile.pre \
 Modules/Setup.thread)