# autoconf input using ocaml.m4

AC_INIT(bz2.mli)

use_findlib=yes
# check for OCaml compiler
AC_PROG_OCAML
AC_PROG_FINDLIB
AC_ARG_OCAML_INSTALLDIR

AC_CACHE_SAVE

# check the C compiler
if test "$CFLAGS" = "" ; then
	CFLAGS="-O2"
fi
AC_PROG_CC
AC_PROG_INSTALL

# check for bzlib
AC_CHECK_HEADER(bzlib.h,,AC_MSG_ERROR(not found))

BZ_PREFIX="BZ2_"
not_ok=""
AC_CHECK_LIB(bz2,${BZ_PREFIX}bzReadOpen,,not_ok=y)
if test $not_ok
then 
  not_ok=""
  BZ_PREFIX=""
  AC_CHECK_LIB(bz2,${BZ_PREFIX}bzReadOpen,,not_ok=y)
fi  
if test $not_ok
then AC_MSG_ERROR(libbz2 not found)
fi
unset not_ok

AC_SUBST(CFLAGS)
AC_SUBST(LIBS)
AC_SUBST(BZ_PREFIX)

# Finally create the Makefile from Makefile.in
AC_OUTPUT(Makefile)
