AC_INIT(Makefile.in)
AC_CONFIG_HEADER(config.h)

AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_CHECK_TOOL(STRIP, strip, true)

AC_EXEEXT
AC_SUBST(EXEEXT)

# Combined check for Microsoft-related bogosities; sets WIN32 if found
AX_WIN32

# vvp32 is by default disabled
#enable_vvp32=no
AC_SUBST(enable_vvp32)

AC_CHECK_PROGS(LEX,flex,none)
if test "$LEX" = "none"
then
	echo "*** Error: No suitable flex found. ***"
        echo "    Please install the 'flex' package."
        exit 1
fi

AC_CHECK_PROGS(YACC,bison,none)
if test "$YACC" = "none"
then
	echo "*** Error: No suitable bison found. ***"
        echo "    Please install the 'bison' package."
        exit 1
fi

AC_PROG_INSTALL

AC_CHECK_HEADERS(getopt.h malloc.h)

AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned)

# For the interactive debugger to work, readline must be installed,
# and that in turn requires termcap. check that the libs really do
# exist.
AC_CHECK_LIB(termcap, tputs)
AC_CHECK_LIB(readline, readline)
AC_CHECK_LIB(history, add_history)
AC_CHECK_HEADERS(readline/readline.h readline/history.h)

# --
# Look for a dl library to use. First look for the standard dlopen
# functions, and failing that look for the HP specific shl_load function.

AC_CHECK_HEADERS(dlfcn.h dl.h, break)

DLLIB=''
AC_CHECK_LIB(dl,dlopen,[DLLIB=-ldl])
if test -z "$DLLIB" ; then
AC_CHECK_LIB(dld,shl_load,[DLLIB=-ldld])
fi
AC_SUBST(DLLIB)

# may modify CPPFLAGS and CFLAGS
AX_CPP_PRECOMP

# Processor specific compile flags
case "${host}" in
    alpha*-*-linux*)
	CPPFLAGS="-mieee $CPPFLAGS"
	CFLAGS="-mieee $CFLAGS"
	;;
esac

# see how we can give some resource usage stats with -v
# Linux does not provide mem stats in rusage, use /proc/self/statm.

AC_CHECK_HEADERS(sys/resource.h)
case "${host}" in *linux*) AC_DEFINE(LINUX) ;; esac

# Linker option used when compiling the target
AX_LD_RDYNAMIC

AX_LD_EXTRALIBS

#######################
## test for underscores. The vpi module loader in vvm needs to know this
## in order to know the name of the start symbol for the .vpi module.
#######################

AX_C_UNDERSCORES_LEADING
AX_C_UNDERSCORES_TRAILING

#######################
## end of test for underscores
#######################

AX_CPP_IDENT

# If not otherwise specified, set the libdir64 variable
# to the same as libdir.
AC_MSG_CHECKING(for libdir64 path)
if test x${libdir64} = x
then
	libdir64="${libdir}"
fi
AC_SUBST(libdir64)
AC_MSG_RESULT(${libdir64})

# where to put vpi subdirectories
AC_MSG_CHECKING(for VPI subdirectories)
if test x${vpidir1} = x
then
	vpidir1="."
fi

AC_SUBST(vpidir1)
AC_SUBST(vpidir2)
AC_MSG_RESULT(${vpidir1} ${vpidir2})

AC_OUTPUT(Makefile)
