dnl $USAGI: configure.in,v 1.12 2003-07-16 09:49:01 yoshfuji Exp $

dnl Copyright (C) 2002 USAGI/WIDE Project.
dnl All rights reserved.
dnl 
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions
dnl are met:
dnl 1. Redistributions of source code must retain the above copyright
dnl    notice, this list of conditions and the following disclaimer.
dnl 2. Redistributions in binary form must reproduce the above copyright
dnl    notice, this list of conditions and the following disclaimer in the
dnl    documentation and/or other materials provided with the distribution.
dnl 3. Neither the name of the project nor the names of its contributors
dnl    may be used to endorse or promote products derived from this software
dnl    without specific prior written permission.
dnl 
dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
dnl ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl SUCH DAMAGE.

AC_PREREQ(2.53)
AC_INIT(ninfod.c)
AC_CONFIG_HEADER(config.h)
AC_PREFIX_DEFAULT(/usr/local/v6)

AC_COPYRIGHT([Copyright (C)2002 USAGI/WIDE Project.  All Rights Reserved.])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
INSTALL_LIB="\${INSTALL_DATA}"
AC_SUBST(INSTALL_LIB)
INSTALL_DIR="\${INSTALL} -d"
AC_SUBST(INSTALL_DIR)

dnl Checks for Enable/With
AC_ARG_ENABLE(debug,
[  --enable-debug          Enable debugging])
if test x"$enableval" != x"no"; then
  AC_DEFINE(ENABLE_DEBUG, 1, 
	    [Enable debugging])
fi

AC_ARG_ENABLE(threads,
[  --disable-threads       Disable threads (and random delay)],,enable_threads=no)
if test x"$enableval" != x"no"; then
  AC_DEFINE(ENABLE_THREADS, 1,
            [Enable threads])
fi

AC_ARG_ENABLE(suptypes,
[  --enable-suptypes       Enable suptypes qtype (deprecated)])
if test x"$enableval" != x"no"; then
  AC_DEFINE(ENABLE_SUPTYPES, 1,
	    [Enable suptypes (deprecated)])
fi

AC_ARG_ENABLE(suptypes,
[  --enable-ttl            Enable ttl support for qtypes (deprecated)])
if test x"$enableval" != x"no"; then
  AC_DEFINE(ENABLE_SUPTYPES, 1,
	    [Enable ttl support for qtypes (deprecated)])
fi

dnl Checks for libraries.

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(limits.h)
AC_CHECK_HEADERS(gnutls/openssl.h)
AC_CHECK_HEADERS(openssl/md5.h)
AC_CHECK_HEADERS(sys/uio.h)
AC_CHECK_HEADERS(sys/utsname.h arpa/inet.h netdb.h syslog.h)
AC_CHECK_HEADERS(sys/capability.h)
AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(netinet/ip6.h netinet/icmp6.h,,,[
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
])
AC_CHECK_HEADERS(linux/rtnetlink.h,,,[
#include <asm/types.h>
#include <sys/socket.h>
])
AC_CHECK_HEADERS(pthread.h)

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

AC_MSG_CHECKING([for struct icmp6_nodeinfo])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/icmp6.h>
],[
struct icmp6_nodeinfo nodeinfo;
],[
	AC_MSG_RESULT([yes])
	AC_DEFINE([HAVE_STRUCT_ICMP6_NODEINFO], 1,
		  [Define to 1 if you have struct icmp6_nodeinfo])
],[
	AC_MSG_RESULT([no])
])

dnl Checks for library functions.
AC_CHECK_FUNCS(nanosleep)
AC_CHECK_LIB(pthread, pthread_create)
AC_CHECK_LIB(cap, cap_init)

AC_CHECK_LIB(gnutls-openssl, MD5_Init,
	AC_DEFINE(HAVE_MD5_INIT)
	LIBS="-lgnutls-openssl $LIBS",
	AC_CHECK_LIB(crypto, MD5_Init,
		AC_DEFINE(HAVE_MD5_INIT)
		LIBS="-lcrypto $LIBS",
	)
)
dnl AC_CHECK_LIB(crypto, MD5Init,
dnl	AC_DEFINE(HAVE_MD5INIT)
dnl	LIBS="-lcrypto $LIBS",
dnl)

dnl AC_SUBST(DEFS)

AC_OUTPUT(Makefile ninfod.sh)
