#!/bin/sh
#
# Do not edit!
# This file was generated from configure.in by BSDBuild 2.8.
#
# To regenerate this file, get the latest BSDBuild release from
# http://hypertriton.com/bsdbuild/, and use the command:
#
#     $ cat configure.in | mkconfigure > configure
#
# Copyright (c) 2001-2010 Hypertriton, Inc. 
# 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.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 AUTHOR 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.
#
PACKAGE="Untitled"
VERSION=""
RELEASE=""
optarg=
for arg
do
	case "$arg" in
	-*=*)
	    optarg=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'`
	    ;;
	*)
	    optarg=
	    ;;
	esac
	case "$arg" in
	--build=*)
	    build_arg=$optarg
	    ;;
	--host=*)
	    host_arg=$optarg
	    ;;
	--target=*)
	    target=$optarg
	    ;;
	--byte-order=*)
	    byte_order=$optarg
	    ;;
	--prefix=*)
	    prefix=$optarg
	    ;;
	--exec-prefix=*)
	    exec_prefix=$optarg
	    ;;
	--sysconfdir=*)
	    sysconfdir=$optarg
	    ;;
	--bindir=*)
	    bindir=$optarg
	    ;;
	--libdir=*)
	    libdir=$optarg
	    ;;
	--datadir=*)
	    datadir=$optarg
	    ;;
	--sharedir=*)
	    datadir=$optarg
	    ;;
	--localedir=*)
	    localedir=$optarg
	    ;;
	--mandir=*)
	    mandir=$optarg
	    ;;
	--infodir=*)
	    infodir=$optarg
	    ;;
	--enable-*)
	    option=`echo $arg | sed -e 's/--enable-//' -e 's/=.*//'`
	    option=`echo $option | sed 's/-/_/g'`
	    case "$arg" in
	        *=*)
	            eval "enable_${option}='$optarg'"
	            eval "prefix_${option}='$optarg'"
		    ;;
		*)
	            eval "enable_${option}=yes"
		    ;;
	    esac
	    ;;
	--disable-*)
	    option=`echo $arg | sed -e 's/--disable-//'`;
	    option=`echo $option | sed 's/-/_/g'`
	    eval "enable_${option}=no"
	    ;;
	--with-*)
	    option=`echo $arg | sed -e 's/--with-//' -e 's/=.*//'`
	    option=`echo $option | sed 's/-/_/g'`
	    case "$arg" in
	        *=*)
	            eval "with_${option}='$optarg'"
	            eval "prefix_${option}='$optarg'"
		    ;;
		*)
	            eval "with_${option}=yes"
		    ;;
	    esac
	    ;;
	--without-*)
	    option=`echo $arg | sed -e 's/--without-//'`;
	    option=`echo $option | sed 's/-/_/g'`
	    eval "with_${option}=no"
	    ;;
	--help)
	    show_help=yes
	    ;;
	--version)
	    show_version=yes
	    ;;
	--srcdir=*)
	    srcdir=$optarg
	    ;;
	--testdir=*)
	    testdir=$optarg
	    ;;
	--cache=*)
	    cache=$optarg
	    ;;
	--includes=*)
	    includes=$optarg
	    ;;
	--cache-file=*)
	    ;;
	--config-cache | -C)
	    ;;
	*)
	    echo "invalid argument: $arg"
	    echo "try ./configure --help"
	    exit 1
	    ;;
	esac
done
if [ -e "/bin/echo" ]; then
    /bin/echo -n ""
    if [ $? = 0 ]; then
    	ECHO_N="/bin/echo -n"
    else
    	ECHO_N="echo -n"
    fi
else
    ECHO_N="echo -n"
fi
PERL=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}" ]; then
		if [ -e "${path}/perl" ]; then
			PERL="${path}/perl"
			break
		fi
	fi
done
if [ "${prefix}" != "" ]; then
    PREFIX="$prefix"
else
    PREFIX="/usr/local"
fi
if [ "${exec_prefix}" != "" ]; then
    EXEC_PREFIX="$exec_prefix"
else
    EXEC_PREFIX="${PREFIX}"
fi
if [ "${srcdir}" != "" ]; then
	if [ "${PERL}" = "" ]; then
		echo "*"
		echo "* Separate build (--srcdir) requires perl, but there is"
		echo "* no perl interpreter to be found in your PATH."
		echo "*"
		exit 1
	fi
	echo "* Separate build (source in ${srcdir})"
	SRC=${srcdir}
	${PERL} ${SRC}/mk/mkconcurrent.pl ${SRC}
	if [ $? != 0 ]; then
		exit 1;
	fi
else
	SRC=`pwd`
fi
BLD=`pwd`
SRCDIR="${SRC}"
BLDDIR="${BLD}"
if [ "${testdir}" != "" ]; then
	echo "Configure tests will be executed in ${testdir}"
	if [ ! -e "${testdir}" ]; then
		echo "Creating ${testdir}"
		mkdir ${testdir}
	fi
else
	testdir="."
fi
if [ "${includes}" = "" ]; then
	includes="yes"
fi
case "${includes}" in
yes|no)
	;;
link)
	if [ "${with_proj_generation}" ]; then
		echo "Cannot use --includes=link with --with-proj-generation!"
		exit 1
	fi
	;;
*)
	echo "Usage: --includes [yes|no|link]"
	exit 1
	;;
esac
if [ "${srcdir}" = "" ]; then
	cat << EOT > configure.dep.pl
#!/usr/bin/perl
# Public domain.
# Scan Makefiles for "include .depend" and generate empty ".depend" files,
# such that make can be run prior to an initial "make depend".
#
my %V = ();
sub MakefileIncludesDepend (\$\$)
{
	my \$path = shift;
	my \$cwd = shift;
	if (!open(MF, \$path)) {
		return (0);
	}
	my @lines = ();
	foreach \$_ () {
		chop;
		if (/^(.+)\\\\\$/) {			# Expansion
			\$line .= \$1;
		} else {				# New line
			if (\$line) {
				push @lines, \$line . \$_;
				\$line = '';
			} else {
				push @lines, \$_;
			}
		}
	}
	foreach \$_ (@lines) {
		if (/^\\s*#/) { next; }
		if (/^\\t/) { next; }
		s/\\\$\\{(\\w+)\\}/\$V{\$1}/g;
		if (/^\\s*(\\w+)\\s*=\\s*"(.+)"\$/ ||
		    /^\\s*(\\w+)\\s*=\\s*(.+)\$/) {
			\$V{\$1} = \$2;
		} elsif (/^\\s*(\\w+)\\s*\\+=\\s*"(.+)"\$/ ||
		         /^\\s*(\\w+)\\s*\\+=\\s*(.+)\$/) {
			if (exists(\$V{\$1}) && \$V{\$1} ne '') {
				\$V{\$1} .= ' '.\$2;
			} else {
				\$V{\$1} = \$2;
			}
		}
		if (/^\\s*include\\s+(.+)\$/) {
			if (\$1 eq '.depend' ||
			    MakefileIncludesDepend(\$cwd.'/'.\$1, \$cwd)) {
				return (1);
			}
		}
	}
	close(MF);
	return (0);
}
sub Scan (\$)
{
	my \$dir = shift;
	unless (opendir(CWD, \$dir)) {
		print STDERR "\$dir: opendir: \$!; ignoring\\n";
		return;
	}
	%V = ();
	if (-e \$dir.'/Makefile' &&
	    MakefileIncludesDepend("\$dir/Makefile", \$dir)) {
		if (open(OUT, ">\$dir/.depend")) {
			close(OUT);
		} else {
			print STDERR "\$dir/.depend: \$!; ignoring\\n";
		}
	}
	foreach my \$ent (readdir(CWD)) {
		my \$file = \$dir.'/'.\$ent;
		if (\$ent =~ /^\\./) {
			next;
		}
		if (-d \$file) {
			Scan(\$file);
			next;
		}
	}
	closedir(CWD);
}
if (@ARGV < 1) {
	print STDERR "Usage: gen-dotdepend.pl [directory]\\n";
	exit(1);
}
Scan(\$ARGV[0]);
EOT
	if [ "${PERL}" != "" ]; then
		${PERL} configure.dep.pl .
		rm -f configure.dep.pl
	else
		echo "*"
		echo "* Warning: No perl was found. Perl is required for automatic"
		echo "* generation of .depend files. You may need to create empty"
		echo "* .depend files where it is required."
		echo "*"
	fi
fi
if [ "${show_help}" = "yes" ]; then
echo "This configure script was generated by BSDBuild 2.8."
echo ""
echo ""
echo "Usage: ./configure [options]"
echo ""
echo "Standard build options:"
echo "    --bindir=DIR              Executables (for common users) [PREFIX/bin]"
echo "    --build=STRING            Host environment for build [auto-detect]"
echo "    --cache=DIR               Cache ./configure results in directory [none]"
echo "    --datadir=DIR             Data files (for programs) [PREFIX/share]"
echo "    --enable-nls              Multi-language support [no]"
echo "    --exec-prefix=DIR         Installation base (MD files) [PREFIX]"
echo "    --host=STRING             Cross-compile for target environment [BUILD]"
echo "    --includes=STRING         Preprocess C headers (yes|no|link) [yes]"
echo "    --infodir=DIR             Texinfo documentation [SHAREDIR/info]"
echo "    --libdir=DIR              System libraries [PREFIX/lib]"
echo "    --libexecdir=DIR          Executables (for programs) [PREFIX/libexec]"
echo "    --localedir=DIR           Multi-language support locales [SHAREDIR/locale]"
echo "    --mandir=DIR              Manual page documentation [PREFIX/man]"
echo "    --prefix=DIR              Installation base (MI files) [/usr/local]"
echo "    --sbindir=DIR             Executables (for administrator) [PREFIX/sbin]"
echo "    --srcdir=DIR              Source directory for concurrent build [.]"
echo "    --sysconfdir=DIR          System configuration files [PREFIX/etc]"
echo "    --testdir=DIR             Execute ./configure tests in directory [.]"
echo "    --with-catman             Install cat files for manual pages [auto-detect]"
echo "    --with-ctags              Generate ctags(1) tag files [no]"
echo "    --with-docs               Generate printable documentation [no]"
echo "    --with-gettext            Use gettext for multi-language [auto-detect]"
echo "    --with-libtool            Specify path to libtool [auto-detect]"
echo "    --with-manlinks           Add manual entries for every function [no]"
echo "    --with-manpages           Generate Unix manual pages [yes]"
echo "    --enable-static           Produce a static binary [default: no]"
echo "    --enable-warnings         Enable compiler warnings [default: no]"
echo "    --with-html-source        Install HTML source/templates [default: no]"
exit 1
fi;
if [ "${show_version}" = "yes" ]; then
echo "BSDBuild 2.8"
exit 0
fi;
if [ "${srcdir}" != "" ]; then
	build_guessed=`sh ${srcdir}/mk/config.guess`
else
	build_guessed=`sh mk/config.guess`
fi
if [ $? != 0 ]; then
	echo "mk/config.guess failed"
	exit 1
fi
if [ "${build_arg}" != "" ]; then
	build="${build_arg}"
else
	build="${build_guessed}"
fi
if [ "${host_arg}" != "" ]; then
	host="${host_arg}"
else
	host="${build}"
fi
if [ "${host}" != "${build_guessed}" ]; then
	CROSS_COMPILING="yes"
else
	CROSS_COMPILING="no"
fi
echo "BSDBuild 2.8 (host: $host)"
if [ -e "Makefile.config" ]; then
	echo "* Overwriting existing Makefile.config"
fi
echo "# Generated by configure script (BSDBuild 2.8)." > Makefile.config
echo "" >> Makefile.config
echo "BUILD=${build}" >> Makefile.config
echo "HOST=${host}" >> Makefile.config
echo "CROSS_COMPILING=${CROSS_COMPILING}" >> Makefile.config
echo "SRCDIR=${SRC}" >> Makefile.config
echo "BLDDIR=${BLD}" >> Makefile.config
echo "Generated by configure script" > config.log
echo "BSDBuild Version: 2.8" >> config.log
echo "Host: $host" >> config.log
for arg
do
	echo "Argument: $arg" >> config.log
done
if [ -e "config" ]; then
	echo "* Overwriting config directory"
	rm -fR "config"
fi
mkdir -p "config"
if [ $? != 0 ]; then
	echo "Could not create config directory."
	exit 1
fi
HAVE_MANDOC="no"
NROFF=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/nroff" ]; then
		NROFF="${path}/nroff"
	fi
done
if [ "${NROFF}" != "" ]; then
	echo | ${NROFF} -Tmandoc >/dev/null
	if [ "$?" = "0" ]; then
		HAVE_MANDOC="yes"
	fi
fi
if [ "${HAVE_MANDOC}" = "no" ]; then
	if [ "${with_manpages}" = "yes" ]; then
		echo "*"
		echo "* --with-manpages was requested, but either the nroff(1)"
		echo "* utility or the mdoc(7) macro package was not found."
		echo "*"
		exit 1
	fi
	echo "HAVE_MANDOC=no" >> Makefile.config
	echo "NOMAN=yes" >> Makefile.config
	echo "NOMANLINKS=yes" >> Makefile.config
else
	echo "HAVE_MANDOC=yes" >> Makefile.config
	if [ "${with_catman}" = "no" ]; then
		echo "NOCATMAN=yes" >> Makefile.config
	else
		if [ "${with_catman}" = "yes" ]; then
			echo "NOCATMAN=no" >> Makefile.config
		else
			case "${host}" in
			*-*-freebsd*)
				echo "NOCATMAN=yes" >> Makefile.config
				;;
			*)
				echo "NOCATMAN=no" >> Makefile.config
				;;
			esac
		fi
	fi
	if [ "${with_manpages}" = "no" ]; then
		echo "NOMAN=yes" >> Makefile.config
		echo "NOMANLINKS=yes" >> Makefile.config
	else
		if [ "${with_manlinks}" != "yes" ]; then
			echo "NOMANLINKS=yes" >> Makefile.config
		fi
	fi
