configure.in 17.2 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 87 88 89 90 91 92 93 94
#
# 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}";;
	*)	SET_CCC=""
	esac
else
        SET_CCC="CCC= ${CCC}"
fi
AC_MSG_RESULT($SET_CCC)


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

113 114 115 116 117 118 119
# 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
120
AC_PROG_CC
121

122 123 124 125 126 127 128
case $ac_sys_system in
hp*|HP*)
    case $CC in
    cc|*/cc) CC="$CC -Aa -D_HPUX_SOURCE";;
    esac;;
esac

129 130 131 132 133 134 135 136
# LINKCC is the command that links the python executable -- default is $(CC).
# This is altered for AIX in order to build the export list before linking.
AC_SUBST(LINKCC)
AC_MSG_CHECKING(LINKCC)
if test -z "$LINKCC"
then
	case $ac_sys_system in
	AIX*)
137
	   LINKCC="\$(srcdir)/makexp_aix python.exp \"\" \$(LIBRARY); \$(PURIFY) \$(CC)";;
138
	*) LINKCC="\$(PURIFY) \$(CC)";;
139 140 141 142
	esac
fi
AC_MSG_RESULT($LINKCC)

Guido van Rossum's avatar
Guido van Rossum committed
143
AC_PROG_RANLIB
144
AC_SUBST(AR)
145
AC_CHECK_PROGS(AR, ar aal, ar)
146
AC_SUBST(INSTALL)
147 148
AC_SUBST(INSTALL_PROGRAM)
AC_SUBST(INSTALL_DATA)
149 150
# Install just never works :-(
if test -z "$INSTALL"
151 152 153 154 155 156 157
then
	INSTALL=cp
	INSTALL_PROGRAM=cp
	INSTALL_DATA=cp
else
	INSTALL_PROGRAM="$INSTALL"
	INSTALL_DATA="$INSTALL -m 644"
158
fi
159

160
# Optimizer/debugger flags passed between Makefiles
161
AC_SUBST(OPT)
162
if test -z "$OPT"
163
then
164 165 166 167 168 169 170
	case $GCC in
	yes)
		case $ac_cv_prog_cc_g in
		yes)	OPT="-g -O2";;
		*)	OPT="-O2";;
		esac
		;;
171 172
	*)	OPT="-O";;
	esac
173
fi
Guido van Rossum's avatar
Guido van Rossum committed
174

175
if test "$ac_arch_flags"
Guido van Rossum's avatar
Guido van Rossum committed
176 177 178
then
	OPT="$OPT $ac_arch_flags"
fi
Guido van Rossum's avatar
Guido van Rossum committed
179 180 181
# checks for UNIX variants that set C preprocessor variables
AC_AIX
AC_MINIX
182

183 184 185 186
AC_MSG_CHECKING(whether $CC accepts -Olimit 1500)
AC_CACHE_VAL(ac_cv_olimit_ok,
[ac_save_cc="$CC"
CC="$CC -Olimit 1500"
187
AC_TRY_RUN([int main() { return 0; }],
188 189 190 191
  ac_cv_olimit_ok=yes,
  ac_cv_olimit_ok=no)
CC="$ac_save_cc"])
AC_MSG_RESULT($ac_cv_olimit_ok)
192
if test $ac_cv_olimit_ok = yes; then
193
  OPT="$OPT -Olimit 1500"
194 195 196 197 198 199 200 201 202 203 204
fi

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)
205
if test $ac_cv_opt_olimit_ok = yes; then
206
  OPT="$OPT -OPT:Olimit=0"
207 208
fi

Guido van Rossum's avatar
Guido van Rossum committed
209 210 211 212 213 214 215 216 217
# 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
218
# checks for header files
219
AC_HEADER_STDC
220
AC_CHECK_HEADERS(dlfcn.h fcntl.h limits.h locale.h ncurses.h pthread.h \
221
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h \
Guido van Rossum's avatar
Guido van Rossum committed
222 223
sys/audioio.h sys/file.h sys/lock.h \
sys/param.h sys/select.h sys/time.h sys/times.h \
224
sys/un.h sys/utsname.h sys/wait.h)
225
AC_HEADER_DIRENT
Guido van Rossum's avatar
Guido van Rossum committed
226 227

# checks for typedefs
228 229 230 231 232
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
233 234 235 236 237 238 239
# 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

240 241 242 243 244 245
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
246

