dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/process.cpp)


AC_ARG_ENABLE(small-code,
	[  --enable-small-code     optimize for small code size],
	SMALLCODE="-O -Os -fno-exceptions",
	SMALLCODE="")
AC_ARG_ENABLE(debug,
	[  --enable-debug          compile with -g option],
	DEBUG="yes",
	DEBUG="")
AC_ARG_ENABLE(profiling,
	[  --enable-profiling      compile with -pg option],
	CXXFLAGS="$CXXFLAGS -pg",
	CXXFLAGS="$CXXFLAGS")
AC_ARG_ENABLE(enosys-notify,
	[  --enable-enosys-notify  enable runtime notification of methods that set ENOSYS],
	RUDIMENTS_ENOSYS_NOTIFY="yes",
	RUDIMENTS_ENOSYS_NOTIFY="")
AC_ARG_WITH(system-libtool,
	[  --with-system-libtool   use system libtool instead of ./libtool],
	USE_SYSTEM_LIBTOOL=$withval,
	USE_SYSTEM_LIBTOOL="no")
AC_ARG_ENABLE(inlines,
	[  --enable-inlines        use inline methods],
	ENABLE_RUDIMENTS_INLINES="yes",
	ENABLE_RUDIMENTS_INLINES="no")
AC_ARG_WITH(pthread-prefix,
	[  --with-pthread-prefix   Location of pthread library],
	PTHREADPATH="$withval",
	PTHREADPATH="")
AC_ARG_ENABLE(ssl,
	[  --disable-ssl           Disable SSL support],
	ENABLE_RUDIMENTS_SSL="no",
	ENABLE_RUDIMENTS_SSL="yes")
AC_ARG_WITH(ssl-includes,
	[  --with-ssl-includes     SSL includes],
	SSLINCLUDES="$withval",
	SSLINCLUDES="")
AC_ARG_WITH(ssl-libs,
	[  --with-ssl-libs         SSL libraries],
	SSLLIBS="$withval",
	SSLLIBS="")
AC_ARG_ENABLE(gss,
	[  --disable-gss           Disable GSS support],
	ENABLE_RUDIMENTS_GSS="no",
	ENABLE_RUDIMENTS_GSS="yes")
AC_ARG_WITH(gss-includes,
	[  --with-gss-includes     GSS includes],
	GSSINCLUDES="$withval",
	GSSINCLUDES="")
AC_ARG_WITH(gss-libs,
	[  --with-gss-libs         GSS libraries],
	GSSLIBS="$withval",
	GSSLIBS="")
