dnl Set the default prefix
AC_PREFIX_DEFAULT([$HOME])
+AC_MSG_CHECKING([for installation prefix])
AC_CACHE_VAL(unet_cv_prefix, [unet_cv_prefix=$HOME])
if test x"$prefix" != xNONE; then
unet_cv_prefix=$prefix
fi
+AC_MSG_RESULT([$unet_cv_prefix])
dnl HACK WARNING: We are referencing an autoconf internal variable. This is
dnl the only way to force the prefix to be retrieved from the config.cache
dnl file!
dnl Define the input and output configuration header file.
AC_CONFIG_HEADER([config.h])
-dnl Demand at least version 2.13 of autoconf
-AC_PREREQ(2.13)
+dnl Demand at least version 2.59 of autoconf (for AS_HELP_STRING)
+AC_PREREQ(2.59)
dnl Find out what type of system we are
AC_CANONICAL_HOST
dnl ANSIfy the C compiler whenever possible.
AM_PROG_CC_STDC
-dnl Use -O3 instead of -O2.
-if test x"$CFLAGS" != x; then
- CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2/-O3/'`
+dnl Allow specification of optimization level.
+AC_ARG_WITH([optimization],
+ AS_HELP_STRING([--with-optimization=[-O2]], [Explicitly set the compiler optimization flags (default: -O3)]),
+ [unet_cv_optimization=$withval],
+ [unet_cv_optimization='-O3'])
+AC_CACHE_CHECK([optimization level], [unet_cv_optimization], [unet_cv_optimization='-O3'])
+if test "x$unet_cv_optimization" = "xno" ; then
+ unet_cv_optimization=""
fi
-dnl Remove -pipe during configure
if test x"$CFLAGS" != x; then
- CFLAGS=`echo "$CFLAGS" | sed -e 's/-pipe//g'`
+ CFLAGS=`echo "$CFLAGS" | sed -e s/-O2/$unet_cv_optimization/`
fi
dnl Notice the -g flag and deal accordingly
if test x"$CFLAGS" != x; then
dnl Do all the checks necessary to figure out -lnsl / -lsocket stuff
AC_LIBRARY_NET
-dnl Look for res_mkquery. Done after AC_LIBRARY_NET in case res_mkquery
-dnl is in one of those libraries somewhere.
-AC_SEARCH_LIBS(res_mkquery, resolv, ,
-[AC_MSG_ERROR([Unable to find library containing res_mkquery()])])
-
dnl Checks for header files.
AC_HEADER_STDC
-AC_CHECK_HEADERS(poll.h sys/devpoll.h sys/event.h)
+AC_CHECK_HEADERS(crypt.h poll.h inttypes.h stdint.h sys/devpoll.h sys/epoll.h sys/event.h sys/param.h sys/resource.h sys/socket.h)
dnl Checks for typedefs, structures, and compiler characteristics
dnl AC_C_CONST
AC_STRUCT_TM
AC_TYPE_UID_T
unet_CHECK_TYPE_SIZES
+AC_CHECK_TYPE(socklen_t, unsigned int)
+AC_CHECK_TYPE(struct sockaddr_in6, [unet_have_sockaddr_in6="yes"], [unet_have_sockaddr_in6="no"], [#include <sys/types.h>
+#include <netinet/in.h>])
dnl Checks for library functions.
-AC_CHECK_FUNC(kqueue)
+AC_CHECK_FUNCS([kqueue setrlimit getrusage times])
dnl Do we have restarting syscalls ?
AC_SYS_RESTARTABLE_SYSCALLS
AC_PATH_PROGS(RMPROG, rm, /bin/rm)
AC_PATH_PROGS(SHPROG, sh, /bin/sh)
+dnl (F)LEX - needed for the new conf file parser
+AC_PROG_LEX
+dnl The autoconf docs say $LEX defaults to 'lex'. They lie.
+if test "$LEX" = ":" ; then
+ AC_MSG_ERROR([Cannot find flex.])
+elif echo "" | $LEX -V -v --version > /dev/null 2>&1 ; then
+ :
+else
+ AC_MSG_ERROR([Cannot use $LEX as flex.])
+fi
+
+if test -z "$LEXLIB" ; then
+ AC_MSG_FAILURE([Cannot find a library with yywrap() in, but flex was found.
+ It's possible the compiler you're using ($CC) is incompatible with the
+ installed library.])
+fi
+
+LIBS="$LEXLIB $LIBS"
+
+dnl YACC - ditto
+AC_PROG_YACC
+dnl The autoconf docs say $YACC defaults to 'yacc'. This seems to be true,
+dnl but judging from AC_PROG_LEX, it may not stay true.
+if test "$YACC" = ":" ; then
+ AC_MSG_ERROR([Cannot find yacc.])
+elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then
+ :
+else
+dnl byacc does not seem to have any way to test for workingness, so only warn.
+ AC_MSG_WARN([$YACC may not work as yacc.])
+fi
+
unet_NONBLOCKING
unet_SIGNALS
-dnl Add -pipe when possible
-unet_PIPE_CFLAGS
-
dnl Check OS for os_dep files.
AC_MSG_CHECKING(for OS-dependent information)
case "$host" in
*-linux*)
AC_MSG_RESULT([Linux ($host) found.])
unet_poll_syscall=yes
- OSDEP_C=os_linux.c
;;
*-solaris*)
else
unet_poll_syscall=no
fi
- OSDEP_C=os_solaris.c
;;
*-sunos*)
AC_MSG_RESULT([Solaris ($host) found.])
unet_poll_syscall=no
- OSDEP_C=os_solaris.c
;;
*-openbsd*)
else
unet_poll_syscall=no
fi
- OSDEP_C=os_openbsd.c
;;
*-*bsd*)
else
unet_poll_syscall=no
fi
- OSDEP_C=os_bsd.c
+ ;;
+
+ *-darwin*)
+ AC_MSG_RESULT([Darwin (Mac OS X) ($host) found.])
+ unet_poll_syscall=no
;;
*)
AC_MSG_RESULT([Unknown system type $host found.])
AC_MSG_WARN([Unknown OS type; using generic routines.])
unet_poll_syscall=no
- OSDEP_C=os_generic.c
;;
esac
-AC_SUBST(OSDEP_C)
dnl Check user configuration options
dnl Start with --enable-poll
AC_MSG_RESULT([$unet_cv_enable_poll])
if test x"$unet_cv_enable_poll" = xyes; then
- AC_DEFINE([USE_POLL], , [Specify whether or not to use poll()])
+ AC_DEFINE([USE_POLL], 1, [Specify whether or not to use poll()])
ENGINE_C=engine_poll.c
else
ENGINE_C=engine_select.c
AC_MSG_RESULT([$unet_cv_enable_debug])
if test x"$unet_cv_enable_debug" = xyes; then
- AC_DEFINE([DEBUGMODE], , [Enable debugging code])
+ AC_DEFINE([DEBUGMODE], 1, [Enable debugging code])
+fi
+
+dnl Now look for --enable-leak-detect
+AC_MSG_CHECKING([whether to enable leak detection])
+AC_ARG_WITH([leak-detect],
+[ --with-leak-detect Turn on the leak detector(requires patched boehm)],
+[unet_cv_with_leak_detect=$with_leak_detect],
+[AC_CACHE_VAL(unet_cv_with_leak_detect,
+[unet_cv_with_leak_detect=no])])
+AC_MSG_RESULT([$unet_cv_enable_leak_detect])
+
+if test x"$unet_cv_with_leak_detect" != xno; then
+ LIBS="-lgc $LIBS"
+ CFLAGS="-DMDEBUG $CFLAGS"
+ if test x"$unet_cv_with_leak_detect" != xyes; then
+ LIBS="-L$unet_cv_with_leak_detect $LIBS"
+ fi
+fi
+
+AC_ARG_WITH([ipv6],
+ AS_HELP_STRING([--without-ipv6], [disable IPv6 support (default is autodetect)]),
+ [ac_cv_use_ipv6=$withval],
+ [ac_cv_use_ipv6=$unet_have_sockaddr_in6])
+AC_CACHE_CHECK([whether to use IPv6], [ac_cv_use_ipv6], [ac_cv_use_ipv6=no])
+if test x"$ac_cv_use_ipv6" != "xno" ; then
+ AC_DEFINE([IPV6], 1, [Enable IPv6 support])
fi
-dnl And now for --enable-asserts
+dnl And now for --disable-asserts
AC_MSG_CHECKING([whether to enable asserts])
AC_ARG_ENABLE([asserts],
-[ --enable-asserts Enable asserts],
+[ --disable-asserts Disable assertion checking],
[unet_cv_enable_asserts=$enable_asserts],
[AC_CACHE_VAL(unet_cv_enable_asserts,
-[unet_cv_enable_asserts=no])])
+[unet_cv_enable_asserts=yes])])
AC_MSG_RESULT([$unet_cv_enable_asserts])
if test x"$unet_cv_enable_asserts" = xno; then
- AC_DEFINE([NDEBUG], , [Disable assertions])
+ AC_DEFINE([NDEBUG], 1, [Disable assertions])
fi
dnl Check for --enable-symbols
if test x"$unet_cv_enable_profile" = xyes; then
CFLAGS="-pg $CFLAGS"
+ LDFLAGS="-pg $LDFLAGS"
fi
dnl Now check for --enable-pedantic
AC_MSG_RESULT([$unet_cv_enable_inlines])
if test x"$unet_cv_enable_inlines" = xyes; then
- AC_DEFINE([FORCEINLINE], , [Force inlining for a few critical functions])
+ AC_DEFINE([FORCEINLINE], 1, [Force inlining for a few critical functions])
fi
-dnl --enable-devpoll check...
+dnl --disable-devpoll check...
AC_MSG_CHECKING([whether to enable the /dev/poll event engine])
AC_ARG_ENABLE([devpoll],
-[ --enable-devpoll Enable the experimental /dev/poll-based engine],
+[ --disable-devpoll Disable the /dev/poll-based engine],
[unet_cv_enable_devpoll=$enable_devpoll],
[AC_CACHE_VAL(unet_cv_enable_devpoll,
-[unet_cv_enable_devpoll=no])])
+[unet_cv_enable_devpoll=yes])])
if test x"$ac_cv_header_sys_devpoll_h" = xno; then
unet_cv_enable_devpoll=no
AC_MSG_RESULT([$unet_cv_enable_devpoll])
if test x"$unet_cv_enable_devpoll" != xno; then
- AC_DEFINE([USE_DEVPOLL], , [Define to enable the /dev/poll engine])
+ AC_DEFINE([USE_DEVPOLL], 1, [Define to enable the /dev/poll engine])
ENGINE_C="engine_devpoll.c $ENGINE_C"
fi
-dnl --enable-kqueue check...
+dnl --disable-kqueue check...
AC_MSG_CHECKING([whether to enable the kqueue event engine])
AC_ARG_ENABLE([kqueue],
-[ --enable-kqueue Enable the experimental kqueue-based engine],
+[ --disable-kqueue Disable the kqueue-based engine],
[unet_cv_enable_kqueue=$enable_kqueue],
[AC_CACHE_VAL(unet_cv_enable_kqueue,
-[unet_cv_enable_kqueue=no])])
+[unet_cv_enable_kqueue=yes])])
if test x"$ac_cv_header_sys_event_h" = xno -o x"$ac_cv_func_kqueue" = xno; then
unet_cv_enable_kqueue=no
AC_MSG_RESULT([$unet_cv_enable_kqueue])
if test x"$unet_cv_enable_kqueue" != xno; then
- AC_DEFINE([USE_KQUEUE], , [Define to enable the kqueue engine])
+ AC_DEFINE([USE_KQUEUE], 1, [Define to enable the kqueue engine])
ENGINE_C="engine_kqueue.c $ENGINE_C"
fi
+dnl --disable-epoll check
+AC_MSG_CHECKING([whether to enable the epoll event engine])
+AC_ARG_ENABLE([epoll],
+[ --disable-epoll Disable the epoll-based engine],
+[unet_cv_enable_epoll=$enable_epoll],
+[AC_CACHE_VAL(unet_cv_enable_epoll,
+[unet_cv_enable_epoll=yes])])
+
+if test x"$ac_cv_header_sys_epoll_h" = xno -o x"$ac_cv_func_epoll" = xno; then
+ unet_cv_enable_epoll=no
+fi
+
+AC_MSG_RESULT([$unet_cv_enable_epoll])
+
+dnl If we have the header and user has not refused epoll, we still need
+dnl to check whether the functions are properly defined.
+if test x"$unet_cv_enable_epoll" != xno; then
+ AC_MSG_CHECKING([whether epoll functions are properly defined])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(10);])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_RESULT([no])
+ AC_DEFINE([EPOLL_NEED_BODY], 1, [Define to implement epoll system calls])])
+ AC_DEFINE([USE_EPOLL], 1, [Define to enable the epoll engine])
+ ENGINE_C="engine_epoll.c $ENGINE_C"
+fi
+
+dnl How to copy one va_list to another?
+AC_CACHE_CHECK([for va_copy], unet_cv_c_va_copy, [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; va_copy(ap1, ap2);])],
+ [unet_cv_c_va_copy="yes"],
+ [unet_cv_c_va_copy="no"]
+)])
+if test "$unet_cv_c_va_copy" = "yes" ; then
+ AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
+fi
+
+AC_CACHE_CHECK([for __va_copy], unet_cv_c___va_copy, [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <stdarg.h>], [va_list ap1, ap2; __va_copy(ap1, ap2);])],
+ [unet_cv_c___va_copy="yes"],
+ [unet_cv_c___va_copy="no"]
+)])
+if test "$unet_cv_c___va_copy" = "yes" ; then
+ AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
+fi
+
dnl --with-symlink lets us set the name of the symlink; defaults to "ircd"
AC_MSG_CHECKING([what name to give the symlink])
AC_ARG_WITH([symlink],
dnl --with-maxcon allows us to set the maximum connections
unet_maxcon=`ulimit -Hn`
+if test x"$unet_maxcon" = xunlimited; then
+ unet_maxcon=`ulimit -Sn`
+fi
unet_maxcon=`expr $unet_maxcon - 4`
AC_MSG_CHECKING([max connections])
AC_ARG_WITH([maxcon],
[Maximum number of network connections])
dnl Finally really generate all output files:
-AC_OUTPUT(Makefile ircd/Makefile doc/Makefile, [echo timestamp > stamp-h])
+AC_OUTPUT(Makefile ircd/Makefile ircd/test/Makefile doc/Makefile, [echo timestamp > stamp-h])
+
+dnl Report configuration
+AC_OUTPUT_COMMANDS([echo "
+ircu is now hopefully configured for your system.
+
+ Host system: $host_os
+ Prefix: $prefix
+ Asserts: $unet_cv_enable_asserts
+ Warnings: $unet_cv_enable_warnings
+ Debug: $unet_cv_enable_debug
+ Profile: $unet_cv_enable_profile
+ Owner/mode: $unet_cv_with_owner.$unet_cv_with_group ($unet_cv_with_mode)
+ Chroot: $unet_cv_with_chroot
+
+ Domain: $unet_cv_with_domain
+ DPath: $unet_cv_with_dpath
+ CPath: $unet_cv_with_cpath
+ LPath: $unet_cv_with_lpath
+ Maximum connections: $unet_cv_with_maxcon
+
+ poll() engine: $unet_cv_enable_poll
+ kqueue() engine: $unet_cv_enable_kqueue
+ /dev/poll engine: $unet_cv_enable_devpoll
+ epoll() engine: $unet_cv_enable_epoll
+"])