Guido van Rossum's avatar
Guido van Rossum committed
247 248
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
249 250 251 252 253 254 255 256

# 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
257
AC_MSG_CHECKING(SO)
258 259
if test -z "$SO"
then
260
	case $ac_sys_system in
261 262
	hp*|HP*)   SO=.sl;;
	*)	   SO=.so;;
263 264
	esac
fi
265
AC_MSG_RESULT($SO)
266 267
# 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
268
AC_MSG_CHECKING(LDSHARED)
269 270
if test -z "$LDSHARED"
then
271
	case $ac_sys_system/$ac_sys_release in
272
	AIX*) LDSHARED="\$(srcdir)/ld_so_aix \$(CC)";;
273
	IRIX/5*) LDSHARED="ld -shared";;
274
	IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
275 276 277
	SunOS/4*) LDSHARED="ld";;
	SunOS/5*) LDSHARED="ld -G";;
	hp*|HP*) LDSHARED="ld -b";;
278
	OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
279
	DYNIX/ptx*) LDSHARED="ld -G";;
280
	next/*) LDSHARED='$(CC) $(CFLAGS) -nostdlib -r';;
281
	Linux*) LDSHARED="gcc -shared";;
282
	FreeBSD*) LDSHARED="ld -Bshareable";;
Guido van Rossum's avatar
Guido van Rossum committed
283
	SCO_SV*) LDSHARED="cc -G -KPIC -Ki486 -belf -Wl,-Bexport";;
284 285 286
	*)	LDSHARED="ld";;
	esac
fi
287
AC_MSG_RESULT($LDSHARED)
288
# CCSHARED are the C *flags* used to create objects to go into a shared
289
# library -- this is only needed for a few systems
290
AC_MSG_CHECKING(CCSHARED)
291 292
if test -z "$CCSHARED"
then
293
	case $ac_sys_system/$ac_sys_release in
Guido van Rossum's avatar
Guido van Rossum committed
294 295 296 297
	hp*|HP*) if test "$GCC" = yes;
		 then CCSHARED="-fpic";
		 else CCSHARED="+z";
		 fi;;
298
	Linux*) CCSHARED="-fpic";;
299
	FreeBSD*) CCSHARED="-fpic";;
Guido van Rossum's avatar
Guido van Rossum committed
300
	SCO_SV*) CCSHARED="-KPIC -dy -Bdynamic";;
301
	IRIX*/6*) CCSHARED="-all";;
302 303
	esac
fi
304
AC_MSG_RESULT($CCSHARED)
305
# LINKFORSHARED are the flags passed to the $(CC) command that links
306
# the python executable -- this is only needed for a few systems
307
AC_MSG_CHECKING(LINKFORSHARED)
308 309
if test -z "$LINKFORSHARED"
then
310
	case $ac_sys_system/$ac_sys_release in
311
	AIX*)	LINKFORSHARED='-Wl,-bE:$(srcdir)/python.exp -lld';;
Guido van Rossum's avatar
Guido van Rossum committed
312
	hp*|HP*)
313
	    LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
314
	Linux*) LINKFORSHARED="-rdynamic";;
Guido van Rossum's avatar
Guido van Rossum committed
315
	next/*) LINKFORSHARED="-u libsys_s";;
Guido van Rossum's avatar
Guido van Rossum committed
316
	SCO_SV*) LINKFORSHARED="-Bdynamic -dy -Wl,-Bexport";;
317
	IRIX*/6*) LINKFORSHARED="-all";;
318 319
	esac
fi
320
AC_MSG_RESULT($LINKFORSHARED)
321

Guido van Rossum's avatar
Guido van Rossum committed
322
# checks for libraries
323 324 325
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
AC_CHECK_LIB(sun, getpwnam)	# NIS (== YP) interface for IRIX 4
326 327 328 329 330 331
# The following three (nsl,inet,socket) are needed on Sequent;
# the order of checking must be this.  Most SVR4 platforms will
# need -lsocket and -lnsl.  However on SGI IRIX 5, these exist but
# broken.  I see no elegant solution (probably CHECK_LIB should be
# fixed to only add the library if the given entry point is not
# satisfied without it).
332
if test "$ac_sys_system" != IRIX
333
then
334 335 336
AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
AC_CHECK_LIB(inet, gethostbyname, [LIBS="-linet $LIBS"], [], -lnsl) # Sequent
AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets
337
fi
Guido van Rossum's avatar
Guido van Rossum committed
338 339 340 341 342
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))
343