AC_ARG_ENABLE(pcre,
	[  --disable-pcre          Don't use PCRE for regular expressions],
	ENABLE_RUDIMENTS_PCRE="no",
	ENABLE_RUDIMENTS_PCRE="yes")
AC_ARG_WITH(pcre-includes,
	[  --with-pcre-includes    PCRE includes],
	PCREINCLUDES="$withval",
	PCREINCLUDES="")
AC_ARG_WITH(pcre-libs,
	[  --with-pcre-libs        PCRE libraries],
	PCRELIBS="$withval",
	PCRELIBS="")
AC_ARG_ENABLE(libcurl,
	[  --disable-libcurl       Disable libcurl support],
	ENABLE_RUDIMENTS_LIBCURL="no",
	ENABLE_RUDIMENTS_LIBCURL="yes")
AC_ARG_WITH(libcurl-includes,
	[  --with-libcurl-includes libcurl includes],
	LIBCURLINCLUDES="$withval",
	LIBCURLINCLUDES="")
AC_ARG_WITH(libcurl-libs,
	[  --with-libcurl-libs     libcurl libraries],
	LIBCURLLIBS="$withval",
	LIBCURLLIBS="")
AC_ARG_ENABLE(built-in-regex,
	[  --enable-built-in-regex Use the built-in regex],
	USE_BUILT_IN_REGULAREXPRESSION="1",
	USE_BUILT_IN_REGULAREXPRESSION="0")
AC_ARG_ENABLE(threads,
	[  --disable-threads       Disable thread support],
	ENABLE_RUDIMENTS_THREADS="no"; INCLUDE_THREAD="0",
	ENABLE_RUDIMENTS_THREADS="yes")

dnl   options to disable building various classes
AC_ARG_ENABLE(character,
	[  --disable-character     Don't build character class],
	INCLUDE_CHARACTER="0",
	INCLUDE_CHARACTER="1")
AC_ARG_ENABLE(charstring,
	[  --disable-charstring    Don't build charstring class],
	INCLUDE_CHARSTRING="0",
	INCLUDE_CHARSTRING="1")
AC_ARG_ENABLE(chat,
	[  --disable-chat          Don't build chat],
	INCLUDE_CHAT="0",
	INCLUDE_CHAT="1")
AC_ARG_ENABLE(client,
	[  --disable-client        Don't build client class],
	INCLUDE_CLIENT="0",
	INCLUDE_CLIENT="1")
AC_ARG_ENABLE(commandline,
	[  --disable-commandline   Don't build commandline class],
	INCLUDE_COMMANDLINE="0",
	INCLUDE_COMMANDLINE="1")
AC_ARG_ENABLE(crypt,
	[  --disable-crypt         Don't build crypt class],
	INCLUDE_CRYPT="0",
	INCLUDE_CRYPT="1")
AC_ARG_ENABLE(datetime,
	[  --disable-datetime      Don't build datetime class],
	INCLUDE_DATETIME="0",
	INCLUDE_DATETIME="1")
AC_ARG_ENABLE(device,
	[  --disable-device        Don't build device class],
	INCLUDE_DEVICE="0",
	INCLUDE_DEVICE="1")
AC_ARG_ENABLE(directory,
	[  --disable-directory     Don't build directory class],
	INCLUDE_DIRECTORY="0",
	INCLUDE_DIRECTORY="1")
AC_ARG_ENABLE(dynamiclib,
	[  --disable-dynamiclib    Don't build dynamiclib class],
	INCLUDE_DYNAMICLIB="0",
	INCLUDE_DYNAMICLIB="1")
AC_ARG_ENABLE(environment,
	[  --disable-environment   Don't build environment class],
	INCLUDE_ENVIRONMENT="0",
	INCLUDE_ENVIRONMENT="1")
AC_ARG_ENABLE(error,
	[  --disable-error         Don't build error],
	INCLUDE_ERROR="0",
	INCLUDE_ERROR="1")
AC_ARG_ENABLE(filedescriptor,
	[  --disable-filedescriptor       Don't build filedescriptor class],
	INCLUDE_FILEDESCRIPTOR="0",
	INCLUDE_FILEDESCRIPTOR="1")
AC_ARG_ENABLE(file,
	[  --disable-file          Don't build file class],
	INCLUDE_FILE="0",
	INCLUDE_FILE="1")
AC_ARG_ENABLE(url,
	[  --disable-url           Don't build url class],
	INCLUDE_URL="0",
	INCLUDE_URL="1")
AC_ARG_ENABLE(filesystem,
	[  --disable-filesystem    Don't build filesystem class],
	INCLUDE_FILESYSTEM="0",
	INCLUDE_FILESYSTEM="1")
AC_ARG_ENABLE(groupentry,
	[  --disable-groupentry    Don't build groupentry class],
	INCLUDE_GROUPENTRY="0",
	INCLUDE_GROUPENTRY="1")
AC_ARG_ENABLE(hostentry,
	[  --disable-hostentry     Don't build hostentry class],
	INCLUDE_HOSTENTRY="0",
	INCLUDE_HOSTENTRY="1")
AC_ARG_ENABLE(inetclient,
	[  --disable-inetclient    Don't build inetclient class],
	INCLUDE_INETCLIENT="0",
	INCLUDE_INETCLIENT="1")
AC_ARG_ENABLE(inetserver,
	[  --disable-inetserver    Don't build inetserver class],
	INCLUDE_INETSERVER="0",
	INCLUDE_INETSERVER="1")
AC_ARG_ENABLE(listener,
	[  --disable-listener      Don't build listener class],
	INCLUDE_LISTENER="0",
	INCLUDE_LISTENER="1")
AC_ARG_ENABLE(logger,
	[  --disable-logger        Don't build logger class],
	INCLUDE_LOGGER="0",
	INCLUDE_LOGGER="1")
AC_ARG_ENABLE(math,
	[  --disable-math          Don't build math class],
	INCLUDE_MATH="0",
	INCLUDE_MATH="1")
dnl force disable math class for now
INCLUDE_MATH="0"
AC_ARG_ENABLE(memorymap,
	[  --disable-memorymap     Don't build memorymap class],
	INCLUDE_MEMORYMAP="0",
	INCLUDE_MEMORYMAP="1")
AC_ARG_ENABLE(memorypool,
	[  --disable-memorypool    Don't build memorypool class],
	INCLUDE_MEMORYPOOL="0",
	INCLUDE_MEMORYPOOL="1")
AC_ARG_ENABLE(modemclient,
	[  --enable-modemclient    Build modemclient class (disabled by default)],
	INCLUDE_MODEMCLIENT="1",
	INCLUDE_MODEMCLIENT="0")
AC_ARG_ENABLE(modemserver,
	[  --enable-modemserver    Build modemserver class (disabled by default)],
	INCLUDE_MODEMSERVER="1",
	INCLUDE_MODEMSERVER="0")
AC_ARG_ENABLE(thread,
	[  --disable-thread        Don't build thread class],
	INCLUDE_THREAD="0",
	INCLUDE_THREAD="1")
AC_ARG_ENABLE(threadmutex,
	[  --disable-threadmutex   Don't build threadmutex class],
	INCLUDE_THREADMUTEX="0",
	INCLUDE_THREADMUTEX="1")
AC_ARG_ENABLE(parameterstring,
	[  --disable-parameterstring      Don't build parameterstring class],
	INCLUDE_PARAMETERSTRING="0",
	INCLUDE_PARAMETERSTRING="1")
AC_ARG_ENABLE(userentry,
	[  --disable-userentry     Don't build userentry class],
	INCLUDE_USERENTRY="0",
	INCLUDE_USERENTRY="1")
AC_ARG_ENABLE(permissions,
	[  --disable-permissions   Don't build permissions],
	INCLUDE_PERMISSIONS="0",
	INCLUDE_PERMISSIONS="1")
AC_ARG_ENABLE(process,
	[  --disable-process       Don't build process],
	INCLUDE_PROCESS="0",
	INCLUDE_PROCESS="1")
AC_ARG_ENABLE(protocolentry,
	[  --disable-protocolentry Don't build protocolentry class],
	INCLUDE_PROTOCOLENTRY="0",
	INCLUDE_PROTOCOLENTRY="1")
AC_ARG_ENABLE(randomnumber,
	[  --disable-randomnumber  Don't build randomnumber],
	INCLUDE_RANDOMNUMBER="0",
	INCLUDE_RANDOMNUMBER="1")
AC_ARG_ENABLE(bytestring,
	[  --disable-bytestring    Don't build bytestring class],
	INCLUDE_BYTESTRING="0",
	INCLUDE_BYTESTRING="1")
AC_ARG_ENABLE(regularexpression,
	[  --disable-regularexpression    Don't build regularexpression],
	INCLUDE_REGULAREXPRESSION="0",
	INCLUDE_REGULAREXPRESSION="1")
AC_ARG_ENABLE(semaphoreset,
	[  --disable-semaphoreset  Don't build semaphoreset],
	INCLUDE_SEMAPHORESET="0",
	INCLUDE_SEMAPHORESET="1")
AC_ARG_ENABLE(serialport,
	[  --enable-serialport     Build serialport class (disabled by default)],
	INCLUDE_SERIALPORT="1",
	INCLUDE_SERIALPORT="0")
AC_ARG_ENABLE(serialportprofile,
	[  --enable-serialportprofile     Build serialportprofile class (disabled by default)],
	INCLUDE_SERIALPORTPROFILE="1",
	INCLUDE_SERIALPORTPROFILE="0")
AC_ARG_ENABLE(server,
	[  --disable-server        Don't build server class],
	INCLUDE_SERVER="0",
	INCLUDE_SERVER="1")
AC_ARG_ENABLE(serviceentry,
	[  --disable-serviceentry  Don't build serviceentry class],
	INCLUDE_SERVICEENTRY="0",
	INCLUDE_SERVICEENTRY="1")
AC_ARG_ENABLE(sharedmemory,
	[  --disable-sharedmemory  Don't build sharedmemory],
	INCLUDE_SHAREDMEMORY="0",
	INCLUDE_SHAREDMEMORY="1")
AC_ARG_ENABLE(signalclasses,
	[  --disable-signalclasses Don't build signalclasses],
	INCLUDE_SIGNALCLASSES="0",
	INCLUDE_SIGNALCLASSES="1")
AC_ARG_ENABLE(snooze,
	[  --disable-snooze        Don't build snooze class],
	INCLUDE_SNOOZE="0",
	INCLUDE_SNOOZE="1")
AC_ARG_ENABLE(stringbuffer,
	[  --disable-stringbuffer  Don't build stringbuffer class],
	INCLUDE_STRINGBUFFER="0",
	INCLUDE_STRINGBUFFER="1")
AC_ARG_ENABLE(sys,
	[  --disable-sys           Don't build sys class],
	INCLUDE_SYSTEM="0",
	INCLUDE_SYSTEM="1")
AC_ARG_ENABLE(unixclient,
	[  --disable-unixclient    Don't build unixclient class],
	INCLUDE_UNIXCLIENT="0",
	INCLUDE_UNIXCLIENT="1")
AC_ARG_ENABLE(unixserver,
	[  --disable-unixserver    Don't build unixserver class],
	INCLUDE_UNIXSERVER="0",
	INCLUDE_UNIXSERVER="1")
AC_ARG_ENABLE(bytebuffer,
	[  --disable-bytebuffer    Don't build bytebuffer class],
	INCLUDE_BYTEBUFFER="0",
	INCLUDE_BYTEBUFFER="1")
AC_ARG_ENABLE(xmldom,
	[  --disable-xmldom        Don't build xmldom class],
	INCLUDE_XMLDOM="0",
	INCLUDE_XMLDOM="1")
AC_ARG_ENABLE(xmlsax,
	[  --disable-xmlsax        Don't build xmlsax class],
	INCLUDE_XMLSAX="0",
	INCLUDE_XMLSAX="1")
AC_ARG_ENABLE(xmldomevents,
	[  --disable-xmldomevents  Don't build xmldomevents class],
	INCLUDE_XMLDOMEVENTS="0",
	INCLUDE_XMLDOMEVENTS="1")
AC_ARG_ENABLE(codetree,
	[  --disable-codetree      Don't build codetree class],
	INCLUDE_CODETREE="0",
	INCLUDE_CODETREE="1")
AC_ARG_ENABLE(compiler,
	[  --disable-compiler      Don't build compiler class],
	INCLUDE_COMPILER="0",
	INCLUDE_COMPILER="1")

if ( test -n "$SMALLCODE" ); then
	AC_DEFINE_UNQUOTED(RUDIMENTS_SMALL_CODE,1,Use small rather than fast code)
fi



dnl Additional defines.
if ( test "$ENABLE_RUDIMENTS_INLINES" = "yes" ); then
	AC_DEFINE_UNQUOTED(ENABLE_RUDIMENTS_INLINES,1,Use inline functions or not)
fi

if ( test "$RUDIMENTS_ENOSYS_NOTIFY" = "yes" ); then
	AC_DEFINE_UNQUOTED(RUDIMENTS_ENOSYS_NOTIFY,1,Enable runtime notification of methods that set ENOSYS)
fi


dnl Checks for programs.
echo
echo "***** Programs ***************"
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_LANG(C++)
echo "******************************"

CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D__EXTENSIONS__ $CPPFLAGS"
CXXFLAGS="$SMALLCODE $CXXFLAGS"
EXTRALIBS=""

dnl Checks for libtool.
echo
echo "***** Libtool ****************"
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
FW_CHECK_USE_SYSTEM_LIBTOOL

dnl have to set ar here because libtool (currently) fails
dnl to use the correct one when cross-compiling
AC_CHECK_PROG(AR,$host_alias-ar,$host_alias-ar,ar)
AC_SUBST(AR)
echo "******************************"


dnl Checks for platform-specific stuff
echo
echo "***** Platform ***************"
FW_CHECK_MULTIARCH
FW_CHECK_MICROSOFT

dnl for mingw32, disable serial-related classes
if ( test -n "$MINGW32" )
then
	INCLUDE_SERIALPORT="0"
	INCLUDE_SERIALPORTPROFILE="0"
	INCLUDE_MODEMCLIENT="0"
	INCLUDE_MODEMSERVER="0"
fi

FW_CHECK_OSX
FW_CHECK_MINIX
FW_CHECK_HAIKU
FW_CHECK_SYLLABLE
FW_CHECK_SCO_OSR

FW_CHECK_SO_EXT
FW_CHECK_LIBDIR

FW_CHECK_PIPE
FW_CHECK_DEBUG

FW_CHECK_WERROR
FW_CHECK_WALL

FW_CHECK_WNOFORMAT
FW_CHECK_WNOOVERLOADEDVIRTUAL

dnl Remove -Wall and -Werror from CPPFLAGS/CXXFLAGS as they cause way to many
dnl problems with the test programs.  They will be reincluded later if
dnl appropriate.
CPPFLAGS=`echo $CPPFLAGS | sed -e "s|-Werror[[^ ]]*||g" -e "s|-Wall||g"`
CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-Werror[[^ ]]*||g" -e "s|-Wall||g"`

dnl If the c++ compiler allows undefined functions, then add -Werror back.
FW_CHECK_UNDEFINED_FUNCTIONS

AC_SUBST(CPPFLAGS)
AC_SUBST(CXXFLAGS)

FW_CHECK_NULL_REDEFINE
FW_CHECK_F_NO_BUILTIN

echo "******************************"

dnl Checks for header files.
echo
echo "***** Headers ****************"

AC_MSG_CHECKING(for stdlib.h)
AC_TRY_COMPILE([#include <stdlib.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_STDLIB_H, 1, Some systems have stdlib.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for stdarg.h)
AC_TRY_COMPILE([#include <stdarg.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_STDARG_H, 1, Some systems have stdarg.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for string.h)
AC_TRY_COMPILE([#include <string.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_STRING_H, 1, Some systems have string.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for dlfcn.h)
AC_TRY_COMPILE([#include <dlfcn.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_DLFCN_H, 1, Some systems have dlfcn.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for poll.h)
AC_TRY_COMPILE([#include <poll.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_POLL_H, 1, Some systems have poll.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/poll.h)
AC_TRY_COMPILE([#include <sys/poll.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_POLL_H, 1, Some systems have sys/poll.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/epoll.h)
AC_TRY_COMPILE([#include <sys/epoll.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_EPOLL_H, 1, Some systems have sys/epoll.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/devpoll.h)
AC_TRY_COMPILE([#include <sys/devpoll.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_DEVPOLL_H, 1, Some systems have sys/devpoll.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for port.h)
AC_TRY_COMPILE([#include <port.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_PORT_H, 1, Some systems have port.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/stat.h)
AC_TRY_COMPILE([#include <sys/stat.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_STAT_H, 1, Some systems have sys/stat.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/types.h)
AC_TRY_COMPILE([#include <sys/types.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_TYPES_H, 1, Some systems have sys/types.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/event.h)
AC_TRY_COMPILE([
#if defined(RUDIMENTS_HAVE_SYS_TYPES_H)
	#include <sys/types.h>
#endif
#include <sys/event.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_EVENT_H, 1, Some systems have sys/event.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ctype.h)
AC_TRY_COMPILE([#include <ctype.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_CTYPE_H, 1, Some systems have ctype.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/wait.h)
AC_TRY_COMPILE([#include <sys/wait.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_WAIT_H, 1, Some systems have sys/wait.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for dirent.h)
AC_TRY_COMPILE([#include <dirent.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_DIRENT_H, 1, Some systems have dirent.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for direct.h)
AC_TRY_COMPILE([#include <direct.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_DIRECT_H, 1, Some systems have direct.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strings.h)
AC_TRY_COMPILE([#include <strings.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_STRINGS_H, 1, Some systems have strings.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for unistd.h)
AC_TRY_COMPILE([#include <unistd.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_UNISTD_H, 1, Some systems have unistd.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for grp.h)
AC_TRY_COMPILE([
#if defined(RUDIMENTS_HAVE_SYS_TYPES_H)
	#include <sys/types.h>
#endif
#include <grp.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_GRP_H, 1, Some systems have grp.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

FW_CHECK_SCO_CFRONT_HACK

AC_MSG_CHECKING(for utime.h)
AC_TRY_COMPILE([#include <utime.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_UTIME_H, 1, Some systems have utime.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for netdb.h)
AC_TRY_COMPILE([#include <netdb.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_NETDB_H, 1, Some systems have netdb.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for netinet/in.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <netinet/in.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_NETINET_IN_H, 1, Some systems have netinet/in.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/un.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <sys/un.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_UN_H, 1, Some systems have sys/un.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/param.h)
AC_TRY_COMPILE([#include <sys/param.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_PARAM_H, 1, Some systems have sys/param.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for time.h)
AC_TRY_COMPILE([#include <time.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_TIME_H, 1, Some systems have time.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/time.h)
AC_TRY_COMPILE([#include <sys/time.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_TIME_H, 1, Some systems have sys/time.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for byteswap.h)
AC_TRY_COMPILE([#include <byteswap.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_BYTESWAP_H, 1, Some systems have byteswap.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for machine/endian.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <machine/endian.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_MACHINE_ENDIAN_H, 1, Some systems have machine/endian.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/select.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <sys/select.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_SELECT_H, 1, Some systems have sys/select.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for netinet/in.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <netinet/in.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_NETINET_IN_H, 1, Some systems have netinet/in.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for netinet/tcp.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <netinet/tcp.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_NETINET_TCP_H, 1, Some systems have netinet/tcp.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/socket.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <sys/socket.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_SOCKET_H, 1, Some systems have sys/socket.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for arpa/inet.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <arpa/inet.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_ARPA_INET_H, 1, Some systems have arpa/inet.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/uio.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <sys/uio.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_UIO_H, 1, Some systems have sys/uio.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for arpa/inet.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <arpa/inet.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_ARPA_INET_H, 1, Some systems have arpa/inet.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for stdint.h)
AC_TRY_COMPILE([#include <stdint.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_STDINT_H, 1, Some systems have stdint.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/bitypes.h)
AC_TRY_COMPILE([#include <sys/bitypes.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_BITYPES_H, 1, Some systems have sys/bitypes.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for inttypes.h)
AC_TRY_COMPILE([#include <inttypes.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_INTTYPES_H, 1, Some systems have inttypes.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for limits.h)
AC_TRY_COMPILE([#include <limits.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_LIMITS_H, 1, Some systems have limits.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fcntl.h)
AC_TRY_COMPILE([#include <fcntl.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_FCNTL_H, 1, Some systems have fcntl.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/fcntl.h)
AC_TRY_COMPILE([#include <sys/fcntl.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_FCNTL_H, 1, Some systems have sys/fcntl.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/ipc.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <sys/ipc.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_IPC_H, 1, Some systems have sys/ipc.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/sem.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <sys/sem.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_SEM_H, 1, Some systems have sys/sem.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for syslog.h)
AC_TRY_LINK([#include <syslog.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYSLOG_H,1,Some systems have syslog.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for errno.h)
AC_TRY_LINK([#include <errno.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_ERRNO_H,1,Some systems have errno.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for linux/rtc.h)
AC_TRY_COMPILE([#include <linux/rtc.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_LINUX_RTC_H, 1, Some systems have linux/rtc.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/ioctl.h)
AC_TRY_LINK([#include <sys/ioctl.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_IOCTL_H,1,Some systems have sys/ioctl.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for os/kernel/OS.h)
AC_TRY_LINK([#include <os/kernel/OS.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_OS_KERNEL_OS_H,1,Some systems have os/kernel/OS.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/byteorder.h)
AC_TRY_LINK([#include <sys/byteorder.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_BYTEORDER_H,1,Some systems have sys/byteorder.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for os/support/ByteOrder.h)
AC_TRY_LINK([#include <os/support/ByteOrder.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_OS_SUPPORT_BYTEORDER_H,1,Some systems have os/support/ByteOrder.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for termios.h)
AC_TRY_COMPILE([#include <termios.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_TERMIOS_H, 1, Some systems have termios.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

dnl don't even look for these under cygwin, they cause all kinds of trouble
if ( test -z "$CYGWIN" )
then
	AC_MSG_CHECKING(for windows.h)
	AC_TRY_COMPILE([#include <windows.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_WINDOWS_H, 1, Some systems have windows.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for winsock2.h)
	AC_TRY_COMPILE([#include <winsock2.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_WINSOCK2_H, 1, Some systems have winsock2.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for tlhelp32.h)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
		#include <windows.h>
	#endif
	#include <tlhelp32.h>],
	[],AC_DEFINE(RUDIMENTS_HAVE_TLHELP32_H, 1, Some systems have tlhelp32.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for sddl.h)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
		#include <windows.h>
	#endif
	#include <sddl.h>],
	[],AC_DEFINE(RUDIMENTS_HAVE_SDDL_H, 1, Some systems have sddl.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for aclapi.h)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
		#include <windows.h>
	#endif
	#include <aclapi.h>],
	[],AC_DEFINE(RUDIMENTS_HAVE_ACLAPI_H, 1, Some systems have aclapi.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for accctrl.h)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
		#include <windows.h>
	#endif
	#include <accctrl.h>],
	[],AC_DEFINE(RUDIMENTS_HAVE_ACCCTRL_H, 1, Some systems have accctrl.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for lm.h)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
		#include <windows.h>
	#endif
	#include <lm.h>],
	[],AC_DEFINE(RUDIMENTS_HAVE_LM_H, 1, Some systems have lm.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for io.h)
AC_TRY_COMPILE([#include <io.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_IO_H, 1, Some systems have io.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for process.h)
AC_TRY_COMPILE([#include <process.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_PROCESS_H, 1, Some systems have process.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/utsname.h)
AC_TRY_COMPILE([#include <sys/utsname.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_UTSNAME_H, 1, Some systems have sys/utsname.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/mman.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <sys/mman.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_MMAN_H, 1, Some systems have sys/mman.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/loadavg.h)
AC_TRY_COMPILE([#include <sys/loadavg.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_LOADAVG_H, 1, Some systems have sys/loadavg.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/reboot.h)
AC_TRY_COMPILE([#include <sys/reboot.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_REBOOT_H, 1, Some systems have sys/reboot.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for linux/reboot.h)
AC_TRY_COMPILE([#include <linux/reboot.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_LINUX_REBOOT_H, 1, Some systems have linux/reboot.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/uadmin.h)
AC_TRY_COMPILE([#include <sys/uadmin.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_UADMIN_H, 1, Some systems have sys/uadmin.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for prototypes.h)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <prototypes.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_PROTOTYPES_H, 1, Some systems have prototypes.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for Roster.h)
AC_TRY_COMPILE([#include <Roster.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_ROSTER_H, 1, Some systems have Roster.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sys/signal.h)
AC_TRY_COMPILE([#include <sys/signal.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_SYS_SIGNAL_H, 1, Some systems have sys/signal.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for new)
AC_TRY_COMPILE([#include <new>],
[],AC_DEFINE(RUDIMENTS_HAVE_NEW, 1, Some systems have new) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for new.h)
AC_TRY_COMPILE([#include <new.h>],
[],AC_DEFINE(RUDIMENTS_HAVE_NEW_H, 1, Some systems have new.h) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))
echo "******************************"


dnl Checks for thread library.
echo
echo "***** Threads ****************"
FW_CHECK_PTHREAD
FW_CHECK_THREAD
FW_CHECK_MUTEX
FW_CHECK_PTHREAD_SIGMASK
echo "******************************"


dnl Checks for TLS/SSL library.
echo
echo "***** TLS/SSL ****************"
FW_CHECK_SSL
echo "******************************"


dnl Checks for GSS library.
echo
echo "***** GSS ********************"
FW_CHECK_GSS
AC_DEFUN(RUDIMENTS_HAS_SSPI,Rudiments supports SSPI)
echo "******************************"


dnl Checks for typedefs, structures, and compiler characteristics.
echo
echo "***** Structures *************"

AC_C_INLINE
AC_C_CONST

AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_CHECK_TYPE([off64_t],[],[AC_DEFINE(off64_t,off_t,Some systems dont have off64_t)])
AC_CHECK_TYPE([nlink_t],[],[AC_DEFINE(nlink_t,short,Some systems dont have nlink_t)])
AC_CHECK_TYPE([key_t],[],[AC_DEFINE(key_t,int,Some systems dont have key_t)],[
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IPC_H
	#include <sys/ipc.h>
#endif])


AC_MSG_CHECKING(for socklen_t)
AC_EGREP_CPP(socklen_t,[#include <sys/socket.h>],AC_MSG_RESULT(yes),AC_MSG_RESULT(no); AC_DEFINE(socklen_t, int, Some systems dont define socklen_t))

AC_MSG_CHECKING(for union semun)
AC_EGREP_CPP(union semun,[#include <sys/sem.h>],AC_DEFINE(RUDIMENTS_HAVE_SEMUN,1,Some systems define union semun) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct msghdr.msg_controllen)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif],
struct msghdr m; m.msg_controllen=0;,AC_DEFINE(RUDIMENTS_HAVE_MSGHDR_MSG_CONTROLLEN,1,Some msghdr structs have a msg_controllen member) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct msghdr.msg_flags)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif],
struct msghdr m; m.msg_flags=0;,AC_DEFINE(RUDIMENTS_HAVE_MSGHDR_MSG_FLAGS,1,Some msghdr structs have a msg_flags member) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct msghdr.msg_accrights)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif],
struct msghdr m; m.msg_accrights=0;,AC_DEFINE(RUDIMENTS_HAVE_MSGHDR_MSG_ACCRIGHTS,1,Some msghdr structs have a msg_accrights member) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct cmsghdr)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif],
struct cmsghdr cm; cm.cmsg_len=0;,AC_DEFINE(RUDIMENTS_HAVE_CMSGHDR,1,Some systems have cmsghdr) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if struct stat contains st_blksize)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
struct stat st;
blksize_t s=st.st_blksize;,AC_DEFINE(RUDIMENTS_HAVE_BLKSIZE_T,1,Some systems dont have st_blksize in struct stat) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if struct stat contains st_blocks)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
struct stat st;
blkcnt_t b=st.st_blocks;,AC_DEFINE(RUDIMENTS_HAVE_BLKCNT_T,1,Some systems dont have st_blocks in struct stat) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if S_ISSOCK exists)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
S_ISSOCK(0);,AC_DEFINE(RUDIMENTS_HAVE_S_ISSOCK,1,Some systems dont have S_ISSOCK) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if S_ISLNK exists)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
S_ISLNK(0);,AC_DEFINE(RUDIMENTS_HAVE_S_ISLNK,1,Some systems dont have S_ISLNK) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if S_ISBLK exists)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
S_ISBLK(0);,AC_DEFINE(RUDIMENTS_HAVE_S_ISBLK,1,Some systems dont have S_ISBLK) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(type of iovec.iov_base)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_UIO_H
	#include <sys/uio.h>
#endif],
struct iovec iov; iov.iov_base=(void *)" ";,AC_DEFINE(RUDIMENTS_IOV_BASE_TYPE,void *,iov_base is void *) AC_MSG_RESULT(void *), AC_DEFINE(RUDIMENTS_IOV_BASE_TYPE,char *,iov_base is char *) AC_MSG_RESULT(char *))

FW_STATFS

AC_MSG_CHECKING(for struct timespec in time.h)
AC_TRY_COMPILE([#include <time.h>],
struct timespec a;,AC_DEFINE(RUDIMENTS_HAVE_STRUCT_TIMESPEC_IN_TIME_H,1,Some systems have struct timespec in time.h) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct timespec in sys/time.h)
AC_TRY_COMPILE([#include <sys/time.h>],
struct timespec a;,AC_DEFINE(RUDIMENTS_HAVE_STRUCT_TIMESPEC_IN_SYS_TIME_H,1,Some systems have struct timespec in sys/time.h) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct timespec in sys/siginfo.h)
AC_TRY_COMPILE([#include <sys/siginfo.h>],
struct timespec a;,AC_DEFINE(RUDIMENTS_HAVE_STRUCT_TIMESPEC_IN_SIGINFO,1,Some systems have struct timespec in sys/siginfo.h) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for struct timespec in pthread.h)
AC_TRY_COMPILE([#include <pthread.h>],
struct timespec a;,AC_DEFINE(RUDIMENTS_HAVE_STRUCT_TIMESPEC_IN_PTHREAD,1,Some systems have struct timespec in pthread.h) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for in_addr_t type)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif
#ifdef RUDIMENTS_HAVE_NETINET_IN_H
	#include <netinet/in.h>
#endif
#ifdef RUDIMENTS_HAVE_ARPA_INET_H
	#include <arpa/inet.h>
#endif],
[in_addr_t i=0;],AC_DEFINE(RUDIMENTS_HAVE_IN_ADDR_T,1,Some systems have in_addr_t type) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sockaddr_un type)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_UN_H
	#include <sys/un.h>
#endif],
[struct sockaddr_un a;],AC_DEFINE(RUDIMENTS_HAVE_SOCKADDR_UN,1,Some systems have sockaddr_un) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for int8_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[int8_t i;],AC_DEFINE(RUDIMENTS_HAVE_INT8_T,1,Some systems have int8_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for uint8_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[uint8_t i;],AC_DEFINE(RUDIMENTS_HAVE_UINT8_T,1,Some systems have uint8_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for int16_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[int16_t i;],AC_DEFINE(RUDIMENTS_HAVE_INT16_T,1,Some systems have int16_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for uint16_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[uint16_t i;],AC_DEFINE(RUDIMENTS_HAVE_UINT16_T,1,Some systems have uint16_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for int32_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[int32_t i;],AC_DEFINE(RUDIMENTS_HAVE_INT32_T,1,Some systems have int32_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for uint32_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[uint32_t i;],AC_DEFINE(RUDIMENTS_HAVE_UINT32_T,1,Some systems have uint32_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for int64_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[int64_t i;],AC_DEFINE(RUDIMENTS_HAVE_INT64_T,1,Some systems have int64_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for uint64_t type)
AC_TRY_COMPILE([#if defined(RUDIMENTS_HAVE_STDINT_H)
	#include <stdint.h>
#elif defined(RUDIMENTS_HAVE_SYS_BITYPES_H)
	#include <sys/bitypes.h>
#elif defined(RUDIMENTS_HAVE_INTTYPES_H)
	#include <inttypes.h>
#endif],
[uint64_t i;],AC_DEFINE(RUDIMENTS_HAVE_UINT64_T,1,Some systems have uint64_t) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

dnl SCO CC doesn't support long long but throws a warning rather than an error
if ( test "$RUDIMENTS_HAVE_SCO" = "yes" -a "$CXX" = "CC" )
then
AC_MSG_CHECKING(for long long type)
AC_MSG_RESULT(no)
else
AC_MSG_CHECKING(for long long type)
AC_TRY_COMPILE([],
[long long i;],AC_DEFINE(RUDIMENTS_HAVE_LONG_LONG,1,Most systems have long long) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for bool)
AC_TRY_COMPILE([],
[bool a=1;],AC_DEFINE(RUDIMENTS_HAVE_BOOL,1,Most systems have bool) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for true/false)
AC_TRY_COMPILE([],
[int a=true;],AC_DEFINE(RUDIMENTS_HAVE_TRUE_FALSE,1,Most systems have true/false) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
echo "******************************"


if ( test "$INCLUDE_SIGNALCLASSES" = "1" )
then

dnl Checks associated with signal handling
echo
echo "***** Signal Handling ********"

AC_MSG_CHECKING(for sigaction)
AC_TRY_COMPILE([#include <signal.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
sigaction(0,NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_SIGACTION,1,Some systems have sigaction) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for signal)
AC_TRY_COMPILE([#include <signal.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
signal(0,NULL);,AC_DEFINE(RUDIMENTS_HAVE_SIGNAL,1,Some systems have signal) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for SetConsoleCtrlHandler)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
SetConsoleCtrlHandler(0,0);,AC_DEFINE(RUDIMENTS_HAVE_SETCONSOLECTRLHANDLER,1,Some systems have SetConsoleCtrlHandler) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for SetUnhandledExceptionFilter)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
SetUnhandledExceptionFilter(0);,AC_DEFINE(RUDIMENTS_HAVE_SETUNHANDLEDEXCEPTIONFILTER,1,Some systems have SetUnhandledExceptionFilter) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))


AC_MSG_CHECKING(signal handler parameter)
AC_TRY_COMPILE([#include <signal.h>],
void (*handler)(int);
#if defined(RUDIMENTS_HAVE_SIGACTION)
	struct sigaction test;
	test.sa_handler=handler;
#elif defined(RUDIMENTS_HAVE_SIGNAL)
	signal(0,handler);
#else
	#error neither sigaction nor signal was found
#endif
,AC_DEFINE(RUDIMENTS_SIGNAL_HANDLER_INT,1,Most systems define signal handlers with an integer parameter) AC_MSG_RESULT(int),AC_MSG_RESULT(void))

AC_MSG_CHECKING(for kill)
AC_TRY_COMPILE([#include <signal.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
kill(0,0);,AC_DEFINE(RUDIMENTS_HAVE_KILL,1,Some systems have kill) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for raise)
AC_TRY_COMPILE([#include <signal.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
raise(0);,AC_DEFINE(RUDIMENTS_HAVE_RAISE,1,Some systems have raise) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GenerateConsoleCtrlEvent)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GenerateConsoleCtrlEvent(0,0);,AC_DEFINE(RUDIMENTS_HAVE_GENERATECONSOLECTRLEVENT,1,Some systems have GenerateConsoleCtrlEvent) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sigsuspend)
AC_TRY_COMPILE([#include <signal.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
sigsuspend(NULL);,AC_DEFINE(RUDIMENTS_HAVE_SIGSUSPEND,1,Some systems have sigsuspend) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sigpending)
AC_TRY_COMPILE([#include <signal.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
sigpending(NULL);,AC_DEFINE(RUDIMENTS_HAVE_SIGPENDING,1,Some systems have sigpending) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for alarm)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
alarm(0);,AC_DEFINE(RUDIMENTS_HAVE_ALARM,1,Some systems have alarm) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for CreateTimerQueueTimer)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
CreateTimerQueueTimer(0,0,0,0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_CREATETIMERQUEUETIMER,1,Some systems have CreateTimerQueueTimer) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

echo "******************************"

fi

dnl Checks associated with date and time
echo
echo "***** Date and Time **********"

AC_MSG_CHECKING(for GetSystemTimeAsFileTime)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
GetSystemTimeAsFileTime(NULL);,AC_DEFINE(RUDIMENTS_HAVE_GETSYSTEMTIMEASFILETIME,1,Some systems have GetSystemTimeAsFileTime) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for SetSystemTime)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
SetSystemTime(NULL);,AC_DEFINE(RUDIMENTS_HAVE_SETSYSTEMTIME,1,Some systems have SetSystemTime) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for tm_zone)
AC_TRY_COMPILE([#include <time.h>],
struct tm t;  t.tm_zone=0;,AC_DEFINE(RUDIMENTS_HAS_TM_ZONE,1,Some systems define tm_zone in their struct tm) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for tm_gmtoff)
AC_TRY_COMPILE([#include <time.h>],
struct tm t; t.tm_gmtoff=0;,AC_DEFINE(RUDIMENTS_HAS_TM_GMTOFF,1,Some systems define tm_gmtoff in their struct tm) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for __tm_zone)
AC_TRY_COMPILE([#include <time.h>],
struct tm t; t.__tm_zone=0;,AC_DEFINE(RUDIMENTS_HAS___TM_ZONE,1,Some systems define __tm_zone in their struct tm) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for __tm_gmtoff)
AC_TRY_COMPILE([#include <time.h>],
struct tm t; t.__tm_gmtoff=0;,AC_DEFINE(RUDIMENTS_HAS___TM_GMTOFF,1,Some systems define __tm_gmtoff in their struct tm) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for timezone)
AC_TRY_COMPILE([#include <time.h>],
long	t=-timezone;,AC_DEFINE(RUDIMENTS_HAS_TIMEZONE,1,Some systems have timezone) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _timezone)
AC_TRY_COMPILE([#include <time.h>],
long	t=-_timezone;,AC_DEFINE(RUDIMENTS_HAS__TIMEZONE,1,Some systems have _timezone) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _get_timezone)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#include <time.h>],
_get_timezone(NULL);,AC_DEFINE(RUDIMENTS_HAS__GET_TIMEZONE,1,Some systems have _get_timezone) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for tm_name)
AC_EGREP_CPP(tm_name,[#include <time.h>],AC_DEFINE(RUDIMENTS_HAS_TM_NAME,1,Some systems define tm_name in their struct tm) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for tm_tzadj)
AC_EGREP_CPP(tm_tzadj,[#include <time.h>],AC_DEFINE(RUDIMENTS_HAS_TM_TZADJ,1,Some systems define tm_tzadj in their struct tm) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for real-time-clock RTC_RD_TIME support)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_LINUX_RTC_H
	#include <linux/rtc.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IOCTL_H
	#include <sys/ioctl.h>
#endif,
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
ioctl(0,RTC_RD_TIME,0);,AC_DEFINE(RUDIMENTS_HAVE_RTC_RD_TIME,1,Do we have real-time-clock RTC_RD_TIME support) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for real-time-clock RTC_SET_TIME support)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_LINUX_RTC_H
	#include <linux/rtc.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IOCTL_H
	#include <sys/ioctl.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
ioctl(0,RTC_SET_TIME,0);,AC_DEFINE(RUDIMENTS_HAVE_RTC_SET_TIME,1,Do we have real-time-clock RTC_SET_TIME support) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for localtime_r)
AC_TRY_COMPILE([#include <time.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
localtime_r(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_LOCALTIME_R,1,Some systems have localtime_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for localtime_s)
AC_TRY_COMPILE([#include <time.h>
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
localtime_s(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_LOCALTIME_S,1,Some systems have localtime_s) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for gettimeofday)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TIME_H
extern "C" {
	#include <sys/time.h>
}
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
gettimeofday(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_GETTIMEOFDAY,1,Some systems have gettimeofday) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for settimeofday)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TIME_H
extern "C" {
	#include <sys/time.h>
}
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
settimeofday(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_SETTIMEOFDAY,1,Some systems have settimeofday) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for set_real_time_clock)
AC_TRY_LINK([#include <os/kernel/OS.h>],
set_real_time_clock(0);,AC_DEFINE(RUDIMENTS_HAVE_SET_REAL_TIME_CLOCK,1,Some systems have set_real_time_clock) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for clock_settime)
AC_TRY_LINK([#include <time.h>],
clock_settime(0,0);,AC_DEFINE(RUDIMENTS_HAVE_CLOCK_SETTIME,1,Some systems have clock_settime) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for tzset)
AC_TRY_COMPILE([#include <time.h>],
tzset();,AC_DEFINE(RUDIMENTS_HAS_TZSET,1,Some systems have tzset) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _tzset)
AC_TRY_COMPILE([#include <time.h>],
_tzset();,AC_DEFINE(RUDIMENTS_HAS__TZSET,1,Some systems have _tzset) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for tzname)
AC_TRY_COMPILE([#include <time.h>],
const char * const *c=tzname;,AC_DEFINE(RUDIMENTS_HAS_TZNAME,1,Some systems have tzname) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _tzname)
AC_TRY_COMPILE([#include <time.h>],
const char * const *c=_tzname;,AC_DEFINE(RUDIMENTS_HAS__TZNAME,1,Some systems have _tzname) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _get_tzname)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#include <time.h>],
_get_tzname(NULL,NULL,0,0);,AC_DEFINE(RUDIMENTS_HAS__GET_TZNAME,1,Some systems have _get_tzname) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for environment functions.
echo
echo "***** Environment ************"

AC_MSG_CHECKING(for setenv)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
setenv(NULL,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_SETENV,1,Some systems have setenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for putenv)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
putenv(NULL);,AC_DEFINE(RUDIMENTS_HAVE_PUTENV,1,Some systems have putenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _putenv)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
_putenv(NULL);,AC_DEFINE(RUDIMENTS_HAVE__PUTENV,1,Some systems have _putenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getenv)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
getenv(NULL);,AC_DEFINE(RUDIMENTS_HAVE_GETENV,1,Some systems have getenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _dupenv_s)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
_dupenv_s(NULL,NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE__DUPENV_S,1,Some systems have _dupenv_s) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for unsetenv)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
unsetenv(NULL);,AC_DEFINE(RUDIMENTS_HAVE_UNSETENV,1,Some systems have unsetenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _NSGetEnviron)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#include <crt_externs.h>],
char **env=(*_NSGetEnviron());,AC_DEFINE(RUDIMENTS_HAVE_NSGETENVIRON,1,Some systems define _NSGetEnviron in crt_externs.h) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for environ)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
char **env=environ;,AC_DEFINE(RUDIMENTS_HAVE_ENVIRON,1,Some systems define environ in unistd.h) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for clearenv)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
clearenv();,AC_DEFINE(RUDIMENTS_HAVE_CLEARENV,1,Some systems have clearenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for regular expression functions.
echo
echo "***** Regular Expressions ****"

if ( test "$USE_BUILT_IN_REGULAREXPRESSION" = "0" )
then

	FW_CHECK_PCRE

	if ( test -z "$HAVE_PCRE" )
	then
		HAVE_REGCOMP=""
		AC_MSG_CHECKING(for regcomp)
		AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
		#include <stdlib.h>
	#endif
	#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#include <regex.h>],
	regcomp(NULL,NULL,0);,HAVE_REGCOMP="yes"; AC_DEFINE(RUDIMENTS_HAVE_REGCOMP,1,some systems have regcomp) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
	fi

	USE_BUILT_IN_REGULAREXPRESSION="0"
fi

AC_MSG_CHECKING(for built-in regex)
if ( test -z "$HAVE_PCRE" -a -z "$HAVE_REGCOMP" )
then
	AC_MSG_RESULT(yes)
	USE_BUILT_IN_REGULAREXPRESSION="1"
else
	AC_MSG_RESULT(no)
fi

echo "******************************"


dnl Checks for networking functions.
echo
echo "***** Networking *************"

AC_MSG_CHECKING(for WSAConnect)
AC_TRY_COMPILE([
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif],
WSAConnect(0,0,0,0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_WSACONNECT,1,Some systems have WSAConnect) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for WSADuplicateSocket)
AC_TRY_COMPILE([
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif],
WSADuplicateSocket(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_WSADUPLICATESOCKET,1,Some systems have WSADuplicateSocket) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for closesocket)
AC_TRY_COMPILE([
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif],
closesocket(0);,AC_DEFINE(RUDIMENTS_HAVE_CLOSESOCKET,1,some systems have closesocket) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if connect has a non-const sockaddr * parameter)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#else
	#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
#endif],
connect(0,(const sockaddr *)NULL,0);,AC_MSG_RESULT(no),AC_DEFINE(RUDIMENTS_HAVE_CONNECT_WITH_NON_CONST_SOCKADDR,1, connect has a const sockaddr * on most systems ) AC_MSG_RESULT(yes))

AC_MSG_CHECKING(if send has a const void * parameter)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#else
	#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
#endif],
send(0,(const void *)NULL,0,0);,AC_DEFINE(RUDIMENTS_HAVE_SEND_WITH_VOID,1, send has a const void * on most systems ) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if recv has a void * parameter)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#else
	#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
#endif],
recv(0,(void *)NULL,0,0);,AC_DEFINE(RUDIMENTS_HAVE_RECV_WITH_VOID,1, recv has a void * on most systems ) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if setsockopt has a const void * parameter)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#else
	#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
#endif],
setsockopt(0,0,0,(const void *)NULL,0);,AC_DEFINE(RUDIMENTS_SETSOCKOPT_OPTVAL_TYPE, const void *, setsockopt has a const void * on most systems ) AC_MSG_RESULT(yes), AC_DEFINE(RUDIMENTS_SETSOCKOPT_OPTVAL_TYPE, const char *, setsockopt has a const void * on most systems ) AC_MSG_RESULT(no))

AC_MSG_CHECKING(if getsockopt has a void * parameter)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#else
	#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
#endif],
void *ptr; getsockopt(0,0,0,ptr,0);,AC_DEFINE(RUDIMENTS_GETSOCKOPT_OPTVAL_TYPE, void *, getsockopt has a void * on most systems ) AC_MSG_RESULT(yes), AC_DEFINE(RUDIMENTS_GETSOCKOPT_OPTVAL_TYPE, char *, getsockopt has a void * on most systems ) AC_MSG_RESULT(no))

AC_MSG_CHECKING(for socklen_t vs size_t)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#else
	#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
#endif],
size_t *ptr; getsockopt(0,0,0,0,ptr);,AC_DEFINE(RUDIMENTS_SOCKLEN_OR_SIZE_T, size_t, getsockopt has a socklen_t * on most systems ) AC_MSG_RESULT(size_t), AC_DEFINE(RUDIMENTS_SOCKLEN_OR_SIZE_T, socklen_t, getsockopt has a socklen_t * on most systems ) AC_MSG_RESULT(socklen_t))

HAVE_INET_ATON="no"
AC_MSG_CHECKING(for inet_aton)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif
#ifdef RUDIMENTS_HAVE_NETINET_IN_H
	#include <netinet/in.h>
#endif
#ifdef RUDIMENTS_HAVE_ARPA_INET_H
	#include <arpa/inet.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
inet_aton(0,NULL);,HAVE_INET_ATON="yes"; AC_DEFINE(RUDIMENTS_HAVE_INET_ATON,1,Some systems have inet_aton) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for inet_addr)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif
#ifdef RUDIMENTS_HAVE_NETINET_IN_H
	#include <netinet/in.h>
#endif
#ifdef RUDIMENTS_HAVE_ARPA_INET_H
	#include <arpa/inet.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
inet_addr(0);,AC_DEFINE(RUDIMENTS_HAVE_INET_ADDR,1,Some systems have inet_addr) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

FW_CHECK_XNET_PROTOTYPES
FW_CHECK_SOCKET_LIBS

OLDLIBS="$LIBS"
LIBS="$LIBS $SOCKETLIBS"

if ( test "$HAVE_INET_ATON" = "yes" )
then
	AC_MSG_CHECKING(whether inet_aton needs -lresolv)
	INETATONLIB=""
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SOCKET_H
	#include <sys/socket.h>
#endif
#ifdef RUDIMENTS_HAVE_NETINET_IN_H
	#include <netinet/in.h>
#endif
#ifdef RUDIMENTS_HAVE_ARPA_INET_H
	#include <arpa/inet.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
inet_aton(0,NULL);,AC_MSG_RESULT(no), INETATONLIB="-lresolv"; AC_MSG_RESULT(yes))
AC_SUBST(INETATONLIB)
fi

echo "******************************"


dnl Checks for nss functions.
echo
echo "***** Name Service Switch ****"

FW_CHECK_PWD
FW_CHECK_SHADOW
FW_CHECK_GRP
FW_CHECK_HOST
FW_CHECK_PROTO
FW_CHECK_SVC

echo "******************************"


dnl Checks for random number generators
echo
echo "** Random Number Generators **"

AC_MSG_CHECKING(for arc4random)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
arc4random();,AC_DEFINE(RUDIMENTS_HAVE_ARC4RANDOM,1,Some systems have arc4random) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for random_r)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
random_r(0,0);,AC_DEFINE(RUDIMENTS_HAVE_RANDOM_R,1,Some systems have random_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for rand_r)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
rand_r(0);,AC_DEFINE(RUDIMENTS_HAVE_RAND_R,1,Some systems have rand_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for lrand48_r)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
lrand48_r(0,0);,AC_DEFINE(RUDIMENTS_HAVE_LRAND48_R,1,Some systems have lrand48_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for random)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
random();,AC_DEFINE(RUDIMENTS_HAVE_RANDOM,1,Some systems have random) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for rand)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
rand();,AC_DEFINE(RUDIMENTS_HAVE_RAND,1,Some systems have rand) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for lrand48)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
lrand48();,AC_DEFINE(RUDIMENTS_HAVE_LRAND48,1,Some systems have lrand48) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for CryptGenRandom)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
CryptGenRandom(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_CRYPTGENRANDOM,1,Some systems have CryptGenRandom) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for semaphore functions
echo
echo "***** Semaphore Functions ****"

if ( test "$INCLUDE_SEMAPHORESET" = "1" )
then

	AC_MSG_CHECKING(for CreateSemaphore)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
	CreateSemaphore(NULL,0,0,"");,AC_DEFINE(RUDIMENTS_HAVE_CREATESEMAPHORE,1,Some systems have CreateSemaphore) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for semget)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IPC_H
	#include <sys/ipc.h>
#endif
#include <sys/sem.h>],
semget(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_SEMGET,1,Some systems have semget) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for semtimedop)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IPC_H
	#include <sys/ipc.h>
#endif
#include <sys/sem.h>],
semtimedop(0,NULL,0,NULL);,AC_DEFINE(RUDIMENTS_HAVE_SEMTIMEDOP,1,Some systems have semtimedop) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

fi

echo "******************************"


dnl Checks for shared memory functions
echo
echo "*** Shared Memory Functions **"

if ( test "$INCLUDE_SHAREDMEMORY" = "1" )
then

	AC_MSG_CHECKING(for shmget)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IPC_H
	#include <sys/ipc.h>
#endif
#include <sys/shm.h>],
shmget(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_SHMGET,1,Some systems have shmget) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

fi

echo "******************************"


dnl Checks for serial port functions
echo
echo "***** Serial Port Functions **"

if ( test "$INCLUDE_SERIALPORT" = "1" -o "$INCLUDE_SERIALPORTPROFILE" = "1" )
then

	AC_MSG_CHECKING(for tcsetattr)
	AC_TRY_COMPILE([#include <termios.h>
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
tcsetattr(0,0,NULL);,AC_DEFINE(RUDIMENTS_HAVE_TCSETATTR,1,Some systems have tcsetattr) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

fi

echo "******************************"


dnl Checks for file functions
echo
echo "***** Timer Functions ********"

FW_CHECK_NANOSLEEP
FW_CHECK_CLOCK_NANOSLEEP

AC_MSG_CHECKING(for Sleep)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
Sleep(0);,AC_DEFINE(RUDIMENTS_HAVE_WINDOWS_SLEEP,1,Some systems have Sleep) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

if ( test "$INCLUDE_INTERVALTIMER" = "1" )
then
	AC_MSG_CHECKING(for setitimer)
	AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TIME_H
	#include <sys/time.h>
#endif],
setitimer(0,NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_SETITIMER,1,Some systems have setitimer) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for struct itimerval)
	AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TIME_H
	#include <sys/time.h>
#endif],
struct itimerval a;,AC_DEFINE(RUDIMENTS_HAVE_STRUCT_ITIMERVAL,1,Some systems have struct itimerval) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

	AC_MSG_CHECKING(for struct timeval)
	AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TIME_H
	#include <sys/time.h>
#endif],
struct timeval a;,AC_DEFINE(RUDIMENTS_HAVE_STRUCT_TIMEVAL,1,Some systems have struct timeval) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))
fi

echo "******************************"


dnl Checks for crypt functions
echo
echo "***** Crypt Functions ********"

FW_CHECK_CRYPT_R

echo "******************************"


dnl Checks for memory map functions
echo
echo "***** Memory Map Functions ***"
FW_CHECK_MMAP

echo "******************************"


dnl Checks for error functions
echo
echo "***** Error Functions ********"

AC_MSG_CHECKING(for strerror)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRINGS_H
	#include <strings.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strerror(0);,AC_DEFINE(RUDIMENTS_HAVE_STRERROR,1,Some systems have strerror) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strerror_r)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRINGS_H
	#include <strings.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strerror_r(0,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_STRERROR_R,1,Some systems have strerror_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strerror_s)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRINGS_H
	#include <strings.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strerror_s(NULL,0,0);,AC_DEFINE(RUDIMENTS_HAVE_STRERROR_S,1,Some systems have strerror_s) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetLastError)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetLastError();,AC_DEFINE(RUDIMENTS_HAVE_GETLASTERROR,1,Some systems have GetLastError) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for string functions
echo
echo "***** String Functions *******"

AC_MSG_CHECKING(for strcasecmp)
AC_TRY_COMPILE([
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strcasecmp(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_STRCASECMP,1,Some systems have strcasecmp) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strncasecmp)
AC_TRY_COMPILE([
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strncasecmp(NULL,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_STRNCASECMP,1,Some systems have strncasecmp) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strtold)
AC_TRY_COMPILE([#ifndef __USE_GNU
	#define __USE_GNU
#endif
#ifndef __USE_ISOC9X
	#define __USE_ISOC9X
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strtold(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_STRTOLD,1,Some systems have strtold) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strtoll)
AC_TRY_COMPILE([#ifndef __USE_GNU
	#define __USE_GNU
#endif
#ifndef __USE_ISOC9X
	#define __USE_ISOC9X
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strtoll(NULL,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_STRTOLL,1,Some systems have strtoll) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strtoull)
AC_TRY_COMPILE([#ifndef __USE_GNU
	#define __USE_GNU
#endif
#ifndef __USE_ISOC9X
	#define __USE_ISOC9X
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strtoull(NULL,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_STRTOULL,1,Some systems have strtoull) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strspn)
AC_TRY_COMPILE([#ifndef __USE_GNU
	#define __USE_GNU
#endif
#ifndef __USE_ISOC9X
	#define __USE_ISOC9X
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strspn(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_STRSPN,1,Some systems have strspn) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strcspn)
AC_TRY_COMPILE([#ifndef __USE_GNU
	#define __USE_GNU
#endif
#ifndef __USE_ISOC9X
	#define __USE_ISOC9X
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
strcspn(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_STRCSPN,1,Some systems have strcspn) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strpbrk)
AC_TRY_COMPILE([#ifndef __USE_GNU
	#define __USE_GNU
#endif
#ifndef __USE_ISOC9X
	#define __USE_ISOC9X
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
char *a=NULL; strpbrk(a,NULL);,AC_DEFINE(RUDIMENTS_HAVE_STRPBRK,1,Some systems have strpbrk) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strchrnul)
AC_TRY_COMPILE([#ifndef __USE_GNU
	#define __USE_GNU
#endif
#ifndef __USE_ISOC9X
	#define __USE_ISOC9X
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
char *a=NULL; strchrnul(a,0);,AC_DEFINE(RUDIMENTS_HAVE_STRCHRNUL,1,Some systems have strchrnul) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

SWAB_DEFINED=""
AC_MSG_CHECKING(whether swab is defined)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
[swab(NULL,NULL,0);],[SWAB_DEFINED="yes"; AC_MSG_RESULT(yes)],[AC_DEFINE(RUDIMENTS_MUST_DEFINE_SWAB,1,Some systems have swab but dont define it) AC_MSG_RESULT(no)])

if ( test -n "$SWAB_DEFINED" )
then
	AC_MSG_CHECKING(swab const char * argument)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
const char *from; char *to; swab(from,to,0);, AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_SWAB_CONST_CHAR,1,Some systems have swab with a const char * argument), AC_MSG_RESULT(no))

	AC_MSG_CHECKING(swab char * argument)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
char *from; char *to; swab(from,to,0);, AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_SWAB_CHAR,1,Some systems have swab with a char * argument), AC_MSG_RESULT(no))

	AC_MSG_CHECKING(swab const void * argument)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
const void *from; void *to; swab(from,to,0);, AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_SWAB_CONST_VOID,1,Some systems have swab with a const void * argument), AC_MSG_RESULT(no))

	AC_MSG_CHECKING(_swab)
	AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_STRING_H
	#include <string.h>
#endif],
_swab(NULL,NULL,0);, AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE__SWAB,1,Some systems have _swab), AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for vsnprintf)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDARG_H
	#include <stdarg.h>
#endif
#include <stdio.h>],
va_list a; vsnprintf(0,0,0,a);,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_VSNPRINTF,1,Most systems have vsnprintf), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for vsnprintf_s)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDARG_H
	#include <stdarg.h>
#endif
#include <stdio.h>],
va_list a; vsnprintf_s(0,0,0,0,a);,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_VSNPRINTF_S,1,Some systems have vsnprintf_s), AC_MSG_RESULT(no))

HAVE___VSNPRINTF=""
AC_MSG_CHECKING(for __vsnprintf)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDARG_H
	#include <stdarg.h>
#endif
#include <stdio.h>],
va_list a; __vsnprintf(0,0,0,a);,[HAVE___VSNPRINTF="yes"; AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE___VSNPRINTF,1,Some systems have __vsnprintf)], AC_MSG_RESULT(no))

if ( test -z "$HAVE___VSNPRINTF" )
then
AC_MSG_CHECKING(for undefined __vsnprintf)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDARG_H
	#include <stdarg.h>
#endif
#include <stdio.h>
extern "C" int __vsnprintf(char *, size_t, const char *, va_list);],
va_list a; __vsnprintf(0,0,0,a);,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_UNDEFINED___VSNPRINTF,1,Some systems have __vsnprintf but its not defined), AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for _vsnprintf)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDARG_H
	#include <stdarg.h>
#endif
#include <stdio.h>],
va_list a; _vsnprintf(0,0,0,a);,[AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE__VSNPRINTF,1,Some systems have _vsnprintf)], AC_MSG_RESULT(no))

AC_MSG_CHECKING(for vdprintf)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDARG_H
	#include <stdarg.h>
#endif
#include <stdio.h>],
va_list a; vdprintf(0,0,a);,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_VDPRINTF,1,Some systems have vdprintf), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for vasprintf)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDARG_H
	#include <stdarg.h>
#endif
#include <stdio.h>],
va_list a; vasprintf(0,0,a);,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_VASPRINTF,1,Some systems have vasprintf), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for llabs)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
long long a; llabs(a);,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_LLABS,1,Some systems have llabs), AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for file functions
echo
echo "***** File Functions *********"

FW_CHECK_LIBCURL

AC_MSG_CHECKING(for open)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_FCNTL_H
	#include <fcntl.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
open(NULL,0,0);,AC_DEFINE(RUDIMENTS_HAVE_OPEN,1,Some systems have open) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _open)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_FCNTL_H
	#include <fcntl.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_open(NULL,0,0);,AC_DEFINE(RUDIMENTS_HAVE__OPEN,1,Some systems have _open) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for CreateFile)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
CreateFile("",0,0,0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_CREATEFILE,1,Some systems have CreateFile) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetFileType)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_ACLAPI_H
	#include <aclapi.h>
#endif
],
GetFileType(0);,AC_DEFINE(RUDIMENTS_HAVE_GETFILETYPE,1,Some systems have GetFileType) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetSecurityInfo)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_ACLAPI_H
	#include <aclapi.h>
#endif
],
GetSecurityInfo(0,SE_FILE_OBJECT,0,0,0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_GETSECURITYINFO,1,Some systems have GetSecurityInfo) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetFileInformationByHandle)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
],
GetFileInformationByHandle(0,0);,AC_DEFINE(RUDIMENTS_HAVE_GETFILEINFORMATIONBYHANDLE,1,Some systems have GetFileInformationByHandle) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for close)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
close(0);,AC_DEFINE(RUDIMENTS_HAVE_CLOSE,1,Some systems have close) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _close)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_close(0);,AC_DEFINE(RUDIMENTS_HAVE__CLOSE,1,Some systems have _close) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for read)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
read(0,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_READ,1,Some systems have read) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _read)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_read(0,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE__READ,1,Some systems have _read) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for write)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
write(0,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_WRITE,1,Some systems have write) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _write)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_write(0,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE__WRITE,1,Some systems have _write) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for unlink)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
unlink(0);,AC_DEFINE(RUDIMENTS_HAVE_UNLINK,1,Some systems have unlink) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _unlink)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_unlink(0);,AC_DEFINE(RUDIMENTS_HAVE__UNLINK,1,Some systems have _unlink) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for lseek)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
lseek(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_LSEEK,1,Some systems have lseek) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _lseek)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_lseek(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE__LSEEK,1,Some systems have _lseek) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for dup)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
dup(0);,AC_DEFINE(RUDIMENTS_HAVE_DUP,1,Some systems have dup) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _dup)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_dup(0);,AC_DEFINE(RUDIMENTS_HAVE__DUP,1,Some systems have _dup) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for dup2)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
dup2(0,0);,AC_DEFINE(RUDIMENTS_HAVE_DUP2,1,Some systems have dup2) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _dup2)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_dup2(0,0);,AC_DEFINE(RUDIMENTS_HAVE__DUP2,1,Some systems have _dup2) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fdatasync)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
fdatasync(0);,AC_DEFINE(RUDIMENTS_HAVE_FDATASYNC,1,Some systems have fdatasync) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for posix_fadvise)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_FCNTL_H
	#include <fcntl.h>
#endif],
posix_fadvise(0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_POSIX_FADVISE,1,Some systems have posix_fadvise) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for posix_fallocate)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_FCNTL_H
	#include <fcntl.h>
#endif],
posix_fallocate(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_POSIX_FALLOCATE,1,Some systems have posix_fallocate) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for pselect)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TIME_H
	#include <sys/time.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_SELECT_H
	#include <sys/select.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
pselect(0,NULL,NULL,NULL,NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_PSELECT,1,Some systems have pselect) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING([for poll])
AC_TRY_COMPILE([
#if defined(RUDIMENTS_HAVE_POLL_H)
	#include <poll.h>
#elif defined(RUDIMENTS_HAVE_SYS_POLL_H)
	#include <sys/poll.h>
#endif
],[
struct pollfd fds[1];
fds[0].fd = 0;
fds[0].events = POLLIN | POLLOUT | POLLERR | POLLHUP | POLLNVAL;

poll(fds, 1, 1000);
],
AC_DEFINE(RUDIMENTS_HAVE_POLL,1,Some systems have poll) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING([for epoll])
AC_TRY_COMPILE([
#if defined(RUDIMENTS_HAVE_SYS_EPOLL_H)
	#include <sys/epoll.h>
#endif
],[
epoll_create1(0);
epoll_ctl(0,0,0,0);
epoll_wait(0,0,0,-1);
],
AC_DEFINE(RUDIMENTS_HAVE_EPOLL,1,Some systems have epoll) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING([for kqueue])
AC_TRY_LINK([
#if defined(RUDIMENTS_HAVE_SYS_TYPES_H)
	#include <sys/types.h>
#endif
#if defined(RUDIMENTS_HAVE_SYS_EVENT_H)
	#include <sys/event.h>
#endif
#if defined(RUDIMENTS_HAVE_SYS_TIME_H)
	#include <sys/time.h>
#endif
],[
kqueue();
kevent(0,0,0,0,0,0);
],
AC_DEFINE(RUDIMENTS_HAVE_KQUEUE,1,Some systems have kqueue) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING([for void * kqueue user data])
AC_TRY_COMPILE([
#if defined(RUDIMENTS_HAVE_SYS_TYPES_H)
	#include <sys/types.h>
#endif
#if defined(RUDIMENTS_HAVE_SYS_EVENT_H)
	#include <sys/event.h>
#endif
#if defined(RUDIMENTS_HAVE_SYS_TIME_H)
	#include <sys/time.h>
#endif
],[
struct kevent kev; int a; EV_SET(&kev,0,0,0,0,0,(void *)&a);
],
AC_DEFINE(RUDIMENTS_HAVE_KQUEUE_VOID_UDATA,1,Some systems have void * kqueue user data) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING([for port_create])
AC_TRY_COMPILE([
#if defined(RUDIMENTS_HAVE_PORT_H)
	#include <port.h>
#endif
],[
port_create();
port_associate(0,0,0,0,0);
port_getn(0,0,0,0,0);
],
AC_DEFINE(RUDIMENTS_HAVE_PORT_CREATE,1,Some systems have port_create) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING([for CreateIoCompletionPort])
AC_TRY_COMPILE([
#if defined(RUDIMENTS_HAVE_WINDOWS_H)
	#include <windows.h>
#endif
],[
CreateIoCompletionPort(0,0,0,0);
],
AC_DEFINE(RUDIMENTS_HAVE_CREATE_IO_COMPLETION_PORT,1,Some systems have CreateIoCompletionPort) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ioctlsocket)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif],
ioctlsocket(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_IOCTLSOCKET,1,Some systems have ioctlsocket) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ioctl)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IOCTL_H
	#include <sys/ioctl.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
ioctl(0,0);,AC_DEFINE(RUDIMENTS_HAVE_IOCTL,1,Some systems have ioctl) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fcntl)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_FCNTL_H
	#include <fcntl.h>
#endif],
fcntl(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_FCNTL,1,Some systems have fcntl) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for LockFileEx)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
	LockFileEx(0,0,0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_LOCKFILEEX,1,Some systems have LockFileEx) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FD_CLOEXEC)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_FCNTL_H
	#include <fcntl.h>
#endif],
long a=FD_CLOEXEC;,AC_DEFINE(RUDIMENTS_HAVE_FD_CLOEXEC,1,Some systems have FD_CLOEXEC) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for HANDLE_FLAG_INHERIT)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
DWORD a=HANDLE_FLAG_INHERIT;,AC_DEFINE(RUDIMENTS_HAVE_HANDLE_FLAG_INHERIT,1,Some systems have HANDLE_FLAG_INHERIT) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for truncate)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif],
truncate("",0);,AC_DEFINE(RUDIMENTS_HAVE_TRUNCATE,1,Some systems have truncate) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ftruncate)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif],
ftruncate(0,0);,AC_DEFINE(RUDIMENTS_HAVE_FTRUNCATE,1,Some systems have ftruncate) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _chsize_s)
AC_TRY_COMPILE([
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_chsize_s(0,0);,AC_DEFINE(RUDIMENTS_HAVE__CHSIZE_S,1,Some systems have _chsize_s) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _chsize_s)
AC_TRY_COMPILE([
#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
SetEndOfFile(0);,AC_DEFINE(RUDIMENTS_HAVE_SETENDOFFILE,1,Some systems have SetEndOfFile) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for link)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
link("","");,AC_DEFINE(RUDIMENTS_HAVE_LINK,1,Some systems have link) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for symlink)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
symlink("","");,AC_DEFINE(RUDIMENTS_HAVE_SYMLINK,1,Some systems have symlink) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for readlink)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
readlink("",NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_READLINK,1,Some systems have readlink) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fchown)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
fchown(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_FCHOWN,1,Some systems have fchown) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for chmod)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
chmod("",0);,AC_DEFINE(RUDIMENTS_HAVE_CHMOD,1,Some systems have chmod) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fchmod)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
fchmod(0,0);,AC_DEFINE(RUDIMENTS_HAVE_FCHMOD,1,Some systems have fchmod) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for SetSecurityInfo)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_ACLAPI_H
	#include <aclapi.h>
#endif],
SetSecurityInfo(0,SE_FILE_OBJECT,0,0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_SETSECURITYINFO,1,Some systems have SetSecurityInfo) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for mkfifo)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif],
mkfifo("",0);,AC_DEFINE(RUDIMENTS_HAVE_MKFIFO,1,Some systems have mkfifo) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for pipe)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
pipe(0);,AC_DEFINE(RUDIMENTS_HAVE_PIPE,1,Some systems have pipe) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _pipe)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_pipe(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE__PIPE,1,Some systems have _pipe) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for CreateNamedPipe)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
	CreateNamedPipe("",0,0,0,0,0,0,NULL);,AC_DEFINE(RUDIMENTS_HAVE_CREATENAMEDPIPE,1,Some systems have CreateNamedPipe) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for pathconf)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
pathconf("",0);,AC_DEFINE(RUDIMENTS_HAVE_PATHCONF,1,Some systems have pathconf) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fpathconf)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
fpathconf(0,0);,AC_DEFINE(RUDIMENTS_HAVE_FPATHCONF,1,Some systems have fpathconf) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

dnl make sure to link this one, OSR 5.0.0 defines it in
dnl the headers but it's not defined in the library
AC_MSG_CHECKING(for mkstemp)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
mkstemp(NULL);,AC_DEFINE(RUDIMENTS_HAVE_MKSTEMP,1,Some systems have mkstemp) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fsync)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
fsync(0);,AC_DEFINE(RUDIMENTS_HAVE_FSYNC,1,Some systems have fsync) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

if ( test -n "$MINGW32" )
then
	AC_MSG_CHECKING(for _commit)
	AC_TRY_COMPILE([#include <io.h>],
	_commit(0);,AC_DEFINE(RUDIMENTS_HAVE_COMMIT,1,Some systems have _commit) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for utime)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TIME_H
	#include <sys/time.h>
#endif
#ifdef RUDIMENTS_HAVE_UTIME_H
	#include <utime.h>
#endif],
utime("",0);,AC_DEFINE(RUDIMENTS_HAVE_UTIME,1,Some systems have utime) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for utimes with const char * argument)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TIME_H
	#include <sys/time.h>
#endif
#ifdef RUDIMENTS_HAVE_UTIME_H
	#include <utime.h>
#endif],
const char *a=0; utimes(a,0);,AC_DEFINE(RUDIMENTS_HAVE_UTIMES_CONST_CHAR,1,Some systems have utimes with const char * argument) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for utimes with char * argument)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TIME_H
	#include <sys/time.h>
#endif
#ifdef RUDIMENTS_HAVE_UTIME_H
	#include <utime.h>
#endif],
char *a=0; utimes(a,0);,AC_DEFINE(RUDIMENTS_HAVE_UTIMES_CHAR,1,Some systems have utimes with char * argument) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for SetFileTime)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
	SetFileTime(0,NULL,NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_SETFILETIME,1,Some systems have SetFileTime) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for mknod)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_FCNTL_H
	#include <fcntl.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
mknod("",0,0);,AC_DEFINE(RUDIMENTS_HAVE_MKNOD,1,Some systems have mknod) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ftok)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IPC_H
	#include <sys/ipc.h>
#endif],
ftok(NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_FTOK,1,Most systems have ftok()) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if ftok takes const char * parameter)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_IPC_H
	#include <sys/ipc.h>
#endif],
const char *var=NULL; ftok(var,0);,AC_DEFINE(RUDIMENTS_HAVE_CONST_CHAR_FTOK,1,Most systems have ftok(const char *, int)) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for access)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
access(NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_ACCESS,1,Most systems have access()) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for _access_s)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
_access_s(NULL,0);,AC_DEFINE(RUDIMENTS_HAVE__ACCESS_S,1,Some systems have _access_s()) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for DuplicateHandle)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
DuplicateHandle(0,0,0,0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_DUPLICATEHANDLE,1,Some systems have DuplicateHandle) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetAce)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetAce(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_GETACE,1,Some systems have GetAce) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for SetEntriesInAcl)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_ACLAPI_H
	#include <aclapi.h>
#endif],
SetEntriesInAcl(0,0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_SETENTRIESINACL,1,Some systems have SetEntriesInAcl) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fdopen)
AC_TRY_LINK([#include <stdio.h>],
fdopen(0,"w");,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_FDOPEN,1,Some systems have fdopen), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FILE->_fileno)
AC_TRY_LINK([#include <stdio.h>],
FILE f; f._fileno=0;,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_FILE_FILENO,1,Some systems have FILE->_fileno), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FILE->_file)
AC_TRY_LINK([#include <stdio.h>],
FILE f; f._file=0;,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_FILE_FILE,1,Some systems have FILE->_file), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FILE->__file)
AC_TRY_LINK([#include <stdio.h>],
FILE f; f.__file=0;,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_FILE__FILE,1,Some systems have FILE->__file), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FILE->__filedes)
AC_TRY_LINK([#include <stdio.h>],
FILE f; f.__filedes=0;,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_FILE_FILEDES,1,Some systems have FILE->__filedes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FILE->_fd)
AC_TRY_LINK([#include <stdio.h>],
FILE f; f._fd=0;,AC_MSG_RESULT(yes) AC_DEFINE(RUDIMENTS_HAVE_FILE__FD,1,Some systems have FILE->_fd), AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for dynamic loader functions
echo
echo "***** Dynamic Loader *********"

AC_MSG_CHECKING(for dlopen)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_DLFCN_H
	#include <dlfcn.h>
#endif],
dlopen("",0);,AC_DEFINE(RUDIMENTS_HAVE_DLOPEN,1,Some systems have dlopen) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for LoadLibrary)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
LoadLibrary("");,AC_DEFINE(RUDIMENTS_HAVE_LOADLIBRARY,1,Some systems have LoadLibrary) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for LoadLibraryEx)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
LoadLibraryEx("",NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_LOADLIBRARYEX,1,Some systems have LoadLibraryEx) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

if ( test "$INCLUDE_DYNAMICLIB" = "1" )
then
	AC_MSG_CHECKING(whether we can link against -ldl)
	FW_TRY_LINK([#ifdef RUDIMENTS_HAVE_DLFCN_H
	#include <dlfcn.h>
#endif],[dlopen("",0);],[$CPPFLAGS],[-ldl],[],[DLLIB="-ldl"; AC_MSG_RESULT(yes)],[DLLIB=""; AC_MSG_RESULT(no)])
fi
AC_SUBST(DLLIB)

echo "******************************"


dnl Checks for byte swap functions
echo
echo "***** Byte Swap Functions ****"

AC_MSG_CHECKING(for htonll)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_NETINET_IN_H
	#include <netinet/in.h>
#endif
#ifdef RUDIMENTS_HAVE_INTTYPES_H
	#include <inttypes.h>
#endif],
htonll(0);,AC_DEFINE(RUDIMENTS_HAVE_HTONLL,1,Some systems have htonll) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ntohll)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_NETINET_IN_H
	#include <netinet/in.h>
#endif
#ifdef RUDIMENTS_HAVE_INTTYPES_H
	#include <inttypes.h>
#endif],
ntohll(0);,AC_DEFINE(RUDIMENTS_HAVE_NTOHLL,1,Some systems have ntohll) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for bswap_64)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_BYTESWAP_H
	#include <byteswap.h>
#endif
#ifdef RUDIMENTS_HAVE_MACHINE_ENDIAN_H
	#include <machine/endian.h>
#endif],
bswap_64(0);,AC_DEFINE(RUDIMENTS_HAVE_BSWAP_64,1,Some systems have bswap_64) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for __bswap64)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_MACHINE_ENDIAN_H
	#include <machine/endian.h>
#endif],
__bswap64(0);,AC_DEFINE(RUDIMENTS_HAVE___BSWAP64,1,Some systems have __bswap64) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for bswap64)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#include <machine/bswap.h>],
bswap64(0);,AC_DEFINE(RUDIMENTS_HAVE_BSWAP64,1,Some systems have bswap64) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for swap64)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif],
swap64(0);,AC_DEFINE(RUDIMENTS_HAVE_SWAP64,1,Some systems have swap64) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for OSSwapLittleToHostInt64)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#include <libkern/OSByteOrder.h>],
OSSwapLittleToHostInt64(0);,AC_DEFINE(RUDIMENTS_HAVE_OSSWAPLITTLETOHOSTINT64,1,Some systems have OSSwapLittleToHostInt64) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for OSSwapHostToLittleInt64)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#include <libkern/OSByteOrder.h>],
OSSwapHostToLittleInt64(0);,AC_DEFINE(RUDIMENTS_HAVE_OSSWAPHOSTTOLITTLEINT64,1,Some systems have OSSwapHostToLittleInt64) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for __swap_int64)
AC_TRY_LINK([#include <os/support/ByteOrder.h>],
__swap_int64(0);,AC_DEFINE(RUDIMENTS_HAVE_SWAP_INT64,1,Some systems have __swap_int64) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for directory functions
echo
echo "***** Directory Functions ****"

AC_MSG_CHECKING(for readdir_r)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#if defined(RUDIMENTS_HAVE_DIRENT_H)
	#include <dirent.h>
#elif defined(RUDIMENTS_HAVE_DIRECT_H)
	#include <direct.h>
#endif],
readdir_r(NULL,NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_READDIR_R,1,Some systems have readdir_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FindFirstFile)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
FindFirstFile("",0),AC_DEFINE(RUDIMENTS_HAVE_FINDFIRSTFILE,1,Some systems have FindFirstFile) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for dirfd)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#if defined(RUDIMENTS_HAVE_DIRENT_H)
	#include <dirent.h>
#elif defined(RUDIMENTS_HAVE_DIRECT_H)
	#include <direct.h>
#endif],
DIR *d; dirfd(d);,AC_DEFINE(RUDIMENTS_HAVE_DIRFD,1,Some systems have dirfd) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for DIR.dd_fd)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#if defined(RUDIMENTS_HAVE_DIRENT_H)
	#include <dirent.h>
#elif defined(RUDIMENTS_HAVE_DIRECT_H)
	#include <direct.h>
#endif],
DIR d; d.dd_fd=1;,AC_DEFINE(RUDIMENTS_HAVE_DIR_DD_FD,1,Some systems have DIR.dd_fd) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for DIR.d_fd)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#if defined(RUDIMENTS_HAVE_DIRENT_H)
	#include <dirent.h>
#elif defined(RUDIMENTS_HAVE_DIRECT_H)
	#include <direct.h>
#endif],
DIR d; d.d_fd=1;,AC_DEFINE(RUDIMENTS_HAVE_DIR_D_FD,1,Some systems have DIR.d_fd) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for mkdir with 2 arguments)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
mkdir("",0),AC_DEFINE(RUDIMENTS_HAVE_MKDIR_2,1,Some systems have mkdir) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for mkdir with 1 argument)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_IO_H
	#include <io.h>
#endif],
mkdir(""),AC_DEFINE(RUDIMENTS_HAVE_MKDIR_1,1,Some systems have mkdir) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for CreateDirectory)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
CreateDirectory("",0),AC_DEFINE(RUDIMENTS_HAVE_CREATEDIRECTORY,1,Some systems have CreateDirectory) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for RemoveDirectory)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
RemoveDirectory(""),AC_DEFINE(RUDIMENTS_HAVE_REMOVEDIRECTORY,1,Some systems have RemoveDirectory) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetCurrentDirectory)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetCurrentDirectory(0,0),AC_DEFINE(RUDIMENTS_HAVE_GETCURRENTDIRECTORY,1,Some systems have GetCurrentDirectory) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for SetCurrentDirectory)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
SetCurrentDirectory(""),AC_DEFINE(RUDIMENTS_HAVE_SETCURRENTDIRECTORY,1,Some systems have SetCurrentDirectory) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for chroot)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
chroot(""),AC_DEFINE(RUDIMENTS_HAVE_CHROOT,1,Some systems have chroot) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for process functions
echo
echo "***** Process Functions ******"

AC_MSG_CHECKING(for umask)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_STAT_H
	#include <sys/stat.h>
#endif],
umask(0),AC_DEFINE(RUDIMENTS_HAVE_UMASK,1,Some systems have umask) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getpid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getpid(),AC_DEFINE(RUDIMENTS_HAVE_GETPID,1,Some systems have getpid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetCurrentProcessId)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#ifdef RUDIMENTS_HAVE_PROCESS_H
	#include <process.h>
#endif],
GetCurrentProcessId(),AC_DEFINE(RUDIMENTS_HAVE_GETCURRENTPROCESSID,1,Some systems have GetCurrentProcessId) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getppid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getppid(),AC_DEFINE(RUDIMENTS_HAVE_GETPPID,1,Some systems have getppid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for Process32First)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif
#include <tlhelp32.h>],
Process32First(0,NULL),AC_DEFINE(RUDIMENTS_HAVE_PROCESS32FIRST,1,Some systems have Process32First) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

HAVE_GETPGID=""
AC_MSG_CHECKING(for getpgid)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getpgid(0),AC_DEFINE(RUDIMENTS_HAVE_GETPGID,1,Some systems have getpgid) AC_MSG_RESULT(yes); HAVE_GETPGID="yes",AC_MSG_RESULT(no))

dnl some linux libc4 systems define getpgid properly in -lg but not in -lc
GETPGIDLIB=""
if ( test "$HAVE_GETPGID" = "yes" )
then
SAVECXXFLAGS="$CXXFLAGS"
dnl Remove the -g arguments.  If included at link time, they'll pull in -lg.
CXXFLAGS=`echo $CXXFLAGS | sed -e "s|-g1||" -e "s|-g2||" -e "s|-g3||" -e "s|-g||"`
AC_MSG_CHECKING(whether getpgid needs -lg)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getpgid(0),AC_MSG_RESULT(no),AC_MSG_RESULT(yes); GETPGIDLIB="-lg")
CXXFLAGS="$SAVECXXFLAGS"
fi
AC_SUBST(GETPGIDLIB)

AC_MSG_CHECKING(for setpgid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
setpgid(0,0),AC_DEFINE(RUDIMENTS_HAVE_SETPGID,1,Some systems have setpgid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getsid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getsid(0),AC_DEFINE(RUDIMENTS_HAVE_GETSID,1,Some systems have getsid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getuid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getuid(),AC_DEFINE(RUDIMENTS_HAVE_GETUID,1,Some systems have getuid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetUserName)
AC_TRY_COMPILE([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetUserName(0,0);,AC_DEFINE(RUDIMENTS_HAVE_GETUSERNAME,1,Some systems have GetUserName) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for geteuid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
geteuid(),AC_DEFINE(RUDIMENTS_HAVE_GETEUID,1,Some systems have geteuid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for setuid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
setuid(0),AC_DEFINE(RUDIMENTS_HAVE_SETUID,1,Some systems have setuid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for setgroups)
AC_TRY_LINK([
#ifdef RUDIMENTS_HAVE_SYS_PARAMS_H
	#include <sys/param.h>
#endif
#if defined(RUDIMENTS_HAVE_SYS_TYPES_H)
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_GRP_H
	#include <grp.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
],
setgroups(0,0),AC_DEFINE(RUDIMENTS_HAVE_SETGROUPS,1,Some systems have setgroups) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

SETEUID=""
AC_MSG_CHECKING(for seteuid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
seteuid(0),AC_DEFINE(RUDIMENTS_HAVE_SETEUID,1,Some systems have seteuid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no); SETEUID="no")

if ( test -n "$SETEUID" )
then
	AC_MSG_CHECKING(for seteuid (not defined in any header))
	AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
extern "C" int seteuid(uid_t euid);
],
seteuid(0),AC_DEFINE(RUDIMENTS_HAVE_SETEUID_BUT_NOT_DEFINED,1,Some systems have seteuid but dont define it in a header file) AC_DEFINE(RUDIMENTS_HAVE_SETEUID,1,Some systems have seteuid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for setreuid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
setreuid(0,0),AC_DEFINE(RUDIMENTS_HAVE_SETREUID,1,Some systems have setreuid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getgid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getgid(),AC_DEFINE(RUDIMENTS_HAVE_GETGID,1,Some systems have getgid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getegid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getegid(),AC_DEFINE(RUDIMENTS_HAVE_GETEGID,1,Some systems have getegid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for setgid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
setgid(0),AC_DEFINE(RUDIMENTS_HAVE_SETGID,1,Some systems have setgid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

SETEGID=""
AC_MSG_CHECKING(for setegid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
setegid(0),AC_DEFINE(RUDIMENTS_HAVE_SETEGID,1,Some systems have setegid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no); SETEGID="no")

if ( test -n "$SETEGID" )
then
	AC_MSG_CHECKING(for setegid (not defined in any header))
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
extern "C" int setegid(gid_t egid);
],
setegid(0),AC_DEFINE(RUDIMENTS_HAVE_SETEGID_BUT_NOT_DEFINED,1,Some systems have setegid but dont define it in a header file) AC_DEFINE(RUDIMENTS_HAVE_SETEGID,1,Some systems have setegid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for setregid)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
setregid(0,0),AC_DEFINE(RUDIMENTS_HAVE_SETREGID,1,Some systems have setregid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for fork)
AC_TRY_LINK([
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
fork(),AC_DEFINE(RUDIMENTS_HAVE_FORK,1,Some systems have fork) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for execvp)
AC_TRY_LINK([
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
execvp(NULL,NULL),AC_DEFINE(RUDIMENTS_HAVE_EXECVP,1,Some systems have execvp) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for CreateProcess)
AC_TRY_LINK([
#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
CreateProcess(0,0,0,0,0,0,0,0,0,0),AC_DEFINE(RUDIMENTS_HAVE_CREATE_PROCESS,1,Some systems have CreateProcess) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FreeConsole)
AC_TRY_LINK([
#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
FreeConsole(),AC_DEFINE(RUDIMENTS_HAVE_FREECONSOLE,1,Some systems have FreeConsole) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for setsid)
AC_TRY_LINK([
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
setsid(),AC_DEFINE(RUDIMENTS_HAVE_SETSID,1,Some systems have setsid) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for atexit)
AC_TRY_LINK([
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
atexit(0),AC_DEFINE(RUDIMENTS_HAVE_ATEXIT,1,Some systems have atexit) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

echo "******************************"


dnl Checks for system functions
echo
echo "***** System Functions *******"

AC_MSG_CHECKING(for getpagesize)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
getpagesize(),AC_DEFINE(RUDIMENTS_HAVE_GETPAGESIZE,1,Some systems have getpagesize) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetSystemInfo)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetSystemInfo(NULL),AC_DEFINE(RUDIMENTS_HAVE_GETSYSTEMINFO,1,Some systems have GetSystemInfo) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GlobalMemoryStatusEx)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GlobalMemoryStatusEx(NULL),AC_DEFINE(RUDIMENTS_HAVE_GLOBALMEMORYSTATUSEX,1,Some systems have GlobalMemoryStatusEx) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetLogicalProcessorInformation)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetLogicalProcessorInformation(0,0),AC_DEFINE(RUDIMENTS_HAVE_GETLOGICALPROCESSORINFORMATION,1,Some systems have GetLogicalProcessorInformation) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for uname)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_UTSNAME_H
	#include <sys/utsname.h>
#endif],
uname(0),AC_DEFINE(RUDIMENTS_HAVE_UNAME,1,Some systems have uname) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetVersionEx)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetVersionEx(0),AC_DEFINE(RUDIMENTS_HAVE_GETVERSIONEX,1,Some systems have GetVersionEx) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for GetNativeSystemInfo)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
GetNativeSystemInfo(0),AC_DEFINE(RUDIMENTS_HAVE_GETNATIVESYSTEMINFO,1,Some systems have GetNativeSystemInfo) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for getloadavg)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_LOADAVG_H
	#include <sys/loadavg.h>
#endif
#ifdef RUDIMENTS_HAVE_STDLIB_H
	#include <stdlib.h>
#endif],
getloadavg(0,0),AC_DEFINE(RUDIMENTS_HAVE_GETLOADAVG,1,Some systems have getloadavg) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for gethostname)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif],
gethostname(0,0),AC_DEFINE(RUDIMENTS_HAVE_GETHOSTNAME,1,Some systems have gethostname) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

HAVE_SETHOSTNAME="no"
AC_MSG_CHECKING(for sethostname)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_WINSOCK2_H
	#include <winsock2.h>
#endif],
sethostname(0,0),HAVE_SETHOSTNAME="yes"; AC_DEFINE(RUDIMENTS_HAVE_SETHOSTNAME,1,Some systems have sethostname) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

if ( test "$HAVE_SETHOSTNAME" = "no" )
then
	AC_MSG_CHECKING(for missing sethostname declaration)
	AC_TRY_LINK([extern "C" { extern int sethostname(char *name, int namelen); }],
sethostname(0,0),AC_DEFINE(RUDIMENTS_HAVE_MISSING_SETHOSTNAME_DECLARATION,1,Some systems have sethostname but forgot to declare it) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for sync)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
sync(),AC_DEFINE(RUDIMENTS_HAVE_SYNC,1,Some systems have sync) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for FlushFileBuffers)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
FlushFileBuffers(0),AC_DEFINE(RUDIMENTS_HAVE_FLUSHFILEBUFFERS,1,Some systems have FlushFileBuffers) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for sysconf)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif],
sysconf(0),AC_DEFINE(RUDIMENTS_HAVE_SYSCONF,1,Some systems have sysconf) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for reboot with 1 argument)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_REBOOT_H
	#include <sys/reboot.h>
#endif],
reboot(0),AC_DEFINE(RUDIMENTS_HAVE_REBOOT_1,1,Some systems have reboot with 1 argument) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for reboot with 2 arguments)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_UNISTD_H
	#include <unistd.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_REBOOT_H
	#include <sys/reboot.h>
#endif],
reboot(0,0),AC_DEFINE(RUDIMENTS_HAVE_REBOOT_2,1,Some systems have reboot with 2 argument) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for uadmin with char * argument)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_PROTOTYPES_H
	#include <prototypes.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_UADMIN_H
	#include <sys/uadmin.h>
#endif],
uadmin(0,0,""),AC_DEFINE(RUDIMENTS_HAVE_UADMIN_CHAR,1,Some systems have uadmin with a char * argument) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for uadmin with integer)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_SYS_TYPES_H
	#include <sys/types.h>
#endif
#ifdef RUDIMENTS_HAVE_PROTOTYPES_H
	#include <prototypes.h>
#endif
#ifdef RUDIMENTS_HAVE_SYS_UADMIN_H
	#include <sys/uadmin.h>
#endif],
uadmin(0,0,0),AC_DEFINE(RUDIMENTS_HAVE_UADMIN_INT,1,Some systems have uadmin with a integer argument) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for BRoster::_ShutDown)
FW_TRY_LINK([#ifdef RUDIMENTS_HAVE_ROSTER_H
	#include <Roster.h>
#endif

class BRoster::Private {
	public:
		Private(BRoster *r) : roster(r) {};
		status_t ShutDown(bool reboot, bool confirm, bool sync) {
			return roster->_ShutDown(reboot,confirm,sync);
		};
	private:
		BRoster	*roster;
};
],
[BRoster r; BRoster::Private rp(&r); rp.ShutDown(0,0,0);],[$CPPFLAGS],[$BELIB],[],[AC_DEFINE(RUDIMENTS_HAVE_BROSTER__SHUTDOWN,1,Some systems have BRoster::_ShutDown) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for InitiateSystemShutdownEx)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
InitiateSystemShutdownEx("","",0,0,0,0),AC_DEFINE(RUDIMENTS_HAVE_INITIATESYSTEMSHUTDOWNEX,1,Some systems have InitiateSystemShutdownEx) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ExitWindowsEx)
AC_TRY_LINK([#ifdef RUDIMENTS_HAVE_WINDOWS_H
	#include <windows.h>
#endif],
ExitWindowsEx(0,0),AC_DEFINE(RUDIMENTS_HAVE_EXITWINDOWSEX,1,Some systems have ExitWindowsEx) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

echo "******************************"


dnl Semantic Versioning
dnl Given a version number MAJOR.MINOR.PATCH, increment the:
dnl 1. MAJOR when you make backwards-incompatible API changes
dnl    (and set MINOR and PATCH to 0)
dnl 2. MINOR when you add backwards-compatible features
dnl    (and set PATCH to 0)
dnl 3. PATCH when you make backwards-compatible fixes
RUDIMENTS_VERSION="0.55.0"
AC_SUBST(RUDIMENTS_VERSION)
AC_DEFINE_UNQUOTED(RUDIMENTS_VERSION,"$RUDIMENTS_VERSION",Version)

dnl Libtool Versioning
dnl For CURRENT:REVISION:AGE version info, apply the following rules in order:
dnl if library source changed at all,         c:r:a -> c:r+1:a
dnl if interfaces added, removed, or changed, c:r:a -> c+1:0:a
dnl if interfaces added,                      c:r:a -> c:r:a+1
dnl if interfaces removed,                    c:r:a -> c:r:0
SONAME_VERSION_INFO="2:0:0"
AC_SUBST(SONAME_VERSION_INFO)


AC_PREFIX_DEFAULT(/usr/local/firstworks)

dnl perform substitutions for disable options
HEADERS0="resultcodes.h debugprint.h"
HEADERS1="linkedlist.h singlylinkedlist.h"
HEADERS2="dictionary.h"
HEADERS3="dynamicarray.h staticarray.h"
PRIVATEHEADERS0="config.h debugprint.h"
PRIVATEHEADERS1="rudimentsinlines.h inttypes.h new.h"
PRIVATEHEADERS2="winsock.h dll.h"
PRIVATEHEADERS3="linkedlist.h linkedlistincludes.h linkedlistinlines.h linkedlistnode.h linkedlistutilinlines.h"
PRIVATEHEADERS4="singlylinkedlist.h singlylinkedlistincludes.h singlylinkedlistinlines.h singlylinkedlistnode.h"
PRIVATEHEADERS5="dictionary.h dictionaryincludes.h dictionaryinlines.h dictionarynode.h"
PRIVATEHEADERS6="dynamicarray.h dynamicarrayincludes.h dynamicarrayinlines.h"
PRIVATEHEADERS7="staticarray.h staticarrayinlines.h"
SRCS="winsock.cpp"
LOBJS="winsock.lo"
EXTRACPPFLAGS=""

if ( test "$INCLUDE_CHARACTER" = "1" )
then
	HEADERS1="$HEADERS1 character.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 characterincludes.h"
	SRCS="$SRCS character.cpp"
	LOBJS="$LOBJS character.lo"
fi

if ( test "$INCLUDE_CHARSTRING" = "1" )
then
	HEADERS1="$HEADERS1 charstring.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 charstring.h charstringincludes.h"
	SRCS="$SRCS charstring.cpp"
	LOBJS="$LOBJS charstring.lo"
fi

if ( test "$INCLUDE_CHAT" = "1" )
then
	HEADERS1="$HEADERS1 chat.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 chat.h chatincludes.h"
	SRCS="$SRCS chat.cpp"
	LOBJS="$LOBJS chat.lo"
fi

if ( test "$INCLUDE_CLIENT" = "1" )
then
	HEADERS1="$HEADERS1 client.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 client.h clientincludes.h"
	SRCS="$SRCS client.cpp"
	LOBJS="$LOBJS client.lo"
fi

if ( test "$INCLUDE_COMMANDLINE" = "1" )
then
	HEADERS1="$HEADERS1 commandline.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 commandline.h commandlineincludes.h"
	SRCS="$SRCS commandline.cpp"
	LOBJS="$LOBJS commandline.lo"
fi

if ( test "$INCLUDE_CRYPT" = "1" )
then
	HEADERS1="$HEADERS1 crypt.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 cryptincludes.h"
	SRCS="$SRCS crypt.cpp"
	LOBJS="$LOBJS crypt.lo"
fi

if ( test "$INCLUDE_DATETIME" = "1" )
then
	HEADERS1="$HEADERS1 datetime.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 datetime.h datetimeincludes.h"
	SRCS="$SRCS datetime.cpp"
	LOBJS="$LOBJS datetime.lo"
fi

if ( test "$INCLUDE_DEVICE" = "1" )
then
	HEADERS1="$HEADERS1 device.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 device.h deviceincludes.h"
	SRCS="$SRCS device.cpp"
	LOBJS="$LOBJS device.lo"
fi

if ( test "$INCLUDE_DIRECTORY" = "1" )
then
	HEADERS1="$HEADERS1 directory.h"
	PRIVATEHEADERS1="$PRIVATEHEADERS1 directory.h directoryincludes.h"
	SRCS="$SRCS directory.cpp"
	LOBJS="$LOBJS directory.lo"
fi

if ( test "$INCLUDE_DYNAMICLIB" = "1" )
then
	HEADERS1="$HEADERS1 dynamiclib.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 dynamiclib.h dynamiclibincludes.h"
	SRCS="$SRCS dynamiclib.cpp"
	LOBJS="$LOBJS dynamiclib.lo"
fi

if ( test "$INCLUDE_ENVIRONMENT" = "1" )
then
	HEADERS1="$HEADERS1 environment.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 environment.h environmentincludes.h"
	SRCS="$SRCS environment.cpp"
	LOBJS="$LOBJS environment.lo"
fi

if ( test "$INCLUDE_ERROR" = "1" )
then
	HEADERS1="$HEADERS1 error.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 errorincludes.h"
	SRCS="$SRCS error.cpp"
	LOBJS="$LOBJS error.lo"
fi

if ( test "$INCLUDE_FILE" = "1" )
then
	HEADERS1="$HEADERS1 file.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 file.h fileincludes.h"
	SRCS="$SRCS file.cpp"
	LOBJS="$LOBJS file.lo"
fi

if ( test "$INCLUDE_URL" = "1" )
then
	HEADERS1="$HEADERS1 url.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 url.h urlincludes.h"
	SRCS="$SRCS url.cpp"
	LOBJS="$LOBJS url.lo"
fi

if ( test "$INCLUDE_FILEDESCRIPTOR" = "1" )
then
	HEADERS1="$HEADERS1 filedescriptor.h stdio.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 filedescriptor.h filedescriptorincludes.h stdio.h"
	SRCS="$SRCS filedescriptor.cpp stdio.cpp"
	LOBJS="$LOBJS filedescriptor.lo stdio.lo"

	#include security too
	HEADERS3="$HEADERS3 security.h"

	# include GSS too
	HEADERS3="$HEADERS3 gss.h"
	PRIVATEHEADERS7="$PRIVATEHEADERS7 gss.h gssmechanism.h gsscredentials.h gsscontext.h gssincludes.h"
	SRCS="$SRCS gss.cpp"
	LOBJS="$LOBJS gss.lo"

	# include TLS too
	HEADERS3="$HEADERS3 tls.h"
	PRIVATEHEADERS7="$PRIVATEHEADERS7 tls.h tlscontext.h tlscertificate.h tlsincludes.h"
	SRCS="$SRCS tls.cpp"
	LOBJS="$LOBJS tls.lo"
fi

if ( test "$INCLUDE_FILESYSTEM" = "1" )
then
	HEADERS1="$HEADERS1 filesystem.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 filesystem.h filesystemincludes.h"
	SRCS="$SRCS filesystem.cpp"
	LOBJS="$LOBJS filesystem.lo"
fi

if ( test "$INCLUDE_GROUPENTRY" = "1" )
then
	HEADERS1="$HEADERS1 groupentry.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 groupentry.h groupentryincludes.h"
	SRCS="$SRCS groupentry.cpp"
	LOBJS="$LOBJS groupentry.lo"
fi

if ( test "$INCLUDE_HOSTENTRY" = "1" )
then
	HEADERS1="$HEADERS1 hostentry.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 hostentry.h hostentryincludes.h"
	SRCS="$SRCS hostentry.cpp"
	LOBJS="$LOBJS hostentry.lo"
fi

if ( test "$INCLUDE_INETCLIENT" = "1" )
then
	HEADERS1="$HEADERS1 inetsocketclient.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 inetsocketclient.h inetsocketclientincludes.h"
	SRCS="$SRCS inetsocketclient.cpp"
	LOBJS="$LOBJS inetsocketclient.lo"
	EXTRACPPFLAGS="$EXTRACPPFLAGS -DINCLUDE_INETCLIENT"
fi

if ( test "$INCLUDE_INETSERVER" = "1" )
then
	HEADERS1="$HEADERS1 inetsocketserver.h"
	PRIVATEHEADERS2="$PRIVATEHEADERS2 inetsocketserver.h inetsocketserverincludes.h"
	SRCS="$SRCS inetsocketserver.cpp"
	LOBJS="$LOBJS inetsocketserver.lo"
	EXTRACPPFLAGS="$EXTRACPPFLAGS -DINCLUDE_INETSERVER"
fi

if ( test "$INCLUDE_LISTENER" = "1" )
then
	HEADERS1="$HEADERS1 listener.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 listener.h listenerincludes.h"
	SRCS="$SRCS listener.cpp"
	LOBJS="$LOBJS listener.lo"
fi

if ( test "$INCLUDE_LOGGER" = "1" )
then
	HEADERS1="$HEADERS1 logger.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 filedestination.h logdestination.h logger.h stderrdestination.h stdoutdestination.h syslogdestination.h loggerincludes.h"
	SRCS="$SRCS logger.cpp"
	LOBJS="$LOBJS logger.lo"
fi

if ( test "$INCLUDE_MATH" = "1" )
then
	HEADERS1="$HEADERS1 math.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 mathincludes.h mathinlines.h"
	SRCS="$SRCS math.cpp"
	LOBJS="$LOBJS math.lo"
fi

if ( test "$INCLUDE_MEMORYMAP" = "1" )
then
	HEADERS1="$HEADERS1 memorymap.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 memorymap.h memorymapincludes.h"
	SRCS="$SRCS memorymap.cpp"
	LOBJS="$LOBJS memorymap.lo"
fi

if ( test "$INCLUDE_MEMORYPOOL" = "1" )
then
	HEADERS1="$HEADERS1 memorypool.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 memorypool.h memorypoolincludes.h"
	SRCS="$SRCS memorypool.cpp"
	LOBJS="$LOBJS memorypool.lo"
fi

if ( test "$INCLUDE_MODEMCLIENT" = "1" )
then
	HEADERS1="$HEADERS1 modemclient.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 modemclient.h modemclientincludes.h"
	SRCS="$SRCS modemclient.cpp"
	LOBJS="$LOBJS modemclient.lo"
	EXTRACPPFLAGS="$EXTRACPPFLAGS -DINCLUDE_MODEMCLIENT"
fi

if ( test "$INCLUDE_MODEMSERVER" = "1" )
then
	HEADERS1="$HEADERS1 modemserver.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 modemserver.h modemserverincludes.h"
	SRCS="$SRCS modemserver.cpp"
	LOBJS="$LOBJS modemserver.lo"
	EXTRACPPFLAGS="$EXTRACPPFLAGS -DINCLUDE_MODEMSERVER"
fi

if ( test "$INCLUDE_THREAD" = "1" )
then
	HEADERS1="$HEADERS1 thread.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 thread.h threadincludes.h"
	SRCS="$SRCS thread.cpp"
	LOBJS="$LOBJS thread.lo"
fi

if ( test "$INCLUDE_THREADMUTEX" = "1" )
then
	HEADERS1="$HEADERS1 threadmutex.h"
	PRIVATEHEADERS3="$PRIVATEHEADERS3 threadmutex.h threadmutexincludes.h"
	SRCS="$SRCS threadmutex.cpp"
	LOBJS="$LOBJS threadmutex.lo"
fi

if ( test "$INCLUDE_PARAMETERSTRING" = "1" )
then
	HEADERS2="$HEADERS2 parameterstring.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 parameterstring.h parameterstringincludes.h"
	SRCS="$SRCS parameterstring.cpp"
	LOBJS="$LOBJS parameterstring.lo"
fi

if ( test "$INCLUDE_USERENTRY" = "1" )
then
	HEADERS2="$HEADERS2 userentry.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 userentry.h userentryincludes.h"
	SRCS="$SRCS userentry.cpp"
	LOBJS="$LOBJS userentry.lo"
fi

if ( test "$INCLUDE_PERMISSIONS" = "1" )
then
	HEADERS2="$HEADERS2 permissions.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 permissions.h permissionsincludes.h"
	SRCS="$SRCS permissions.cpp"
	LOBJS="$LOBJS permissions.lo"
fi

if ( test "$INCLUDE_PROCESS" = "1" )
then
	HEADERS2="$HEADERS2 process.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 process.h processincludes.h"
	SRCS="$SRCS process.cpp"
	LOBJS="$LOBJS process.lo"
fi

if ( test "$INCLUDE_PROTOCOLENTRY" = "1" )
then
	HEADERS2="$HEADERS2 protocolentry.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 protocolentry.h protocolentryincludes.h"
	SRCS="$SRCS protocolentry.cpp"
	LOBJS="$LOBJS protocolentry.lo"
fi

if ( test "$INCLUDE_RANDOMNUMBER" = "1" )
then
	HEADERS2="$HEADERS2 randomnumber.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 randomnumber.h randomnumberincludes.h"
	SRCS="$SRCS randomnumber.cpp"
	LOBJS="$LOBJS randomnumber.lo"
fi

if ( test "$INCLUDE_BYTESTRING" = "1" )
then
	HEADERS2="$HEADERS2 bytestring.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 bytestringincludes.h"
	SRCS="$SRCS bytestring.cpp"
	LOBJS="$LOBJS bytestring.lo"
fi

if ( test "$INCLUDE_REGULAREXPRESSION" = "1" )
then
	HEADERS2="$HEADERS2 regularexpression.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 regularexpression.h regularexpressionincludes.h"
	SRCS="$SRCS regularexpression.cpp"
	LOBJS="$LOBJS regularexpression.lo"
fi

if ( test "$USE_BUILT_IN_REGULAREXPRESSION" = "1" )
then
	SRCS="$SRCS regex.cpp"
	LOBJS="$LOBJS regex.lo"
fi

if ( test "$INCLUDE_SEMAPHORESET" = "1" )
then
	HEADERS2="$HEADERS2 semaphoreset.h"
	PRIVATEHEADERS4="$PRIVATEHEADERS4 semaphoreset.h semaphoresetincludes.h"
	SRCS="$SRCS semaphoreset.cpp"
	LOBJS="$LOBJS semaphoreset.lo"
fi

if ( test "$INCLUDE_SERIALPORT" = "1" )
then
	HEADERS2="$HEADERS2 serialport.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 serialport.h serialportincludes.h"
	SRCS="$SRCS serialport.cpp"
	LOBJS="$LOBJS serialport.lo"
fi

if ( test "$INCLUDE_SERIALPORTPROFILE" = "1" )
then
	HEADERS2="$HEADERS2 serialportprofile.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 serialportprofile.h serialportprofileincludes.h"
	SRCS="$SRCS serialportprofile.cpp"
	LOBJS="$LOBJS serialportprofile.lo"
fi

if ( test "$INCLUDE_SERVER" = "1" )
then
	HEADERS2="$HEADERS2 server.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 server.h serverincludes.h"
	SRCS="$SRCS server.cpp"
	LOBJS="$LOBJS server.lo"
fi

if ( test "$INCLUDE_SERVICEENTRY" = "1" )
then
	HEADERS2="$HEADERS2 serviceentry.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 serviceentry.h serviceentryincludes.h"
	SRCS="$SRCS serviceentry.cpp"
	LOBJS="$LOBJS serviceentry.lo"
fi

if ( test "$INCLUDE_SHAREDMEMORY" = "1" )
then
	HEADERS2="$HEADERS2 sharedmemory.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 sharedmemory.h sharedmemoryincludes.h"
	SRCS="$SRCS sharedmemory.cpp"
	LOBJS="$LOBJS sharedmemory.lo"
fi

if ( test "$INCLUDE_SIGNALCLASSES" = "1" )
then
	HEADERS2="$HEADERS2 signalclasses.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 signalhandler.h signalset.h signalclassesincludes.h"
	SRCS="$SRCS signalclasses.cpp"
	LOBJS="$LOBJS signalclasses.lo"
fi

if ( test "$INCLUDE_SNOOZE" = "1" )
then
	HEADERS2="$HEADERS2 snooze.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 snooze.h snoozeincludes.h"
	SRCS="$SRCS snooze.cpp"
	LOBJS="$LOBJS snooze.lo"
fi

if ( test "$INCLUDE_STRINGBUFFER" = "1" )
then
	HEADERS2="$HEADERS2 stringbuffer.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 stringbuffer.h stringbufferincludes.h"
	SRCS="$SRCS stringbuffer.cpp"
	LOBJS="$LOBJS stringbuffer.lo"
fi

if ( test "$INCLUDE_SYSTEM" = "1" )
then
	HEADERS2="$HEADERS2 sys.h"
	PRIVATEHEADERS5="$PRIVATEHEADERS5 sysincludes.h"
	SRCS="$SRCS sys.cpp"
	LOBJS="$LOBJS sys.lo"
fi

if ( test "$INCLUDE_UNIXCLIENT" = "1" )
then
	HEADERS3="$HEADERS3 unixsocketclient.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 unixsocketclient.h unixsocketclientincludes.h"
	SRCS="$SRCS unixsocketclient.cpp"
	LOBJS="$LOBJS unixsocketclient.lo"
	EXTRACPPFLAGS="$EXTRACPPFLAGS -DINCLUDE_UNIXCLIENT"
fi

if ( test "$INCLUDE_UNIXSERVER" = "1" )
then
	HEADERS3="$HEADERS3 unixsocketserver.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 unixsocketserver.h unixsocketserverincludes.h"
	SRCS="$SRCS unixsocketserver.cpp"
	LOBJS="$LOBJS unixsocketserver.lo"
	EXTRACPPFLAGS="$EXTRACPPFLAGS -DINCLUDE_UNIXSERVER"
fi

if ( test "$INCLUDE_BYTEBUFFER" = "1" )
then
	HEADERS3="$HEADERS3 bytebuffer.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 bytebuffer.h bytebufferincludes.h"
	SRCS="$SRCS bytebuffer.cpp"
	LOBJS="$LOBJS bytebuffer.lo"
fi

if ( test "$INCLUDE_XMLDOM" = "1" )
then
	HEADERS3="$HEADERS3 xmldom.h xmldomnode.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 xmldom.h xmldomincludes.h xmldomnode.h xmldomnodeincludes.h"
	SRCS="$SRCS xmldom.cpp xmldomnode.cpp"
	LOBJS="$LOBJS xmldom.lo xmldomnode.lo"
fi

if ( test "$INCLUDE_XMLSAX" = "1" )
then
	HEADERS3="$HEADERS3 xmlsax.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 xmlsax.h xmlsaxincludes.h"
	SRCS="$SRCS xmlsax.cpp"
	LOBJS="$LOBJS xmlsax.lo"
fi

if ( test "$INCLUDE_XMLDOMEVENTS" = "1" )
then
	HEADERS3="$HEADERS3 xmldomevents.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 xmldomevents.h xmldomeventsincludes.h"
	SRCS="$SRCS xmldomevents.cpp"
	LOBJS="$LOBJS xmldomevents.lo"
fi

if ( test "$INCLUDE_CODETREE" = "1" )
then
	HEADERS3="$HEADERS3 codetree.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 codetree.h codetreeincludes.h codetreegrammar.h"
	SRCS="$SRCS codetree.cpp"
	LOBJS="$LOBJS codetree.lo"
fi

if ( test "$INCLUDE_COMPILER" = "1" )
then
	HEADERS3="$HEADERS3 compiler.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 compiler.h compilerincludes.h"
	SRCS="$SRCS compiler.cpp"
	LOBJS="$LOBJS compiler.lo"
fi

if ( test "$INCLUDE_INETSERVER" = "1" -o "$INCLUDE_INETCLIENT" = "1" )
then
	HEADERS3="$HEADERS3 inetsocketutil.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 inetsocketutil.h inetsocketutilincludes.h"
	SRCS="$SRCS inetsocketutil.cpp"
	LOBJS="$LOBJS inetsocketutil.lo"
fi

if ( test "$INCLUDE_UNIXSERVER" = "1" -o "$INCLUDE_UNIXCLIENT" = "1" )
then
	HEADERS3="$HEADERS3 unixsocketutil.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 unixsocketutil.h unixsocketutilincludes.h"
	SRCS="$SRCS unixsocketutil.cpp"
	LOBJS="$LOBJS unixsocketutil.lo"
fi

if ( test "$INCLUDE_INETSERVER" = "1" -o "$INCLUDE_UNIXSERVER" = "1" )
then
	HEADERS3="$HEADERS3 socketserver.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 socketserver.h socketserverincludes.h"
	SRCS="$SRCS socketserver.cpp"
	LOBJS="$LOBJS socketserver.lo"
fi

if ( test "$INCLUDE_INETCLIENT" = "1" -o "$INCLUDE_UNIXCLIENT" = "1" )
then
	HEADERS3="$HEADERS3 socketclient.h"
	PRIVATEHEADERS6="$PRIVATEHEADERS6 socketclient.h socketclientincludes.h"
	SRCS="$SRCS socketclient.cpp"
	LOBJS="$LOBJS socketclient.lo"
fi

if ( test "$INCLUDE_MODEMCLIENT" = "1" -o  "$INCLUDE_MODEMSERVER" = "1" )
then
	PRIVATEHEADERS6="$PRIVATEHEADERS6 modemutil.h"
	SRCS="$SRCS modemutil.cpp"
	LOBJS="$LOBJS modemutil.lo"
fi


AC_SUBST(HEADERS0)
AC_SUBST(HEADERS1)
AC_SUBST(HEADERS2)
AC_SUBST(HEADERS3)
AC_SUBST(PRIVATEHEADERS0)
AC_SUBST(PRIVATEHEADERS1)
AC_SUBST(PRIVATEHEADERS2)
AC_SUBST(PRIVATEHEADERS3)
AC_SUBST(PRIVATEHEADERS4)
AC_SUBST(PRIVATEHEADERS5)
AC_SUBST(PRIVATEHEADERS6)
AC_SUBST(PRIVATEHEADERS7)
AC_SUBST(SRCS)
AC_SUBST(LOBJS)
AC_SUBST(EXTRACPPFLAGS)


# prepend DESTDIR where appropriate
if ( test "`echo $ac_default_prefix | cut -c1`" = "/" )
then
	ac_default_prefix='${DESTDIR}'"$ac_default_prefix"
fi
if ( test "`echo $prefix | cut -c1`" = "/" )
then
	prefix='${DESTDIR}'"$prefix"
fi
if ( test "`echo $exec_prefix | cut -c1`" = "/" )
then
	exec_prefix='${DESTDIR}'"$exec_prefix"
fi
if ( test "`echo $includedir | cut -c1`" = "/" )
then
	includedir='${DESTDIR}'"$includedir"
fi
if ( test "`echo $libdir | cut -c1`" = "/" )
then
	libdir='${DESTDIR}'"$libdir"
fi
if ( test "`echo $libexecdir | cut -c1`" = "/" )
then
	libexecdir='${DESTDIR}'"$libexecdir"
fi
if ( test "`echo $bindir | cut -c1`" = "/" )
then
	bindir='${DESTDIR}'"$bindir"
fi
if ( test "`echo $localstatedir | cut -c1`" = "/" )
then
	localstatedir='${DESTDIR}'"$localstatedir"
fi
if ( test "`echo $sysconfdir | cut -c1`" = "/" )
then
	sysconfdir='${DESTDIR}'"$sysconfdir"
fi
if ( test "`echo $mandir | cut -c1`" = "/" )
then
	mandir='${DESTDIR}'"$mandir"
fi
if ( test "`echo $datadir | cut -c1`" = "/" )
then
	datadir='${DESTDIR}'"$datadir"
fi


dnl Output files.
echo
echo "***** Output Files ***********"
AC_CONFIG_HEADER(include/rudiments/private/config.h)
AC_CONFIG_SRCDIR(test/xmls.cpp)
AC_CONFIG_FILES(config.mk src/Makefile include/Makefile bin/rudiments-config rudiments.pc)
AC_OUTPUT
chmod 755 bin/rudiments-config
echo "******************************"
echo


dnl Summary.
echo
echo "***** Summary ****************"

echo " Version      : $RUDIMENTS_VERSION"

PCREBUILD="no "
if ( test -n "$HAVE_PCRE" )
then
	PCREBUILD="yes"
fi

LIBCURLBUILD="no "
if ( test -n "$HAVE_LIBCURL" )
then
	LIBCURLBUILD="yes"
fi

SSLBUILD="no "
if ( test -n "$SSLLIBS" )
then
	SSLBUILD="yes"
fi

GSSBUILD="no "
if ( test -n "$HAVE_GSS" )
then
	GSSBUILD="yes"
fi

echo " Features     : Threads $HAS_THREADS"
echo "                PCRE    $PCREBUILD"
echo "                libcurl $LIBCURLBUILD"
echo "                TLS/SSL $SSLBUILD"
echo "                GSS     $GSSBUILD"
echo "******************************"
echo
echo "If you expected a feature that doesn't show up in the Summary"
echo "then the configure script probably couldn't find a package it needed to"
echo "build it.  You can manually specify package locations using command line"
echo "options."
echo
echo "Type:  configure --help   for a list of options."
echo