fi
if [ "${with_docs}" = "no" ]; then
	echo "NODOC=yes" >> Makefile.config
fi
if [ "${enable_nls}" = "yes" ]; then
ENABLE_NLS="yes"
echo "#ifndef ENABLE_NLS" > config/enable_nls.h
echo "#define ENABLE_NLS \"$ENABLE_NLS\"" >> config/enable_nls.h
echo "#endif" >> config/enable_nls.h
echo "hdefs[\"ENABLE_NLS\"] = \"$ENABLE_NLS\"" >>configure.lua
msgfmt=""
for path in `echo $PATH | sed 's/:/ /g'`; do
	if [ -x "${path}/msgfmt" ]; then
		msgfmt=${path}/msgfmt
	fi
done
if [ "${msgfmt}" != "" ]; then
	HAVE_GETTEXT="yes"
else
	HAVE_GETTEXT="no"
fi
echo "#ifndef ENABLE_NLS" > config/enable_nls.h
echo "#define ENABLE_NLS \"$ENABLE_NLS\"" >> config/enable_nls.h
echo "#endif" >> config/enable_nls.h
echo "hdefs[\"ENABLE_NLS\"] = \"$ENABLE_NLS\"" >>configure.lua
else
ENABLE_NLS="no"
HAVE_GETTEXT="no"
echo "#undef ENABLE_NLS" >config/enable_nls.h
echo "hdefs[\"ENABLE_NLS\"] = nil" >>configure.lua
fi;
echo "ENABLE_NLS=$ENABLE_NLS" >>Makefile.config
echo "mdefs[\"ENABLE_NLS\"] = \"$ENABLE_NLS\"" >>configure.lua
echo "HAVE_GETTEXT=$HAVE_GETTEXT" >>Makefile.config
echo "mdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
CTAGS=""
if [ "${with_ctags}" = "yes" ]; then
	for path in `echo $PATH | sed 's/:/ /g'`; do
		if [ -x "${path}/ectags" ]; then
			CTAGS="${path}/ectags"
		fi
	done
	if [ "${CTAGS}" = "" ]; then
		for path in `echo $PATH | sed 's/:/ /g'`; do
			if [ -x "${path}/ctags" ]; then
				CTAGS="${path}/ctags"
			fi
		done
	fi
fi
echo "CTAGS=${CTAGS}" >> Makefile.config
LIBTOOL_BUNDLED="yes"
LIBTOOL=\${TOP}/mk/libtool/libtool
echo "LIBTOOL=${LIBTOOL}" >> Makefile.config
echo "PREFIX?=${PREFIX}" >> Makefile.config
echo "#ifndef PREFIX" > config/prefix.h
echo "#define PREFIX \"$PREFIX\"" >> config/prefix.h
echo "#endif" >> config/prefix.h
echo "hdefs[\"PREFIX\"] = \"$PREFIX\"" >>configure.lua
if [ "${localedir}" != "" ]; then
	LOCALEDIR="${localedir}"
else
	LOCALEDIR="${SHAREDIR}/locale"
fi
echo "#ifndef LOCALEDIR" > config/localedir.h
echo "#define LOCALEDIR \"$LOCALEDIR\"" >> config/localedir.h
echo "#endif" >> config/localedir.h
echo "hdefs[\"LOCALEDIR\"] = \"$LOCALEDIR\"" >>configure.lua
if [ "${mandir}" != "" ]; then
	MANDIR="${mandir}"
else
	MANDIR="${PREFIX}/man"
fi
echo "#ifndef MANDIR" > config/mandir.h
echo "#define MANDIR \"$MANDIR\"" >> config/mandir.h
echo "#endif" >> config/mandir.h
echo "hdefs[\"MANDIR\"] = \"$MANDIR\"" >>configure.lua
if [ "${sharedir}" != "" ]; then
	SHAREDIR="${sharedir}"
else
	SHAREDIR="${PREFIX}/share"
fi
echo "#ifndef SHAREDIR" > config/sharedir.h
echo "#define SHAREDIR \"$SHAREDIR\"" >> config/sharedir.h
echo "#endif" >> config/sharedir.h
echo "hdefs[\"SHAREDIR\"] = \"$SHAREDIR\"" >>configure.lua
if [ "${datadir}" != "" ]; then
	DATADIR="${datadir}"
else
	DATADIR="${PREFIX}/share"
fi
echo "#ifndef DATADIR" > config/datadir.h
echo "#define DATADIR \"$DATADIR\"" >> config/datadir.h
echo "#endif" >> config/datadir.h
echo "hdefs[\"DATADIR\"] = \"$DATADIR\"" >>configure.lua
if [ "${libdir}" != "" ]; then
	LIBDIR="${libdir}"
else
	LIBDIR="${PREFIX}/lib"
fi
echo "#ifndef LIBDIR" > config/libdir.h
echo "#define LIBDIR \"$LIBDIR\"" >> config/libdir.h
echo "#endif" >> config/libdir.h
echo "hdefs[\"LIBDIR\"] = \"$LIBDIR\"" >>configure.lua
if [ "${sbindir}" != "" ]; then
	SBINDIR="${sbindir}"
else
	SBINDIR="${PREFIX}/sbin"
fi
echo "#ifndef SBINDIR" > config/sbindir.h
echo "#define SBINDIR \"$SBINDIR\"" >> config/sbindir.h
echo "#endif" >> config/sbindir.h
echo "hdefs[\"SBINDIR\"] = \"$SBINDIR\"" >>configure.lua
if [ "${infodir}" != "" ]; then
	INFODIR="${infodir}"
else
	INFODIR="${SHAREDIR}/info"
fi
echo "#ifndef INFODIR" > config/infodir.h
echo "#define INFODIR \"$INFODIR\"" >> config/infodir.h
echo "#endif" >> config/infodir.h
echo "hdefs[\"INFODIR\"] = \"$INFODIR\"" >>configure.lua
if [ "${sysconfdir}" != "" ]; then
	SYSCONFDIR="${sysconfdir}"
else
	SYSCONFDIR="${PREFIX}/etc"
fi
echo "#ifndef SYSCONFDIR" > config/sysconfdir.h
echo "#define SYSCONFDIR \"$SYSCONFDIR\"" >> config/sysconfdir.h
echo "#endif" >> config/sysconfdir.h
echo "hdefs[\"SYSCONFDIR\"] = \"$SYSCONFDIR\"" >>configure.lua
if [ "${bindir}" != "" ]; then
	BINDIR="${bindir}"
else
	BINDIR="${PREFIX}/bin"
fi
echo "#ifndef BINDIR" > config/bindir.h
echo "#define BINDIR \"$BINDIR\"" >> config/bindir.h
echo "#endif" >> config/bindir.h
echo "hdefs[\"BINDIR\"] = \"$BINDIR\"" >>configure.lua
if [ "${libexecdir}" != "" ]; then
	LIBEXECDIR="${libexecdir}"
else
	LIBEXECDIR="${PREFIX}/libexec"
fi
echo "#ifndef LIBEXECDIR" > config/libexecdir.h
echo "#define LIBEXECDIR \"$LIBEXECDIR\"" >> config/libexecdir.h
echo "#endif" >> config/libexecdir.h
echo "hdefs[\"LIBEXECDIR\"] = \"$LIBEXECDIR\"" >>configure.lua
if [ "${localstatedir}" != "" ]; then
	LOCALSTATEDIR="${localstatedir}"
else
	LOCALSTATEDIR="${PREFIX}/var"
fi
echo "#ifndef LOCALSTATEDIR" > config/localstatedir.h
echo "#define LOCALSTATEDIR \"$LOCALSTATEDIR\"" >> config/localstatedir.h
echo "#endif" >> config/localstatedir.h
echo "hdefs[\"LOCALSTATEDIR\"] = \"$LOCALSTATEDIR\"" >>configure.lua
VERSION="1.0"
echo "#ifndef VERSION" > config/version.h
echo "#define VERSION \"$VERSION\"" >> config/version.h
echo "#endif" >> config/version.h
echo "hdefs[\"VERSION\"] = \"$VERSION\"" >>configure.lua
LOCALEDIR="$SRC/locale"
echo "#ifndef LOCALEDIR" > config/localedir.h
echo "#define LOCALEDIR \"$LOCALEDIR\"" >> config/localedir.h
echo "#endif" >> config/localedir.h
echo "hdefs[\"LOCALEDIR\"] = \"$LOCALEDIR\"" >>configure.lua
LOCALEDIR="$SRC/locale"
echo "LOCALEDIR=$LOCALEDIR" >>Makefile.config
echo "mdefs[\"LOCALEDIR\"] = \"$LOCALEDIR\"" >>configure.lua
BINDIR="${PREFIX}"
echo "BINDIR=$BINDIR" >>Makefile.config
echo "mdefs[\"BINDIR\"] = \"$BINDIR\"" >>configure.lua
HTMLDIR="${PREFIX}/html"
echo "HTMLDIR=$HTMLDIR" >>Makefile.config
echo "mdefs[\"HTMLDIR\"] = \"$HTMLDIR\"" >>configure.lua
SYSCONFDIR="${PREFIX}/etc"
echo "SYSCONFDIR=$SYSCONFDIR" >>Makefile.config
echo "mdefs[\"SYSCONFDIR\"] = \"$SYSCONFDIR\"" >>configure.lua
SUDO=""
echo "SUDO=$SUDO" >>Makefile.config
echo "mdefs[\"SUDO\"] = \"$SUDO\"" >>configure.lua
$ECHO_N "checking for a C compiler..."
$ECHO_N "checking for a C compiler..." >> config.log
if [ "$CC" = "" ]; then
	for i in `echo $PATH |sed 's/:/ /g'`; do
		if [ -x "${i}/cc" ]; then
			if [ -f "${i}/cc" ]; then
				CC="${i}/cc"
				break
			fi
		elif [ -x "${i}/gcc" ]; then
			if [ -f "${i}/gcc" ]; then
				CC="${i}/gcc"
				break
			fi
		fi
	done
	if [ "$CC" = "" ]; then
		echo "*"
		echo "* Unable to find a standard C compiler in PATH. You may need"
		echo "* to set the CC environment variable."
		echo "*"
		echo "Unable to find a C compiler in PATH." >> config.log
		HAVE_CC="no"
		echo "no"
	else
		HAVE_CC="yes"
		echo "yes, ${CC}"
		echo "yes, ${CC}" >> config.log
	fi
