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], [3.5.0-dev])
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 AC_CONFIG_SUBDIRS(libratbox)
31 dnl Check for various compilers. -jmallett
32 dnl But if $CC turns out to be gcc, sure as hell it's, well, gcc. -joshk
34 if test "$ac_cv_c_compiler_gnu" != yes; then
37 AC_MSG_CHECKING($CC -version for TenDRA or MIPSpro)
38 case `$CC -version 2>&1` in
40 AC_MSG_RESULT([yes, TenDRA])
42 CPPFLAGS="$CPPFLAGS -Ylonglong -Yansi -I/usr/include"
47 AC_MSG_RESULT([yes, MIPSpro])
58 AC_MSG_CHECKING([$CC -V for Sun Workshop, Forte, HPUX or Tru64 cc])
60 *Sun*WorkShop* | *Forte*Developer*)
61 AC_MSG_RESULT(Sun Workshop/Forte)
62 IRC_CFLAGS="-fast -xinline=dlinkAdd,dlinkAddBefore,dlinkAddTail,dlinkDelete,dlink_list_length,dlink_node,dlinkMoveList,_MyMalloc,_MyRealloc,_MyFree,_DupString"
67 AC_MSG_RESULT(Tru64 cc)
69 CPPFLAGS="-I/usr/local/include"
73 AC_MSG_RESULT(HPUX cc)
84 AC_MSG_CHECKING([uname -s for Solaris, AIX or HPUX])
88 dnl only do this if we haven't already detected the newer one
89 dnl and we're not already using gcc
91 if test "$HPUX" != yes -a "$ac_cv_c_compiler_gnu" = no; then
92 AC_MSG_RESULT(assuming old HPUX with its own cc)
93 IRC_CFLAGS="$IRC_CFLAGS +e"
96 AC_MSG_RESULT(already using newer HPUX)
100 AC_MSG_RESULT(SunOS or Solaris)
101 AC_DEFINE(__EXTENSIONS__, 1, [This is needed to use strtok_r on Solaris.])
105 AC_MSG_RESULT(AIX - Sorry you poor bastard..really we are)
106 IRC_CFLAGS="$IRC_CFLAGS -Wl,-brtl -Wl,-G"
113 if test "$ac_cv_c_compiler_gnu" = yes; then
114 AC_MSG_CHECKING(if $CC is Apple GCC)
116 case `$CC -v 2>&1 | tail -n 1` in
127 IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall -std=gnu99"
130 dnl If we support -g, use it!
131 if test "$ac_cv_prog_cc_g" = yes; then
132 dnl Tru64 needs -g3 for -O2
133 if test "$Tru" = yes; then
134 IRC_CFLAGS="$IRC_CFLAGS -g3"
136 IRC_CFLAGS="$IRC_CFLAGS -g"
140 dnl SVR4 SGS based on what we know about the compiler -jmallett
141 AC_MSG_CHECKING(if $CC supports the SVR4 SGS interfaces)
142 if test "$SGS" = "yes"; then
148 dnl We prefer gcc -MM because it's a lot less bloated
149 AC_PATH_PROG(MKDEP, mkdep)
150 AC_PATH_PROG(MAKEDEPEND, makedepend)
152 AC_MSG_CHECKING(how to generate dependency info)
156 if test "$ac_cv_c_compiler_gnu" = yes; then
157 AC_MSG_RESULT(gcc -MM)
159 elif test ! -z "$MKDEP"; then
162 dnl Tru64's mkdep is very loud
163 if test -z "$Tru"; then
166 STDOUT=" 2> /dev/null"
168 elif test "$SunWorkShop" = yes; then
169 AC_MSG_RESULT($CC -xM)
171 STDOUT="> .depend 2> /dev/null"
172 elif test ! -z "$MAKEDEPEND"; then
173 AC_MSG_RESULT(makedepend)
174 MKDEP="$MAKEDEPEND -f-"
176 AC_MSG_RESULT([nothing suitable.. forget it!])
183 dnl check for /dev/null so we can use it to hold evil fd's
184 AC_MSG_CHECKING([for /dev/null])
185 if test -c /dev/null ; then
186 AC_DEFINE(PATH_DEVNULL, "/dev/null", [Path to /dev/null])
189 AC_DEFINE(PATH_DEVNULL, "devnull.log", [Path to /dev/null])
190 AC_MSG_RESULT(no - using devnull.log)
193 dnl jdc -- If CFLAGS is defined, best use it everywhere...
194 dnl NOTE: jv says it must be added to the *END*, because things like
195 dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid.
196 if test ! -z "$CFLAGS"; then
197 IRC_CFLAGS="$IRC_CFLAGS $CFLAGS"
202 AC_PROG_GCC_TRADITIONAL
209 AC_PATH_PROG(SED, sed)
212 AC_PATH_PROG(RANLIB, ranlib)
213 AC_PATH_PROG(TOUCH, touch)
217 dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found
218 if test "$YACC" = "yacc" -a -z "`which $YACC 2>/dev/null`"; then
219 AC_MSG_ERROR([could not locate a suitable parser generator; install bison, yacc, or byacc])
224 if test "$LEX" = ":"; then
225 AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
228 AC_ARG_ENABLE([fhs-paths],
229 [AS_HELP_STRING([--enable-fhs-paths], [Use more FHS-like pathnames (for packagers).])],
231 [dnl detect if the user appears to want --enable-fhs-paths
232 AS_IF([test "$libexecdir" = '${exec_prefix}/libexec' && \
233 test "$localstatedir" = '${prefix}/var' && \
234 test "$libdir" = '${exec_prefix}/lib'],
235 [enable_fhs_paths=no],
236 [enable_fhs_paths=yes])
238 dnl use directory structure of cached as default (hack)
239 AS_IF([test "x$enable_fhs_paths" = "xyes"],
240 [dnl Avoid name collisions.
241 pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}'
242 rundir=${rundir-'${prefix}/run'}
243 pkgrundir='${rundir}/${PACKAGE_TARNAME}'
244 pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'],
245 [libexecdir='${bindir}'
246 pkglibexecdir='${libexecdir}'
247 rundir='${sysconfdir}'
248 pkgrundir='${rundir}'
249 localstatedir='${prefix}'
250 pkglocalstatedir='${sysconfdir}'])
251 pkglibdir='${libdir}/${PACKAGE_TARNAME}'
252 AC_SUBST([pkglibdir])
254 AC_SUBST([pkgrundir])
255 AC_SUBST([pkglocalstatedir])
256 AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as band database]])
257 AC_SUBST([pkglibexecdir])
258 AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])
260 dnl Checks for header files.
263 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])
265 dnl Stuff that the memory manager (imalloc) depends on
266 dnl ==================================================
269 if test "$ac_cv_header_machine_endian_h" = "no" ; then
274 AC_CHECK_SIZEOF(short)
276 AC_CHECK_SIZEOF(long)
277 AC_CHECK_SIZEOF(long long)
279 dnl Networking Functions
280 dnl ====================
282 AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])])
284 dnl SunOS/Solaris required libnsl for inet_ntoa()
285 if test x"$SUN" = xyes; then
286 AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])])
289 AC_CHECK_TYPE(socklen_t, ,
290 [AC_DEFINE([socklen_t], [unsigned int],
291 [If we don't have a real socklen_t, unsigned int is good enough.])],
292 [#include <sys/types.h>
293 #include <sys/socket.h>])
296 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
298 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
300 CRYPT_LIB=$ac_cv_search_crypt
302 if test "$CRYPT_LIB" = "none required"; then
304 elif test "$CRYPT_LIB" = no; then
310 if test "$ac_cv_header_sys_wait_h" = yes -o "$ac_cv_header_wait_h" = yes; then
312 dnl We need one of the above to build viconf. Just a sanity check,
313 dnl we don't want to stop people from building the rest of ircd
314 dnl just because they can't build viconf.
321 dnl See whether we can include both string.h and strings.h.
322 AC_CACHE_CHECK([whether string.h and strings.h may both be included],
323 gcc_cv_header_string,
327 #include <strings.h>],
328 [gcc_cv_header_string=yes],
329 [gcc_cv_header_string=no])
332 if test "$gcc_cv_header_string" = "yes"; then
333 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
338 dnl Check for stdarg.h - if we can't find it, halt configure
339 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - charybdis will not compile without it **])])
341 dnl Checks for the existence of strlcat, strlcpy, basename...
342 dnl This more reliable test only works with gcc though.
344 if test "$ac_cv_c_compiler_gnu" = yes; then
346 AC_MSG_CHECKING(for strlcpy)
348 CFLAGS="$CFLAGS -Wimplicit -Werror"
352 [[#include <string.h>
353 #include <stdlib.h>]],
354 [[char *a = malloc(6);
355 strlcpy(a, "hello", 6);]]
358 AC_DEFINE(HAVE_STRLCPY, 1, [Define if strlcpy is available (most BSDs.)])],
362 AC_MSG_CHECKING(for strlcat)
365 [[#include <string.h>
366 #include <stdlib.h>]],
367 [[char *a = malloc(6);
369 strlcat(a, "hello", 6);]]
372 AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available (most BSDs.)])],
380 dnl Better than nothing. The more complicated test above probably fixes powerpc,
383 AC_CHECK_FUNCS([strlcat strlcpy])
387 AC_CHECK_TYPE([u_int32_t], [],
389 AC_CHECK_TYPE([uint32_t],
391 AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.])
394 AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int])
395 AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.])
399 AC_CHECK_TYPE([u_int16_t], [],
401 AC_CHECK_TYPE([uint16_t],
403 AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute])
406 AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int])
407 AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.])
411 AC_CHECK_TYPE([in_port_t], [],
412 [AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])],
413 [[#include <sys/types.h>
414 #include <netinet/in.h>]])
416 AC_CHECK_TYPE([sa_family_t], [],
417 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
418 [[#include <sys/types.h>
419 #include <sys/socket.h>]])
421 AC_CHECK_TYPES([uintptr_t])
423 dnl check for various functions...
424 AC_CHECK_FUNCS([socketpair vsnprintf mmap gettimeofday strdup strndup ])
428 dnl Specialized functions checks
429 dnl ============================
431 dnl check for nanosleep
432 AC_CHECK_FUNC(nanosleep,,[AC_CHECK_LIB(rt,nanosleep,
434 [AC_CHECK_LIB(posix4,nanosleep, LIBS="${LIBS} -lposix4"
436 if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_posix4_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno
438 AC_MSG_RESULT("nanosleep not found..using select for delay")
440 AC_DEFINE([HAVE_NANOSLEEP], 1, [Define if nanosleep exists])
444 AC_MSG_CHECKING(for OpenSSL)
445 AC_ARG_ENABLE(openssl,
446 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
447 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
448 [cf_enable_openssl=$enableval],
449 [cf_enable_openssl="auto"])
451 if test "$cf_enable_openssl" != "no" ; then
452 cf_openssl_basedir=""
453 if test "$cf_enable_openssl" != "auto" &&
454 test "$cf_enable_openssl" != "yes" ; then
455 dnl Support for --enable-openssl=/some/place
456 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
458 dnl Do the auto-probe here. Check some common directory paths.
459 for dirs in /usr/local/ssl /usr/pkg /usr/local \
460 /usr/local/openssl ; do
461 if test -f "${dirs}/include/openssl/opensslv.h" ; then
462 cf_openssl_basedir="${dirs}"
468 dnl Now check cf_openssl_found to see if we found anything.
469 if test ! -z "$cf_openssl_basedir"; then
470 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
471 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
472 SSL_LIBS="-L${cf_openssl_basedir}/lib"
474 dnl OpenSSL wasn't found in the directory specified. Naughty
476 cf_openssl_basedir=""
479 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
480 dnl are in /usr/include and /usr/lib. In this case, we don't want to
481 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
482 dnl We can't do this check above, because some people want two versions
483 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
484 dnl and they want /usr/local/ssl to have preference.
485 if test -f "/usr/include/openssl/opensslv.h" ; then
486 cf_openssl_basedir="/usr"
490 dnl If we have a basedir defined, then everything is okay. Otherwise,
491 dnl we have a problem.
492 if test ! -z "$cf_openssl_basedir"; then
493 AC_MSG_RESULT($cf_openssl_basedir)
494 cf_enable_openssl="yes"
496 AC_MSG_RESULT([not found. Specify a correct path?])
497 cf_enable_openssl="no"
499 unset cf_openssl_basedir
501 dnl If --disable-openssl was specified
502 AC_MSG_RESULT(disabled)
505 save_CPPFLAGS="$CPPFLAGS"
506 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
508 LIBS="$LIBS $SSL_LIBS"
509 if test "$cf_enable_openssl" != no; then
510 dnl Check OpenSSL version (must be 0.9.6 or above!)
511 AC_MSG_CHECKING(for OpenSSL 0.9.6 or above)
514 [#include <openssl/opensslv.h>
515 #include <stdlib.h>],
516 [[if ( OPENSSL_VERSION_NUMBER >= 0x00906000)
517 exit(0); else exit(1);]]),
518 cf_openssl_version_ok=yes,
519 cf_openssl_version_ok=no,
520 cf_openssl_version_ok=no)
522 if test "$cf_openssl_version_ok" = yes; then
525 dnl Work around pmake/gmake conditional incompatibilities
526 AC_SUBST(ENCSPEED, encspeed)
528 dnl Do all the HAVE_LIBCRYPTO magic -- and check for ciphers
529 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
530 AC_CHECK_LIB(crypto, RSA_free)
531 SSL_LIBS="$SSL_LIBS -lcrypto"
532 SSL_SRCS_ENABLE='$(SSL_SRCS)'
534 AC_MSG_RESULT(no - OpenSSL support disabled)
538 CPPFLAGS="$save_CPPFLAGS"
541 dnl End OpenSSL detection
544 dnl Specialized functions and libraries
545 dnl ===================================
547 AC_ARG_WITH(zlib-path,
548 AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]),
549 [LIBS="$LIBS -L$withval"],)
552 AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]),
553 [zlib=$enableval],[zlib=yes])
555 if test "$zlib" = yes; then
557 AC_CHECK_HEADER(zlib.h, [
558 AC_CHECK_LIB(z, zlibVersion,
560 AC_SUBST(ZLIB_LD, -lz)
561 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.])
567 dnl IO Loop Selection
568 dnl =================
570 AC_ARG_ENABLE(ports, AC_HELP_STRING([--enable-ports],[Force solaris I/O ports subsystem usage.]),
571 [ if test $enableval = yes; then
572 SELECT_TYPE_EXPLICIT="ports"
578 AC_ARG_ENABLE(poll, AC_HELP_STRING([--enable-poll],[Force poll() usage.]),
579 [ if test $enableval = yes; then
580 SELECT_TYPE_EXPLICIT="poll"
586 AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select],[Force select() usage.]),
587 [ if test $enableval = yes; then
588 SELECT_TYPE_EXPLICIT="select"
594 AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
595 [ if test $enableval = yes; then
596 SELECT_TYPE_EXPLICIT="kqueue"
602 AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
603 [ if test $enableval = yes; then
604 SELECT_TYPE_EXPLICIT="epoll"
605 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
611 dnl **********************************************************************
612 dnl Check for --with-confdir [deprecated, use --sysconfdir instead]
613 dnl **********************************************************************
615 AC_ARG_WITH([confdir],
616 [AC_HELP_STRING([--with-confdir=DIR],
617 [Directory to install config files [deprecated, use --sysconfdir instead].])],
618 [ sysconfdir=`echo $withval | sed 's/\/$//'` ],
619 [ confdir='${sysconfdir}' ])
620 AC_DEFINE_DIR([ETC_DIR], [sysconfdir], [Prefix where config files are installed.])
622 dnl **********************************************************************
623 dnl Check for --with-logdir
624 dnl **********************************************************************
626 AC_MSG_CHECKING([whether to modify logdir])
628 AC_HELP_STRING([--with-logdir=DIR],
629 [Directory where to write logfiles.]),
630 [ logdir=`echo $withval | sed 's/\/$//'`
632 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
633 [logdir='${localstatedir}/log/${PACKAGE_TARNAME}'],
634 [logdir='${prefix}/logs'])
636 AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.])
637 AC_SUBST_DIR([logdir])
639 dnl **********************************************************************
640 dnl Check for --with-helpdir
641 dnl **********************************************************************
643 AC_MSG_CHECKING([whether to modify helpdir])
645 AC_HELP_STRING([--with-helpdir=DIR],
646 [Directory to install help files.]),
647 [ helpdir=`echo $withval | sed 's/\/$//'`
648 AC_MSG_RESULT(yes) ],
649 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
650 [helpdir='${datadir}/${PACKAGE_TARNAME}/help'],
651 [helpdir='${prefix}/help'])
653 AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.])
654 AC_SUBST_DIR([helpdir])
656 dnl **********************************************************************
657 dnl Check for --with-moduledir
658 dnl **********************************************************************
660 AC_MSG_CHECKING([whether to modify moduledir])
661 AC_ARG_WITH(moduledir,
662 [AC_HELP_STRING([--with-moduledir=DIR],
663 [Directory to install modules.])],
664 [ moduledir=`echo $withval | sed 's/\/$//'`
666 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
667 [moduledir='${pkglibdir}/modules'],
668 [moduledir='${prefix}/modules'])
671 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
672 AC_SUBST_DIR([moduledir])
674 dnl Check for --with-rundir
676 AC_MSG_CHECKING([whether or modify rundir])
677 AC_ARG_WITH([rundir],
678 [AC_HELP_STRING([--with-rundir=DIR],
679 [Directory in which to store pidfile.])],
680 [AC_MSG_RESULT([yes])
681 rundir=`echo $withval | sed 's/\/$//'`],
683 AS_IF([test "x$enable_fhs_paths" = "xyes"],
684 [rundir='${prefix}/run'],
685 [rundir='${sysconfdir}'])])
687 AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.])
689 dnl Installed utility program prefixes (does not affect binaries
690 dnl installed into pkglibexecdir)
691 AC_MSG_CHECKING([for program prefix])
692 AC_ARG_WITH([program-prefix],
693 [AS_HELP_STRING([--with-program-prefix=], [If set, programs installed into PATH will be installed with names prefixed by this prefix.])],
694 [test "x$with_program_prefix" = "xno" && with_program_prefix=],
695 [with_program_prefix=])
696 AC_MSG_RESULT(["$with_program_prefix"])
697 PROGRAM_PREFIX="$with_program_prefix"
698 AC_SUBST([PROGRAM_PREFIX])
699 AC_DEFINE_UNQUOTED([PROGRAM_PREFIX], ["$with_program_prefix"], [String with which all programs intended to be in PATH are prefixed.])
701 dnl **********************************************************************
703 dnl **********************************************************************
705 AC_MSG_CHECKING([whether custom branding is requested])
706 AC_ARG_WITH(custom-branding,
707 AC_HELP_STRING([--with-custom-branding=NAME],
708 [Custom branding name.]),
709 [BRANDING_NAME=$withval
710 AC_MSG_RESULT([yes])],
711 [BRANDING_NAME=$PACKAGE_NAME
715 AC_MSG_CHECKING([whether a custom version is requested])
716 AC_ARG_WITH(custom-version,
717 AC_HELP_STRING([--with-custom-version=NAME],
718 [Custom version branding.]),
719 [BRANDING_VERSION=$withval
720 AC_MSG_RESULT([yes])],
721 [BRANDING_VERSION=$PACKAGE_VERSION
725 AC_DEFINE_UNQUOTED(BRANDING_NAME, ["$BRANDING_NAME"], [Custom branding name.])
726 AC_DEFINE_UNQUOTED(BRANDING_VERSION, ["$BRANDING_VERSION"], [Custom branding name.])
728 if test "x$BRANDING_NAME" != "x$PACKAGE_NAME"; then
729 AC_DEFINE(CUSTOM_BRANDING, 1, [Define if custom branding is enabled.])
732 if test ! -z "$SELECT_TYPE_EXPLICIT"; then
733 SELECT_TYPE="$SELECT_TYPE_EXPLICIT";
734 echo "Forcing $SELECT_TYPE to be enabled"
737 if test ! "x$use_ports" = "xno"; then
738 AC_CHECK_FUNCS(port_getn, [haveports=yes], [haveports=no])
739 if test "x$haveports" = "xyes" ; then
744 if test ! "x$use_select" = "xno"; then
745 AC_CHECK_FUNCS(select, [haveselect=yes], [haveselect=no])
746 if test "x$haveselect" = "xyes" ; then
751 if test ! "x$use_poll" = "xno"; then
752 AC_CHECK_FUNCS(poll, [havepoll=yes], [havepoll=no])
753 if test "x$havepoll" = "xyes" ; then
758 if test ! "x$use_kqueue" = "xno"; then
759 AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
760 if test "x$havekqueue" = "xyes" ; then
765 if test ! "x$use_epoll" = "xno"; then
766 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
767 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
768 if test "x$haveepoll" = "xyes" ; then
769 AC_MSG_CHECKING(for epoll support in kernel)
772 #include <sys/param.h>
773 #include <sys/types.h>
774 #include <sys/epoll.h>
775 #include <sys/syscall.h>
779 main(int argc, char **argv)
783 epfd = epoll_create(256);
784 return (epfd == -1 ? 1 : 0);
785 }, [AC_MSG_RESULT(yes)
786 AC_DEFINE(HAVE_EPOLL, 1,
787 [Define if your system supports the epoll system calls])
788 SELECT_TYPE="epoll"],
789 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
795 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
796 if test "x$haveepoll" = "xno" ; then
797 AC_MSG_CHECKING(for epoll system call)
800 #include <sys/param.h>
801 #include <sys/types.h>
802 #include <sys/epoll.h>
803 #include <sys/syscall.h>
807 epoll_create(int size)
809 return (syscall(__NR_epoll_create, size));
813 main(int argc, char **argv)
817 epfd = epoll_create(256);
818 exit (epfd == -1 ? 1 : 0);
819 }, [AC_MSG_RESULT(yes)
820 AC_DEFINE(HAVE_EPOLL, 1,
821 [Define if your system supports the epoll system calls])
822 SELECT_TYPE="epoll"],
823 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
831 if test -z "$SELECT_TYPE"; then
832 AC_MSG_ERROR([Unable to find a usable IO interface],)
835 echo "Using $SELECT_TYPE for select loop."
837 AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE", [This is the type of IO loop we are using])
838 AC_SUBST(SELECT_TYPE)
841 dnl Debug-related options
842 dnl =====================
844 AC_ARG_ENABLE(assert,
845 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
846 [assert=$enableval], [assert=no])
848 if test "$assert" = no; then
849 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
850 elif test "$assert" = soft; then
851 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
852 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
853 elif test "$assert" = yes; then
857 AC_MSG_CHECKING(if you want IO Debugging hooks)
858 AC_ARG_ENABLE(iodebug,
859 AC_HELP_STRING([--enable-iodebug],[Enable IO Debugging hooks]),
860 [iodebug=$enableval], [iodebug=no])
862 if test "$iodebug" = yes; then
863 AC_DEFINE(USE_IODEBUG_HOOKS, 1, [Define this to enable IO Debug hooks.])
870 AC_MSG_CHECKING(if you want to do a profile build)
871 AC_ARG_ENABLE(profile,
872 AC_HELP_STRING([--enable-profile],[Enable profiling]),
873 [profile=$enableval], [profile=no])
875 if test "$profile" = yes; then
876 if test "$ac_cv_c_compiler_gnu" = yes; then
877 IRC_CFLAGS="$IRC_CFLAGS -pg"
878 AC_MSG_RESULT([yes, adding -pg])
879 AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
881 AC_MSG_RESULT([no, profile builds only work with gcc])
887 AC_ARG_ENABLE(balloc,
888 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
889 [balloc=$enableval], [balloc=yes])
891 if test "$balloc" = no; then
892 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
895 AC_ARG_ENABLE(small-net,
896 AC_HELP_STRING([--enable-small-net],[Enable small network support.]),
897 [small_net=$enableval], [small_net=no])
899 if test "$small_net" = yes; then
900 dnl AC_DEFINE([HASHSIZE], 4096, [Max number of buckets in hash tables.])
901 AC_DEFINE([NICKNAMEHISTORYLENGTH], 1500, [Size of the WHOWAS array.])
902 AC_DEFINE([CHANNEL_HEAP_SIZE], 256, [Size of the channel heap.])
903 AC_DEFINE([BAN_HEAP_SIZE], 128, [Size of the ban heap.])
904 AC_DEFINE([CLIENT_HEAP_SIZE], 256, [Size of the client heap.])
905 AC_DEFINE([LCLIENT_HEAP_SIZE], 128, [Size of the local client heap.])
906 AC_DEFINE([PCLIENT_HEAP_SIZE], 32, [Size of the pre-client heap.])
907 AC_DEFINE([USER_HEAP_SIZE], 128, [Size of the user heap.])
908 AC_DEFINE([DNODE_HEAP_SIZE], 256, [Size of the dlink_node heap.])
909 AC_DEFINE([TOPIC_HEAP_SIZE], 256, [Size of the topic heap.])
910 AC_DEFINE([LINEBUF_HEAP_SIZE], 128, [Size of the linebuf heap.])
911 AC_DEFINE([MEMBER_HEAP_SIZE], 256, [Sizeof member heap.])
912 AC_DEFINE([ND_HEAP_SIZE], 128, [Size of the nick delay heap.])
913 AC_DEFINE([CONFITEM_HEAP_SIZE], 128, [Size of the confitem heap.])
914 AC_DEFINE([MONITOR_HEAP_SIZE], 128, [Size of the monitor heap.])
915 AC_DEFINE([FD_HEAP_SIZE], 128, [Size of fd heap.])
916 AC_DEFINE([AWAY_HEAP_SIZE], 128, [Size of away heap.])
918 dnl These settings are for a large network like efnet..they will use lots of memory
919 dnl so enable small net unless you really need this much support
920 AC_DEFINE([NICKNAMEHISTORYLENGTH], 15000, [Size of the WHOWAS array.])
921 AC_DEFINE([CHANNEL_HEAP_SIZE], 8192, [Size of the channel heap.])
922 AC_DEFINE([BAN_HEAP_SIZE], 4096, [Size of the ban heap.])
923 AC_DEFINE([CLIENT_HEAP_SIZE], 8192, [Size of the client heap.])
924 AC_DEFINE([LCLIENT_HEAP_SIZE], 1024, [Size of the local client heap.])
925 AC_DEFINE([PCLIENT_HEAP_SIZE], 256, [Size of the pre-client heap.])
926 AC_DEFINE([USER_HEAP_SIZE], 8192, [Size of the user heap.])
927 AC_DEFINE([DNODE_HEAP_SIZE], 8192, [Size of the dlink_node heap.])
928 AC_DEFINE([TOPIC_HEAP_SIZE], 4096, [Size of the topic heap.])
929 AC_DEFINE([LINEBUF_HEAP_SIZE], 2048, [Size of the linebuf heap.])
930 AC_DEFINE([MEMBER_HEAP_SIZE], 32768, [Sizeof member heap.])
931 AC_DEFINE([ND_HEAP_SIZE], 512, [Size of the nick delay heap.])
932 AC_DEFINE([CONFITEM_HEAP_SIZE], 256, [Size of the confitem heap.])
933 AC_DEFINE([MONITOR_HEAP_SIZE], 1024, [Size of the monitor heap.])
934 AC_DEFINE([FD_HEAP_SIZE], 1024, [Size of fd heap.])
935 AC_DEFINE([AWAY_HEAP_SIZE], 512, [Size of away heap.])
939 AC_HELP_STRING([--with-nicklen=LENGTH],[Set the upper-bound nick length to LENGTH (default 31, max 50)]),
941 if ! expr "$withval" + 0 >/dev/null 2>&1; then
942 AC_ERROR([NICKLEN must be a numeric value])
944 if test $withval -gt 50; then
946 AC_MSG_WARN([NICKLEN has a hard limit of 50. Setting NICKLEN=50])
947 elif test $withval -lt 9; then
949 AC_MSG_WARN([NICKLEN has a lower limit of 9. Setting NICKLEN=9])
955 AC_ARG_WITH(topiclen,
956 AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
958 if test $withval -ge 390; then
960 AC_MSG_WARN([TOPICLEN has a hard limit of 390. Setting TOPICLEN=390])
966 AC_DEFINE_UNQUOTED(TOPICLEN, ${TOPICLEN}, [Maximum topic length (<=390)])
967 AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length])
970 dnl Some first-stage sanity checks.
971 if test "$shared_modules" = yes; then
972 dnl TenDRA's cc is called tcc too.
973 if test "$CC" = tcc -a "$TenDRA" = "no"; then
974 AC_MSG_WARN([disabling shared modules: Tiny C Compiler can't create PIC])
979 dnl Second stage: check for functions and headers.
980 if test "$shared_modules" = yes; then
982 AC_CHECK_HEADERS(dlfcn.h)
983 AC_SEARCH_LIBS(shl_load, dld,
985 AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if the shl_load function is available.])
987 MOD_TARGET=hpux_shared
993 AC_SEARCH_LIBS(dlopen, [dl c_r],
995 AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
997 MOD_TARGET=shared_modules
999 if test "$AppleGCC" = yes; then
1000 AC_CHECK_HEADERS([mach-o/dyld.h])
1002 AC_CHECK_FUNC(dlsym, ,
1004 AC_MSG_WARN([dlsym is not available, shared modules disabled])
1007 AC_CHECK_FUNCS(dlfunc)
1015 AC_DEFINE_UNQUOTED(SHARED_SUFFIX, "$SUFFIX", [Suffix for shared libraries on this platform.])
1017 dnl Third stage - wrangling the linker.
1018 if test "$shared_modules" = yes; then
1019 # The GNU linker requires the -export-dynamic option to make
1020 # all symbols visible in the dynamic symbol table.
1021 hold_ldflags=$LDFLAGS
1022 AC_MSG_CHECKING(for the ld -export-dynamic flag)
1023 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic -Werror"
1024 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1025 LDFLAGS=$hold_ldflags
1027 if expr "`uname -s`" : ^IRIX >/dev/null 2>&1; then
1028 found="no, IRIX ld uses -B,dynamic"
1029 LDFLAGS="${LDFLAGS} -Wl,-B,dynamic"
1032 if expr "`uname -s`" : ^AIX >/dev/null 2>&1; then
1033 found="no, AIX ld uses -G -brtl"
1034 LDFLAGS="${LDFLAGS} -Wl,-G,-brtl"
1037 AC_MSG_RESULT($found)
1039 if test "$found" = yes; then
1040 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
1043 AC_MSG_CHECKING(for compiler option to produce PIC)
1044 dnl The order should be here to check for groups of compilers,
1045 dnl then for odd compilers, then if no PICFLAGS were set up,
1046 dnl check for GCC and set defaults, or else error. -jmallett
1047 if test "$SGS" = "yes"; then
1048 AC_MSG_RESULT([SVR4 SGS interfaces: -KPIC -DPIC -G])
1049 PICFLAGS="-KPIC -DPIC -G"
1052 if test "$AppleGCC" = "yes"; then
1053 AC_MSG_RESULT([Darwin Mach-O bundles: -fno-common -bundle -flat_namespace -undefined suppress])
1054 PICFLAGS="-fno-common -bundle -flat_namespace -undefined suppress"
1056 dnl Please note, that on HPUX two different stages of module compilation occurs, since
1057 dnl while compiling modules, the compiler does not allow you to give arguments
1058 dnl to the linker. (I did not design this)
1059 dnl So we need -c in the first stage of module compilation.
1060 dnl In the second stage, we link the modules via ld -b.
1061 dnl Additionally, HPUX does not like -export-dynamic, it likes -E instead.
1063 if test "$HPUX" = "yes" -a "$CC" != gcc; then
1064 AC_MSG_RESULT(HP-UX cc: +z -r -q -n)
1065 PICFLAGS="+z -r -q -n -c"
1066 AC_MSG_CHECKING([if +ESfic is required on this platform])
1068 if expr "`$CC +ESfic 2>&1`" : ".*neither supported.*" >/dev/null; then
1072 PICFLAGS="$PICFLAGS +ESfic"
1075 LDFLAGS="${LDFLAGS} -Wl,-E"
1077 if test "$Tru" = yes -a "$CC" != gcc; then
1078 AC_MSG_RESULT([Tru64: -shared -expect_unresolved '*'])
1079 PICFLAGS="-shared -expect_unresolved '*' "
1080 LDFLAGS="-call_shared"
1082 if test -z "$PICFLAGS"; then
1083 if test "$ac_cv_c_compiler_gnu" = "yes"; then
1084 AC_MSG_RESULT(gcc: -fPIC -DPIC -shared)
1085 PICFLAGS="-fPIC -DPIC -shared"
1093 # rpath, for finding libratbox.so at run time
1094 hold_ldflags=$LDFLAGS
1095 AC_MSG_CHECKING(for the ld -rpath flag)
1096 LDFLAGS="${LDFLAGS} -Wl,-rpath=${libdir}"
1097 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1098 LDFLAGS=$hold_ldflags
1099 AC_MSG_RESULT($found)
1100 if test "$found" = yes; then
1101 LDFLAGS="${LDFLAGS} -Wl,-rpath=\${libdir}"
1104 # This must be down here, or it will mess up checks like the ones
1105 # for -Wl,-export-dynamic
1108 AC_ARG_ENABLE(warnings,
1109 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
1111 IRC_CFLAGS="$IRC_CFLAGS -O0"
1112 CFLAGS="$IRC_CFLAGS"
1114 CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
1115 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
1116 CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit)
1117 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
1118 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
1119 CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_write_strings)
1120 CHARYBDIS_C_GCC_TRY_FLAGS([-Werror-implicit-function-declaration], charybdis_cv_c_gcc_w_error_implicit_function_declaration)
1121 CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes)
1122 CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis)
1123 CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w)
1124 CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
1125 CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow)
1126 CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
1127 CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
1128 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
1129 CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_externs)
1130 CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused)
1131 CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls)
1132 CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
1133 CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wno-format-security], charybdis_cv_c_gcc_w_format)
1135 IRC_CFLAGS="$CFLAGS"
1138 if test "$shared_modules" = no; then
1140 MOD_TARGET="libmodules.a"
1141 MODULES_LIBS="../modules/libmodules.a"
1143 AC_DEFINE(STATIC_MODULES, 1, [Define to 1 if dynamic modules can't be used.])
1144 AC_MSG_WARN([shared module support has been disabled!])
1147 dnl Stage 5 - underscores in front of symbol names.
1148 if test "$shared_modules" = yes; then
1150 AC_CHECK_FUNC(nlist,,
1151 AC_CHECK_LIB(dl, nlist, nlist_lib="-ldl",
1152 AC_CHECK_LIB(elf, nlist, nlist_lib="-lelf",)
1156 dnl We need to find out whether underscores are appended to symbol
1157 dnl names in executable files. First, though, we need to see
1158 dnl where nlist.h is hiding.
1159 AC_CHECK_HEADER(libelf/nlist.h, [ nlist_h="libelf/nlist.h" ], )
1160 AC_CHECK_HEADER(elf/nlist.h, [ nlist_h="elf/nlist.h" ], )
1161 AC_CHECK_HEADER(nlist.h, [ nlist_h="nlist.h" ], )
1162 if test x"$nlist_h" = "x"; then
1163 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "", [String containing extra underscores prepended to symbols loaded from modules.])
1165 AC_MSG_CHECKING(for extra underscores prepended to symbol names)
1166 AC_CACHE_VAL(symbol_underscores,
1168 cat << EOF > conftest.c
1172 void _modinit(void);
1173 int main(int argc, char *argv[[]]) {
1175 struct nlist nl[[5]];
1177 /* fill the names in this way, so it'll work almost everywhere */
1178 nl[[0]].n_name = "_modinit";
1179 nl[[1]].n_name = "__modinit";
1180 nl[[2]].n_name = "___modinit";
1181 nl[[3]].n_name = "____modinit";
1182 nl[[0]].n_value = nl[[1]].n_value = nl[[2]].n_value = nl[[3]].n_value = nl[[4]].n_name = NULL;
1184 if(argc < 2 || (nlist(argv[[1]], nl)) == -1) exit(-1);
1185 for(i = 0; i < 4; i++) {
1186 if(nl[[i]].n_value != NULL)
1189 for(j = 0; j < i; j++)
1196 void _modinit(void) { return; }
1198 $CC $CPPFLAGS $IRC_CFLAGS -o conftest conftest.c $nlist_lib >/dev/null 2>&1
1199 symbol_underscores=`./conftest conftest`
1200 AC_MSG_RESULT($symbol_underscores)
1201 $RM -f conftest conftest.c
1203 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "${symbol_underscores}", [String containing extra underscores prepended to symbols loaded from modules.])
1207 IRC_CFLAGS="$IRC_CFLAGS $CWARNS"
1209 AC_SUBST(MODULES_LIBS)
1210 AC_SUBST(MOD_TARGET)
1212 AC_SUBST(SSL_SRCS_ENABLE)
1213 AC_SUBST(SSL_INCLUDES)
1218 AC_SUBST(IRC_CFLAGS)
1222 if test "$prefix" = "NONE"; then
1223 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
1227 dnl Don't get bitten by Cygwin's stupidity if the user specified
1228 dnl a custom prefix with a trailing slash
1230 prefix=`echo $prefix | sed 's/\/$//'`
1231 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
1239 extensions/Makefile \
1247 AC_CONFIG_COMMANDS([tools/genssl.sh_chmod], [chmod 755 tools/genssl.sh])
1251 if test "$cf_openssl_version_ok" = yes; then
1257 if test "$shared_modules" = yes; then
1264 Configuration of ${BRANDING_NAME}-${BRANDING_VERSION}:
1265 Install directory : $prefix
1269 Socket Engine : $SELECT_TYPE
1270 Small network : $small_net
1271 Block allocator : $balloc
1273 Nickname length : $NICKLEN
1274 Topic length : $TOPICLEN
1276 Use (g)make to compile $BRANDING_NAME, then (g)make install to install it.