#
# Copyright (C) 2000, 2001  Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

AC_INIT(queryperf.c)

AC_PREREQ(2.13)

AC_PROG_CC

AC_DEFUN(AC_TYPE_SOCKLEN_T,
[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
[
  AC_TRY_COMPILE(
  [#include <sys/types.h>
   #include <sys/socket.h>],
  [socklen_t len = 42; return len;],
  ac_cv_type_socklen_t=yes,
  ac_cv_type_socklen_t=no)
])
  if test $ac_cv_type_socklen_t != yes; then
    AC_DEFINE(socklen_t, int, [Define to `int' if `socklen_t' does not exist.])
  fi
])

AC_DEFUN(AC_SA_LEN,
[AC_CACHE_CHECK([for sa_len], ac_cv_sa_len,
[
  AC_TRY_COMPILE(
  [#include <sys/types.h>
   #include <sys/socket.h>],
  [struct sockaddr sa; sa.sa_len = 0;],
  ac_cv_sa_len=yes,
  ac_cv_sa_len=no)
])
  if test $ac_cv_sa_len = yes; then
    AC_DEFINE(HAVE_SA_LEN, 1, [Define to 1 if `struct sockaddr' has element `sa_len'.])
  fi
])

AC_CONFIG_HEADERS(config.h)
AC_SEARCH_LIBS(res_mkquery, resolv bind)
AC_SEARCH_LIBS(__res_mkquery, resolv bind)
AC_SEARCH_LIBS(res_9_mkquery, resolv bind)
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, inet_ntoa)
AC_CHECK_FUNCS(gethostbyname2)
AC_CHECK_FUNC(getaddrinfo,
    AC_DEFINE(HAVE_GETADDRINFO, 1, [Define to 1 if you have the `getaddrinfo' function.]),
    [AC_LIBOBJ(getaddrinfo)])
AC_CHECK_FUNC(getnameinfo,
    AC_DEFINE(HAVE_GETNAMEINFO, 1, [Define to 1 if you have the `getnameinfo' function.]),
    [AC_LIBOBJ(getnameinfo)])

AC_TYPE_SOCKLEN_T
AC_SA_LEN

AC_OUTPUT(Makefile)