else
	HAVE_CC="yes"
	echo "using ${CC}"
fi
if [ "${HAVE_CC}" = "yes" ]; then
	$ECHO_N "checking whether the C compiler works..."
	$ECHO_N "checking whether the C compiler works..." >> config.log
	cat << 'EOT' > conftest.c
int main(int argc, char *argv[]) { return (0); }
EOT
	$CC -o conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
	    echo "no, the test failed to compile"
	    echo "no, the test failed to compile" >> config.log
		HAVE_CC="no"
	else
		echo "yes"
		echo "yes" >> config.log
		HAVE_CC="yes"
	fi
	if [ "${EXECSUFFIX}" = "" ]; then
		EXECSUFFIX=""
		for OUTFILE in conftest.exe conftest conftest.*; do
			if [ -f $OUTFILE ]; then
				case $OUTFILE in
				*.c | *.o | *.obj | *.bb | *.bbg | *.d | *.pdb | *.tds | *.xcoff | *.dSYM | *.xSYM )
					;;
				*.* )
					EXECSUFFIX=`expr "$OUTFILE" : '[^.]*\(\..*\)'`
					break ;;
				* )
					break ;;
				esac;
		    fi
		done
		if [ "$EXECSUFFIX" != "" ]; then
			echo "Detected executable suffix: $EXECSUFFIX" >> config.log
		fi
echo "EXECSUFFIX=$EXECSUFFIX" >>Makefile.config
echo "mdefs[\"EXECSUFFIX\"] = \"$EXECSUFFIX\"" >>configure.lua
echo "#ifndef EXECSUFFIX" > config/execsuffix.h
echo "#define EXECSUFFIX \"$EXECSUFFIX\"" >> config/execsuffix.h
echo "#endif" >> config/execsuffix.h
echo "hdefs[\"EXECSUFFIX\"] = \"$EXECSUFFIX\"" >>configure.lua
	fi
	rm -f conftest.c conftest$EXECSUFFIX
	TEST_CFLAGS=""
fi
$ECHO_N "checking for compiler warning options..."
$ECHO_N "checking for compiler warning options..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_CC_WARNINGS" ]; then
		HAVE_CC_WARNINGS=`cat ${cache}/ctest-HAVE_CC_WARNINGS`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_CC_WARNINGS`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int main(int argc, char *argv[]) { return (0); }
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c " >>config.log
	$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c  2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_CC_WARNINGS="yes"
echo "HAVE_CC_WARNINGS=$HAVE_CC_WARNINGS" >>Makefile.config
echo "mdefs[\"HAVE_CC_WARNINGS\"] = \"$HAVE_CC_WARNINGS\"" >>configure.lua
echo "#ifndef HAVE_CC_WARNINGS" > config/have_cc_warnings.h
echo "#define HAVE_CC_WARNINGS \"$HAVE_CC_WARNINGS\"" >> config/have_cc_warnings.h
echo "#endif" >> config/have_cc_warnings.h
echo "hdefs[\"HAVE_CC_WARNINGS\"] = \"$HAVE_CC_WARNINGS\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_CC_WARNINGS="no"
echo "HAVE_CC_WARNINGS=$HAVE_CC_WARNINGS" >>Makefile.config
echo "mdefs[\"HAVE_CC_WARNINGS\"] = \"$HAVE_CC_WARNINGS\"" >>configure.lua
echo "#undef HAVE_CC_WARNINGS" >config/have_cc_warnings.h
echo "hdefs[\"HAVE_CC_WARNINGS\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_CC_WARNINGS" > ${cache}/ctest-HAVE_CC_WARNINGS
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_CC_WARNINGS
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_CC_WARNINGS}" = "yes" ]; then
TEST_CFLAGS="-Wall -Werror"
fi;
$ECHO_N "checking for gcc..."
$ECHO_N "checking for gcc..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_GCC" ]; then
		HAVE_GCC=`cat ${cache}/ctest-HAVE_GCC`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_GCC`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int main(int argc, char *argv[]) {
#if !defined(__GNUC__)
# error "Not GCC"
#endif
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c " >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c  2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_GCC="yes"
echo "HAVE_GCC=$HAVE_GCC" >>Makefile.config
echo "mdefs[\"HAVE_GCC\"] = \"$HAVE_GCC\"" >>configure.lua
echo "#ifndef HAVE_GCC" > config/have_gcc.h
echo "#define HAVE_GCC \"$HAVE_GCC\"" >> config/have_gcc.h
echo "#endif" >> config/have_gcc.h
echo "hdefs[\"HAVE_GCC\"] = \"$HAVE_GCC\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_GCC="no"
echo "HAVE_GCC=$HAVE_GCC" >>Makefile.config
echo "mdefs[\"HAVE_GCC\"] = \"$HAVE_GCC\"" >>configure.lua
echo "#undef HAVE_GCC" >config/have_gcc.h
echo "hdefs[\"HAVE_GCC\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_GCC" > ${cache}/ctest-HAVE_GCC
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_GCC
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
$ECHO_N "checking for IEEE754 floating point..."
$ECHO_N "checking for IEEE754 floating point..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_IEEE754" ]; then
		HAVE_IEEE754=`cat ${cache}/ctest-HAVE_IEEE754`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_IEEE754`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int
main(int argc, char *argv[])
{
	float f = 1.5;
	double d = 2.5;
	f = 0;
	d = 0;
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c " >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c  2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_IEEE754="yes"
echo "HAVE_IEEE754=$HAVE_IEEE754" >>Makefile.config
echo "mdefs[\"HAVE_IEEE754\"] = \"$HAVE_IEEE754\"" >>configure.lua
echo "#ifndef HAVE_IEEE754" > config/have_ieee754.h
echo "#define HAVE_IEEE754 \"$HAVE_IEEE754\"" >> config/have_ieee754.h
echo "#endif" >> config/have_ieee754.h
echo "hdefs[\"HAVE_IEEE754\"] = \"$HAVE_IEEE754\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_IEEE754="no"
echo "HAVE_IEEE754=$HAVE_IEEE754" >>Makefile.config
echo "mdefs[\"HAVE_IEEE754\"] = \"$HAVE_IEEE754\"" >>configure.lua
echo "#undef HAVE_IEEE754" >config/have_ieee754.h
echo "hdefs[\"HAVE_IEEE754\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_IEEE754" > ${cache}/ctest-HAVE_IEEE754
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_IEEE754
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
$ECHO_N "checking aligned attribute..."
$ECHO_N "checking aligned attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_ALIGNED_ATTRIBUTE" ]; then
		HAVE_ALIGNED_ATTRIBUTE=`cat ${cache}/ctest-HAVE_ALIGNED_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_ALIGNED_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int main(int argc, char *argv[])
{
	struct s1 { int x,y,z; } __attribute__ ((aligned(16)));
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_ALIGNED_ATTRIBUTE="yes"
echo "HAVE_ALIGNED_ATTRIBUTE=$HAVE_ALIGNED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_ALIGNED_ATTRIBUTE\"] = \"$HAVE_ALIGNED_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_ALIGNED_ATTRIBUTE" > config/have_aligned_attribute.h
echo "#define HAVE_ALIGNED_ATTRIBUTE \"$HAVE_ALIGNED_ATTRIBUTE\"" >> config/have_aligned_attribute.h
echo "#endif" >> config/have_aligned_attribute.h
echo "hdefs[\"HAVE_ALIGNED_ATTRIBUTE\"] = \"$HAVE_ALIGNED_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_ALIGNED_ATTRIBUTE="no"
echo "HAVE_ALIGNED_ATTRIBUTE=$HAVE_ALIGNED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_ALIGNED_ATTRIBUTE\"] = \"$HAVE_ALIGNED_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_ALIGNED_ATTRIBUTE" >config/have_aligned_attribute.h
echo "hdefs[\"HAVE_ALIGNED_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_ALIGNED_ATTRIBUTE" > ${cache}/ctest-HAVE_ALIGNED_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_ALIGNED_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking bounded attribute..."
$ECHO_N "checking bounded attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_BOUNDED_ATTRIBUTE" ]; then
		HAVE_BOUNDED_ATTRIBUTE=`cat ${cache}/ctest-HAVE_BOUNDED_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_BOUNDED_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
void foo(char *, int) __attribute__ ((__bounded__(__string__,1,2)));
void foo(char *a, int c) { }
int main(int argc, char *argv[])
{
	char buf[32];
	foo(buf, sizeof(buf));
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c " >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c  2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_BOUNDED_ATTRIBUTE="yes"
echo "HAVE_BOUNDED_ATTRIBUTE=$HAVE_BOUNDED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_BOUNDED_ATTRIBUTE\"] = \"$HAVE_BOUNDED_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_BOUNDED_ATTRIBUTE" > config/have_bounded_attribute.h
echo "#define HAVE_BOUNDED_ATTRIBUTE \"$HAVE_BOUNDED_ATTRIBUTE\"" >> config/have_bounded_attribute.h
echo "#endif" >> config/have_bounded_attribute.h
echo "hdefs[\"HAVE_BOUNDED_ATTRIBUTE\"] = \"$HAVE_BOUNDED_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_BOUNDED_ATTRIBUTE="no"
echo "HAVE_BOUNDED_ATTRIBUTE=$HAVE_BOUNDED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_BOUNDED_ATTRIBUTE\"] = \"$HAVE_BOUNDED_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_BOUNDED_ATTRIBUTE" >config/have_bounded_attribute.h
echo "hdefs[\"HAVE_BOUNDED_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_BOUNDED_ATTRIBUTE" > ${cache}/ctest-HAVE_BOUNDED_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_BOUNDED_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
$ECHO_N "checking const attribute..."
$ECHO_N "checking const attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_CONST_ATTRIBUTE" ]; then
		HAVE_CONST_ATTRIBUTE=`cat ${cache}/ctest-HAVE_CONST_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_CONST_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int foo(int) __attribute__ ((const));
