dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/ypcat.c)
AM_INIT_AUTOMAKE(yp-tools, 2.4)
AM_CONFIG_HEADER(config.h)
AC_PREFIX_DEFAULT(/usr)

dnl Set of available languages.
ALL_LINGUAS="de"

AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

if test x"$ac_default_prefix" = x"/usr"
then
   rootbindir="/bin"
else
   rootbindir=$ac_default_prefix"/bin"
fi
AC_SUBST(rootbindir)

dnl Should we install domainname ? default yes
AC_ARG_ENABLE(domainname,
        [  --disable-domainname    Don't install domainname [default=yes]],
              INSTALL_DOMAINNAME=$enableval, INSTALL_DOMAINNAME=yes)
if test "$INSTALL_DOMAINNAME" = "no"
then
   DOMAINNAME=
   MAN_DOMAINNAME=
else
   DOMAINNAME=domainname
   MAN_DOMAINNAME="domainname.8 nisdomainname.8 ypdomainname.8"
fi
AC_SUBST(DOMAINNAME)
AC_SUBST(MAN_DOMAINNAME)


test "$CFLAGS" = "" && CFLAGS="-O3"

dnl Checks for programs.
AC_PROG_CC
dnl If we're using gcc, we want warning flags
dnl test -n "$GCC" && WARNFLAGS="-Wall"
test -n "$GCC" && WARNFLAGS="-W -Wall -Wbad-function-cast -Wcast-align -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wshadow -Wstrict-prototypes -Wundef"
AC_SUBST(WARNFLAGS)
AC_ISC_POSIX
AC_PROG_INSTALL
AC_PROG_MAKE_SET

dnl Checks for libraries.
dnl Replace `main' with a function in -lnsl:
AC_CHECK_LIB(nsl, yp_get_default_domain)
AC_CHECK_LIB(crypt,crypt,LIBCRYPT="-lcrypt",LIBCRYPT="")
AC_SUBST(LIBCRYPT)

dnl Checks for header files.
AC_CHECK_HEADERS(crypt.h getopt.h rpc/clnt_soc.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

dnl Checks for library functions.
AC_CHECK_FUNC(getopt_long, , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"])

AC_REPLACE_FUNCS(ypbinderr_string)

AM_FUNC_GETLINE
if test $am_cv_func_working_getline != yes; then
  AC_CHECK_FUNCS(getdelim)
else
  AC_CHECK_FUNCS(getline)
fi

dnl internationalization macros
AM_GNU_GETTEXT

AC_OUTPUT([Makefile intl/Makefile lib/Makefile src/Makefile man/Makefile
	   etc/Makefile po/Makefile.in man/sedscript],
          [chmod +x man/sedscript])