344 345
AC_MSG_CHECKING(for --with(out)-readline)
AC_ARG_WITH(readline,
346 347 348 349
[--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
350

351 352 353 354 355 356
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
357
if test "${with_thread+set}" != set; then
358 359 360 361 362 363 364 365 366 367 368 369 370
   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)
371
AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [
372
AC_MSG_RESULT($withval)
373
if test -d "$withval"
Guido van Rossum's avatar
Guido van Rossum committed
374
then LDFLAGS="$LDFLAGS -L$withval"
Guido van Rossum's avatar
Guido van Rossum committed
375
fi
376
AC_DEFINE(_REENTRANT)
377 378 379
AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(C_THREADS)
LIBOBJS="$LIBOBJS thread.o"],[
380
AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
381 382
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lpthreads"
383 384 385 386
LIBOBJS="$LIBOBJS thread.o"], [
AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lpthread"
387 388 389 390
LIBOBJS="$LIBOBJS thread.o"], [
AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD)
AC_DEFINE(_POSIX_THREADS)
LIBS="$LIBS -lthread"
391
LIBOBJS="$LIBOBJS thread.o"])
392 393
])])])

394
AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD)
395 396
LIBS="$LIBS -lmpc"
LIBOBJS="$LIBOBJS thread.o"])
397
AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD)
398 399
LIBS="$LIBS -lthread"
LIBOBJS="$LIBOBJS thread.o"])
400
], AC_MSG_RESULT(no))
401

402
# -I${DLINCLDIR} is added to the compile rule for importdl.o
403 404
AC_SUBST(DLINCLDIR)
DLINCLDIR=/
Guido van Rossum's avatar
Guido van Rossum committed
405

406
AC_MSG_CHECKING(for --with-sgi-dl)
407
AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY   IRIX 4 dynamic linking], [
408
AC_MSG_RESULT($withval)
409
AC_DEFINE(WITH_SGI_DL)
410 411
dldir=$withval
if test -d "$dldir"
Guido van Rossum's avatar
Guido van Rossum committed
412
then LDFLAGS="$LDFLAGS -L$dldir"
413
else AC_ERROR(proper usage is --with-sgi-dl=DIRECTORY)
Guido van Rossum's avatar
Guido van Rossum committed
414
fi
415
DLINCLDIR=${dldir}
416
LIBS="$LIBS -ldl -lmld"], AC_MSG_RESULT(no))
417

418
AC_MSG_CHECKING(for --with-dl-dld)
419
AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR  GNU dynamic linking], [
420
AC_MSG_RESULT($withval)
421
AC_DEFINE(WITH_DL_DLD)
422 423 424
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
425
then LDFLAGS="$LDFLAGS -L$dldir -L$dlddir"
426 427 428
else AC_ERROR(proper usage is --with-dl-dld=DL_DIRECTORY,DLD_DIRECTORY)
fi
DLINCLDIR=${dldir}
429
LIBS="$LIBS -ldl -ldld"], AC_MSG_RESULT(no))
Guido van Rossum's avatar
Guido van Rossum committed
430 431

# checks for library functions
432 433 434
AC_CHECK_FUNCS(alarm chown clock dlopen execv flock fork ftime ftruncate \
 gethostname_r getpeername getpgrp getpid getpwent gettimeofday getwd \
 kill link lstat mkfifo nice pause plock putenv readlink \
435
 select setgid setlocale setuid setsid setpgid setpgrp setvbuf \
436
 sigaction siginterrupt sigrelse strftime symlink \
437
 tcgetpgrp tcsetpgrp times truncate uname waitpid)
438
AC_REPLACE_FUNCS(dup2 getcwd strdup strerror memmove)
439 440 441
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
442 443

# checks for structures
444
AC_HEADER_TIME
Guido van Rossum's avatar
Guido van Rossum committed
445
AC_STRUCT_TM
446 447 448 449 450 451 452 453 454 455 456 457
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