int foo(int x) { return (x*x); }
int main(int argc, char *argv[])
{
	int x = foo(1);
	return (x);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_CONST_ATTRIBUTE="yes"
echo "HAVE_CONST_ATTRIBUTE=$HAVE_CONST_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_CONST_ATTRIBUTE\"] = \"$HAVE_CONST_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_CONST_ATTRIBUTE" > config/have_const_attribute.h
echo "#define HAVE_CONST_ATTRIBUTE \"$HAVE_CONST_ATTRIBUTE\"" >> config/have_const_attribute.h
echo "#endif" >> config/have_const_attribute.h
echo "hdefs[\"HAVE_CONST_ATTRIBUTE\"] = \"$HAVE_CONST_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_CONST_ATTRIBUTE="no"
echo "HAVE_CONST_ATTRIBUTE=$HAVE_CONST_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_CONST_ATTRIBUTE\"] = \"$HAVE_CONST_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_CONST_ATTRIBUTE" >config/have_const_attribute.h
echo "hdefs[\"HAVE_CONST_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_CONST_ATTRIBUTE" > ${cache}/ctest-HAVE_CONST_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_CONST_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking deprecated attribute..."
$ECHO_N "checking deprecated attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_DEPRECATED_ATTRIBUTE" ]; then
		HAVE_DEPRECATED_ATTRIBUTE=`cat ${cache}/ctest-HAVE_DEPRECATED_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_DEPRECATED_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
void foo(void) __attribute__ ((deprecated));
void foo(void) { }
int main(int argc, char *argv[])
{
/*	foo(); */
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_DEPRECATED_ATTRIBUTE="yes"
echo "HAVE_DEPRECATED_ATTRIBUTE=$HAVE_DEPRECATED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_DEPRECATED_ATTRIBUTE\"] = \"$HAVE_DEPRECATED_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_DEPRECATED_ATTRIBUTE" > config/have_deprecated_attribute.h
echo "#define HAVE_DEPRECATED_ATTRIBUTE \"$HAVE_DEPRECATED_ATTRIBUTE\"" >> config/have_deprecated_attribute.h
echo "#endif" >> config/have_deprecated_attribute.h
echo "hdefs[\"HAVE_DEPRECATED_ATTRIBUTE\"] = \"$HAVE_DEPRECATED_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_DEPRECATED_ATTRIBUTE="no"
echo "HAVE_DEPRECATED_ATTRIBUTE=$HAVE_DEPRECATED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_DEPRECATED_ATTRIBUTE\"] = \"$HAVE_DEPRECATED_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_DEPRECATED_ATTRIBUTE" >config/have_deprecated_attribute.h
echo "hdefs[\"HAVE_DEPRECATED_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_DEPRECATED_ATTRIBUTE" > ${cache}/ctest-HAVE_DEPRECATED_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_DEPRECATED_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking format attribute..."
$ECHO_N "checking format attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_FORMAT_ATTRIBUTE" ]; then
		HAVE_FORMAT_ATTRIBUTE=`cat ${cache}/ctest-HAVE_FORMAT_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_FORMAT_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
void foo1(char *, ...)
     __attribute__((__format__ (printf, 1, 2)));
void foo2(char *, ...)
     __attribute__((__format__ (__printf__, 1, 2)))
     __attribute__((__nonnull__ (1)));
void foo1(char *a, ...) {}
void foo2(char *a, ...) {}
int main(int argc, char *argv[])
{
	foo1("foo %s", "bar");
	foo2("foo %d", 1);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c " >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c  2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_FORMAT_ATTRIBUTE="yes"
echo "HAVE_FORMAT_ATTRIBUTE=$HAVE_FORMAT_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_FORMAT_ATTRIBUTE\"] = \"$HAVE_FORMAT_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_FORMAT_ATTRIBUTE" > config/have_format_attribute.h
echo "#define HAVE_FORMAT_ATTRIBUTE \"$HAVE_FORMAT_ATTRIBUTE\"" >> config/have_format_attribute.h
echo "#endif" >> config/have_format_attribute.h
echo "hdefs[\"HAVE_FORMAT_ATTRIBUTE\"] = \"$HAVE_FORMAT_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_FORMAT_ATTRIBUTE="no"
echo "HAVE_FORMAT_ATTRIBUTE=$HAVE_FORMAT_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_FORMAT_ATTRIBUTE\"] = \"$HAVE_FORMAT_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_FORMAT_ATTRIBUTE" >config/have_format_attribute.h
echo "hdefs[\"HAVE_FORMAT_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_FORMAT_ATTRIBUTE" > ${cache}/ctest-HAVE_FORMAT_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_FORMAT_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
$ECHO_N "checking nonnull attribute..."
$ECHO_N "checking nonnull attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_NONNULL_ATTRIBUTE" ]; then
		HAVE_NONNULL_ATTRIBUTE=`cat ${cache}/ctest-HAVE_NONNULL_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_NONNULL_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
void foo(char *) __attribute__((__nonnull__ (1)));
void foo(char *a) { }
int main(int argc, char *argv[])
{
	foo("foo");
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_NONNULL_ATTRIBUTE="yes"
echo "HAVE_NONNULL_ATTRIBUTE=$HAVE_NONNULL_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_NONNULL_ATTRIBUTE\"] = \"$HAVE_NONNULL_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_NONNULL_ATTRIBUTE" > config/have_nonnull_attribute.h
echo "#define HAVE_NONNULL_ATTRIBUTE \"$HAVE_NONNULL_ATTRIBUTE\"" >> config/have_nonnull_attribute.h
echo "#endif" >> config/have_nonnull_attribute.h
echo "hdefs[\"HAVE_NONNULL_ATTRIBUTE\"] = \"$HAVE_NONNULL_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_NONNULL_ATTRIBUTE="no"
echo "HAVE_NONNULL_ATTRIBUTE=$HAVE_NONNULL_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_NONNULL_ATTRIBUTE\"] = \"$HAVE_NONNULL_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_NONNULL_ATTRIBUTE" >config/have_nonnull_attribute.h
echo "hdefs[\"HAVE_NONNULL_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_NONNULL_ATTRIBUTE" > ${cache}/ctest-HAVE_NONNULL_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_NONNULL_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking noreturn attribute..."
$ECHO_N "checking noreturn attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_NORETURN_ATTRIBUTE" ]; then
		HAVE_NORETURN_ATTRIBUTE=`cat ${cache}/ctest-HAVE_NORETURN_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_NORETURN_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
void foo(void) __attribute__ ((noreturn));
void foo(void) { _exit(0); }
int main(int argc, char *argv[])
{
	foo();
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_NORETURN_ATTRIBUTE="yes"
echo "HAVE_NORETURN_ATTRIBUTE=$HAVE_NORETURN_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_NORETURN_ATTRIBUTE\"] = \"$HAVE_NORETURN_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_NORETURN_ATTRIBUTE" > config/have_noreturn_attribute.h
echo "#define HAVE_NORETURN_ATTRIBUTE \"$HAVE_NORETURN_ATTRIBUTE\"" >> config/have_noreturn_attribute.h
echo "#endif" >> config/have_noreturn_attribute.h
echo "hdefs[\"HAVE_NORETURN_ATTRIBUTE\"] = \"$HAVE_NORETURN_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_NORETURN_ATTRIBUTE="no"
echo "HAVE_NORETURN_ATTRIBUTE=$HAVE_NORETURN_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_NORETURN_ATTRIBUTE\"] = \"$HAVE_NORETURN_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_NORETURN_ATTRIBUTE" >config/have_noreturn_attribute.h
echo "hdefs[\"HAVE_NORETURN_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_NORETURN_ATTRIBUTE" > ${cache}/ctest-HAVE_NORETURN_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_NORETURN_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking packed attribute..."
$ECHO_N "checking packed attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_PACKED_ATTRIBUTE" ]; then
		HAVE_PACKED_ATTRIBUTE=`cat ${cache}/ctest-HAVE_PACKED_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_PACKED_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int main(int argc, char *argv[])
{
	struct s1 { char c; int x,y,z; } __attribute__ ((packed));
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS -Wall -Werror -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_PACKED_ATTRIBUTE="yes"
echo "HAVE_PACKED_ATTRIBUTE=$HAVE_PACKED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_PACKED_ATTRIBUTE\"] = \"$HAVE_PACKED_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_PACKED_ATTRIBUTE" > config/have_packed_attribute.h
echo "#define HAVE_PACKED_ATTRIBUTE \"$HAVE_PACKED_ATTRIBUTE\"" >> config/have_packed_attribute.h
echo "#endif" >> config/have_packed_attribute.h
echo "hdefs[\"HAVE_PACKED_ATTRIBUTE\"] = \"$HAVE_PACKED_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_PACKED_ATTRIBUTE="no"
echo "HAVE_PACKED_ATTRIBUTE=$HAVE_PACKED_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_PACKED_ATTRIBUTE\"] = \"$HAVE_PACKED_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_PACKED_ATTRIBUTE" >config/have_packed_attribute.h
echo "hdefs[\"HAVE_PACKED_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_PACKED_ATTRIBUTE" > ${cache}/ctest-HAVE_PACKED_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_PACKED_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking pure attribute..."
$ECHO_N "checking pure attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_PURE_ATTRIBUTE" ]; then
		HAVE_PURE_ATTRIBUTE=`cat ${cache}/ctest-HAVE_PURE_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_PURE_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int foo(int) __attribute__ ((pure));
int foo(int x) { return (x*x); }
int main(int argc, char *argv[])
{
	int x = foo(1);
	return (x);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_PURE_ATTRIBUTE="yes"
echo "HAVE_PURE_ATTRIBUTE=$HAVE_PURE_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_PURE_ATTRIBUTE\"] = \"$HAVE_PURE_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_PURE_ATTRIBUTE" > config/have_pure_attribute.h
echo "#define HAVE_PURE_ATTRIBUTE \"$HAVE_PURE_ATTRIBUTE\"" >> config/have_pure_attribute.h
echo "#endif" >> config/have_pure_attribute.h
echo "hdefs[\"HAVE_PURE_ATTRIBUTE\"] = \"$HAVE_PURE_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_PURE_ATTRIBUTE="no"
echo "HAVE_PURE_ATTRIBUTE=$HAVE_PURE_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_PURE_ATTRIBUTE\"] = \"$HAVE_PURE_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_PURE_ATTRIBUTE" >config/have_pure_attribute.h
echo "hdefs[\"HAVE_PURE_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_PURE_ATTRIBUTE" > ${cache}/ctest-HAVE_PURE_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_PURE_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking warn_unused_result attribute..."
$ECHO_N "checking warn_unused_result attribute..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_WARN_UNUSED_RESULT_ATTRIBUTE" ]; then
		HAVE_WARN_UNUSED_RESULT_ATTRIBUTE=`cat ${cache}/ctest-HAVE_WARN_UNUSED_RESULT_ATTRIBUTE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_WARN_UNUSED_RESULT_ATTRIBUTE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int foo(void) __attribute__ ((warn_unused_result));
int foo(void) { return (1); }
int main(int argc, char *argv[])
{
	int rv = foo();
	return (rv);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS  -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_WARN_UNUSED_RESULT_ATTRIBUTE="yes"
echo "HAVE_WARN_UNUSED_RESULT_ATTRIBUTE=$HAVE_WARN_UNUSED_RESULT_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"] = \"$HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"" >>configure.lua
echo "#ifndef HAVE_WARN_UNUSED_RESULT_ATTRIBUTE" > config/have_warn_unused_result_attribute.h
echo "#define HAVE_WARN_UNUSED_RESULT_ATTRIBUTE \"$HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"" >> config/have_warn_unused_result_attribute.h
echo "#endif" >> config/have_warn_unused_result_attribute.h
echo "hdefs[\"HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"] = \"$HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_WARN_UNUSED_RESULT_ATTRIBUTE="no"
echo "HAVE_WARN_UNUSED_RESULT_ATTRIBUTE=$HAVE_WARN_UNUSED_RESULT_ATTRIBUTE" >>Makefile.config
echo "mdefs[\"HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"] = \"$HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"" >>configure.lua
echo "#undef HAVE_WARN_UNUSED_RESULT_ATTRIBUTE" >config/have_warn_unused_result_attribute.h
echo "hdefs[\"HAVE_WARN_UNUSED_RESULT_ATTRIBUTE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_WARN_UNUSED_RESULT_ATTRIBUTE" > ${cache}/ctest-HAVE_WARN_UNUSED_RESULT_ATTRIBUTE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_WARN_UNUSED_RESULT_ATTRIBUTE
fi
rm -f conftest.c $testdir/conftest
$ECHO_N "checking for long double..."
$ECHO_N "checking for long double..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_LONG_DOUBLE" ]; then
		HAVE_LONG_DOUBLE=`cat ${cache}/ctest-HAVE_LONG_DOUBLE`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_LONG_DOUBLE`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int
