dnl $Id: configure.in,v 1.25 2000/11/17 06:51:11 ishisone Exp $
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Copyright (c) 2000 Japan Network Information Center.  All rights reserved.
dnl  
dnl By using this file, you agree to the terms and conditions set forth bellow.
dnl 
dnl 			LICENSE TERMS AND CONDITIONS 
dnl 
dnl The following License Terms and Conditions apply, unless a different
dnl license is obtained from Japan Network Information Center ("JPNIC"),
dnl a Japanese association, Fuundo Bldg., 1-2 Kanda Ogawamachi, Chiyoda-ku,
dnl Tokyo, Japan.
dnl 
dnl 1. Use, Modification and Redistribution (including distribution of any
dnl    modified or derived work) in source and/or binary forms is permitted
dnl    under this License Terms and Conditions.
dnl 
dnl 2. Redistribution of source code must retain the copyright notices as they
dnl    appear in each source code file, this License Terms and Conditions.
dnl 
dnl 3. Redistribution in binary form must reproduce the Copyright Notice,
dnl    this License Terms and Conditions, in the documentation and/or other
dnl    materials provided with the distribution.  For the purposes of binary
dnl    distribution the "Copyright Notice" refers to the following language:
dnl    "Copyright (c) Japan Network Information Center.  All rights reserved."
dnl 
dnl 4. Neither the name of JPNIC may be used to endorse or promote products
dnl    derived from this Software without specific prior written approval of
dnl    JPNIC.
dnl 
dnl 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
dnl    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dnl    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
dnl    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
dnl    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
dnl    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
dnl    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
dnl    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
dnl    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
dnl    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
dnl    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
dnl 
dnl 6. Indemnification by Licensee
dnl    Any person or entities using and/or redistributing this Software under
dnl    this License Terms and Conditions shall defend indemnify and hold
dnl    harmless JPNIC from and against any and all judgements damages,
dnl    expenses, settlement liabilities, cost and other liabilities of any
dnl    kind as a result of use and redistribution of this Software or any
dnl    claim, suite, action, litigation or proceeding by any third party
dnl    arising out of or relates to this License Terms and Conditions.
dnl 
dnl 7. Governing Law, Jurisdiction and Venue
dnl    This License Terms and Conditions shall be governed by and and
dnl    construed in accordance with the law of Japan. Any person or entities
dnl    using and/or redistributing this Software under this License Terms and
dnl    Conditions hereby agrees and consent to the personal and exclusive
dnl    jurisdiction and venue of Tokyo District Court of Japan.

AC_INIT(include/mdn/converter.h)

AC_CANONICAL_HOST

zld=no
AC_ARG_ENABLE(zld,
[  --enable-zld            enable ZLD support. [default=no]],
	zld=$enableval)
case "$zld" in
no)
    ;;
yes)
    AC_DEFINE(MDN_SUPPORT_ZLD)
    ;;
*)
    AC_MSG_ERROR([You must specify yes or no to --enable-zld option.])
    ;;
esac

utf8name=no
AC_ARG_WITH(utf8,
[  --with-utf8=NAME        codeset name for UTF-8 encoding [UTF-8]],
	utf8name=$withval)
case "$utf8name" in
no)
    ;;
yes)
    AC_MSG_ERROR([You must specify NAME to --with-utf8 option.])
    ;;
*)
    AC_DEFINE_UNQUOTED(MDN_UTF8_ENCODING_NAME, "$utf8name")
    ;;
esac

raceprefix=no
AC_ARG_WITH(race-prefix,
[  --with-race-prefix=PREFIX     prefix for RACE encoding [bq--]],
	raceprefix=$withval)
case "$raceprefix" in
no)
    ;;
yes)
    AC_MSG_ERROR([You must specify PREFIX to --with-race-prefix option.])
    ;;
*)
    AC_DEFINE_UNQUOTED(MDN_RACE_PREFIX, "$raceprefix")
    ;;
esac

bracesuffix=no
AC_ARG_WITH(brace-suffix,
[  --with-brace-suffix=PREFIX     suffix for BRACE encoding [-8q9]],
	bracesuffix=$withval)
case "$bracesuffix" in
no)
    ;;
yes)
    AC_MSG_ERROR([You must specify SUFFIX to --with-brace-suffix option.])
    ;;
*)
    AC_DEFINE_UNQUOTED(MDN_BRACE_SUFFIX, "$bracesuffix")
    ;;
esac

laceprefix=no
AC_ARG_WITH(lace-prefix,
[  --with-lace-prefix=PREFIX     prefix for LACE encoding [bq--]],
	laceprefix=$withval)