458 459
was_it_defined=no
AC_MSG_CHECKING(whether sys/select.h and sys/time.h may both be included)
460
AC_TRY_COMPILE([
461 462 463
#include <sys/types.h>
#include <sys/select.h>
#include <sys/time.h>
464 465
], [;], [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
466 467

# checks for compiler characteristics
468

469
AC_C_CHAR_UNSIGNED
470

471
AC_C_CONST
472

473 474 475 476
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
477

478 479 480 481
works=no
AC_MSG_CHECKING(for working signed char)
AC_TRY_COMPILE([], [signed char c;], works=yes, AC_DEFINE(signed, []))
AC_MSG_RESULT($works)
482

483 484
have_prototypes=no
AC_MSG_CHECKING(for prototypes)
485 486
AC_TRY_COMPILE([int foo(int x) { return 0; }], [return foo(10);],
AC_DEFINE(HAVE_PROTOTYPES) have_prototypes=yes)
487
AC_MSG_RESULT($have_prototypes)
488

489 490
works=no
AC_MSG_CHECKING(for variable length prototypes and stdarg.h)
491
AC_TRY_COMPILE([
492
#include <stdarg.h>
493 494 495 496 497 498 499 500 501
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);],
502 503
AC_DEFINE(HAVE_STDARG_PROTOTYPES) works=yes)
AC_MSG_RESULT($works)
504

505 506 507 508 509 510
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
511 512
fi

513 514
bad_forward=no
AC_MSG_CHECKING(for bad static forward)
515
AC_TRY_RUN([
516 517
struct s { int a; int b; };
static struct s foo;
Guido van Rossum's avatar
Guido van Rossum committed
518 519 520 521 522
int foobar() {
 static int random;
 random = (int) &foo;
 return random;
}
523
static struct s foo = { 1, 2 };
Guido van Rossum's avatar
Guido van Rossum committed
524 525 526
main() {
 exit(!((int)&foo == foobar()));
}
527 528
], , AC_DEFINE(BAD_STATIC_FORWARD) bad_forward=yes)
AC_MSG_RESULT($bad_forward)
529

530 531
va_list_is_array=no
AC_MSG_CHECKING(whether va_list is an array)
532 533 534 535 536 537
AC_TRY_COMPILE([
#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
#else
#include <varargs.h>
#endif
538 539 540
], [va_list list1, list2; list1 = list2;], , 
AC_DEFINE(VA_LIST_IS_ARRAY) va_list_is_array=yes)
AC_MSG_RESULT($va_list_is_array)
541

Guido van Rossum's avatar
Guido van Rossum committed
542 543 544
# checks for system services
# (none yet)

545 546
# Linux requires this for correct f.p. operations
AC_CHECK_LIB(ieee, __fpu_control)
Guido van Rossum's avatar
Guido van Rossum committed
547

548 549 550 551 552 553 554 555
# 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])

556 557
# check for --with-libm=...
AC_SUBST(LIBM)
558 559 560 561
case $ac_sys_system in
next) ;;
*) LIBM=-lm
esac
562
AC_MSG_CHECKING(for --with-libm=STRING)
563
AC_ARG_WITH(libm, [--with-libm=STRING        math library], [
564 565 566 567
if test "$withval" = no
then LIBM=
     AC_MSG_RESULT(force LIBM empty)
elif test "$withval" != yes
568
then LIBM=$withval
569
     AC_MSG_RESULT(set LIBM=\"$withval\")
570
else AC_ERROR(proper usage is --with-libm=STRING)
571 572
fi],
[AC_MSG_RESULT(default LIBM=\"$LIBM\")])
573 574 575

# check for --with-libc=...
AC_SUBST(LIBC)
576
AC_MSG_CHECKING(for --with-libc=STRING)
577
AC_ARG_WITH(libc, [--with-libc=STRING        C library], [
578 579 580 581
if test "$withval" = no
then LIBC=
     AC_MSG_RESULT(force LIBC empty)
elif test "$withval" != yes
582
then LIBC=$withval
583
     AC_MSG_RESULT(set LIBC=\"$withval\")
584
else AC_ERROR(proper usage is --with-libc=STRING)
585 586
fi],
[AC_MSG_RESULT(default LIBC=\"$LIBC\")])
587

588 589 590 591
# check for hypot() in math library
LIBS_SAVE=$LIBS
LIBS="$LIBS $LIBM"
AC_CHECK_FUNCS(hypot)
592
AC_REPLACE_FUNCS(hypot)
593 594
LIBS=$LIBS_SAVE

595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
# 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

611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635
# 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
636
# generate output files
637 638 639 640 641
AC_OUTPUT(Makefile \
 Objects/Makefile \
 Parser/Makefile \
 Python/Makefile \
 Modules/Makefile.pre)