main(int argc, char *argv[])
{
	long double ld = 0.1;
	ld = 0;
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_LONG_DOUBLE="yes"
echo "#ifndef HAVE_LONG_DOUBLE" > config/have_long_double.h
echo "#define HAVE_LONG_DOUBLE \"$HAVE_LONG_DOUBLE\"" >> config/have_long_double.h
echo "#endif" >> config/have_long_double.h
echo "hdefs[\"HAVE_LONG_DOUBLE\"] = \"$HAVE_LONG_DOUBLE\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_LONG_DOUBLE="no"
echo "#undef HAVE_LONG_DOUBLE" >config/have_long_double.h
echo "hdefs[\"HAVE_LONG_DOUBLE\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_LONG_DOUBLE" > ${cache}/ctest-HAVE_LONG_DOUBLE
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_LONG_DOUBLE
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
$ECHO_N "checking for long long..."
$ECHO_N "checking for long long..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_LONG_LONG" ]; then
		HAVE_LONG_LONG=`cat ${cache}/ctest-HAVE_LONG_LONG`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_LONG_LONG`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
int
main(int argc, char *argv[])
{
	long long ll = 0.0;
	unsigned long long ull = 0.0;
	ll = 1.0;
	ull = 1.0;
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_LONG_LONG="yes"
echo "#ifndef HAVE_LONG_LONG" > config/have_long_long.h
echo "#define HAVE_LONG_LONG \"$HAVE_LONG_LONG\"" >> config/have_long_long.h
echo "#endif" >> config/have_long_long.h
echo "hdefs[\"HAVE_LONG_LONG\"] = \"$HAVE_LONG_LONG\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_LONG_LONG="no"
echo "#undef HAVE_LONG_LONG" >config/have_long_long.h
echo "hdefs[\"HAVE_LONG_LONG\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_LONG_LONG" > ${cache}/ctest-HAVE_LONG_LONG
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_LONG_LONG
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
$ECHO_N "checking for cygwin environment..."
$ECHO_N "checking for cygwin environment..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_CYGWIN" ]; then
		HAVE_CYGWIN=`cat ${cache}/ctest-HAVE_CYGWIN`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_CYGWIN`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
#include 
int
main(int argc, char *argv[]) {
	struct stat sb;
	DWORD rv;
	rv = GetFileAttributes("foo");
	stat("foo", &sb);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS -mcygwin -o $testdir/conftest conftest.c" >>config.log
	$CC $CFLAGS $TEST_CFLAGS -mcygwin -o $testdir/conftest conftest.c 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_CYGWIN="yes"
echo "HAVE_CYGWIN=$HAVE_CYGWIN" >>Makefile.config
echo "mdefs[\"HAVE_CYGWIN\"] = \"$HAVE_CYGWIN\"" >>configure.lua
echo "#ifndef HAVE_CYGWIN" > config/have_cygwin.h
echo "#define HAVE_CYGWIN \"$HAVE_CYGWIN\"" >> config/have_cygwin.h
echo "#endif" >> config/have_cygwin.h
echo "hdefs[\"HAVE_CYGWIN\"] = \"$HAVE_CYGWIN\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_CYGWIN="no"
echo "HAVE_CYGWIN=$HAVE_CYGWIN" >>Makefile.config
echo "mdefs[\"HAVE_CYGWIN\"] = \"$HAVE_CYGWIN\"" >>configure.lua
echo "#undef HAVE_CYGWIN" >config/have_cygwin.h
echo "hdefs[\"HAVE_CYGWIN\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_CYGWIN" > ${cache}/ctest-HAVE_CYGWIN
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_CYGWIN
fi
rm -f conftest.c $testdir/conftest
echo "CC=$CC" >>Makefile.config
echo "mdefs[\"CC\"] = \"$CC\"" >>configure.lua
echo "CFLAGS=$CFLAGS" >>Makefile.config
echo "mdefs[\"CFLAGS\"] = \"$CFLAGS\"" >>configure.lua
$ECHO_N "checking for PerCGI (http://percgi.org/)..."
$ECHO_N "checking for PerCGI (http://percgi.org/)..." >> config.log
MK_EXEC_FOUND="No"
if [ "" != "" ]; then
	if [ -e "/bin/percgi-config" ]; then
		PERCGI_VERSION=`/bin/percgi-config --version`
		MK_EXEC_FOUND="Yes"
	fi
else
	MK_CACHED="No"
	if [ "${cache}" != "" ]; then
		if [ -e "${cache}/exec-PERCGI_VERSION" ]; then
			PERCGI_VERSION=`cat ${cache}/exec-PERCGI_VERSION`
			MK_EXEC_FOUND=`cat ${cache}/exec-found-PERCGI_VERSION`
			MK_CACHED="Yes"
		fi
	fi
	if [ "${MK_CACHED}" = "No" ]; then
		PERCGI_VERSION=""
		for path in `echo $PATH | sed 's/:/ /g'`; do
			if [ -e "${path}/percgi-config" ]; then
				PERCGI_VERSION=`${path}/percgi-config --version`
				MK_EXEC_FOUND="Yes"
				break
			fi
		done
		if [ "${cache}" != "" ]; then
			echo "$PERCGI_VERSION" > ${cache}/exec-PERCGI_VERSION
			echo $MK_EXEC_FOUND > ${cache}/exec-found-PERCGI_VERSION
		fi
	fi
fi
if [ "${PERCGI_VERSION}" != "" ]; then
if [ "" != "" ]; then
echo "yes ($PERCGI_VERSION in )"
echo "yes ($PERCGI_VERSION in )" >> config.log
else
echo "yes ($PERCGI_VERSION)"
echo "yes ($PERCGI_VERSION)" >> config.log
fi;
if [ "1.0" != "" ]; then
MK_VERSION_MAJOR=`echo "$PERCGI_VERSION" |sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\).*/\1/'`;
MK_VERSION_MINOR=`echo "$PERCGI_VERSION" |sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\).*/\2/'`;
MK_VERSION_OK="no"
if [ $MK_VERSION_MAJOR -gt 1 ]; then
	MK_VERSION_OK="yes";
elif [ $MK_VERSION_MAJOR -eq 1 ]; then
	if [ "$MK_VERSION_MINOR" = "" ]; then
		MK_VERSION_OK="yes"
	else
		if [ $MK_VERSION_MINOR -ge 0 ]; then
			MK_VERSION_OK="yes"
		fi
	fi
fi
if [ "${MK_VERSION_OK}" != "yes" ]; then
echo "Version 1.0 or greater is required (found $PERCGI_VERSION)"
exit 1
fi;
fi;
MK_EXEC_FOUND="No"
if [ "" != "" ]; then
	if [ -e "/bin/percgi-config" ]; then
		PERCGI_CFLAGS=`/bin/percgi-config --cflags`
		MK_EXEC_FOUND="Yes"
	fi
else
	MK_CACHED="No"
	if [ "${cache}" != "" ]; then
		if [ -e "${cache}/exec-PERCGI_CFLAGS" ]; then
			PERCGI_CFLAGS=`cat ${cache}/exec-PERCGI_CFLAGS`
			MK_EXEC_FOUND=`cat ${cache}/exec-found-PERCGI_CFLAGS`
			MK_CACHED="Yes"
		fi
	fi
	if [ "${MK_CACHED}" = "No" ]; then
		PERCGI_CFLAGS=""
		for path in `echo $PATH | sed 's/:/ /g'`; do
			if [ -e "${path}/percgi-config" ]; then
				PERCGI_CFLAGS=`${path}/percgi-config --cflags`
				MK_EXEC_FOUND="Yes"
				break
			fi
		done
		if [ "${cache}" != "" ]; then
			echo "$PERCGI_CFLAGS" > ${cache}/exec-PERCGI_CFLAGS
			echo $MK_EXEC_FOUND > ${cache}/exec-found-PERCGI_CFLAGS
		fi
	fi
fi
MK_EXEC_FOUND="No"
if [ "" != "" ]; then
	if [ -e "/bin/percgi-config" ]; then
		PERCGI_LIBS=`/bin/percgi-config --libs`
		MK_EXEC_FOUND="Yes"
	fi
else
	MK_CACHED="No"
	if [ "${cache}" != "" ]; then
		if [ -e "${cache}/exec-PERCGI_LIBS" ]; then
			PERCGI_LIBS=`cat ${cache}/exec-PERCGI_LIBS`
			MK_EXEC_FOUND=`cat ${cache}/exec-found-PERCGI_LIBS`
			MK_CACHED="Yes"
		fi
	fi
	if [ "${MK_CACHED}" = "No" ]; then
		PERCGI_LIBS=""
		for path in `echo $PATH | sed 's/:/ /g'`; do
			if [ -e "${path}/percgi-config" ]; then
				PERCGI_LIBS=`${path}/percgi-config --libs`
				MK_EXEC_FOUND="Yes"
				break
			fi
		done
		if [ "${cache}" != "" ]; then
			echo "$PERCGI_LIBS" > ${cache}/exec-PERCGI_LIBS
			echo $MK_EXEC_FOUND > ${cache}/exec-found-PERCGI_LIBS
		fi
	fi
fi
$ECHO_N "checking whether PerCGI works..."
$ECHO_N "checking whether PerCGI works..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_PERCGI" ]; then
		HAVE_PERCGI=`cat ${cache}/ctest-HAVE_PERCGI`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_PERCGI`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
int
main(int argc, char *argv[])
{
	CGI_Init(NULL);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${PERCGI_CFLAGS} -o $testdir/conftest conftest.c ${PERCGI_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${PERCGI_CFLAGS} -o $testdir/conftest conftest.c ${PERCGI_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_PERCGI="yes"
echo "HAVE_PERCGI=$HAVE_PERCGI" >>Makefile.config
echo "mdefs[\"HAVE_PERCGI\"] = \"$HAVE_PERCGI\"" >>configure.lua
echo "#ifndef HAVE_PERCGI" > config/have_percgi.h
echo "#define HAVE_PERCGI \"$HAVE_PERCGI\"" >> config/have_percgi.h
echo "#endif" >> config/have_percgi.h
echo "hdefs[\"HAVE_PERCGI\"] = \"$HAVE_PERCGI\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_PERCGI="no"
echo "HAVE_PERCGI=$HAVE_PERCGI" >>Makefile.config
echo "mdefs[\"HAVE_PERCGI\"] = \"$HAVE_PERCGI\"" >>configure.lua
echo "#undef HAVE_PERCGI" >config/have_percgi.h
echo "hdefs[\"HAVE_PERCGI\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_PERCGI" > ${cache}/ctest-HAVE_PERCGI
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_PERCGI
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_PERCGI}" = "yes" ]; then
echo "PERCGI_CFLAGS=$PERCGI_CFLAGS" >>Makefile.config
echo "mdefs[\"PERCGI_CFLAGS\"] = \"$PERCGI_CFLAGS\"" >>configure.lua
echo "#ifndef PERCGI_CFLAGS" > config/percgi_cflags.h
echo "#define PERCGI_CFLAGS \"$PERCGI_CFLAGS\"" >> config/percgi_cflags.h
echo "#endif" >> config/percgi_cflags.h
echo "hdefs[\"PERCGI_CFLAGS\"] = \"$PERCGI_CFLAGS\"" >>configure.lua
echo "PERCGI_LIBS=$PERCGI_LIBS" >>Makefile.config
echo "mdefs[\"PERCGI_LIBS\"] = \"$PERCGI_LIBS\"" >>configure.lua
echo "#ifndef PERCGI_LIBS" > config/percgi_libs.h
echo "#define PERCGI_LIBS \"$PERCGI_LIBS\"" >> config/percgi_libs.h
echo "#endif" >> config/percgi_libs.h
echo "hdefs[\"PERCGI_LIBS\"] = \"$PERCGI_LIBS\"" >>configure.lua
else
echo "#undef PERCGI_CFLAGS" >config/percgi_cflags.h
echo "hdefs[\"PERCGI_CFLAGS\"] = nil" >>configure.lua
PERCGI_CFLAGS=""
echo "#undef PERCGI_LIBS" >config/percgi_libs.h
echo "hdefs[\"PERCGI_LIBS\"] = nil" >>configure.lua
PERCGI_LIBS=""
fi;
else
if [ "" != "" ]; then
echo "no (not in )"
echo "no (not in )" >> config.log
else
echo "no"
echo "no" >> config.log
fi;
echo "#undef HAVE_PERCGI" >config/have_percgi.h
echo "hdefs[\"HAVE_PERCGI\"] = nil" >>configure.lua
echo "#undef PERCGI_CFLAGS" >config/percgi_cflags.h
echo "hdefs[\"PERCGI_CFLAGS\"] = nil" >>configure.lua
echo "#undef PERCGI_LIBS" >config/percgi_libs.h
echo "hdefs[\"PERCGI_LIBS\"] = nil" >>configure.lua
fi;
$ECHO_N "checking for Libidn (http://www.gnu.org/software/libidn/)..."
$ECHO_N "checking for Libidn (http://www.gnu.org/software/libidn/)..." >> config.log
if [ "" != "" ]; then
	MK_EXEC_PKGPREFIX=`pkg-config --variable=prefix libidn`
	if [ "$MK_EXEC_PKGPREFIX" != "" ]; then
		echo " "
		echo "* "
		echo "* ERROR: According to pkg-config, libidn is installed in prefix: "
		echo "* $MK_EXEC_PKGPREFIX, but the prefix () was specified."
		echo "* "
		echo "* Please re-run ./configure again with the correct libidn prefix"
		echo "* (or specify no prefix at all to enable auto-detection)."
		echo "* "
		exit 1
	else
		LIBIDN_VERSION=`pkg-config libidn --modversion`
	fi
else
	LIBIDN_VERSION=`pkg-config libidn --modversion`
fi
if [ "" != "" ]; then
	MK_EXEC_PKGPREFIX=`pkg-config --variable=prefix libidn`
	if [ "$MK_EXEC_PKGPREFIX" != "" ]; then
		echo " "
		echo "* "
		echo "* ERROR: According to pkg-config, libidn is installed in prefix: "
		echo "* $MK_EXEC_PKGPREFIX, but the prefix () was specified."
		echo "* "
		echo "* Please re-run ./configure again with the correct libidn prefix"
		echo "* (or specify no prefix at all to enable auto-detection)."
		echo "* "
		exit 1
	else
		LIBIDN_CFLAGS=`pkg-config libidn --cflags`
	fi
else
	LIBIDN_CFLAGS=`pkg-config libidn --cflags`
fi
if [ "" != "" ]; then
	MK_EXEC_PKGPREFIX=`pkg-config --variable=prefix libidn`
	if [ "$MK_EXEC_PKGPREFIX" != "" ]; then
		echo " "
		echo "* "
		echo "* ERROR: According to pkg-config, libidn is installed in prefix: "
		echo "* $MK_EXEC_PKGPREFIX, but the prefix () was specified."
		echo "* "
		echo "* Please re-run ./configure again with the correct libidn prefix"
		echo "* (or specify no prefix at all to enable auto-detection)."
		echo "* "
		exit 1
	else
		LIBIDN_LIBS=`pkg-config libidn --libs`
	fi
else
	LIBIDN_LIBS=`pkg-config libidn --libs`
fi
if [ "${LIBIDN_VERSION}" != "" ]; then
if [ "" != "" ]; then
echo "yes ($LIBIDN_VERSION in )"
echo "yes ($LIBIDN_VERSION in )" >> config.log
else
echo "yes ($LIBIDN_VERSION)"
echo "yes ($LIBIDN_VERSION)" >> config.log
fi;
if [ "1.0" != "" ]; then
MK_VERSION_MAJOR=`echo "$LIBIDN_VERSION" |sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\).*/\1/'`;
MK_VERSION_MINOR=`echo "$LIBIDN_VERSION" |sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\).*/\2/'`;
MK_VERSION_OK="no"
if [ $MK_VERSION_MAJOR -gt 1 ]; then
	MK_VERSION_OK="yes";
