dnl Process this file with autoconf to produce a configure script for Dinero IV.
dnl Written by Jan Edler.
dnl
dnl $Header: /home/edler/dinero/d4/RCS/configure.in,v 1.3 1997/12/08 19:37:38 edler Exp $
AC_INIT(d4.h)
AC_CONFIG_HEADER(config.h)

dnl Checks for programs.
if test "x$CFLAGS" = x; then
	CFLAGS=-O3	# this is really poor, need a better way XXX
fi
AC_PROG_CC

dnl check for any specific host dependencies
AC_AIX
if test x$GCC = xyes; then
	CFLAGS="$CFLAGS -g"
	CFLAGS="$CFLAGS -Wall -Wcast-qual -Wshadow -Wpointer-arith"
	CFLAGS="$CFLAGS -Wmissing-prototypes"
fi
AC_PROG_RANLIB

dnl Checks for header files.
AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(short,0)
AC_CHECK_SIZEOF(int,0)
AC_CHECK_SIZEOF(long,0)
AC_CHECK_SIZEOF(void*,0)

dnl this is probably not worth the trouble,
dnl and is ineffective without checking the timing,
dnl in case unaligned accesses are slowly emulated, as on alpha
dnl if test "$cross_compiling" = yes; then
dnl   D4_UNALIGN_OK=0
dnl else
dnl   AC_C_BIGENDIAN
dnl   AC_MSG_CHECKING(if unaligned loads and stores are allowed)
dnl   AC_TRY_RUN([union { int i[3]; char c[1]; } u;
dnl 	main(){ *(int*)&u.c[1] = getpid();
dnl 		*(int*)&u.c[2] = *(int*)&u.c[1]; exit(0);}],
dnl 	D4_UNALIGN_OK=1, D4_UNALIGN_OK=0, D4_UNALIGN_OK=0)
dnl   if test "$D4_UNALIGN_OK" = 1; then
dnl     AC_MSG_RESULT(yes)
dnl   else
dnl     AC_MSG_RESULT(no)
dnl   fi
dnl fi
dnl AC_DEFINE_UNQUOTED(D4_UNALIGN_OK,$D4_UNALIGN_OK)


dnl Checks for library functions.
AC_CHECK_FUNCS(random modf)
if test "$ac_cv_func_random" != yes; then
  AC_CHECK_LIB(m,random)
fi
if test "$ac_cv_func_modf" != yes; then
  AC_CHECK_LIB(m,modf)
fi
AC_MSG_CHECKING(if random is defined in stdlib.h)
AC_EGREP_HEADER(random,stdlib.h,D4_RANDOM_DEF="",D4_RANDOM_DEF=long)
if test "$D4_RANDOM_DEF" = ""; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_DEFINE_UNQUOTED(D4_RANDOM_DEF,$D4_RANDOM_DEF)
fi

dnl some miscellaneous stuff
AC_PROG_MAKE_SET

dnl compile debugging code by using --with-debug
D4_DEBUG_FLAGS=-DNDEBUG
AC_ARG_WITH(debug,
[  --with-debug                   enable debugging code in d4],
[case "$withval" in
  yes)	D4_DEBUG_FLAGS=
	;;
  no)	:
	;;
  *)	AC_MSG_ERROR($withval makes no sense for --with-debug)
	;;
esac])
AC_SUBST(D4_DEBUG_FLAGS)

AC_OUTPUT(Makefile)
