dnl Process this file with autoconf to produce a configure script.
dnl
AC_INIT(SWrite.c)
AC_PREREQ(2.13)
AC_CONFIG_HEADER(config.h)
wi_ARG_ENABLE_DEBUG
wi_ARG_DISABLE_PRECOMP
wi_ARG_WITH_SOCKS5
want_unix_domain_sockets=yes
AC_ARG_ENABLE([unix-sockets],[  --enable-unix-sockets   enable support for UNIX domain sockets],[want_unix_domain_sockets="$enableval"],[want_unix_domain_sockets=yes])
wi_ARG_DISABLE_MACOSX_UNIVERSAL



dnl ---------------------------------------------------------------------------
dnl Environment and compiler settings.
dnl ---------------------------------------------------------------------------
dnl
wi_ENV_VAR_MESSAGES
wi_OS_VAR
AC_PROG_CC
wi_CC_PRECOMP
wi_CFLAGS
wi_CFLAGS_REENTRANT
wi_MACOSX_UNIVERSAL_CFLAGS
wi_SFLAG
AC_OBJEXT
AC_EXEEXT



dnl ---------------------------------------------------------------------------
dnl Checks for header files.
dnl ---------------------------------------------------------------------------
dnl
AC_HEADER_STDC
dnl strings.h for AIX FD_ZERO which uses bzero
AC_CHECK_HEADERS(arpa/nameser.h net/errno.h nserve.h resolv.h strings.h sys/socket.h sys/time.h time.h unistd.h)
AC_TIME_WITH_SYS_TIME

wi_UNIX_DOMAIN_SOCKETS
SIO_OBJS_U=''
SIO_SOBJS_U=''
if test "$wi_cv_unix_domain_sockets" = yes ; then
	SIO_OBJS_U='$(OBJS_U) '
	SIO_SOBJS_U='$(SOBJS_U) '
fi
AC_SUBST(SIO_OBJS_U)
AC_SUBST(SIO_SOBJS_U)



dnl ---------------------------------------------------------------------------
dnl Checks for libraries.
dnl Needed to build the samples.
dnl ---------------------------------------------------------------------------
dnl
wi_NET_LIBS
wi_LIB_SOCKS5



dnl ---------------------------------------------------------------------------
dnl Checks for typedefs, structures, and compiler characteristics.
dnl ---------------------------------------------------------------------------
dnl
AC_C_CONST
AC_TYPE_SIZE_T
wi__RES_DEFDNAME
wi_STRUCT_TIMEVAL_FIELD_TYPES
wi_VOID_MAIN_RETURN_TYPE
wi_CHECK_TYPE(negative_control_t, long, [])
wi_CHECK_TYPE(ssize_t, long, [])
wi_CHECK_TYPE(sa_family_t, unsigned short, [#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
])
wi_UNISTD_FUNC_PARAM_TYPES
wi_HEADER_SYS_SELECT_H
wi_FUNC_SELECT_ARGTYPES
wi_TYPE_SIG_ATOMIC_T
wi_STRUCT_CMSGHDR
wi_MSGHDR_CONTROL
wi_MSGHDR_ACCRIGHTS



dnl ---------------------------------------------------------------------------
dnl Checks for library functions.
dnl ---------------------------------------------------------------------------
dnl
AC_CHECK_FUNCS(gethostbyaddr_r gethostbyname_r gethostname getdomainname getservbyname_r getservbyport_r inet_ntop recvmsg sigaction sigsetjmp strerror)
wi_SNPRINTF
AC_FUNC_ALLOCA	dnl Only needed for Linux
wi_FUNC_SIGSETJMP



dnl ---------------------------------------------------------------------------
dnl Checks for system characteristics.
dnl ---------------------------------------------------------------------------
dnl
AC_PROG_MAKE_SET
wi_PROG_TAR
wi_CREATE_TAR_FILES
wi_PROG_RANLIB
wi_PROG_AR
wi_PROG_CCDV
CPPFLAGS="-I. $CPPFLAGS"
wi_BEAUTIFY_ENVIRONMENT_VARIABLES



dnl ---------------------------------------------------------------------------
dnl Extra steps to work with precompiled headers.
dnl ---------------------------------------------------------------------------
dnl
SIO_PRECOMP="pch.mk.none"
if test "${wi_cv_cc_precomp}_${wi_cv_cc_precomp_type}" = "yes_gcc_gch_files" ; then
	SIO_PRECOMP="pch.mk.gcc-gch"
elif test "${wi_cv_cc_precomp}_${SYS}" = "yes_macosx" ; then
	SIO_PRECOMP="pch.mk.$SYS"
fi
AC_SUBST_FILE(SIO_PRECOMP)



dnl ---------------------------------------------------------------------------
dnl Version lookups for Makefile variables.
dnl ---------------------------------------------------------------------------
dnl
changequote(<<, >>)dnl
SIO_VERSION=`sed -n '/kSioVersion/{
	s/^[^0-9]*//
	s/\ .*$//
	p
	q
}' sio.h`
changequote([, ])dnl



dnl ---------------------------------------------------------------------------
dnl Create Makefiles and config.h files.
dnl ---------------------------------------------------------------------------
dnl
wi_SUMMARIZE_COMPILER_FLAGS
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
AC_SUBST(DEFS)
AC_SUBST(SFLAG)
AC_SUBST(SIO_VERSION)
AC_SUBST(DEBUGBUILD)
AC_SUBST(MAKE)
AC_OUTPUT([Makefile ucase_c/Makefile ucase_s/Makefile time_c/Makefile time_s/Makefile srltest/Makefile sendmessage/Makefile])
