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


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],
	CXXFLAGS="$CXXFLAGS -g",
	CXXFLAGS="$CXXFLAGS")
AC_ARG_ENABLE(profiling,
	[  --enable-profiling      compile with -pg option],
	CXXFLAGS="$CXXFLAGS -pg",
	CXXFLAGS="$CXXFLAGS")
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(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(threads,
	[  --disable-threads       Disable thread support],
	ENABLE_RUDIMENTS_THREADS="no",
	ENABLE_RUDIMENTS_THREADS="yes")

dnl   options to disable building various classes
AC_ARG_ENABLE(charstring,
	[  --disable-charstring    Don't build charstring class],
	INCLUDE_CHARSTRING="0",
	INCLUDE_CHARSTRING="1")
AC_ARG_ENABLE(character,
	[  --disable-character     Don't build character class],
	INCLUDE_CHARACTER="0",
	INCLUDE_CHARACTER="1")
AC_ARG_ENABLE(intervaltimer,
	[  --disable-intervaltimer Don't build intervaltimer class],
	INCLUDE_INTERVALTIMER="0",
	INCLUDE_INTERVALTIMER="1")
AC_ARG_ENABLE(snooze,
	[  --disable-snooze        Don't build snooze class],
	INCLUDE_SNOOZE="0",
	INCLUDE_SNOOZE="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(rawbuffer,
	[  --disable-rawbuffer     Don't build rawbuffer class],
	INCLUDE_RAWBUFFER="0",
	INCLUDE_RAWBUFFER="1")
AC_ARG_ENABLE(memorymap,
	[  --disable-memorymap     Don't build memorymap class],
	INCLUDE_MEMORYMAP="0",
	INCLUDE_MEMORYMAP="1")
AC_ARG_ENABLE(mutex,
	[  --disable-mutex         Don't build mutex class],
	INCLUDE_MUTEX="0",
	INCLUDE_MUTEX="1")
AC_ARG_ENABLE(serialport,
	[  --disable-serialport    Don't build serialport class],
	INCLUDE_SERIALPORT="0",
	INCLUDE_SERIALPORT="1")
AC_ARG_ENABLE(serialportprofile,
	[  --disable-serialportprofile    Don't build serialportprofile class],
	INCLUDE_SERIALPORTPROFILE="0",
	INCLUDE_SERIALPORTPROFILE="1")
AC_ARG_ENABLE(parameterstring,
	[  --disable-parameterstring      Don't build parameterstring class],
	INCLUDE_PARAMETERSTRING="0",
	INCLUDE_PARAMETERSTRING="1")
AC_ARG_ENABLE(environment,
	[  --disable-environment   Don't build environment class],
	INCLUDE_ENVIRONMENT="0",
	INCLUDE_ENVIRONMENT="1")
AC_ARG_ENABLE(commandline,
	[  --disable-commandline   Don't build commandline class],
	INCLUDE_COMMANDLINE="0",
	INCLUDE_COMMANDLINE="1")
AC_ARG_ENABLE(datetime,
	[  --disable-datetime      Don't build datetime class],
	INCLUDE_DATETIME="0",
	INCLUDE_DATETIME="1")
AC_ARG_ENABLE(timezonefile,
	[  --disable-timezonefile  Don't build timezonefile class],
	INCLUDE_TIMEZONEFILE="0",
	INCLUDE_TIMEZONEFILE="1")
AC_ARG_ENABLE(groupentry,
	[  --disable-groupentry    Don't build groupentry class],
	INCLUDE_GROUPENTRY="0",
	INCLUDE_GROUPENTRY="1")
AC_ARG_ENABLE(passwdentry,
	[  --disable-passwdentry   Don't build passwdentry class],
	INCLUDE_PASSWDENTRY="0",
	INCLUDE_PASSWDENTRY="1")
AC_ARG_ENABLE(serviceentry,
	[  --disable-serviceentry  Don't build serviceentry class],
	INCLUDE_SERVICEENTRY="0",
	INCLUDE_SERVICEENTRY="1")
AC_ARG_ENABLE(shadowentry,
	[  --disable-shadowentry   Don't build shadowentry class],
	INCLUDE_SHADOWENTRY="0",
	INCLUDE_SHADOWENTRY="1")
AC_ARG_ENABLE(rpcentry,
	[  --disable-rpcentry      Don't build rpcentry class],
	INCLUDE_RPCENTRY="0",
	INCLUDE_RPCENTRY="1")
AC_ARG_ENABLE(protocolentry,
	[  --disable-protocolentry Don't build protocolentry class],
	INCLUDE_PROTOCOLENTRY="0",
	INCLUDE_PROTOCOLENTRY="1")
AC_ARG_ENABLE(hostentry,
	[  --disable-hostentry     Don't build hostentry class],
	INCLUDE_HOSTENTRY="0",
	INCLUDE_HOSTENTRY="1")
AC_ARG_ENABLE(dynamiclib,
	[  --disable-dynamiclib    Don't build dynamiclib class],
	INCLUDE_DYNAMICLIB="0",
	INCLUDE_DYNAMICLIB="1")
AC_ARG_ENABLE(crypt,
	[  --disable-crypt         Don't build crypt class],
	INCLUDE_CRYPT="0",
	INCLUDE_CRYPT="1")
AC_ARG_ENABLE(variablebuffer,
	[  --disable-variablebuffer       Don't build variablebuffer class],
	INCLUDE_VARIABLEBUFFER="0",
	INCLUDE_VARIABLEBUFFER="1")
AC_ARG_ENABLE(stringbuffer,
	[  --disable-stringbuffer  Don't build stringbuffer class],
	INCLUDE_STRINGBUFFER="0",
	INCLUDE_STRINGBUFFER="1")
AC_ARG_ENABLE(xmlsax,
	[  --disable-xmlsax        Don't build xmlsax class],
	INCLUDE_XMLSAX="0",
	INCLUDE_XMLSAX="1")
AC_ARG_ENABLE(xmldom,
	[  --disable-xmldom        Don't build xmldom class],
	INCLUDE_XMLDOM="0",
	INCLUDE_XMLDOM="1")
AC_ARG_ENABLE(dtd,
	[  --disable-dtd           Don't build dtd class],
	INCLUDE_DTD="0",
	INCLUDE_DTD="1")
AC_ARG_ENABLE(filesystem,
	[  --disable-filesystem    Don't build filesystem class],
	INCLUDE_FILESYSTEM="0",
	INCLUDE_FILESYSTEM="1")
AC_ARG_ENABLE(directory,
	[  --disable-directory     Don't build directory class],
	INCLUDE_DIRECTORY="0",
	INCLUDE_DIRECTORY="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(shmfile,
	[  --disable-shmfile       Don't build shmfile class],
	INCLUDE_SHMFILE="0",
	INCLUDE_SHMFILE="1")
AC_ARG_ENABLE(device,
	[  --disable-device        Don't build device class],
	INCLUDE_DEVICE="0",
	INCLUDE_DEVICE="1")
AC_ARG_ENABLE(client,
	[  --disable-client        Don't build client class],
	INCLUDE_CLIENT="0",
	INCLUDE_CLIENT="1")
AC_ARG_ENABLE(inetclient,
	[  --disable-inetclient    Don't build inetclient class],
	INCLUDE_INETCLIENT="0",
	INCLUDE_INETCLIENT="1")
AC_ARG_ENABLE(unixclient,
	[  --disable-unixclient    Don't build unixclient class],
	INCLUDE_UNIXCLIENT="0",
	INCLUDE_UNIXCLIENT="1")
AC_ARG_ENABLE(modemclient,
	[  --disable-modemclient   Don't build modemclient class],
	INCLUDE_MODEMCLIENT="0",
	INCLUDE_MODEMCLIENT="1")
AC_ARG_ENABLE(modemserver,
	[  --disable-modemserver   Don't build modemserver class],
	INCLUDE_MODEMSERVER="0",
	INCLUDE_MODEMSERVER="1")
AC_ARG_ENABLE(server,
	[  --disable-server        Don't build server class],
	INCLUDE_SERVER="0",
	INCLUDE_SERVER="1")
AC_ARG_ENABLE(inetserver,
	[  --disable-inetserver    Don't build inetserver class],
	INCLUDE_INETSERVER="0",
	INCLUDE_INETSERVER="1")
AC_ARG_ENABLE(unixserver,
	[  --disable-unixserver    Don't build unixserver class],
	INCLUDE_UNIXSERVER="0",
	INCLUDE_UNIXSERVER="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(memorypool,
	[  --disable-memorypool    Don't build memorypool class],
	INCLUDE_MEMORYPOOL="0",
	INCLUDE_MEMORYPOOL="1")
AC_ARG_ENABLE(signalclasses,
	[  --disable-signalclasses Don't build signalclasses],
	INCLUDE_SIGNALCLASSES="0",
	INCLUDE_SIGNALCLASSES="1")
AC_ARG_ENABLE(daemonprocess,
	[  --disable-daemonprocess Don't build daemonprocess],
	INCLUDE_DAEMONPROCESS="0",
	INCLUDE_DAEMONPROCESS="1")
AC_ARG_ENABLE(process,
	[  --disable-process       Don't build process],
	INCLUDE_PROCESS="0",
	INCLUDE_PROCESS="1")
AC_ARG_ENABLE(semaphoreset,
	[  --disable-semaphoreset  Don't build semaphoreset],
	INCLUDE_SEMAPHORESET="0",
	INCLUDE_SEMAPHORESET="1")
AC_ARG_ENABLE(sharedmemory,
	[  --disable-sharedmemory  Don't build sharedmemory],
	INCLUDE_SHAREDMEMORY="0",
	INCLUDE_SHAREDMEMORY="1")
AC_ARG_ENABLE(permissions,
	[  --disable-permissions   Don't build permissions],
	INCLUDE_PERMISSIONS="0",
	INCLUDE_PERMISSIONS="1")
AC_ARG_ENABLE(regularexpression,
	[  --disable-regularexpression    Don't build regularexpression],
	INCLUDE_REGULAREXPRESSION="0",
	INCLUDE_REGULAREXPRESSION="1")
AC_ARG_ENABLE(randomnumber,
	[  --disable-randomnumber  Don't build randomnumber],
	INCLUDE_RANDOMNUMBER="0",
	INCLUDE_RANDOMNUMBER="1")
AC_ARG_ENABLE(chat,
	[  --disable-chat          Don't build chat],
	INCLUDE_CHAT="0",
	INCLUDE_CHAT="1")
AC_ARG_ENABLE(error,
	[  --disable-error         Don't build error],
	INCLUDE_ERROR="0",
	INCLUDE_ERROR="1")


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

AC_SUBST(CPPFLAGS)
AC_SUBST(CXXFLAGS)

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


dnl check for hacks here
FW_CHECK_HACKS


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 "******************************"


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_MICROSOFT
FW_CHECK_OSX
FW_CHECK_SO_EXT
FW_CHECK_LIBDIR

FW_CHECK_PIPE
FW_CHECK_WALL
FW_CHECK_PTHREAD_COMPILE
echo "******************************"


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

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 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))

if ( test -n "$MINGW32" )
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 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))
fi

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([#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([#include <sys/types.h>
#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([#include <sys/types.h>
#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([#include <sys/types.h>
#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([#include <sys/types.h>
#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 sys/uio.h)
AC_TRY_COMPILE([#include <sys/types.h>
#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([#include <sys/types.h>
#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 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))
echo "******************************"


dnl Checks for thread library.
echo
echo "***** threads ****************"
FW_CHECK_PTHREAD
FW_CHECK_MUTEX
echo "******************************"


dnl Checks for ssl library.
echo
echo "***** ssl ********************"
FW_CHECK_SSL
echo "******************************"


dnl Checks for pcre library.
echo
echo "***** pcre *******************"
FW_CHECK_PCRE
echo "******************************"


dnl Checks for typedefs, structures, and compiler characteristics.
echo
echo "***** Structures *************"
AC_C_CONST
AC_TYPE_UID_T
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T

AC_CHECK_TYPE([off64_t],[],[AC_DEFINE(off64_t,off_t,Some systems don't have off64_t)])
AC_CHECK_TYPE([nlink_t],[],[AC_DEFINE(nlink_t,short,Some systems don't have nlink_t)])
AC_CHECK_TYPE([key_t],[],[AC_DEFINE(key_t,int,Some systems don't have key_t)])

FW_CXX_NAMESPACES

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 don't 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([#include <sys/types.h>
#include <sys/socket.h>],
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([#include <sys/types.h>
#include <sys/socket.h>],
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(if struct stat contains st_blksize)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>],
struct stat st;
blksize_t s=st.st_blksize;,AC_DEFINE(RUDIMENTS_HAVE_BLKSIZE_T,1,Some systems don't 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([#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>],
struct stat st;
blkcnt_t b=st.st_blocks;,AC_DEFINE(RUDIMENTS_HAVE_BLKCNT_T,1,Some systems don't have st_blocks in struct stat) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(if S_ISSOCK exists)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>],
S_ISSOCK(0);,AC_DEFINE(RUDIMENTS_HAVE_S_ISSOCK,1,Some systems don't have S_ISSOCK) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(type of iovec.iov_base)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>
#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 *))

AC_MSG_CHECKING(CMSG_SPACE)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
CMSG_SPACE(0);,AC_DEFINE(RUDIMENTS_HAVE_CMSG_SPACE,1,Some systems have CMSG_SPACE) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(CMSG_LEN)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
CMSG_LEN(0);,AC_DEFINE(RUDIMENTS_HAVE_CMSG_LEN,1,Some systems have CMSG_LEN) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

FW_STATFS

AC_MSG_CHECKING(for struct timespec)
AC_TRY_COMPILE([#include <sys/time.h>],
struct timespec a;,AC_DEFINE(RUDIMENTS_HAVE_STRUCT_TIMESPEC,1,Some systems have struct timespec) 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))
echo "******************************"


dnl Checks associated with signal handlers
echo
echo "***** Signal Handlers ********"
AC_TYPE_SIGNAL
AC_MSG_CHECKING(signal handler parameter)
AC_TRY_COMPILE([#include <signal.h>],
void (*handler)(int); struct sigaction test; test.sa_handler=handler;,AC_DEFINE(RUDIMENTS_SIGNAL_HANDLER_INT,1,Most systems define signal handlers with an integer parameter) AC_MSG_RESULT(int),AC_MSG_RESULT(void))
echo "******************************"


dnl Checks associated with time structure
echo
echo "***** Time Structure *********"

if ( test -n "$MINGW32" )
then
	AC_MSG_CHECKING(GetSystemTime)
	AC_TRY_COMPILE([#include <windows.h>
#include <stdlib.h>],
GetSystemTime(NULL);,AC_DEFINE(RUDIMENTS_HAVE_GETSYSTEMTIME,1,Some systems have GetSystemTime) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
fi

AC_MSG_CHECKING(for tm_zone)
AC_EGREP_CPP(tm_zone,[#include <time.h>],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_EGREP_CPP(tm_gmtoff,[#include <time.h>],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_EGREP_CPP(__tm_zone,[#include <time.h>],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_EGREP_CPP(__tm_gmtoff,[#include <time.h>],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 use _timezone instead of 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 support)
AC_TRY_COMPILE([#include <linux/rtc.h>
#include <sys/ioctl.h>],
ioctl(0,RTC_RD_TIME,0);,AC_DEFINE(RUDIMENTS_HAVE_RTC,1,Do we have a real-time-clock) AC_MSG_RESULT(yes),AC_MSG_RESULT(no))

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

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

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


dnl Checks for library functions.
echo
echo "***** Functions **************"
dnl AC_FUNC_MMAP

AC_MSG_CHECKING(for setenv)
AC_TRY_COMPILE([#include <stdlib.h>],
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([#include <stdlib.h>],
putenv(NULL);,AC_DEFINE(RUDIMENTS_HAVE_PUTENV,1,Some systems have putenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

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

if ( test -z "$HAVE_PCRE" )
then
	HAVE_REGCOMP=""
	AC_MSG_CHECKING(for regcomp)
	AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/types.h>
#include <regex.h>],
regcomp(NULL,NULL,0);,HAVE_REGCOMP="yes"; AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
fi

INCLUDE_REGULAREXPRESSION="0"
if ( test -n "$HAVE_PCRE" -o -n "$HAVE_REGCOMP" )
then
	INCLUDE_REGULAREXPRESSION="1"
fi
AC_SUBST(INCLUDE_REGULAREXPRESSION)

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

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

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

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

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

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

AC_MSG_CHECKING(for rand_r)
AC_TRY_COMPILE([#include <stdlib.h>],
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 setuid)
AC_TRY_COMPILE([#include <sys/types.h>
#include <unistd.h>],
setuid(0);,AC_DEFINE(RUDIMENTS_HAVE_SETUID,1,Some systems have setuid) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

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

FW_CHECK_XNET_PROTOTYPES
FW_CHECK_SOCKET_LIBS

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

FW_CHECK_PWD
FW_CHECK_SHADOW
FW_CHECK_GRP
FW_CHECK_HOST
FW_CHECK_PROTO
FW_CHECK_SVC

AC_MSG_CHECKING(for semtimedop)
AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>
#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))

AC_MSG_CHECKING(for xattr)
AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/xattr.h>],
setxattr(NULL,NULL,NULL,0,0);,AC_DEFINE(RUDIMENTS_HAVE_XATTRS,1,Some systems have extended filesystem attributes) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for readdir_r)
AC_TRY_COMPILE([#include <stdlib.h>
#include <dirent.h>],
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 fdatasync)
AC_TRY_COMPILE([#include <stdlib.h>
#include <unistd.h>],
fdatasync(0);,AC_DEFINE(RUDIMENTS_HAVE_FDATASYNC,1,Some systems have fdatasync) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

FW_CHECK_NANOSLEEP
FW_CHECK_CLOCK_NANOSLEEP

FW_CHECK_SHM_OPEN

FW_CHECK_RPC

AC_MSG_CHECKING(for pselect)
AC_TRY_COMPILE([#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/select.h>
#include <stdlib.h>],
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 posix_fadvise)
AC_TRY_COMPILE([#include <fcntl.h>],
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([#include <fcntl.h>],
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))

FW_CHECK_CRYPT_R
FW_CHECK_MMAP

AC_MSG_CHECKING(for strlcat)
AC_TRY_COMPILE([
#include <stdlib.h>
#include <string.h>],
strlcat(NULL,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_STRLCAT,1,Some systems have strlcat) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for strlcpy)
AC_TRY_COMPILE([
#include <stdlib.h>
#include <string.h>],
strlcpy(NULL,NULL,0);,AC_DEFINE(RUDIMENTS_HAVE_STRLCPY,1,Some systems have strlcpy) 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
#include <stdlib.h>
#include <string.h>],
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
#include <stdlib.h>
#include <string.h>],
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
#include <stdlib.h>
#include <string.h>],
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
#include <stdlib.h>
#include <string.h>],
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
#include <stdlib.h>
#include <string.h>],
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
#include <stdlib.h>
#include <string.h>],
strpbrk(NULL,NULL);,AC_DEFINE(RUDIMENTS_HAVE_STRPBRK,1,Some systems have strpbrk) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

SWAB_DEFINED=""
AC_MSG_CHECKING(whether swab is defined in unistd.h)
AC_TRY_COMPILE([#include <stdlib.h>
#include <unistd.h>
#include <string.h>],
[swab(NULL,NULL,0);],[SWAB_DEFINED="yes"; AC_MSG_RESULT(yes)],[AC_DEFINE(RUDIMENTS_MUST_DEFINE_SWAB,1,Some systems have swab but don't define it) AC_MSG_RESULT(no)])

if ( test -n "$SWAB_DEFINED" )
then
	AC_MSG_CHECKING(swab arguments)
	AC_TRY_COMPILE([#include <stdlib.h>
#include <unistd.h>
#include <string.h>],
void *from; void *to; swab(from,to,0);, AC_MSG_RESULT(void *), AC_DEFINE(RUDIMENTS_HAVE_SWAB_CHAR,1,Some systems have swab with a char * argument) AC_MSG_RESULT(char *))
fi

AC_MSG_CHECKING(for _NSGetEnviron)
AC_TRY_COMPILE([#include <stdlib.h>
#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([#include <stdlib.h>
#include <unistd.h>],
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([#include <stdlib.h>],
clearenv();,AC_DEFINE(RUDIMENTS_HAVE_CLEARENV,1,Some systems have clearenv) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))

AC_MSG_CHECKING(for ioctl)
AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/ioctl.h>],
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>
#else
#include <unistd.h>
#endif
#include <fcntl.h>],
fcntl(0,0,0);,AC_DEFINE(RUDIMENTS_HAVE_FCNTL,1,Some systems have fcntl) 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([#include <stdlib.h>
#include <dlfcn.h>],[dlopen(NULL,0);],[$CPPFLAGS],[-ldl],[],[DLLIB="-ldl"; AC_MSG_RESULT(yes)],[DLLIB=""; AC_MSG_RESULT(no)])
fi
AC_SUBST(DLLIB)

AC_MSG_CHECKING(for ftok)
AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>],
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([#include <stdlib.h>
#include <sys/types.h>
#include <sys/ipc.h>],
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(whether inet_aton needs -lresolv)
AC_TRY_LINK([#include <stdlib.h>
#include <arpa/inet.h>],
inet_aton(NULL,NULL);,AC_SUBST(INETATONLIB,) AC_MSG_RESULT(no), AC_SUBST(INETATONLIB,-lresolv) AC_MSG_RESULT(yes))

AC_MSG_CHECKING(for bswap_64)
AC_TRY_LINK([#include <stdlib.h>
#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([#include <stdlib.h>
#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([#include <stdlib.h>
#include <sys/types.h>
#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([#include <stdlib.h>
#include <sys/types.h>],
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([#include <stdlib.h>
#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([#include <stdlib.h>
#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 dirfd)
AC_TRY_LINK([#include <sys/types.h>
#ifdef RUDIMENTS_HAVE_DIRENT_H
#include <dirent.h>
#else
#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([#include <sys/types.h>
#ifdef RUDIMENTS_HAVE_DIRENT_H
#include <dirent.h>
#else
#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([#include <sys/types.h>
#ifdef RUDIMENTS_HAVE_DIRENT_H
#include <dirent.h>
#else
#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))

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



dnl Default build variables.
RUDIMENTS_VERSION="0.31"
AC_SUBST(RUDIMENTS_VERSION)
AC_DEFINE_UNQUOTED(RUDIMENTS_VERSION,"$RUDIMENTS_VERSION",Version)
dnl rules for CURRENT:REVISION:AGE version info:
dnl 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="1:0:0"
AC_SUBST(SONAME_VERSION_INFO)
AC_PREFIX_DEFAULT(/usr/local/firstworks)



dnl   perform substitutions for disable options
AC_SUBST(INCLUDE_CHARSTRING)
AC_SUBST(INCLUDE_CHARACTER)
AC_SUBST(INCLUDE_INTERVALTIMER)
AC_SUBST(INCLUDE_SNOOZE)
AC_SUBST(INCLUDE_MATH)
AC_SUBST(INCLUDE_RAWBUFFER)
AC_SUBST(INCLUDE_MEMORYMAP)
AC_SUBST(INCLUDE_MUTEX)
AC_SUBST(INCLUDE_SERIALPORT)
AC_SUBST(INCLUDE_SERIALPORTPROFILE)
AC_SUBST(INCLUDE_PARAMETERSTRING)
AC_SUBST(INCLUDE_ENVIRONMENT)
AC_SUBST(INCLUDE_COMMANDLINE)
AC_SUBST(INCLUDE_DATETIME)
AC_SUBST(INCLUDE_TIMEZONEFILE)
AC_SUBST(INCLUDE_GROUPENTRY)
AC_SUBST(INCLUDE_PASSWDENTRY)
AC_SUBST(INCLUDE_SERVICEENTRY)
AC_SUBST(INCLUDE_SHADOWENTRY)
AC_SUBST(INCLUDE_RPCENTRY)
AC_SUBST(INCLUDE_PROTOCOLENTRY)
AC_SUBST(INCLUDE_HOSTENTRY)
AC_SUBST(INCLUDE_DYNAMICLIB)
AC_SUBST(INCLUDE_CRYPT)
AC_SUBST(INCLUDE_VARIABLEBUFFER)
AC_SUBST(INCLUDE_STRINGBUFFER)
AC_SUBST(INCLUDE_XMLSAX)
AC_SUBST(INCLUDE_XMLDOM)
AC_SUBST(INCLUDE_DTD)
AC_SUBST(INCLUDE_FILESYSTEM)
AC_SUBST(INCLUDE_DIRECTORY)
AC_SUBST(INCLUDE_FILEDESCRIPTOR)
AC_SUBST(INCLUDE_FILE)
AC_SUBST(INCLUDE_SHMFILE)
AC_SUBST(INCLUDE_DEVICE)
AC_SUBST(INCLUDE_DATATRANSPORT)
AC_SUBST(INCLUDE_CLIENT)
AC_SUBST(INCLUDE_INETCLIENT)
AC_SUBST(INCLUDE_UNIXCLIENT)
AC_SUBST(INCLUDE_MODEMCLIENT)
AC_SUBST(INCLUDE_MODEMSERVER)
AC_SUBST(INCLUDE_SERVER)
AC_SUBST(INCLUDE_INETSERVER)
AC_SUBST(INCLUDE_UNIXSERVER)
AC_SUBST(INCLUDE_LISTENER)
AC_SUBST(INCLUDE_LOGGER)
AC_SUBST(INCLUDE_MEMORYPOOL)
AC_SUBST(INCLUDE_SIGNALCLASSES)
AC_SUBST(INCLUDE_DAEMONPROCESS)
AC_SUBST(INCLUDE_PROCESS)
AC_SUBST(INCLUDE_SEMAPHORESET)
AC_SUBST(INCLUDE_SHAREDMEMORY)
AC_SUBST(INCLUDE_PERMISSIONS)
AC_SUBST(INCLUDE_REGULAREXPRESSION)
AC_SUBST(INCLUDE_RANDOMNUMBER)
AC_SUBST(INCLUDE_CONTAINER)
AC_SUBST(INCLUDE_CHAT)
AC_SUBST(INCLUDE_ERROR)
#AC_SUBST(INCLUDE_DICTIONARY)
#AC_SUBST(INCLUDE_LIST)


# 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.C)
AC_CONFIG_FILES(config.mk bin/rudiments-config features.mk rudiments.pc)
AC_OUTPUT
chmod 755 bin/rudiments-config
echo "******************************"
echo