elif [ $MK_VERSION_MAJOR -eq 1 ]; then
	if [ "$MK_VERSION_MINOR" = "" ]; then
		MK_VERSION_OK="yes"
	else
		if [ $MK_VERSION_MINOR -ge 0 ]; then
			MK_VERSION_OK="yes"
		fi
	fi
fi
if [ "${MK_VERSION_OK}" != "yes" ]; then
echo "Version 1.0 or greater is required (found $LIBIDN_VERSION)"
exit 1
fi;
fi;
$ECHO_N "checking whether libidn works..."
$ECHO_N "checking whether libidn works..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_LIBIDN" ]; then
		HAVE_LIBIDN=`cat ${cache}/ctest-HAVE_LIBIDN`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_LIBIDN`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
#include 
#include 
#include 
int main(int argc, char *argv[]) {
	char *buf = "foo.com", *p;
	int rv;
	rv = idna_to_unicode_lzlz(buf, &p, 0);
	return ((rv == IDNA_SUCCESS) ? 0 : 1);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${LIBIDN_CFLAGS} -o $testdir/conftest conftest.c ${LIBIDN_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${LIBIDN_CFLAGS} -o $testdir/conftest conftest.c ${LIBIDN_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_LIBIDN="yes"
echo "HAVE_LIBIDN=$HAVE_LIBIDN" >>Makefile.config
echo "mdefs[\"HAVE_LIBIDN\"] = \"$HAVE_LIBIDN\"" >>configure.lua
echo "#ifndef HAVE_LIBIDN" > config/have_libidn.h
echo "#define HAVE_LIBIDN \"$HAVE_LIBIDN\"" >> config/have_libidn.h
echo "#endif" >> config/have_libidn.h
echo "hdefs[\"HAVE_LIBIDN\"] = \"$HAVE_LIBIDN\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_LIBIDN="no"
echo "HAVE_LIBIDN=$HAVE_LIBIDN" >>Makefile.config
echo "mdefs[\"HAVE_LIBIDN\"] = \"$HAVE_LIBIDN\"" >>configure.lua
echo "#undef HAVE_LIBIDN" >config/have_libidn.h
echo "hdefs[\"HAVE_LIBIDN\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_LIBIDN" > ${cache}/ctest-HAVE_LIBIDN
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_LIBIDN
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_LIBIDN}" = "yes" ]; then
echo "LIBIDN_CFLAGS=$LIBIDN_CFLAGS" >>Makefile.config
echo "mdefs[\"LIBIDN_CFLAGS\"] = \"$LIBIDN_CFLAGS\"" >>configure.lua
echo "#ifndef LIBIDN_CFLAGS" > config/libidn_cflags.h
echo "#define LIBIDN_CFLAGS \"$LIBIDN_CFLAGS\"" >> config/libidn_cflags.h
echo "#endif" >> config/libidn_cflags.h
echo "hdefs[\"LIBIDN_CFLAGS\"] = \"$LIBIDN_CFLAGS\"" >>configure.lua
echo "LIBIDN_LIBS=$LIBIDN_LIBS" >>Makefile.config
echo "mdefs[\"LIBIDN_LIBS\"] = \"$LIBIDN_LIBS\"" >>configure.lua
echo "#ifndef LIBIDN_LIBS" > config/libidn_libs.h
echo "#define LIBIDN_LIBS \"$LIBIDN_LIBS\"" >> config/libidn_libs.h
echo "#endif" >> config/libidn_libs.h
echo "hdefs[\"LIBIDN_LIBS\"] = \"$LIBIDN_LIBS\"" >>configure.lua
else
echo "#undef LIBIDN_CFLAGS" >config/libidn_cflags.h
echo "hdefs[\"LIBIDN_CFLAGS\"] = nil" >>configure.lua
LIBIDN_CFLAGS=""
echo "#undef LIBIDN_LIBS" >config/libidn_libs.h
echo "hdefs[\"LIBIDN_LIBS\"] = nil" >>configure.lua
LIBIDN_LIBS=""
fi;
else
if [ "" != "" ]; then
echo "no (not in )"
echo "no (not in )" >> config.log
else
echo "no"
echo "no" >> config.log
fi;
echo "#undef HAVE_LIBIDN" >config/have_libidn.h
echo "hdefs[\"HAVE_LIBIDN\"] = nil" >>configure.lua
echo "#undef LIBIDN_CFLAGS" >config/libidn_cflags.h
echo "hdefs[\"LIBIDN_CFLAGS\"] = nil" >>configure.lua
echo "#undef LIBIDN_LIBS" >config/libidn_libs.h
echo "hdefs[\"LIBIDN_LIBS\"] = nil" >>configure.lua
fi;
$ECHO_N "checking for iconv()..."
$ECHO_N "checking for iconv()..." >> config.log
ICONV_CFLAGS=""
ICONV_LIBS=""
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_ICONV" ]; then
		HAVE_ICONV=`cat ${cache}/ctest-HAVE_ICONV`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_ICONV`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
