#
# $Id: configure.in,v 1.7 1997/07/04 10:07:25 swen Exp $
#
dnl Process this file with autoconf to produce a configure script.
AC_INIT(ypbind.c)
AM_INIT_AUTOMAKE(ypbind, 3.3)
AM_CONFIG_HEADER(config.h)
AC_REVISION($Revision: 1.7 $)dnl
AC_PREFIX_DEFAULT(/usr)
AC_PREFIX_PROGRAM(ypbind)

dnl We want autoconf to check whether -g is available
dnl We reset it back soon.
CCOPTS="$CFLAGS"
unset CFLAGS

dnl This sets/resets compiling with -g by default. It should be set to yes for
dnl development versions and set to no for release versions.
use_cc_g_flag=no

dnl Checks for programs.
AC_PROG_CC
# If we're using gcc, we want warning flags
test -n "$GCC" &&
  WARNFLAGS="-Wall"
AC_SUBST(WARNFLAGS)

dnl
dnl This part supplies reasonable defaults for CFLAGS, if they weren't
dnl specified by ''CFLAGS=flags ./configure''
dnl
if test "x$CCOPTS" = x; then
    if test x$GCC = xyes; then
        CCOPTS='-O2'
    else
        CCOPTS="$CFLAGS"
    fi
fi
CFLAGS="$CCOPTS"

AM_PROG_INSTALL

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h sys/file.h sys/ioctl.h syslog.h unistd.h)
AC_CHECK_HEADERS(sys/ipc.h sys/shm.h sys/sem.h)
AC_CHECK_HEADERS(rpc/svc_soc.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
ST_DECL_SVC_REGISTER
ST_HAS_SVC_GETCALLER

dnl Checks for library functions.
AC_FUNC_MMAP
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(mkdir putenv strdup strerror)
AC_CHECK_FUNCS(semget shmget, AC_DEFINE(HAVE_IPC))
AC_CHECK_FUNCS(syslog)
if test $ac_cv_func_syslog = no; then
  # syslog is not in the default libraries.  See if it's in some other.
  for lib in bsd socket inet; do
    AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG)
      LIBS="$LIBS $lib"; break])
  done
fi
AC_CHECK_LIB(socket,socket)
AC_CHECK_LIB(nsl,gethostbyname)
AC_CHECK_LIB(resolv, res_gethostbyname, RESOLV="-lresolv", RESOLV="")
if test x$RESOLV != x
then
  AC_DEFINE(HAVE_RES_GETHOSTBYNAME)
else
  AC_CHECK_LIB(resolv+, gethostbyname, RESOLV="-lresolv+", RESOLV="")
fi
AC_SUBST(RESOLV)
AC_CHECK_FUNCS(_dns_gethostbyname)

AC_ARG_WITH(bindingdir,
  [  --without-bindingdir    Do not maintain a bindingfile
  --with-bindingdir[=DIR] Create bindingfile in /var/yp/binding,
			  or DIR, if set (default)],
  [

     if test "$withval"; then
       if test "$withval" != "no"; then
         if test "$withval" != "yes"; then
           AC_DEFINE_UNQUOTED(BINDINGDIR, "$withval")
         else
           AC_DEFINE(BINDINGDIR, "/var/yp/binding")
         fi
       fi
     else
       AC_DEFINE(BINDINGDIR, "/var/yp/binding")
     fi
  ],
  AC_DEFINE(BINDINGDIR, "/var/yp/binding")
)


AC_OUTPUT(Makefile patchlevel.h ypbind.man, [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])