case "$laceprefix" in
no)
    ;;
yes)
    AC_MSG_ERROR([You must specify PREFIX to --with-lace-prefix option.])
    ;;
*)
    AC_DEFINE_UNQUOTED(MDN_LACE_PREFIX, "$laceprefix")
    ;;
esac

iconv=no
AC_ARG_WITH(iconv,
[  --with-iconv=LIB        special library for iconv []],
	iconv=$withval)
case "$iconv" in
no)
    ICONVLIB=
    ;;
yes)
    AC_MSG_WARN([You must supply LIB to --with-iconv option.
  -liconv is assumed.])
    ICONVLIB=-liconv
    ;;
*)
    ICONVLIB=$iconv
    ;;
esac
AC_SUBST(ICONVLIB)

AC_ARG_WITH(iconv-sofile,
[  --with-iconv-sofile=PATH        shared library file for libiconv []],
	iconv_file=$withval, iconv_file=guess)
ICONVSOFILE=
case "$iconv_file" in
no)
    ICONVSOFILE=none
    ;;
yes)
    AC_MSG_ERROR([You must supply PATH to --with-iconv-sofile option.])
    ;;
guess)
    if test "$ICONVLIB" = ""; then
	ICONVSOFILE=none
    else
	AC_MSG_CHECKING(pathname of iconv shared library)
	ic_libdir=
	ic_libname=
	case "$host" in
	*-hpux*)
	    SO=sl
	    ;;
	*)
	    SO=so
	    ;;
	esac
	for arg in $ICONVLIB; do
	    case "$arg" in
	    -L*) ic_libdir="$ic_libdir `echo $arg | sed s/-L//`" ;;
	    -l*) ic_libname=`echo $arg | sed s/-l//` ;;
	    /*.$SO*) ICONVSOFILE=$arg ;;
	    esac
	done
	if test "$ICONVSOFILE" = ""; then
	    if test "$ic_libname" = ""; then
		AC_MSG_RESULT(unknown)
		AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file])
		ICONVSOFILE=none
	    else
		if test "$ic_libdir" = ""; then
		    # Standard (and semi-standard) library directories
		    ic_libdir="/lib /usr/lib /usr/local/lib"
		fi
		for dir in $ic_libdir; do
		    ICONVSOFILE=`ls -r $dir/lib$ic_libname.$SO* 2>/dev/null | head -1`
		    if test "$ICONVSOFILE" != ""; then
			break
		    fi
		done
		if test "$ICONVSOFILE" != ""; then
		    AC_MSG_RESULT($ICONVSOFILE)
		else
		    AC_MSG_RESULT(unknown)
		    AC_MSG_WARN([use --with-iconv-sofile for specifying iconv shared library file])
		    ICONVSOFILE=none
		fi
	    fi
	fi
    fi
    ;;
*)
    ICONVSOFILE=$iconv_file
    ;;
esac
AC_SUBST(ICONVSOFILE)

dnl Figure out preload stuff.
PRELOAD_VAR="LD_PRELOAD"
PRELOAD_SEP=":"
PRELOAD_LAST=""
case "$host" in
*-solaris*)
    PRELOAD_SEP=" "
    ;;
*-osf*)
    PRELOAD_VAR="_RLD_LIST"
    PRELOAD_LAST=":DEFAULT"
    ;;
esac
AC_SUBST(PRELOAD_VAR)
AC_SUBST(PRELOAD_SEP)
AC_SUBST(PRELOAD_LAST)

dnl Checks for standard tools.
AC_PROG_CC
AC_PROG_INSTALL
AM_PROG_LIBTOOL

dnl Checks for header files.
AC_CHECK_HEADERS(unistd.h locale.h langinfo.h sys/select.h iconv.h)

dnl Checks for data types.
AC_TYPE_UID_T
dnl for dnsproxy.
AC_CHECK_TYPE(BOOL, int)

dnl Checks for libraries.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, inet_addr)

dnl Checks for library functions.
AC_CHECK_FUNCS(vsnprintf setvbuf setlocale nl_langinfo memmove bcopy)

dnl Output.
AC_CONFIG_HEADER(include/config.h)
AC_OUTPUT(
	Makefile
	include/Makefile
	include/mdn/Makefile
	lib/Makefile
	dnsproxy/Makefile
	man/Makefile
	tools/Makefile
	tools/mdnconv/Makefile
	tools/runmdn/Makefile
	tools/runmdn/runmdn
)