#include 
#include 
#include 
int main(int argc, char *argv[])
{
	char *inbuf = "foo";
	size_t inlen = strlen(inbuf), rv;
	char *outbuf = malloc(3);
	size_t outbuflen = 3;
	iconv_t cd;
	cd = iconv_open("ISO-8859-1", "UTF-8");
	rv = iconv(cd, &inbuf, &inlen, &outbuf, &outbuflen);
	if (rv == (size_t)-1 && errno == E2BIG) {
	}
	iconv_close(cd);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_ICONV="yes"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#ifndef HAVE_ICONV" > config/have_iconv.h
echo "#define HAVE_ICONV \"$HAVE_ICONV\"" >> config/have_iconv.h
echo "#endif" >> config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_ICONV="no"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#undef HAVE_ICONV" >config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_ICONV" > ${cache}/ctest-HAVE_ICONV
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_ICONV
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_ICONV}" = "no" ]; then
$ECHO_N "checking for iconv() in -liconv..."
$ECHO_N "checking for iconv() in -liconv..." >> config.log
if [ "" != "" ]; then
if [ -e  "/include/iconv.h" ]; then
ICONV_CFLAGS="-I/include"
ICONV_LIBS="-L/lib -liconv"
fi;
else
if [ -e  "/usr/include/iconv.h" ]; then
ICONV_CFLAGS="-I/usr/include"
ICONV_LIBS="-L/usr/lib -liconv"
fi;
if [ -e  "/usr/local/include/iconv.h" ]; then
ICONV_CFLAGS="-I/usr/local/include"
ICONV_LIBS="-L/usr/local/lib -liconv"
fi;
if [ -e  "/opt/include/iconv.h" ]; then
ICONV_CFLAGS="-I/opt/include"
ICONV_LIBS="-L/opt/lib -liconv"
fi;
if [ -e  "/opt/local/include/iconv.h" ]; then
ICONV_CFLAGS="-I/opt/local/include"
ICONV_LIBS="-L/opt/local/lib -liconv"
fi;
fi;
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_ICONV" ]; then
		HAVE_ICONV=`cat ${cache}/ctest-HAVE_ICONV`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_ICONV`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
#include 
#include 
#include 
int main(int argc, char *argv[])
{
	char *inbuf = "foo";
	size_t inlen = strlen(inbuf), rv;
	char *outbuf = malloc(3);
	size_t outbuflen = 3;
	iconv_t cd;
	cd = iconv_open("ISO-8859-1", "UTF-8");
	rv = iconv(cd, &inbuf, &inlen, &outbuf, &outbuflen);
	if (rv == (size_t)-1 && errno == E2BIG) {
	}
	iconv_close(cd);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_ICONV="yes"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#ifndef HAVE_ICONV" > config/have_iconv.h
echo "#define HAVE_ICONV \"$HAVE_ICONV\"" >> config/have_iconv.h
echo "#endif" >> config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_ICONV="no"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#undef HAVE_ICONV" >config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_ICONV" > ${cache}/ctest-HAVE_ICONV
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_ICONV
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_ICONV}" = "yes" ]; then
$ECHO_N "checking for iconv() in -liconv (const)..."
$ECHO_N "checking for iconv() in -liconv (const)..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_ICONV" ]; then
		HAVE_ICONV=`cat ${cache}/ctest-HAVE_ICONV`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_ICONV`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
#include 
#include 
#include 
int main(int argc, char *argv[])
{
	const char *inbuf = "foo";
	size_t inlen = strlen(inbuf), rv;
	char *outbuf = malloc(3);
	size_t outbuflen = 3;
	iconv_t cd;
	cd = iconv_open("ISO-8859-1", "UTF-8");
	rv = iconv(cd, &inbuf, &inlen, &outbuf, &outbuflen);
	if (rv == (size_t)-1 && errno == E2BIG) {
	}
	iconv_close(cd);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_ICONV="yes"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#ifndef HAVE_ICONV" > config/have_iconv.h
echo "#define HAVE_ICONV \"$HAVE_ICONV\"" >> config/have_iconv.h
echo "#endif" >> config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_ICONV="no"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#undef HAVE_ICONV" >config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_ICONV" > ${cache}/ctest-HAVE_ICONV
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_ICONV
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
fi;
else
$ECHO_N "checking for iconv() with const..."
$ECHO_N "checking for iconv() with const..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_ICONV" ]; then
		HAVE_ICONV=`cat ${cache}/ctest-HAVE_ICONV`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_ICONV`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
#include 
#include 
#include 
int main(int argc, char *argv[])
{
	const char *inbuf = "foo";
	size_t inlen = strlen(inbuf), rv;
	char *outbuf = malloc(3);
	size_t outbuflen = 3;
	iconv_t cd;
	cd = iconv_open("ISO-8859-1", "UTF-8");
	rv = iconv(cd, &inbuf, &inlen, &outbuf, &outbuflen);
	if (rv == (size_t)-1 && errno == E2BIG) {
	}
	iconv_close(cd);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wno-cast-qual -o $testdir/conftest conftest.c ${ICONV_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_ICONV="yes"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#ifndef HAVE_ICONV" > config/have_iconv.h
echo "#define HAVE_ICONV \"$HAVE_ICONV\"" >> config/have_iconv.h
echo "#endif" >> config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_ICONV="no"
echo "HAVE_ICONV=$HAVE_ICONV" >>Makefile.config
echo "mdefs[\"HAVE_ICONV\"] = \"$HAVE_ICONV\"" >>configure.lua
echo "#undef HAVE_ICONV" >config/have_iconv.h
echo "hdefs[\"HAVE_ICONV\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_ICONV" > ${cache}/ctest-HAVE_ICONV
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_ICONV
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
fi;
echo "ICONV_CFLAGS=$ICONV_CFLAGS" >>Makefile.config
echo "mdefs[\"ICONV_CFLAGS\"] = \"$ICONV_CFLAGS\"" >>configure.lua
echo "#ifndef ICONV_CFLAGS" > config/iconv_cflags.h
echo "#define ICONV_CFLAGS \"$ICONV_CFLAGS\"" >> config/iconv_cflags.h
echo "#endif" >> config/iconv_cflags.h
echo "hdefs[\"ICONV_CFLAGS\"] = \"$ICONV_CFLAGS\"" >>configure.lua
echo "ICONV_LIBS=$ICONV_LIBS" >>Makefile.config
echo "mdefs[\"ICONV_LIBS\"] = \"$ICONV_LIBS\"" >>configure.lua
echo "#ifndef ICONV_LIBS" > config/iconv_libs.h
echo "#define ICONV_LIBS \"$ICONV_LIBS\"" >> config/iconv_libs.h
echo "#endif" >> config/iconv_libs.h
echo "hdefs[\"ICONV_LIBS\"] = \"$ICONV_LIBS\"" >>configure.lua
if [ "${HAVE_ICONV}" = "yes" ]; then
$ECHO_N "checking whether iconv() is const-correct..."
$ECHO_N "checking whether iconv() is const-correct..." >> config.log
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_ICONV_CONST" ]; then
		HAVE_ICONV_CONST=`cat ${cache}/ctest-HAVE_ICONV_CONST`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_ICONV_CONST`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
