dnl	Bitmap to EPS conversion lib
AC_INIT(bmepsm.c)
AC_CONFIG_HEADER(config.h)
AC_PROG_CC
AC_PROG_CPP
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_PROG(RANLIB,ranlib,ranlib,[echo Skipping ranlib])
AC_HEADER_CHECK(string.h, AC_DEFINE(HAVE_STRING_H))
AC_HEADER_CHECK(sys/types.h, AC_DEFINE(HAVE_SYS_TYPES_H))
AC_HEADER_CHECK(stdlib.h, AC_DEFINE(HAVE_STDLIB_H))
AC_HEADER_CHECK(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
AC_HEADER_CHECK(malloc.h, AC_DEFINE(HAVE_MALLOC_H))
AC_HEADER_CHECK(string.h, AC_DEFINE(HAVE_STRING_H))
AC_HEADER_CHECK(setjmp.h, AC_DEFINE(HAVE_SETJMP_H))
AC_HEADER_CHECK(process.h, AC_DEFINE(HAVE_PROCESS_H))
AC_HEADER_CHECK(io.h, AC_DEFINE(HAVE_IO_H))
AC_HEADER_CHECK(fcntl.h, AC_DEFINE(HAVE_FCNTL_H))
AC_HAVE_FUNCS(strcasecmp stricmp unlink remove getpid rint)
AC_HAVE_FUNCS(getmode _getmode setmode _setmode fileno _fileno)
AC_CHECK_LIB(z, deflate, ZLIB='-lz';AC_DEFINE(HAVE_ZLIB),ZLIB='')
AC_SUBST(ZLIB)
echo "Checking for libpng... "
AC_TRY_COMPILE([#include <png.h>], [
png_structp png_ptr;
], LIBPNG='-lpng';echo yes;AC_DEFINE(HAVE_LIBPNG), LIBPNG='';echo no)
AC_SUBST(LIBPNG)
echo "Checking for jpeglib... "
AC_TRY_COMPILE([#include <stdio.h>
#include <sys/types.h>
#include <jpeglib.h>], [
  struct jpeg_decompress_struct cinfo;
],echo yes;LIBJPG='-ljpeg';AC_DEFINE(HAVE_JPEGLIB_H),LIBJPG='';echo no)
AC_SUBST(LIBJPG)
echo "Checking for NetPBM..."
LIBPNM=''
AC_TRY_COMPILE([#include <stdio.h>
#include <pnm.h>
],[
int cols, rows, format;
xelval maxval;
cols = rows = format = 0;
pnm_readpnminit(stdin, &cols, &rows, &maxval, &format);
],echo yes;LIBPNM='-lnetpbm';AC_DEFINE(HAVE_PNM_H),LIBPNM='';echo no)
AC_SUBST(LIBPNM)
AC_MSG_CHECKING(DOS/Windows variant of setmode())
AC_TRY_COMPILE([
#include <stdio.h>
#if HAVE_IO_H
#include <io.h>
#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
],[
#if HAVE_SETMODE
#ifdef O_BINARY
  (void)setmode(0, O_BINARY);
#else
#ifdef _O_BINARY
  (void)setmode(0, _O_BINARY);
#else
  3 = 5; /* force error */
#endif
#endif
#else
#if HAVE__SETMODE
#ifdef O_BINARY
#else
  (void)_setmode(0, O_BINARY);
#ifdef _O_BINARY
  (void)_setmode(0, _O_BINARY);
#else
  3 = 5; /* force error */
#endif
#endif
#else
  3 = 5; /* force error */
#endif
#endif
],[AC_MSG_RESULT(yes);AC_DEFINE(HAVE_DOSWIN_SETMODE)],[AC_MSG_RESULT(no)])
AC_SUBST(RANLIB)
AC_OUTPUT(Makefile)
AC_OUTPUT(Makefile-shared-linux)
AC_OUTPUT(Makefile-shared-solaris-workshop)
echo " "
echo For a normal build use the file \"Makefile\" and proceed with
echo "  make"
echo "  make install"
echo to install the software. This is what I recommend to the majority
echo of users.
echo " "
echo To build a shared library libbmeps.so on Linux systems
echo use \"Makefile-shared-linux\", run
echo "  make -f Makefile-shared-linux"
echo "  make -f Makefile-shared-linux install"
echo "  make -f Makefile-shared-linux clean"
echo "  /sbin/ldconfig"
echo to build and install the software. This is only recommended for
echo experienced users, developers and people creating Linux and
echo LaTeX distributions or binary installation packages.
echo Note: When installing libbmeps.so into a non-standard directory
echo you may need to set the LD_LIBRARY_PATH environment variable
echo to contain the directory.
echo " "
if test "X$LIBPNG" = "X"
then
echo 'WARNING: THE LIBPNG LIBRARY WAS NOT FOUND!'
echo 'You should install the library and -- if necessary -- the'
echo 'developer package needed to compile applications using this'
echo 'library.'
fi
if test "X$ZLIB" = "X"
then
echo 'WARNING: THE ZLIB LIBRARY WAS NOT FOUND!'
echo 'You should install the library and -- if necessary -- the'
echo 'developer package needed to compile applications using this'
echo 'library.'
fi

