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

# $Id: configure.in 659 2016-03-17 06:20:36Z ume $

AC_PREREQ(2.57)
AC_INIT(Socket6.pm)
AC_CONFIG_SRCDIR(Socket6.pm)
AC_CONFIG_HEADER(config.h)

AC_PROG_CC

changequote(<<, >>)
default_perl_path=`which perl | sed -e 's/\/\/*[^\/]*$//'`
changequote([,])

AC_ARG_WITH(perl,[  --with-perl=path-to-perl],
[	ac_cv_path_perl=$withval
],[
AC_PATH_PROGS(perl,perl5 jperl5 perl jperl,,/usr/local/bin:/opt/local/bin:/usr/bin:$default_perl_path:.)
])

if test x"$ac_cv_path_perl" = x""; then
	AC_MSG_ERROR([Cannot find perl; please use --with-perl=/path/to/perl option.])
fi
PERLPATH=$ac_cv_path_perl

SOCKET6_CHECK_PL_SV_UNDEF(AC_DEFINE(HAVE_PL_SV_UNDEF,[1],[Do we have a pl_sv_undef?]), , $ac_cv_path_perl)

IPv6_CHECK_FUNC(getaddrinfo)
IPv6_CHECK_FUNC(getnameinfo)
IPv6_CHECK_FUNC(gethostbyname2)
IPv6_CHECK_FUNC(getipnodebyname)
IPv6_CHECK_FUNC(getipnodebyaddr)
IPv6_CHECK_FUNC(inet_pton)
IPv6_CHECK_FUNC(inet_ntop)

if test $ac_cv_lib_inet6_getaddrinfo = yes; then
	INET6LIBS="-L$ipv6_cv_dir/lib -linet6"
fi

IPv6_CHECK_INET_NTOP()
IPv6_CHECK_SA_LEN()
IPv6_CHECK_SIN6_SCOPE_ID()
IPv6_CHECK_SOCKLEN_T()

AC_SUBST(DEFINES)
AC_SUBST(INET6LIBS)
AC_SUBST(PERLPATH)
AC_OUTPUT(config.pl gailookup.pl)