#include 
#include 
#include 
#include 
int main(int argc, char *argv[])
{
	const char *inbuf = "foo";
	size_t inlen = strlen(inbuf), rv;
	char *outbuf = malloc(3);
	size_t outbuflen = 3;
	iconv_t cd;
	cd = iconv_open("ISO-8859-1", "UTF-8");
	rv = iconv(cd, &inbuf, &inlen, &outbuf, &outbuflen);
	if (rv == (size_t)-1 && errno == E2BIG) {
	}
	iconv_close(cd);
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wcast-qual -Werror -o $testdir/conftest conftest.c ${ICONV_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${ICONV_CFLAGS} -Wcast-qual -Werror -o $testdir/conftest conftest.c ${ICONV_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_ICONV_CONST="yes"
echo "HAVE_ICONV_CONST=$HAVE_ICONV_CONST" >>Makefile.config
echo "mdefs[\"HAVE_ICONV_CONST\"] = \"$HAVE_ICONV_CONST\"" >>configure.lua
echo "#ifndef HAVE_ICONV_CONST" > config/have_iconv_const.h
echo "#define HAVE_ICONV_CONST \"$HAVE_ICONV_CONST\"" >> config/have_iconv_const.h
echo "#endif" >> config/have_iconv_const.h
echo "hdefs[\"HAVE_ICONV_CONST\"] = \"$HAVE_ICONV_CONST\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_ICONV_CONST="no"
echo "HAVE_ICONV_CONST=$HAVE_ICONV_CONST" >>Makefile.config
echo "mdefs[\"HAVE_ICONV_CONST\"] = \"$HAVE_ICONV_CONST\"" >>configure.lua
echo "#undef HAVE_ICONV_CONST" >config/have_iconv_const.h
echo "hdefs[\"HAVE_ICONV_CONST\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_ICONV_CONST" > ${cache}/ctest-HAVE_ICONV_CONST
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_ICONV_CONST
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
else
echo "#undef HAVE_ICONV_CONST" >config/have_iconv_const.h
echo "hdefs[\"HAVE_ICONV_CONST\"] = nil" >>configure.lua
fi;
CFLAGS="$CFLAGS -I$SRC"
CXXFLAGS="$CXXFLAGS -I$SRC"
echo "CFLAGS=$CFLAGS" >>Makefile.config
echo "mdefs[\"CFLAGS\"] = \"$CFLAGS\"" >>configure.lua
echo "CXXFLAGS=$CXXFLAGS" >>Makefile.config
echo "mdefs[\"CXXFLAGS\"] = \"$CXXFLAGS\"" >>configure.lua
CFLAGS="$CFLAGS -D_USE_PERCGI_STD"
CXXFLAGS="$CXXFLAGS -D_USE_PERCGI_STD"
echo "CFLAGS=$CFLAGS" >>Makefile.config
echo "mdefs[\"CFLAGS\"] = \"$CFLAGS\"" >>configure.lua
echo "CXXFLAGS=$CXXFLAGS" >>Makefile.config
echo "mdefs[\"CXXFLAGS\"] = \"$CXXFLAGS\"" >>configure.lua
CFLAGS="$CFLAGS -D_USE_PERCGI_VAR"
CXXFLAGS="$CXXFLAGS -D_USE_PERCGI_VAR"
echo "CFLAGS=$CFLAGS" >>Makefile.config
echo "mdefs[\"CFLAGS\"] = \"$CFLAGS\"" >>configure.lua
echo "CXXFLAGS=$CXXFLAGS" >>Makefile.config
echo "mdefs[\"CXXFLAGS\"] = \"$CXXFLAGS\"" >>configure.lua
if [ "${HAVE_PERCGI}" != "yes" ]
 then
	echo "*"
	echo "* This software requires the PerCGI library"
	echo "* (http://percgi.org/)"
	echo "*"
	exit 1
fi
if [ "${ENABLE_NLS}" = "yes" ]
 then
$ECHO_N "checking for a gettext library..."
$ECHO_N "checking for a gettext library..." >> config.log
GETTEXT_CFLAGS=""
GETTEXT_LIBS=""
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_GETTEXT" ]; then
		HAVE_GETTEXT=`cat ${cache}/ctest-HAVE_GETTEXT`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_GETTEXT`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
int main(int argc, char *argv[])
{
	char *s;
	bindtextdomain("foo", "/foo");
	textdomain("foo");
	s = gettext("string");
	s = dgettext("foo","string");
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${GETTEXT_CFLAGS} -o $testdir/conftest conftest.c ${GETTEXT_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${GETTEXT_CFLAGS} -o $testdir/conftest conftest.c ${GETTEXT_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_GETTEXT="yes"
echo "HAVE_GETTEXT=$HAVE_GETTEXT" >>Makefile.config
echo "mdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
echo "#ifndef HAVE_GETTEXT" > config/have_gettext.h
echo "#define HAVE_GETTEXT \"$HAVE_GETTEXT\"" >> config/have_gettext.h
echo "#endif" >> config/have_gettext.h
echo "hdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_GETTEXT="no"
echo "HAVE_GETTEXT=$HAVE_GETTEXT" >>Makefile.config
echo "mdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
echo "#undef HAVE_GETTEXT" >config/have_gettext.h
echo "hdefs[\"HAVE_GETTEXT\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_GETTEXT" > ${cache}/ctest-HAVE_GETTEXT
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_GETTEXT
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_GETTEXT}" = "no" ]; then
$ECHO_N "checking whether gettext requires -lintl..."
$ECHO_N "checking whether gettext requires -lintl..." >> config.log
if [ "" != "" ]; then
if [ -e  "/include/libintl.h" ]; then
GETTEXT_CFLAGS="-I/include"
GETTEXT_LIBS="-L/lib -lintl"
fi;
else
if [ -e  "/include/libintl.h" ]; then
GETTEXT_CFLAGS="-I/include"
GETTEXT_LIBS="-L/lib -lintl"
fi;
if [ -e  "/usr/include/libintl.h" ]; then
GETTEXT_CFLAGS="-I/usr/include"
GETTEXT_LIBS="-L/usr/lib -lintl"
fi;
if [ -e  "/usr/local/include/libintl.h" ]; then
GETTEXT_CFLAGS="-I/usr/local/include"
GETTEXT_LIBS="-L/usr/local/lib -lintl"
fi;
if [ -e  "/opt/include/libintl.h" ]; then
GETTEXT_CFLAGS="-I/opt/include"
GETTEXT_LIBS="-L/opt/lib -lintl"
fi;
if [ -e  "/opt/local/include/libintl.h" ]; then
GETTEXT_CFLAGS="-I/opt/local/include"
GETTEXT_LIBS="-L/opt/local/lib -lintl"
fi;
fi;
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_GETTEXT" ]; then
		HAVE_GETTEXT=`cat ${cache}/ctest-HAVE_GETTEXT`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_GETTEXT`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
int main(int argc, char *argv[])
{
	char *s;
	bindtextdomain("foo", "/foo");
	textdomain("foo");
	s = gettext("string");
	s = dgettext("foo","string");
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${GETTEXT_CFLAGS} -o $testdir/conftest conftest.c ${GETTEXT_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${GETTEXT_CFLAGS} -o $testdir/conftest conftest.c ${GETTEXT_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_GETTEXT="yes"
echo "HAVE_GETTEXT=$HAVE_GETTEXT" >>Makefile.config
echo "mdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
echo "#ifndef HAVE_GETTEXT" > config/have_gettext.h
echo "#define HAVE_GETTEXT \"$HAVE_GETTEXT\"" >> config/have_gettext.h
echo "#endif" >> config/have_gettext.h
echo "hdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_GETTEXT="no"
echo "HAVE_GETTEXT=$HAVE_GETTEXT" >>Makefile.config
echo "mdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
echo "#undef HAVE_GETTEXT" >config/have_gettext.h
echo "hdefs[\"HAVE_GETTEXT\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_GETTEXT" > ${cache}/ctest-HAVE_GETTEXT
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_GETTEXT
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_GETTEXT}" = "yes" ]; then
echo "GETTEXT_CFLAGS=$GETTEXT_CFLAGS" >>Makefile.config
echo "mdefs[\"GETTEXT_CFLAGS\"] = \"$GETTEXT_CFLAGS\"" >>configure.lua
echo "#ifndef GETTEXT_CFLAGS" > config/gettext_cflags.h
echo "#define GETTEXT_CFLAGS \"$GETTEXT_CFLAGS\"" >> config/gettext_cflags.h
echo "#endif" >> config/gettext_cflags.h
echo "hdefs[\"GETTEXT_CFLAGS\"] = \"$GETTEXT_CFLAGS\"" >>configure.lua
echo "GETTEXT_LIBS=$GETTEXT_LIBS" >>Makefile.config
echo "mdefs[\"GETTEXT_LIBS\"] = \"$GETTEXT_LIBS\"" >>configure.lua
echo "#ifndef GETTEXT_LIBS" > config/gettext_libs.h
echo "#define GETTEXT_LIBS \"$GETTEXT_LIBS\"" >> config/gettext_libs.h
echo "#endif" >> config/gettext_libs.h
echo "hdefs[\"GETTEXT_LIBS\"] = \"$GETTEXT_LIBS\"" >>configure.lua
else
$ECHO_N "checking whether -lintl requires -liconv..."
$ECHO_N "checking whether -lintl requires -liconv..." >> config.log
if [ "" != "" ]; then
if [ -e  "/include/iconv.h" ]; then
GETTEXT_CFLAGS="${GETTEXT_CFLAGS} -I/include"
GETTEXT_LIBS="${GETTEXT_LIBS} -L/lib -liconv"
fi;
else
if [ -e  "/include/iconv.h" ]; then
GETTEXT_CFLAGS="${GETTEXT_CFLAGS} -I/include"
GETTEXT_LIBS="${GETTEXT_LIBS} -L/lib -liconv"
fi;
if [ -e  "/usr/include/iconv.h" ]; then
GETTEXT_CFLAGS="${GETTEXT_CFLAGS} -I/usr/include"
GETTEXT_LIBS="${GETTEXT_LIBS} -L/usr/lib -liconv"
fi;
if [ -e  "/usr/local/include/iconv.h" ]; then
GETTEXT_CFLAGS="${GETTEXT_CFLAGS} -I/usr/local/include"
GETTEXT_LIBS="${GETTEXT_LIBS} -L/usr/local/lib -liconv"
fi;
if [ -e  "/opt/include/iconv.h" ]; then
GETTEXT_CFLAGS="${GETTEXT_CFLAGS} -I/opt/include"
GETTEXT_LIBS="${GETTEXT_LIBS} -L/opt/lib -liconv"
fi;
if [ -e  "/opt/local/include/iconv.h" ]; then
GETTEXT_CFLAGS="${GETTEXT_CFLAGS} -I/opt/local/include"
GETTEXT_LIBS="${GETTEXT_LIBS} -L/opt/local/lib -liconv"
fi;
fi;
MK_CACHED="No"
MK_COMPILE_STATUS="OK"
if [ "${cache}" != "" ]; then
	if [ -e "${cache}/ctest-HAVE_GETTEXT" ]; then
		HAVE_GETTEXT=`cat ${cache}/ctest-HAVE_GETTEXT`
		MK_COMPILE_STATUS=`cat ${cache}/ctest-status-HAVE_GETTEXT`
		MK_CACHED="Yes"
	fi
fi
if [ "${MK_CACHED}" = "No" ]; then
	cat << EOT > conftest.c
#include 
int main(int argc, char *argv[])
{
	char *s;
	bindtextdomain("foo", "/foo");
	textdomain("foo");
	s = gettext("string");
	s = dgettext("foo","string");
	return (0);
}
EOT
	echo "$CC $CFLAGS $TEST_CFLAGS ${GETTEXT_CFLAGS} -o $testdir/conftest conftest.c ${GETTEXT_LIBS}" >>config.log
	$CC $CFLAGS $TEST_CFLAGS ${GETTEXT_CFLAGS} -o $testdir/conftest conftest.c ${GETTEXT_LIBS} 2>>config.log
	if [ $? != 0 ]; then
		echo "-> failed ($?)" >> config.log
		MK_COMPILE_STATUS="FAIL($?)"
	fi
fi
if [ "${MK_COMPILE_STATUS}" = "OK" ]; then
echo "yes"
echo "yes" >> config.log
HAVE_GETTEXT="yes"
echo "HAVE_GETTEXT=$HAVE_GETTEXT" >>Makefile.config
echo "mdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
echo "#ifndef HAVE_GETTEXT" > config/have_gettext.h
echo "#define HAVE_GETTEXT \"$HAVE_GETTEXT\"" >> config/have_gettext.h
echo "#endif" >> config/have_gettext.h
echo "hdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
else
echo "no"
echo "no" >> config.log
HAVE_GETTEXT="no"
echo "HAVE_GETTEXT=$HAVE_GETTEXT" >>Makefile.config
echo "mdefs[\"HAVE_GETTEXT\"] = \"$HAVE_GETTEXT\"" >>configure.lua
echo "#undef HAVE_GETTEXT" >config/have_gettext.h
echo "hdefs[\"HAVE_GETTEXT\"] = nil" >>configure.lua
fi;
if [ "${cache}" != "" ]; then
	echo "$HAVE_GETTEXT" > ${cache}/ctest-HAVE_GETTEXT
	echo $MK_COMPILE_STATUS > ${cache}/ctest-status-HAVE_GETTEXT
fi
rm -f conftest.c $testdir/conftest$EXECSUFFIX
if [ "${HAVE_GETTEXT}" = "yes" ]; then
echo "GETTEXT_CFLAGS=$GETTEXT_CFLAGS" >>Makefile.config
echo "mdefs[\"GETTEXT_CFLAGS\"] = \"$GETTEXT_CFLAGS\"" >>configure.lua
echo "#ifndef GETTEXT_CFLAGS" > config/gettext_cflags.h
echo "#define GETTEXT_CFLAGS \"$GETTEXT_CFLAGS\"" >> config/gettext_cflags.h
echo "#endif" >> config/gettext_cflags.h
echo "hdefs[\"GETTEXT_CFLAGS\"] = \"$GETTEXT_CFLAGS\"" >>configure.lua
echo "GETTEXT_LIBS=$GETTEXT_LIBS" >>Makefile.config
echo "mdefs[\"GETTEXT_LIBS\"] = \"$GETTEXT_LIBS\"" >>configure.lua
echo "#ifndef GETTEXT_LIBS" > config/gettext_libs.h
echo "#define GETTEXT_LIBS \"$GETTEXT_LIBS\"" >> config/gettext_libs.h
echo "#endif" >> config/gettext_libs.h
echo "hdefs[\"GETTEXT_LIBS\"] = \"$GETTEXT_LIBS\"" >>configure.lua
else
echo "#undef GETTEXT_CFLAGS" >config/gettext_cflags.h
echo "hdefs[\"GETTEXT_CFLAGS\"] = nil" >>configure.lua
GETTEXT_CFLAGS=""
echo "#undef GETTEXT_LIBS" >config/gettext_libs.h
echo "hdefs[\"GETTEXT_LIBS\"] = nil" >>configure.lua
GETTEXT_LIBS=""
fi;
fi;
else
echo "#undef GETTEXT_CFLAGS" >config/gettext_cflags.h
echo "hdefs[\"GETTEXT_CFLAGS\"] = nil" >>configure.lua
echo "#undef GETTEXT_LIBS" >config/gettext_libs.h
echo "hdefs[\"GETTEXT_LIBS\"] = nil" >>configure.lua
fi;
	if [ "${HAVE_GETTEXT}" != "yes" ]
 then
		echo "*"
		echo "* --enable-nls was given but gettext was not found. "
		echo "*"
		exit 1
	fi
fi
if [ "${enable_warnings}" = "yes" ]
 then
CFLAGS="$CFLAGS -Wall -Werror -Wmissing-prototypes"
echo "CFLAGS=$CFLAGS" >>Makefile.config
echo "mdefs[\"CFLAGS\"] = \"$CFLAGS\"" >>configure.lua
CFLAGS="$CFLAGS -Wno-unused"
echo "CFLAGS=$CFLAGS" >>Makefile.config
echo "mdefs[\"CFLAGS\"] = \"$CFLAGS\"" >>configure.lua
fi
if [ "${enable_static}" = "yes" ]
 then
LDFLAGS="-static"
echo "LDFLAGS=$LDFLAGS" >>Makefile.config
echo "mdefs[\"LDFLAGS\"] = \"$LDFLAGS\"" >>configure.lua
fi
if [ "${with_html_source}" = "yes" ]
 then
HTML_INSTSOURCE="Yes"
echo "HTML_INSTSOURCE=$HTML_INSTSOURCE" >>Makefile.config
echo "mdefs[\"HTML_INSTSOURCE\"] = \"$HTML_INSTSOURCE\"" >>configure.lua
else
HTML_INSTSOURCE="No"
echo "HTML_INSTSOURCE=$HTML_INSTSOURCE" >>Makefile.config
echo "mdefs[\"HTML_INSTSOURCE\"] = \"$HTML_INSTSOURCE\"" >>configure.lua
fi