dnl Process this file with autoconf to produce a configure script.

AC_INIT(barcode.h)
AC_PREREQ(2.12)

AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_INSTALL

dnl Add "-Wall" if this is gcc
if test x$GCC = xyes; then
	CFLAGS="$CFLAGS -Wall"
fi


dnl Check for getopt and libpaper. If getopt is missing, use our version
AC_CHECK_HEADER(getopt.h, ,NO_GETOPT=-DNO_GETOPT;GETOPT_O=compat/getopt.o)
AC_CHECK_HEADER(paper.h, LIBPAPER=-lpaper, NO_LIBPAPER=-DNO_LIBPAPER)
AC_CHECK_HEADERS(unistd.h)

AC_CHECK_FUNC(strerror, , NO_STRERROR=-DNO_STRERROR)
AC_CHECK_FUNCS(strcasecmp)

dnl Check if this is gmake, but allow ovverriding using $MAKE
AC_MSG_CHECKING("for gmake")
GMAKE=no
${MAKE=make} --version 2> /dev/null | grep GNU > /dev/null && GMAKE=yes
AC_MSG_RESULT($GMAKE)
if test "$GMAKE" = "yes"; then
	GMAKEDEPEND0='ifeq (.depend,$(wildcard .depend))'
	GMAKEDEPEND1='include .depend'
	GMAKEDEPEND2='endif'
fi

dnl Check if we use makeinfo or the local texi2html tool
AC_MSG_CHECKING("if makeinfo can output html")
MAKEINFOHTML=no
${MAKEINFO=makeinfo} --help | grep .--html > /dev/null && MAKEINFOHTML=yes
AC_MSG_RESULT($MAKEINFOHTML)
if test "$MAKEINFOHTML" = "yes"; then
   REMOVEHTMLTAGS="cat"
   INFOTOHTML="$MAKEINFO --html"
else
   REMOVEHTMLTAGS="sed 's/ifnottex/ifinfo/; s/ifnotinfo/iftex/'"
   INFOTOHTML="perl texi2html -monolithic"
fi


AC_SUBST(GETOPT_O)
AC_SUBST(NO_GETOPT)
AC_SUBST(NO_LIBPAPER)
AC_SUBST(LIBPAPER)
AC_SUBST(NO_STRERROR)
AC_SUBST(GMAKEDEPEND0)
AC_SUBST(GMAKEDEPEND1)
AC_SUBST(GMAKEDEPEND2)

AC_OUTPUT(Makefile)

AC_SUBST(MAKEINFO)
AC_SUBST(REMOVEHTMLTAGS)
AC_SUBST(INFOTOHTML)

AC_OUTPUT(doc/Makefile)

