1 dnl $Id: configure.ac 3516 2007-06-10 16:14:03Z jilles $
2 dnl Process this file with autoconf to produce a configure script.
4 dnl TODO: clean up all the OpenSSL and shared module checking stuff;
5 dnl the most major changes have already been made and it looks like
6 dnl said functions need to be just about as complex as they already are.
10 dnl Sneaky way to get an Id tag into the configure script
11 AC_COPYRIGHT([$Id: configure.ac 3516 2007-06-10 16:14:03Z jilles $])
13 AC_INIT([charybdis],[2.3.0])
15 AC_CONFIG_HEADER(include/setup.h)
17 AC_PREFIX_DEFAULT($HOME/ircd)
22 dnl Checks for programs.
26 dnl Make sure autoconf doesn't interfere with cflags -jmallett
29 dnl Check for various compilers. -jmallett
30 dnl But if $CC turns out to be gcc, sure as hell it's, well, gcc. -joshk
32 if test "$ac_cv_c_compiler_gnu" != yes; then
35 AC_MSG_CHECKING($CC -version for TenDRA or MIPSpro)
36 case `$CC -version 2>&1` in
38 AC_MSG_RESULT([yes, TenDRA])
40 CPPFLAGS="$CPPFLAGS -Ylonglong -Yansi -I/usr/include"
45 AC_MSG_RESULT([yes, MIPSpro])
56 AC_MSG_CHECKING([$CC -V for Sun Workshop, Forte, HPUX or Tru64 cc])
58 *Sun*WorkShop* | *Forte*Developer*)
59 AC_MSG_RESULT(Sun Workshop/Forte)
60 IRC_CFLAGS="-fast -xinline=dlinkAdd,dlinkAddBefore,dlinkAddTail,dlinkDelete,dlink_list_length,dlink_node,dlinkMoveList,_MyMalloc,_MyRealloc,_MyFree,_DupString"
65 AC_MSG_RESULT(Tru64 cc)
67 CPPFLAGS="-I/usr/local/include"
71 AC_MSG_RESULT(HPUX cc)
82 AC_MSG_CHECKING([uname -s for Cygwin, Solaris, AIX or HPUX])
86 dnl only do this if we haven't already detected the newer one
87 dnl and we're not already using gcc
89 if test "$HPUX" != yes -a "$ac_cv_c_compiler_gnu" = no; then
90 AC_MSG_RESULT(assuming old HPUX with its own cc)
91 IRC_CFLAGS="$IRC_CFLAGS +e"
94 AC_MSG_RESULT(already using newer HPUX)
102 AC_MSG_RESULT(SunOS or Solaris)
103 AC_DEFINE(__EXTENSIONS__, 1, [This is needed to use strtok_r on Solaris.])
107 AC_MSG_RESULT(AIX - Sorry you poor bastard..really we are)
108 IRC_CFLAGS="$IRC_CFLAGS -Wl,-brtl -Wl,-G"
115 if test "$ac_cv_c_compiler_gnu" = yes; then
116 AC_MSG_CHECKING(if $CC is Apple GCC)
118 case `$CC -v 2>&1 | tail -n 1` in
129 IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall"
132 dnl If we support -g, use it!
133 if test "$ac_cv_prog_cc_g" = yes; then
134 dnl Tru64 needs -g3 for -O2
135 if test "$Tru" = yes; then
136 IRC_CFLAGS="$IRC_CFLAGS -g3"
138 IRC_CFLAGS="$IRC_CFLAGS -g"
142 dnl SVR4 SGS based on what we know about the compiler -jmallett
143 AC_MSG_CHECKING(if $CC supports the SVR4 SGS interfaces)
144 if test "$SGS" = "yes"; then
150 dnl We prefer gcc -MM because it's a lot less bloated
151 AC_PATH_PROG(MKDEP, mkdep)
152 AC_PATH_PROG(MAKEDEPEND, makedepend)
154 AC_MSG_CHECKING(how to generate dependency info)
158 if test "$ac_cv_c_compiler_gnu" = yes; then
159 AC_MSG_RESULT(gcc -MM)
161 elif test ! -z "$MKDEP"; then
164 dnl Tru64's mkdep is very loud
165 if test -z "$Tru"; then
168 STDOUT=" 2> /dev/null"
170 elif test "$SunWorkShop" = yes; then
171 AC_MSG_RESULT($CC -xM)
173 STDOUT="> .depend 2> /dev/null"
174 elif test ! -z "$MAKEDEPEND"; then
175 AC_MSG_RESULT(makedepend)
176 MKDEP="$MAKEDEPEND -f-"
178 AC_MSG_RESULT([nothing suitable.. forget it!])
185 dnl check for /dev/null so we can use it to hold evil fd's
186 AC_MSG_CHECKING([for /dev/null])
187 if test -c /dev/null ; then
188 AC_DEFINE(PATH_DEVNULL, "/dev/null", [Path to /dev/null])
191 AC_DEFINE(PATH_DEVNULL, "devnull.log", [Path to /dev/null])
192 AC_MSG_RESULT(no - using devnull.log)
195 dnl jdc -- If CFLAGS is defined, best use it everywhere...
196 dnl NOTE: jv says it must be added to the *END*, because things like
197 dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid.
198 if test ! -z "$CFLAGS"; then
199 IRC_CFLAGS="$IRC_CFLAGS $CFLAGS"
204 AC_PROG_GCC_TRADITIONAL
211 AC_PATH_PROG(SED, sed)
214 AC_PATH_PROG(RANLIB, ranlib)
215 AC_PATH_PROG(TOUCH, touch)
219 dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found
220 if test "$YACC" = "yacc" -a -z "`which $YACC 2>/dev/null`"; then
221 AC_MSG_ERROR([could not locate a suitable parser generator; install bison, yacc, or byacc])
226 if test "$LEX" = ":"; then
227 AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
230 dnl use directory structure of cached as default (hack)
231 if test "$libexecdir" = '${exec_prefix}/libexec' &&
232 test "$localstatedir" = '${prefix}/var'; then
233 libexecdir='${bindir}'
234 localstatedir='${prefix}'
237 dnl Checks for header files.
240 AC_CHECK_HEADERS([crypt.h sys/resource.h sys/param.h errno.h sys/syslog.h stddef.h sys/wait.h wait.h sys/epoll.h sys/uio.h machine/endian.h])
242 dnl Stuff that the memory manager (imalloc) depends on
243 dnl ==================================================
246 if test "$ac_cv_header_machine_endian_h" = "no" ; then
251 AC_CHECK_SIZEOF(short)
253 AC_CHECK_SIZEOF(long)
254 AC_CHECK_SIZEOF(long long)
259 AC_MSG_CHECKING([the system's memory page size])
268 FILE *fp = fopen("conftest.malloc", "w");
271 fprintf(fp, "%d\n", getpagesize());
277 if test -f "conftest.malloc" ; then
278 pagesize=`cat conftest.malloc`
281 if test "$pagesize" != "no" ; then
282 AC_MSG_RESULT($pagesize)
284 if test "$ac_cv_sizeof_int" = "4" ; then
289 AC_MSG_RESULT([$pagesize (guessing)])
291 AC_DEFINE_UNQUOTED(MALLOC_PAGESIZE, $pagesize,
292 [the system's memory page size])
294 dnl Networking Functions
295 dnl ====================
297 AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])])
299 dnl SunOS/Solaris required libnsl for inet_ntoa()
300 if test x"$SUN" = xyes; then
301 AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])])
304 AC_CHECK_MEMBER([struct sockaddr.sa_len], [AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr has a 'sa_len'
305 member.])],,[[#include <sys/types.h>
306 #include <sys/socket.h>
309 AC_CHECK_TYPE(socklen_t, ,
310 [AC_DEFINE([socklen_t], [unsigned int],
311 [If we don't have a real socklen_t, unsigned int is good enough.])],
312 [#include <sys/types.h>
313 #include <sys/socket.h>])
316 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
318 if test $ipv6 != yes; then
321 AC_MSG_CHECKING([for core IPv6 support])
325 [[#define IN_AUTOCONF
326 #include <sys/types.h>
327 #include <sys/socket.h>
328 #include <netinet/in.h>]],
329 [[struct sockaddr_in6 s;
333 if test "$CYGWIN" = "yes"; then
334 AC_MSG_RESULT([no, Cygwin's IPv6 is incomplete])
338 AC_DEFINE(IPV6, 1, [Define if IPv6 support is present and available.])
340 AC_MSG_CHECKING([for struct in6addr_any])
343 [[#define IN_AUTOCONF
344 #include <sys/types.h>
345 #include <sys/socket.h>
346 #include <netinet/in.h>]],
347 [[struct in6_addr a = in6addr_any;]]
349 [AC_MSG_RESULT(yes)],
352 AC_DEFINE(NO_IN6ADDR_ANY, 1, [Define to 1 if your system has no in6addr_any.])
362 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
364 CRYPT_LIB=$ac_cv_search_crypt
366 if test "$CRYPT_LIB" = "none required"; then
368 elif test "$CRYPT_LIB" = no; then
374 if test "$ac_cv_header_sys_wait_h" = yes -o "$ac_cv_header_wait_h" = yes; then
376 dnl We need one of the above to build viconf. Just a sanity check,
377 dnl we don't want to stop people from building the rest of ircd
378 dnl just because they can't build viconf.
385 dnl See whether we can include both string.h and strings.h.
386 AC_CACHE_CHECK([whether string.h and strings.h may both be included],
387 gcc_cv_header_string,
391 #include <strings.h>],
392 [gcc_cv_header_string=yes],
393 [gcc_cv_header_string=no])
396 if test "$gcc_cv_header_string" = "yes"; then
397 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
402 dnl Check for stdarg.h - if we can't find it, halt configure
403 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - ircd-ratbox will not compile without it **])])
405 dnl Checks for the existence of strlcat, strlcpy, basename...
406 dnl This more reliable test only works with gcc though.
408 if test "$ac_cv_c_compiler_gnu" = yes; then
410 AC_MSG_CHECKING(for strlcpy)
412 CFLAGS="$CFLAGS -Wimplicit -Werror"
416 [[#include <string.h>
417 #include <stdlib.h>]],
418 [[char *a = malloc(6);
419 strlcpy(a, "hello", 6);]]
422 AC_DEFINE(HAVE_STRLCPY, 1, [Define if strlcpy is available (most BSDs.)])],
426 AC_MSG_CHECKING(for strlcat)
429 [[#include <string.h>
430 #include <stdlib.h>]],
431 [[char *a = malloc(6);
433 strlcat(a, "hello", 6);]]
436 AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available (most BSDs.)])],
444 dnl Better than nothing. The more complicated test above probably fixes powerpc,
447 AC_CHECK_FUNCS([strlcat strlcpy])
451 AC_CHECK_TYPE([u_int32_t], [],
453 AC_CHECK_TYPE([uint32_t],
455 AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.])
458 AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int])
459 AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.])
463 AC_CHECK_TYPE([u_int16_t], [],
465 AC_CHECK_TYPE([uint16_t],
467 AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute])
470 AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int])
471 AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.])
475 AC_CHECK_TYPE([in_port_t], [],
476 [AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])],
477 [[#include <sys/types.h>
478 #include <netinet/in.h>]])
480 AC_CHECK_TYPE([sa_family_t], [],
481 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
482 [[#include <sys/types.h>
483 #include <sys/socket.h>]])
485 AC_CHECK_TYPES([uintptr_t])
487 dnl check for various functions...
488 AC_CHECK_FUNCS([socketpair vsnprintf mmap gettimeofday strdup strndup ])
492 dnl Specialized functions checks
493 dnl ============================
495 dnl check for nanosleep
496 AC_CHECK_FUNC(nanosleep,,[AC_CHECK_LIB(rt,nanosleep,
498 [AC_CHECK_LIB(posix4,nanosleep, LIBS="${LIBS} -lposix4"
500 if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_posix4_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno
502 AC_MSG_RESULT("nanosleep not found..using select for delay")
504 AC_DEFINE([HAVE_NANOSLEEP], 1, [Define if nanosleep exists])
508 AC_MSG_CHECKING(for OpenSSL)
509 AC_ARG_ENABLE(openssl,
510 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
511 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
512 [cf_enable_openssl=$enableval],
513 [cf_enable_openssl="auto"])
515 if test "$cf_enable_openssl" != "no" ; then
516 cf_openssl_basedir=""
517 if test "$cf_enable_openssl" != "auto" &&
518 test "$cf_enable_openssl" != "yes" ; then
519 dnl Support for --enable-openssl=/some/place
520 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
522 dnl Do the auto-probe here. Check some common directory paths.
523 for dirs in /usr/local/ssl /usr/pkg /usr/local \
524 /usr/local/openssl ; do
525 if test -f "${dirs}/include/openssl/opensslv.h" ; then
526 cf_openssl_basedir="${dirs}"
532 dnl Now check cf_openssl_found to see if we found anything.
533 if test ! -z "$cf_openssl_basedir"; then
534 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
535 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
536 SSL_LIBS="-L${cf_openssl_basedir}/lib"
538 dnl OpenSSL wasn't found in the directory specified. Naughty
540 cf_openssl_basedir=""
543 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
544 dnl are in /usr/include and /usr/lib. In this case, we don't want to
545 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
546 dnl We can't do this check above, because some people want two versions
547 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
548 dnl and they want /usr/local/ssl to have preference.
549 if test -f "/usr/include/openssl/opensslv.h" ; then
550 cf_openssl_basedir="/usr"
554 dnl If we have a basedir defined, then everything is okay. Otherwise,
555 dnl we have a problem.
556 if test ! -z "$cf_openssl_basedir"; then
557 AC_MSG_RESULT($cf_openssl_basedir)
558 cf_enable_openssl="yes"
560 AC_MSG_RESULT([not found. Specify a correct path?])
561 cf_enable_openssl="no"
563 unset cf_openssl_basedir
565 dnl If --disable-openssl was specified
566 AC_MSG_RESULT(disabled)
569 save_CPPFLAGS="$CPPFLAGS"
570 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
572 LIBS="$LIBS $SSL_LIBS"
573 if test "$cf_enable_openssl" != no; then
574 dnl Check OpenSSL version (must be 0.9.6 or above!)
575 AC_MSG_CHECKING(for OpenSSL 0.9.6 or above)
578 [#include <openssl/opensslv.h>
579 #include <stdlib.h>],
580 [[if ( OPENSSL_VERSION_NUMBER >= 0x00906000)
581 exit(0); else exit(1);]]),
582 cf_openssl_version_ok=yes,
583 cf_openssl_version_ok=no,
584 cf_openssl_version_ok=no)
586 if test "$cf_openssl_version_ok" = yes; then
589 dnl Work around pmake/gmake conditional incompatibilities
590 AC_SUBST(ENCSPEED, encspeed)
592 dnl Do all the HAVE_LIBCRYPTO magic -- and check for ciphers
593 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
594 AC_CHECK_LIB(crypto, RSA_free)
595 SSL_LIBS="$SSL_LIBS -lcrypto"
596 SSL_SRCS_ENABLE='$(SSL_SRCS)'
598 AC_MSG_RESULT(no - OpenSSL support disabled)
602 CPPFLAGS="$save_CPPFLAGS"
605 dnl End OpenSSL detection
608 dnl Specialized functions and libraries
609 dnl ===================================
611 AC_ARG_WITH(zlib-path,
612 AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]),
613 [LIBS="$LIBS -L$withval"],)
616 AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]),
617 [zlib=$enableval],[zlib=yes])
619 if test "$zlib" = yes; then
621 AC_CHECK_HEADER(zlib.h, [
622 AC_CHECK_LIB(z, zlibVersion,
624 AC_SUBST(ZLIB_LD, -lz)
625 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.])
631 dnl IO Loop Selection
632 dnl =================
634 AC_ARG_ENABLE(ports, AC_HELP_STRING([--enable-ports],[Force solaris I/O ports subsystem usage.]),
635 [ if test $enableval = yes; then
636 SELECT_TYPE_EXPLICIT="ports"
642 AC_ARG_ENABLE(poll, AC_HELP_STRING([--enable-poll],[Force poll() usage.]),
643 [ if test $enableval = yes; then
644 SELECT_TYPE_EXPLICIT="poll"
650 AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select],[Force select() usage.]),
651 [ if test $enableval = yes; then
652 SELECT_TYPE_EXPLICIT="select"
658 AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
659 [ if test $enableval = yes; then
660 SELECT_TYPE_EXPLICIT="kqueue"
666 AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
667 [ if test $enableval = yes; then
668 SELECT_TYPE_EXPLICIT="epoll"
669 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
675 dnl **********************************************************************
676 dnl Check for --with-confdir
677 dnl **********************************************************************
679 AC_MSG_CHECKING([whether to modify confdir])
681 AC_HELP_STRING([--with-confdir=DIR],
682 [Directory to install config files.]),
683 [ confdir=`echo $withval | sed 's/\/$//'`
685 AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.])
686 AC_SUBST_DIR([confdir]) ],
687 [ confdir='${prefix}/etc'
689 AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.])
690 AC_SUBST_DIR([confdir])]
693 dnl **********************************************************************
694 dnl Check for --with-logdir
695 dnl **********************************************************************
697 AC_MSG_CHECKING([whether to modify logdir])
699 AC_HELP_STRING([--with-logdir=DIR],
700 [Directory where to write logfiles.]),
701 [ logdir=`echo $withval | sed 's/\/$//'`
703 AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.])
704 AC_SUBST_DIR([logdir]) ],
705 [ logdir='${prefix}/logs'
707 AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.])
708 AC_SUBST_DIR([logdir])]
711 dnl **********************************************************************
712 dnl Check for --with-helpdir
713 dnl **********************************************************************
715 AC_MSG_CHECKING([whether to modify helpdir])
717 AC_HELP_STRING([--with-helpdir=DIR],
718 [Directory to install help files.]),
719 [ helpdir=`echo $withval | sed 's/\/$//'`
721 AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help files are installed.])
722 AC_SUBST_DIR([helpdir]) ],
723 [ helpdir='${prefix}/help'
725 AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help file are installed.])
726 AC_SUBST_DIR([helpdir])]
729 dnl **********************************************************************
730 dnl Check for --with-moduledir
731 dnl **********************************************************************
733 AC_MSG_CHECKING([whether to modify moduledir])
734 AC_ARG_WITH(moduledir,
735 AC_HELP_STRING([--with-moduledir=DIR],
736 [Directory to install modules.]),
737 [ moduledir=`echo $withval | sed 's/\/$//'`
739 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
740 AC_SUBST_DIR([moduledir]) ],
741 [ moduledir='${prefix}/modules'
743 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
744 AC_SUBST_DIR([moduledir])]
747 if test ! -z "$SELECT_TYPE_EXPLICIT"; then
748 SELECT_TYPE="$SELECT_TYPE_EXPLICIT";
749 echo "Forcing $SELECT_TYPE to be enabled"
752 if test ! "x$use_ports" = "xno"; then
753 AC_CHECK_FUNCS(port_getn, [haveports=yes], [haveports=no])
754 if test "x$haveports" = "xyes" ; then
759 if test ! "x$use_select" = "xno"; then
760 AC_CHECK_FUNCS(select, [haveselect=yes], [haveselect=no])
761 if test "x$haveselect" = "xyes" ; then
766 if test ! "x$use_poll" = "xno"; then
767 AC_CHECK_FUNCS(poll, [havepoll=yes], [havepoll=no])
768 if test "x$havepoll" = "xyes" ; then
773 if test ! "x$use_kqueue" = "xno"; then
774 AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
775 if test "x$havekqueue" = "xyes" ; then
780 if test ! "x$use_epoll" = "xno"; then
781 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
782 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
783 if test "x$haveepoll" = "xyes" ; then
784 AC_MSG_CHECKING(for epoll support in kernel)
787 #include <sys/param.h>
788 #include <sys/types.h>
789 #include <sys/epoll.h>
790 #include <sys/syscall.h>
794 main(int argc, char **argv)
798 epfd = epoll_create(256);
799 return (epfd == -1 ? 1 : 0);
800 }, [AC_MSG_RESULT(yes)
801 AC_DEFINE(HAVE_EPOLL, 1,
802 [Define if your system supports the epoll system calls])
803 SELECT_TYPE="epoll"],
804 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
810 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
811 if test "x$haveepoll" = "xno" ; then
812 AC_MSG_CHECKING(for epoll system call)
815 #include <sys/param.h>
816 #include <sys/types.h>
817 #include <sys/epoll.h>
818 #include <sys/syscall.h>
822 epoll_create(int size)
824 return (syscall(__NR_epoll_create, size));
828 main(int argc, char **argv)
832 epfd = epoll_create(256);
833 exit (epfd == -1 ? 1 : 0);
834 }, [AC_MSG_RESULT(yes)
835 AC_DEFINE(HAVE_EPOLL, 1,
836 [Define if your system supports the epoll system calls])
837 SELECT_TYPE="epoll"],
838 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
846 if test -z "$SELECT_TYPE"; then
847 AC_MSG_ERROR([Unable to find a usable IO interface],)
850 echo "Using $SELECT_TYPE for select loop."
852 AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE", [This is the type of IO loop we are using])
853 AC_SUBST(SELECT_TYPE)
856 dnl Debug-related options
857 dnl =====================
859 AC_ARG_ENABLE(assert,
860 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
861 [assert=$enableval], [assert=no])
863 if test "$assert" = no; then
864 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
865 elif test "$assert" = soft; then
866 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
867 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
868 elif test "$assert" = yes; then
872 AC_MSG_CHECKING(if you want IO Debugging hooks)
873 AC_ARG_ENABLE(iodebug,
874 AC_HELP_STRING([--enable-iodebug],[Enable IO Debugging hooks]),
875 [iodebug=$enableval], [iodebug=no])
877 if test "$iodebug" = yes; then
878 AC_DEFINE(USE_IODEBUG_HOOKS, 1, [Define this to enable IO Debug hooks.])
885 AC_MSG_CHECKING(if you want to do a profile build)
886 AC_ARG_ENABLE(profile,
887 AC_HELP_STRING([--enable-profile],[Enable profiling]),
888 [profile=$enableval], [profile=no])
890 if test "$profile" = yes; then
891 if test "$ac_cv_c_compiler_gnu" = yes; then
892 IRC_CFLAGS="$IRC_CFLAGS -pg"
893 AC_MSG_RESULT([yes, adding -pg])
894 AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
896 AC_MSG_RESULT([no, profile builds only work with gcc])
902 AC_ARG_ENABLE(balloc,
903 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
904 [balloc=$enableval], [balloc=yes])
906 if test "$balloc" = no; then
907 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
910 AC_ARG_ENABLE(small-net,
911 AC_HELP_STRING([--enable-small-net],[Enable small network support.]),
912 [small_net=$enableval], [small_net=no])
914 if test "$small_net" = yes; then
915 dnl AC_DEFINE([HASHSIZE], 4096, [Max number of buckets in hash tables.])
916 AC_DEFINE([NICKNAMEHISTORYLENGTH], 1500, [Size of the WHOWAS array.])
917 AC_DEFINE([CHANNEL_HEAP_SIZE], 256, [Size of the channel heap.])
918 AC_DEFINE([BAN_HEAP_SIZE], 128, [Size of the ban heap.])
919 AC_DEFINE([CLIENT_HEAP_SIZE], 256, [Size of the client heap.])
920 AC_DEFINE([LCLIENT_HEAP_SIZE], 128, [Size of the local client heap.])
921 AC_DEFINE([PCLIENT_HEAP_SIZE], 32, [Size of the pre-client heap.])
922 AC_DEFINE([USER_HEAP_SIZE], 128, [Size of the user heap.])
923 AC_DEFINE([DNODE_HEAP_SIZE], 256, [Size of the dlink_node heap.])
924 AC_DEFINE([TOPIC_HEAP_SIZE], 256, [Size of the topic heap.])
925 AC_DEFINE([LINEBUF_HEAP_SIZE], 128, [Size of the linebuf heap.])
926 AC_DEFINE([MEMBER_HEAP_SIZE], 256, [Sizeof member heap.])
927 AC_DEFINE([ND_HEAP_SIZE], 128, [Size of the nick delay heap.])
928 AC_DEFINE([CONFITEM_HEAP_SIZE], 128, [Size of the confitem heap.])
929 AC_DEFINE([MONITOR_HEAP_SIZE], 128, [Size of the monitor heap.])
931 dnl These settings are for a large network like efnet..they will use lots of memory
932 dnl so enable small net unless you really need this much support
933 AC_DEFINE([NICKNAMEHISTORYLENGTH], 15000, [Size of the WHOWAS array.])
934 AC_DEFINE([CHANNEL_HEAP_SIZE], 8192, [Size of the channel heap.])
935 AC_DEFINE([BAN_HEAP_SIZE], 4096, [Size of the ban heap.])
936 AC_DEFINE([CLIENT_HEAP_SIZE], 8192, [Size of the client heap.])
937 AC_DEFINE([LCLIENT_HEAP_SIZE], 1024, [Size of the local client heap.])
938 AC_DEFINE([PCLIENT_HEAP_SIZE], 256, [Size of the pre-client heap.])
939 AC_DEFINE([USER_HEAP_SIZE], 8192, [Size of the user heap.])
940 AC_DEFINE([DNODE_HEAP_SIZE], 8192, [Size of the dlink_node heap.])
941 AC_DEFINE([TOPIC_HEAP_SIZE], 4096, [Size of the topic heap.])
942 AC_DEFINE([LINEBUF_HEAP_SIZE], 2048, [Size of the linebuf heap.])
943 AC_DEFINE([MEMBER_HEAP_SIZE], 32768, [Sizeof member heap.])
944 AC_DEFINE([ND_HEAP_SIZE], 512, [Size of the nick delay heap.])
945 AC_DEFINE([CONFITEM_HEAP_SIZE], 256, [Size of the confitem heap.])
946 AC_DEFINE([MONITOR_HEAP_SIZE], 1024, [Size of the monitor heap.])
950 AC_HELP_STRING([--with-nicklen=LENGTH],[Set the nick length to LENGTH (default 15, max 50)]),
952 if test $withval -ge 50; then
954 AC_MSG_WARN([NICKLEN has a hard limit of 50. Setting NICKLEN=50])
960 AC_ARG_WITH(topiclen,
961 AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
963 if test $withval -ge 390; then
965 AC_MSG_WARN([TOPICLEN has a hard limit of 390. Setting TOPICLEN=390])
971 AC_DEFINE_UNQUOTED(TOPICLEN, ${TOPICLEN}, [Maximum topic length (<=390)])
972 AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length])
975 dnl Some first-stage sanity checks.
976 if test "$shared_modules" = yes; then
978 if test "$CYGWIN" = yes; then
979 AC_MSG_WARN([disabling shared modules; Cygwin is at present unable to build them.])
983 dnl TenDRA's cc is called tcc too.
984 if test "$CC" = tcc -a "$TenDRA" = "no"; then
985 AC_MSG_WARN([disabling shared modules: Tiny C Compiler can't create PIC])
990 dnl Second stage: check for functions and headers.
991 if test "$shared_modules" = yes; then
993 AC_CHECK_HEADERS(dlfcn.h)
994 AC_SEARCH_LIBS(shl_load, dld,
996 AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if the shl_load function is available.])
998 MOD_TARGET=hpux_shared
1004 AC_SEARCH_LIBS(dlopen, [dl c_r],
1006 AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
1008 MOD_TARGET=shared_modules
1009 SEDOBJ="s/\.o/.so/g"
1010 if test "$AppleGCC" = yes; then
1011 AC_CHECK_HEADERS([mach-o/dyld.h])
1013 AC_CHECK_FUNC(dlsym, ,
1015 AC_MSG_WARN([dlsym is not available, shared modules disabled])
1018 AC_CHECK_FUNCS(dlfunc)
1026 AC_DEFINE_UNQUOTED(SHARED_SUFFIX, "$SUFFIX", [Suffix for shared libraries on this platform.])
1028 dnl Third stage - wrangling the linker.
1029 if test "$shared_modules" = yes; then
1030 # The GNU linker requires the -export-dynamic option to make
1031 # all symbols visible in the dynamic symbol table.
1032 hold_ldflags=$LDFLAGS
1033 AC_MSG_CHECKING(for the ld -export-dynamic flag)
1034 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic -Werror"
1035 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1036 LDFLAGS=$hold_ldflags
1038 if expr "`uname -s`" : ^IRIX >/dev/null 2>&1; then
1039 found="no, IRIX ld uses -B,dynamic"
1040 LDFLAGS="${LDFLAGS} -Wl,-B,dynamic"
1043 if expr "`uname -s`" : ^AIX >/dev/null 2>&1; then
1044 found="no, AIX ld uses -G -brtl"
1045 LDFLAGS="${LDFLAGS} -Wl,-G,-brtl"
1048 AC_MSG_RESULT($found)
1050 if test "$found" = yes; then
1051 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
1054 AC_MSG_CHECKING(for compiler option to produce PIC)
1055 dnl The order should be here to check for groups of compilers,
1056 dnl then for odd compilers, then if no PICFLAGS were set up,
1057 dnl check for GCC and set defaults, or else error. -jmallett
1058 if test "$SGS" = "yes"; then
1059 AC_MSG_RESULT([SVR4 SGS interfaces: -KPIC -DPIC -G])
1060 PICFLAGS="-KPIC -DPIC -G"
1063 if test "$AppleGCC" = "yes"; then
1064 AC_MSG_RESULT([Darwin Mach-O bundles: -fno-common -bundle -flat_namespace -undefined suppress])
1065 PICFLAGS="-fno-common -bundle -flat_namespace -undefined suppress"
1067 dnl Please note, that on HPUX two different stages of module compilation occurs, since
1068 dnl while compiling modules, the compiler does not allow you to give arguments
1069 dnl to the linker. (I did not design this)
1070 dnl So we need -c in the first stage of module compilation.
1071 dnl In the second stage, we link the modules via ld -b.
1072 dnl Additionally, HPUX does not like -export-dynamic, it likes -E instead.
1074 if test "$HPUX" = "yes" -a "$CC" != gcc; then
1075 AC_MSG_RESULT(HP-UX cc: +z -r -q -n)
1076 PICFLAGS="+z -r -q -n -c"
1077 AC_MSG_CHECKING([if +ESfic is required on this platform])
1079 if expr "`$CC +ESfic 2>&1`" : ".*neither supported.*" >/dev/null; then
1083 PICFLAGS="$PICFLAGS +ESfic"
1086 LDFLAGS="${LDFLAGS} -Wl,-E"
1088 if test "$Tru" = yes -a "$CC" != gcc; then
1089 AC_MSG_RESULT([Tru64: -shared -expect_unresolved '*'])
1090 PICFLAGS="-shared -expect_unresolved '*' "
1091 LDFLAGS="-call_shared"
1093 if test -z "$PICFLAGS"; then
1094 if test "$ac_cv_c_compiler_gnu" = "yes"; then
1095 AC_MSG_RESULT(gcc: -fPIC -DPIC -shared)
1096 PICFLAGS="-fPIC -DPIC -shared"
1104 # This must be down here, or it will mess up checks like the ones
1105 # for -Wl,-export-dynamic
1107 AC_ARG_ENABLE(warnings,
1108 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
1110 IRC_CFLAGS="$IRC_CFLAGS -O0"
1111 CFLAGS="$IRC_CFLAGS"
1113 CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
1114 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
1115 CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit)
1116 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
1117 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
1118 CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes)
1119 CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis)
1120 CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w)
1121 CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
1122 CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow)
1123 CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
1124 CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
1125 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
1126 CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_externs)
1127 CHARYBDIS_C_GCC_TRY_FLAGS([-Wbad-function-cast], charybdis_cv_c_gcc_w_bad_function_cast)
1128 CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused)
1129 CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls)
1130 CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
1131 CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat=2], charybdis_cv_c_gcc_w_format)
1132 CHARYBDIS_C_GCC_TRY_FLAGS([-pedantic], charybdis_cv_c_gcc_pedantic)
1134 IRC_CFLAGS="$CFLAGS"
1137 if test "$shared_modules" = no; then
1139 MOD_TARGET="libmodules.a"
1140 MODULES_LIBS="../modules/libmodules.a"
1142 AC_DEFINE(STATIC_MODULES, 1, [Define to 1 if dynamic modules can't be used.])
1143 AC_MSG_WARN([shared module support has been disabled!])
1146 dnl Stage 5 - underscores in front of symbol names.
1147 if test "$shared_modules" = yes; then
1149 AC_CHECK_FUNC(nlist,,
1150 AC_CHECK_LIB(dl, nlist, nlist_lib="-ldl",
1151 AC_CHECK_LIB(elf, nlist, nlist_lib="-lelf",)
1155 dnl We need to find out whether underscores are appended to symbol
1156 dnl names in executable files. First, though, we need to see
1157 dnl where nlist.h is hiding.
1158 AC_CHECK_HEADER(libelf/nlist.h, [ nlist_h="libelf/nlist.h" ], )
1159 AC_CHECK_HEADER(elf/nlist.h, [ nlist_h="elf/nlist.h" ], )
1160 AC_CHECK_HEADER(nlist.h, [ nlist_h="nlist.h" ], )
1161 if test x"$nlist_h" = "x"; then
1162 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "", [String containing extra underscores prepended to symbols loaded from modules.])
1164 AC_MSG_CHECKING(for extra underscores prepended to symbol names)
1165 AC_CACHE_VAL(symbol_underscores,
1167 cat << EOF > conftest.c
1171 void _modinit(void);
1172 int main(int argc, char *argv[[]]) {
1174 struct nlist nl[[5]];
1176 /* fill the names in this way, so it'll work almost everywhere */
1177 nl[[0]].n_name = "_modinit";
1178 nl[[1]].n_name = "__modinit";
1179 nl[[2]].n_name = "___modinit";
1180 nl[[3]].n_name = "____modinit";
1181 nl[[0]].n_value = nl[[1]].n_value = nl[[2]].n_value = nl[[3]].n_value = nl[[4]].n_name = NULL;
1183 if(argc < 2 || (nlist(argv[[1]], nl)) == -1) exit(-1);
1184 for(i = 0; i < 4; i++) {
1185 if(nl[[i]].n_value != NULL)
1188 for(j = 0; j < i; j++)
1195 void _modinit(void) { return; }
1197 $CC $CPPFLAGS $IRC_CFLAGS -o conftest conftest.c $nlist_lib >/dev/null 2>&1
1198 symbol_underscores=`./conftest conftest`
1199 AC_MSG_RESULT($symbol_underscores)
1200 $RM -f conftest conftest.c
1202 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "${symbol_underscores}", [String containing extra underscores prepended to symbols loaded from modules.])
1206 AC_SUBST(MODULES_LIBS)
1207 AC_SUBST(MOD_TARGET)
1209 AC_SUBST(SSL_SRCS_ENABLE)
1210 AC_SUBST(SSL_INCLUDES)
1215 AC_SUBST(IRC_CFLAGS)
1219 if test "$prefix" = "NONE"; then
1220 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
1224 dnl Don't get bitten by Cygwin's stupidity if the user specified
1225 dnl a custom prefix with a trailing slash
1227 prefix=`echo $prefix | sed 's/\/$//'`
1228 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
1234 libcharybdis/Makefile \
1236 extensions/Makefile \
1237 unsupported/Makefile \
1247 if test "$cf_openssl_version_ok" = yes; then
1253 if test "$shared_modules" = yes; then
1261 Install directory : $prefix
1265 IPv6 support : $have_v6
1266 Socket Engine : $SELECT_TYPE
1267 Small network : $small_net
1268 Block allocator : $balloc
1270 Nickname length : $NICKLEN
1271 Topic length : $TOPICLEN
1273 Use make to compile Charybdis, then make install to install it.