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])
15 AC_CONFIG_MACRO_DIR([m4])
16 AC_CONFIG_HEADER(include/setup.h)
18 AC_PREFIX_DEFAULT($HOME/ircd)
23 dnl Checks for programs.
27 dnl Make sure autoconf doesn't interfere with cflags -jmallett
30 AC_CONFIG_SUBDIRS(libratbox)
32 dnl Check for various compilers. -jmallett
33 dnl But if $CC turns out to be gcc, sure as hell it's, well, gcc. -joshk
35 if test "$ac_cv_c_compiler_gnu" != yes; then
38 AC_MSG_CHECKING($CC -version for TenDRA or MIPSpro)
39 case `$CC -version 2>&1` in
41 AC_MSG_RESULT([yes, TenDRA])
43 CPPFLAGS="$CPPFLAGS -Ylonglong -Yansi -I/usr/include"
48 AC_MSG_RESULT([yes, MIPSpro])
59 AC_MSG_CHECKING([$CC -V for Sun Workshop, Forte, HPUX or Tru64 cc])
61 *Sun*WorkShop* | *Forte*Developer*)
62 AC_MSG_RESULT(Sun Workshop/Forte)
63 IRC_CFLAGS="-fast -xinline=dlinkAdd,dlinkAddBefore,dlinkAddTail,dlinkDelete,dlink_list_length,dlink_node,dlinkMoveList,_MyMalloc,_MyRealloc,_MyFree,_DupString"
68 AC_MSG_RESULT(Tru64 cc)
70 CPPFLAGS="-I/usr/local/include"
74 AC_MSG_RESULT(HPUX cc)
85 AC_MSG_CHECKING([uname -s for Solaris, AIX, HPUX or Darwin])
89 dnl only do this if we haven't already detected the newer one
90 dnl and we're not already using gcc
92 if test "$HPUX" != yes -a "$ac_cv_c_compiler_gnu" = no; then
93 AC_MSG_RESULT(assuming old HPUX with its own cc)
94 IRC_CFLAGS="$IRC_CFLAGS +e"
97 AC_MSG_RESULT(already using newer HPUX)
101 AC_MSG_RESULT(SunOS or Solaris)
102 AC_DEFINE(__EXTENSIONS__, 1, [This is needed to use strtok_r on Solaris.])
106 AC_MSG_RESULT(AIX - Sorry you poor bastard..really we are)
107 IRC_CFLAGS="$IRC_CFLAGS -Wl,-brtl -Wl,-G"
110 AC_MSG_RESULT(Darwin)
118 if test "$ac_cv_c_compiler_gnu" = yes; then
119 IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall -std=gnu99"
122 dnl If we support -g, use it!
123 if test "$ac_cv_prog_cc_g" = yes; then
124 dnl Tru64 needs -g3 for -O2
125 if test "$Tru" = yes; then
126 IRC_CFLAGS="$IRC_CFLAGS -g3"
128 IRC_CFLAGS="$IRC_CFLAGS -g"
132 dnl SVR4 SGS based on what we know about the compiler -jmallett
133 AC_MSG_CHECKING(if $CC supports the SVR4 SGS interfaces)
134 if test "$SGS" = "yes"; then
140 dnl We prefer gcc -MM because it's a lot less bloated
141 AC_PATH_PROG(MKDEP, mkdep)
142 AC_PATH_PROG(MAKEDEPEND, makedepend)
144 AC_MSG_CHECKING(how to generate dependency info)
148 if test "$ac_cv_c_compiler_gnu" = yes; then
149 AC_MSG_RESULT(gcc -MM)
151 elif test ! -z "$MKDEP"; then
154 dnl Tru64's mkdep is very loud
155 if test -z "$Tru"; then
158 STDOUT=" 2> /dev/null"
160 elif test "$SunWorkShop" = yes; then
161 AC_MSG_RESULT($CC -xM)
163 STDOUT="> .depend 2> /dev/null"
164 elif test ! -z "$MAKEDEPEND"; then
165 AC_MSG_RESULT(makedepend)
166 MKDEP="$MAKEDEPEND -f-"
168 AC_MSG_RESULT([nothing suitable.. forget it!])
175 dnl check for /dev/null so we can use it to hold evil fd's
176 AC_MSG_CHECKING([for /dev/null])
177 if test -c /dev/null ; then
178 AC_DEFINE(PATH_DEVNULL, "/dev/null", [Path to /dev/null])
181 AC_DEFINE(PATH_DEVNULL, "devnull.log", [Path to /dev/null])
182 AC_MSG_RESULT(no - using devnull.log)
185 dnl jdc -- If CFLAGS is defined, best use it everywhere...
186 dnl NOTE: jv says it must be added to the *END*, because things like
187 dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid.
188 if test ! -z "$CFLAGS"; then
189 IRC_CFLAGS="$IRC_CFLAGS $CFLAGS"
194 AC_PROG_GCC_TRADITIONAL
201 AC_PATH_PROG(SED, sed)
204 AC_PATH_PROG(RANLIB, ranlib)
205 AC_PATH_PROG(TOUCH, touch)
209 dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found
210 if test "$YACC" = "yacc" -a -z "`which $YACC 2>/dev/null`"; then
211 AC_MSG_ERROR([could not locate a suitable parser generator; install bison, yacc, or byacc])
216 if test "$LEX" = ":"; then
217 AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
220 AC_ARG_ENABLE([fhs-paths],
221 [AS_HELP_STRING([--enable-fhs-paths], [Use more FHS-like pathnames (for packagers).])],
223 [dnl detect if the user appears to want --enable-fhs-paths
224 AS_IF([test "$libexecdir" = '${exec_prefix}/libexec' && \
225 test "$localstatedir" = '${prefix}/var' && \
226 test "$libdir" = '${exec_prefix}/lib'],
227 [enable_fhs_paths=no],
228 [enable_fhs_paths=yes])
230 dnl use directory structure of cached as default (hack)
231 AS_IF([test "x$enable_fhs_paths" = "xyes"],
232 [dnl Avoid name collisions.
233 pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}'
234 rundir=${rundir-'${prefix}/run'}
235 pkgrundir='${rundir}/${PACKAGE_TARNAME}'
236 pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'],
237 [libexecdir='${bindir}'
238 pkglibexecdir='${libexecdir}'
239 rundir='${sysconfdir}'
240 pkgrundir='${rundir}'
241 localstatedir='${prefix}'
242 pkglocalstatedir='${sysconfdir}'])
243 pkglibdir='${libdir}/${PACKAGE_TARNAME}'
244 AC_SUBST([pkglibdir])
246 AC_SUBST([pkgrundir])
247 AC_SUBST([pkglocalstatedir])
248 AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as ban database]])
249 AC_SUBST([pkglibexecdir])
250 AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])
252 dnl Checks for header files.
255 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])
257 dnl Stuff that the memory manager (imalloc) depends on
258 dnl ==================================================
261 if test "$ac_cv_header_machine_endian_h" = "no" ; then
266 AC_CHECK_SIZEOF(short)
268 AC_CHECK_SIZEOF(long)
269 AC_CHECK_SIZEOF(long long)
271 dnl Networking Functions
272 dnl ====================
274 AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])])
276 dnl SunOS/Solaris required libnsl for inet_ntoa()
277 if test x"$SUN" = xyes; then
278 AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])])
281 AC_CHECK_TYPE(socklen_t, ,
282 [AC_DEFINE([socklen_t], [unsigned int],
283 [If we don't have a real socklen_t, unsigned int is good enough.])],
284 [#include <sys/types.h>
285 #include <sys/socket.h>])
288 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
290 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
292 CRYPT_LIB=$ac_cv_search_crypt
294 if test "$CRYPT_LIB" = "none required"; then
296 elif test "$CRYPT_LIB" = no; then
302 if test "$ac_cv_header_sys_wait_h" = yes -o "$ac_cv_header_wait_h" = yes; then
304 dnl We need one of the above to build viconf. Just a sanity check,
305 dnl we don't want to stop people from building the rest of ircd
306 dnl just because they can't build viconf.
313 dnl See whether we can include both string.h and strings.h.
314 AC_CACHE_CHECK([whether string.h and strings.h may both be included],
315 gcc_cv_header_string,
319 #include <strings.h>],
320 [gcc_cv_header_string=yes],
321 [gcc_cv_header_string=no])
324 if test "$gcc_cv_header_string" = "yes"; then
325 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
330 dnl Check for stdarg.h - if we can't find it, halt configure
331 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - charybdis will not compile without it **])])
333 dnl Checks for the existence of strlcat, strlcpy, basename...
334 dnl This more reliable test only works with gcc though.
336 if test "$ac_cv_c_compiler_gnu" = yes; then
338 AC_MSG_CHECKING(for strlcpy)
340 CFLAGS="$CFLAGS -Wimplicit -Werror"
344 [[#include <string.h>
345 #include <stdlib.h>]],
346 [[char *a = malloc(6);
347 strlcpy(a, "hello", 6);]]
350 AC_DEFINE(HAVE_STRLCPY, 1, [Define if strlcpy is available (most BSDs.)])],
354 AC_MSG_CHECKING(for strlcat)
357 [[#include <string.h>
358 #include <stdlib.h>]],
359 [[char *a = malloc(6);
361 strlcat(a, "hello", 6);]]
364 AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available (most BSDs.)])],
372 dnl Better than nothing. The more complicated test above probably fixes powerpc,
375 AC_CHECK_FUNCS([strlcat strlcpy])
379 AC_CHECK_TYPE([u_int32_t], [],
381 AC_CHECK_TYPE([uint32_t],
383 AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.])
386 AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int])
387 AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.])
391 AC_CHECK_TYPE([u_int16_t], [],
393 AC_CHECK_TYPE([uint16_t],
395 AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute])
398 AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int])
399 AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.])
403 AC_CHECK_TYPE([in_port_t], [],
404 [AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])],
405 [[#include <sys/types.h>
406 #include <netinet/in.h>]])
408 AC_CHECK_TYPE([sa_family_t], [],
409 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
410 [[#include <sys/types.h>
411 #include <sys/socket.h>]])
413 AC_CHECK_TYPES([uintptr_t])
415 dnl check for various functions...
416 AC_CHECK_FUNCS([socketpair vsnprintf mmap gettimeofday strdup strndup ])
420 dnl Specialized functions checks
421 dnl ============================
423 dnl check for nanosleep
424 AC_CHECK_FUNC(nanosleep,,[AC_CHECK_LIB(rt,nanosleep,
426 [AC_CHECK_LIB(posix4,nanosleep, LIBS="${LIBS} -lposix4"
428 if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_posix4_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno
430 AC_MSG_RESULT("nanosleep not found..using select for delay")
432 AC_DEFINE([HAVE_NANOSLEEP], 1, [Define if nanosleep exists])
436 AC_MSG_CHECKING(for OpenSSL)
437 AC_ARG_ENABLE(openssl,
438 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
439 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
440 [cf_enable_openssl=$enableval],
441 [cf_enable_openssl="auto"])
443 if test "$cf_enable_openssl" != "no" ; then
444 cf_openssl_basedir=""
445 if test "$cf_enable_openssl" != "auto" &&
446 test "$cf_enable_openssl" != "yes" ; then
447 dnl Support for --enable-openssl=/some/place
448 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
450 dnl Do the auto-probe here. Check some common directory paths.
451 for dirs in /usr/local/ssl /usr/pkg /usr/local \
452 /usr/local/openssl ; do
453 if test -f "${dirs}/include/openssl/opensslv.h" ; then
454 cf_openssl_basedir="${dirs}"
460 dnl Now check cf_openssl_found to see if we found anything.
461 if test ! -z "$cf_openssl_basedir"; then
462 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
463 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
464 SSL_LIBS="-L${cf_openssl_basedir}/lib"
466 dnl OpenSSL wasn't found in the directory specified. Naughty
468 cf_openssl_basedir=""
471 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
472 dnl are in /usr/include and /usr/lib. In this case, we don't want to
473 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
474 dnl We can't do this check above, because some people want two versions
475 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
476 dnl and they want /usr/local/ssl to have preference.
477 if test -f "/usr/include/openssl/opensslv.h" ; then
478 cf_openssl_basedir="/usr"
482 dnl If we have a basedir defined, then everything is okay. Otherwise,
483 dnl we have a problem.
484 if test ! -z "$cf_openssl_basedir"; then
485 AC_MSG_RESULT($cf_openssl_basedir)
486 cf_enable_openssl="yes"
488 AC_MSG_RESULT([not found. Specify a correct path?])
489 cf_enable_openssl="no"
491 unset cf_openssl_basedir
493 dnl If --disable-openssl was specified
494 AC_MSG_RESULT(disabled)
497 save_CPPFLAGS="$CPPFLAGS"
498 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
500 LIBS="$LIBS $SSL_LIBS"
501 if test "$cf_enable_openssl" != no; then
502 dnl Check OpenSSL version (must be 0.9.6 or above!)
503 AC_MSG_CHECKING(for OpenSSL 0.9.6 or above)
506 [#include <openssl/opensslv.h>
507 #include <stdlib.h>],
508 [[if ( OPENSSL_VERSION_NUMBER >= 0x00906000)
509 exit(0); else exit(1);]]),
510 cf_openssl_version_ok=yes,
511 cf_openssl_version_ok=no,
512 cf_openssl_version_ok=no)
514 if test "$cf_openssl_version_ok" = yes; then
517 dnl Work around pmake/gmake conditional incompatibilities
518 AC_SUBST(ENCSPEED, encspeed)
520 dnl Do all the HAVE_LIBCRYPTO magic -- and check for ciphers
521 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
522 AC_CHECK_LIB(crypto, RSA_free)
523 SSL_LIBS="$SSL_LIBS -lcrypto"
524 SSL_SRCS_ENABLE='$(SSL_SRCS)'
526 AC_MSG_RESULT(no - OpenSSL support disabled)
530 CPPFLAGS="$save_CPPFLAGS"
533 dnl End OpenSSL detection
536 dnl Specialized functions and libraries
537 dnl ===================================
539 AC_ARG_WITH(zlib-path,
540 AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]),
541 [LIBS="$LIBS -L$withval"],)
544 AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]),
545 [zlib=$enableval],[zlib=yes])
547 if test "$zlib" = yes; then
549 AC_CHECK_HEADER(zlib.h, [
550 AC_CHECK_LIB(z, zlibVersion,
552 AC_SUBST(ZLIB_LD, -lz)
553 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.])
559 dnl Check for shared sqlite
560 dnl ======================
561 AC_ARG_WITH(shared-sqlite,
562 AC_HELP_STRING([--with-shared-sqlite],[Use shared sqlite]),
563 [shared_sqlite=$withval],[shared_sqlite=no])
565 if test "$shared_sqlite" = yes; then
566 PKG_CHECK_MODULES(SQLITE, [sqlite3],
572 if test "$shared_sqlite" = no; then
573 SQLITE_SRC="sqlite3.c"
576 AC_SUBST(SQLITE_LD, "$SQLITE_LIBS")
577 AC_SUBST(SQLITE_INCLUDES, "$SQLITE_CFLAGS")
580 dnl IO Loop Selection
581 dnl =================
583 AC_ARG_ENABLE(ports, AC_HELP_STRING([--enable-ports],[Force solaris I/O ports subsystem usage.]),
584 [ if test $enableval = yes; then
585 SELECT_TYPE_EXPLICIT="ports"
591 AC_ARG_ENABLE(poll, AC_HELP_STRING([--enable-poll],[Force poll() usage.]),
592 [ if test $enableval = yes; then
593 SELECT_TYPE_EXPLICIT="poll"
599 AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select],[Force select() usage.]),
600 [ if test $enableval = yes; then
601 SELECT_TYPE_EXPLICIT="select"
607 AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
608 [ if test $enableval = yes; then
609 SELECT_TYPE_EXPLICIT="kqueue"
615 AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
616 [ if test $enableval = yes; then
617 SELECT_TYPE_EXPLICIT="epoll"
618 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
624 dnl **********************************************************************
625 dnl Check for --with-confdir [deprecated, use --sysconfdir instead]
626 dnl **********************************************************************
628 AC_ARG_WITH([confdir],
629 [AC_HELP_STRING([--with-confdir=DIR],
630 [Directory to install config files [deprecated, use --sysconfdir instead].])],
631 [ sysconfdir=`echo $withval | sed 's/\/$//'` ],
632 [ confdir='${sysconfdir}' ])
633 AC_DEFINE_DIR([ETC_DIR], [sysconfdir], [Prefix where config files are installed.])
635 dnl **********************************************************************
636 dnl Check for --with-logdir
637 dnl **********************************************************************
639 AC_MSG_CHECKING([whether to modify logdir])
641 AC_HELP_STRING([--with-logdir=DIR],
642 [Directory where to write logfiles.]),
643 [ logdir=`echo $withval | sed 's/\/$//'`
645 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
646 [logdir='${localstatedir}/log/${PACKAGE_TARNAME}'],
647 [logdir='${prefix}/logs'])
649 AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.])
650 AC_SUBST_DIR([logdir])
652 dnl **********************************************************************
653 dnl Check for --with-helpdir
654 dnl **********************************************************************
656 AC_MSG_CHECKING([whether to modify helpdir])
658 AC_HELP_STRING([--with-helpdir=DIR],
659 [Directory to install help files.]),
660 [ helpdir=`echo $withval | sed 's/\/$//'`
661 AC_MSG_RESULT(yes) ],
662 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
663 [helpdir='${datadir}/${PACKAGE_TARNAME}/help'],
664 [helpdir='${prefix}/help'])
666 AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.])
667 AC_SUBST_DIR([helpdir])
669 dnl **********************************************************************
670 dnl Check for --with-moduledir
671 dnl **********************************************************************
673 AC_MSG_CHECKING([whether to modify moduledir])
674 AC_ARG_WITH(moduledir,
675 [AC_HELP_STRING([--with-moduledir=DIR],
676 [Directory to install modules.])],
677 [ moduledir=`echo $withval | sed 's/\/$//'`
679 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
680 [moduledir='${pkglibdir}/modules'],
681 [moduledir='${prefix}/modules'])
684 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
685 AC_SUBST_DIR([moduledir])
687 dnl Check for --with-rundir
689 AC_MSG_CHECKING([whether or modify rundir])
690 AC_ARG_WITH([rundir],
691 [AC_HELP_STRING([--with-rundir=DIR],
692 [Directory in which to store pidfile.])],
693 [AC_MSG_RESULT([yes])
694 rundir=`echo $withval | sed 's/\/$//'`],
696 AS_IF([test "x$enable_fhs_paths" = "xyes"],
697 [rundir='${prefix}/run'],
698 [rundir='${sysconfdir}'])])
700 AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.])
702 dnl Installed utility program prefixes (does not affect binaries
703 dnl installed into pkglibexecdir)
704 AC_MSG_CHECKING([for program prefix])
705 AC_ARG_WITH([program-prefix],
706 [AS_HELP_STRING([--with-program-prefix=], [If set, programs installed into PATH will be installed with names prefixed by this prefix.])],
707 [test "x$with_program_prefix" = "xno" && with_program_prefix=],
708 [with_program_prefix=])
709 AC_MSG_RESULT(["$with_program_prefix"])
710 PROGRAM_PREFIX="$with_program_prefix"
711 AC_SUBST([PROGRAM_PREFIX])
712 AC_DEFINE_UNQUOTED([PROGRAM_PREFIX], ["$with_program_prefix"], [String with which all programs intended to be in PATH are prefixed.])
714 dnl **********************************************************************
716 dnl **********************************************************************
718 AC_MSG_CHECKING([whether custom branding is requested])
719 AC_ARG_WITH(custom-branding,
720 AC_HELP_STRING([--with-custom-branding=NAME],
721 [Custom branding name.]),
722 [BRANDING_NAME=$withval
723 AC_MSG_RESULT([yes])],
724 [BRANDING_NAME=$PACKAGE_NAME
728 AC_MSG_CHECKING([whether a custom version is requested])
729 AC_ARG_WITH(custom-version,
730 AC_HELP_STRING([--with-custom-version=NAME],
731 [Custom version branding.]),
732 [BRANDING_VERSION=$withval
733 AC_MSG_RESULT([yes])],
734 [BRANDING_VERSION=$PACKAGE_VERSION
738 AC_DEFINE_UNQUOTED(BRANDING_NAME, ["$BRANDING_NAME"], [Custom branding name.])
739 AC_DEFINE_UNQUOTED(BRANDING_VERSION, ["$BRANDING_VERSION"], [Custom branding name.])
741 if test "x$BRANDING_NAME" != "x$PACKAGE_NAME"; then
742 AC_DEFINE(CUSTOM_BRANDING, 1, [Define if custom branding is enabled.])
745 if test ! -z "$SELECT_TYPE_EXPLICIT"; then
746 SELECT_TYPE="$SELECT_TYPE_EXPLICIT";
747 echo "Forcing $SELECT_TYPE to be enabled"
750 if test ! "x$use_ports" = "xno"; then
751 AC_CHECK_FUNCS(port_getn, [haveports=yes], [haveports=no])
752 if test "x$haveports" = "xyes" ; then
757 if test ! "x$use_select" = "xno"; then
758 AC_CHECK_FUNCS(select, [haveselect=yes], [haveselect=no])
759 if test "x$haveselect" = "xyes" ; then
764 if test ! "x$use_poll" = "xno"; then
765 AC_CHECK_FUNCS(poll, [havepoll=yes], [havepoll=no])
766 if test "x$havepoll" = "xyes" ; then
771 if test ! "x$use_kqueue" = "xno"; then
772 AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
773 if test "x$havekqueue" = "xyes" ; then
778 if test ! "x$use_epoll" = "xno"; then
779 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
780 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
781 if test "x$haveepoll" = "xyes" ; then
782 AC_MSG_CHECKING(for epoll support in kernel)
785 #include <sys/param.h>
786 #include <sys/types.h>
787 #include <sys/epoll.h>
788 #include <sys/syscall.h>
792 main(int argc, char **argv)
796 epfd = epoll_create(256);
797 return (epfd == -1 ? 1 : 0);
798 }, [AC_MSG_RESULT(yes)
799 AC_DEFINE(HAVE_EPOLL, 1,
800 [Define if your system supports the epoll system calls])
801 SELECT_TYPE="epoll"],
802 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
808 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
809 if test "x$haveepoll" = "xno" ; then
810 AC_MSG_CHECKING(for epoll system call)
813 #include <sys/param.h>
814 #include <sys/types.h>
815 #include <sys/epoll.h>
816 #include <sys/syscall.h>
820 epoll_create(int size)
822 return (syscall(__NR_epoll_create, size));
826 main(int argc, char **argv)
830 epfd = epoll_create(256);
831 exit (epfd == -1 ? 1 : 0);
832 }, [AC_MSG_RESULT(yes)
833 AC_DEFINE(HAVE_EPOLL, 1,
834 [Define if your system supports the epoll system calls])
835 SELECT_TYPE="epoll"],
836 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
844 if test -z "$SELECT_TYPE"; then
845 AC_MSG_ERROR([Unable to find a usable IO interface],)
848 echo "Using $SELECT_TYPE for select loop."
850 AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE", [This is the type of IO loop we are using])
851 AC_SUBST(SELECT_TYPE)
854 dnl Debug-related options
855 dnl =====================
857 AC_ARG_ENABLE(assert,
858 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
859 [assert=$enableval], [assert=no])
861 if test "$assert" = no; then
862 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
863 elif test "$assert" = soft; then
864 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
865 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
866 elif test "$assert" = yes; then
870 AC_MSG_CHECKING(if you want IO Debugging hooks)
871 AC_ARG_ENABLE(iodebug,
872 AC_HELP_STRING([--enable-iodebug],[Enable IO Debugging hooks]),
873 [iodebug=$enableval], [iodebug=no])
875 if test "$iodebug" = yes; then
876 AC_DEFINE(USE_IODEBUG_HOOKS, 1, [Define this to enable IO Debug hooks.])
883 AC_MSG_CHECKING(if you want to do a profile build)
884 AC_ARG_ENABLE(profile,
885 AC_HELP_STRING([--enable-profile],[Enable profiling]),
886 [profile=$enableval], [profile=no])
888 if test "$profile" = yes; then
889 if test "$ac_cv_c_compiler_gnu" = yes; then
890 IRC_CFLAGS="$IRC_CFLAGS -pg"
891 AC_MSG_RESULT([yes, adding -pg])
892 AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
894 AC_MSG_RESULT([no, profile builds only work with gcc])
900 AC_ARG_ENABLE(balloc,
901 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
902 [balloc=$enableval], [balloc=yes])
904 if test "$balloc" = no; then
905 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
908 AC_ARG_ENABLE(small-net,
909 AC_HELP_STRING([--enable-small-net],[Enable small network support.]),
910 [small_net=$enableval], [small_net=no])
912 if test "$small_net" = yes; then
913 dnl AC_DEFINE([HASHSIZE], 4096, [Max number of buckets in hash tables.])
914 AC_DEFINE([NICKNAMEHISTORYLENGTH], 1500, [Size of the WHOWAS array.])
915 AC_DEFINE([CHANNEL_HEAP_SIZE], 256, [Size of the channel heap.])
916 AC_DEFINE([BAN_HEAP_SIZE], 128, [Size of the ban heap.])
917 AC_DEFINE([CLIENT_HEAP_SIZE], 256, [Size of the client heap.])
918 AC_DEFINE([LCLIENT_HEAP_SIZE], 128, [Size of the local client heap.])
919 AC_DEFINE([PCLIENT_HEAP_SIZE], 32, [Size of the pre-client heap.])
920 AC_DEFINE([USER_HEAP_SIZE], 128, [Size of the user heap.])
921 AC_DEFINE([DNODE_HEAP_SIZE], 256, [Size of the dlink_node heap.])
922 AC_DEFINE([TOPIC_HEAP_SIZE], 256, [Size of the topic heap.])
923 AC_DEFINE([LINEBUF_HEAP_SIZE], 128, [Size of the linebuf heap.])
924 AC_DEFINE([MEMBER_HEAP_SIZE], 256, [Sizeof member heap.])
925 AC_DEFINE([ND_HEAP_SIZE], 128, [Size of the nick delay heap.])
926 AC_DEFINE([CONFITEM_HEAP_SIZE], 128, [Size of the confitem heap.])
927 AC_DEFINE([MONITOR_HEAP_SIZE], 128, [Size of the monitor heap.])
928 AC_DEFINE([FD_HEAP_SIZE], 128, [Size of fd heap.])
929 AC_DEFINE([AWAY_HEAP_SIZE], 128, [Size of away 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.])
947 AC_DEFINE([FD_HEAP_SIZE], 1024, [Size of fd heap.])
948 AC_DEFINE([AWAY_HEAP_SIZE], 512, [Size of away heap.])
952 AC_HELP_STRING([--with-nicklen=LENGTH],[Set the upper-bound nick length to LENGTH (default 31, max 50)]),
954 if ! expr "$withval" + 0 >/dev/null 2>&1; then
955 AC_ERROR([NICKLEN must be a numeric value])
957 if test $withval -gt 50; then
959 AC_MSG_WARN([NICKLEN has a hard limit of 50. Setting NICKLEN=50])
960 elif test $withval -lt 9; then
962 AC_MSG_WARN([NICKLEN has a lower limit of 9. Setting NICKLEN=9])
968 AC_ARG_WITH(topiclen,
969 AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
971 if test $withval -ge 390; then
973 AC_MSG_WARN([TOPICLEN has a hard limit of 390. Setting TOPICLEN=390])
979 AC_DEFINE_UNQUOTED(TOPICLEN, ${TOPICLEN}, [Maximum topic length (<=390)])
980 AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length])
983 dnl Some first-stage sanity checks.
984 if test "$shared_modules" = yes; then
985 dnl TenDRA's cc is called tcc too.
986 if test "$CC" = tcc -a "$TenDRA" = "no"; then
987 AC_MSG_WARN([disabling shared modules: Tiny C Compiler can't create PIC])
992 dnl Second stage: check for functions and headers.
993 if test "$shared_modules" = yes; then
995 AC_CHECK_HEADERS(dlfcn.h)
996 AC_SEARCH_LIBS(shl_load, dld,
998 AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if the shl_load function is available.])
1000 MOD_TARGET=hpux_shared
1001 SEDOBJ="s/\.o/.sl/g"
1006 AC_SEARCH_LIBS(dlopen, [dl c_r],
1008 AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
1010 MOD_TARGET=shared_modules
1011 SEDOBJ="s/\.o/.so/g"
1012 if test "$AppleGCC" = yes; then
1013 AC_CHECK_HEADERS([mach-o/dyld.h])
1015 AC_CHECK_FUNC(dlsym, ,
1017 AC_MSG_WARN([dlsym is not available, shared modules disabled])
1020 AC_CHECK_FUNCS(dlfunc)
1028 AC_DEFINE_UNQUOTED(SHARED_SUFFIX, "$SUFFIX", [Suffix for shared libraries on this platform.])
1030 dnl Third stage - wrangling the linker.
1031 if test "$shared_modules" = yes; then
1032 # The GNU linker requires the -export-dynamic option to make
1033 # all symbols visible in the dynamic symbol table.
1034 hold_ldflags=$LDFLAGS
1035 AC_MSG_CHECKING(for the ld -export-dynamic flag)
1036 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic -Werror"
1037 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1038 LDFLAGS=$hold_ldflags
1040 if expr "`uname -s`" : ^IRIX >/dev/null 2>&1; then
1041 found="no, IRIX ld uses -B,dynamic"
1042 LDFLAGS="${LDFLAGS} -Wl,-B,dynamic"
1045 if expr "`uname -s`" : ^AIX >/dev/null 2>&1; then
1046 found="no, AIX ld uses -G -brtl"
1047 LDFLAGS="${LDFLAGS} -Wl,-G,-brtl"
1050 AC_MSG_RESULT($found)
1052 if test "$found" = yes; then
1053 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
1056 AC_MSG_CHECKING(for compiler option to produce PIC)
1057 dnl The order should be here to check for groups of compilers,
1058 dnl then for odd compilers, then if no PICFLAGS were set up,
1059 dnl check for GCC and set defaults, or else error. -jmallett
1060 if test "$SGS" = "yes"; then
1061 AC_MSG_RESULT([SVR4 SGS interfaces: -KPIC -DPIC -G])
1062 PICFLAGS="-KPIC -DPIC -G"
1065 if test "$AppleGCC" = "yes"; then
1066 AC_MSG_RESULT([Darwin Mach-O bundles: -fno-common -bundle -flat_namespace -undefined suppress])
1067 PICFLAGS="-fno-common -bundle -flat_namespace -undefined suppress"
1069 dnl Please note, that on HPUX two different stages of module compilation occurs, since
1070 dnl while compiling modules, the compiler does not allow you to give arguments
1071 dnl to the linker. (I did not design this)
1072 dnl So we need -c in the first stage of module compilation.
1073 dnl In the second stage, we link the modules via ld -b.
1074 dnl Additionally, HPUX does not like -export-dynamic, it likes -E instead.
1076 if test "$HPUX" = "yes" -a "$CC" != gcc; then
1077 AC_MSG_RESULT(HP-UX cc: +z -r -q -n)
1078 PICFLAGS="+z -r -q -n -c"
1079 AC_MSG_CHECKING([if +ESfic is required on this platform])
1081 if expr "`$CC +ESfic 2>&1`" : ".*neither supported.*" >/dev/null; then
1085 PICFLAGS="$PICFLAGS +ESfic"
1088 LDFLAGS="${LDFLAGS} -Wl,-E"
1090 if test "$Tru" = yes -a "$CC" != gcc; then
1091 AC_MSG_RESULT([Tru64: -shared -expect_unresolved '*'])
1092 PICFLAGS="-shared -expect_unresolved '*' "
1093 LDFLAGS="-call_shared"
1095 if test -z "$PICFLAGS"; then
1096 if test "$ac_cv_c_compiler_gnu" = "yes"; then
1097 AC_MSG_RESULT(gcc: -fPIC -DPIC -shared)
1098 PICFLAGS="-fPIC -DPIC -shared"
1106 # rpath, for finding libratbox.so at run time
1107 hold_ldflags=$LDFLAGS
1108 AC_MSG_CHECKING(for the ld -rpath flag)
1109 LDFLAGS="${LDFLAGS} -Wl,-rpath=${libdir}"
1110 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1111 LDFLAGS=$hold_ldflags
1112 AC_MSG_RESULT($found)
1113 if test "$found" = yes; then
1114 LDFLAGS="${LDFLAGS} -Wl,-rpath=\${libdir}"
1117 # This must be down here, or it will mess up checks like the ones
1118 # for -Wl,-export-dynamic
1121 AC_ARG_ENABLE(warnings,
1122 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
1124 IRC_CFLAGS="$IRC_CFLAGS -O0"
1125 CFLAGS="$IRC_CFLAGS"
1127 CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
1128 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
1129 CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit)
1130 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
1131 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
1132 CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_write_strings)
1133 CHARYBDIS_C_GCC_TRY_FLAGS([-Werror-implicit-function-declaration], charybdis_cv_c_gcc_w_error_implicit_function_declaration)
1134 CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes)
1135 CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis)
1136 CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w)
1137 CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
1138 CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow)
1139 CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
1140 CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
1141 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
1142 CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_externs)
1143 CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused)
1144 CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls)
1145 CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
1146 CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wno-format-security], charybdis_cv_c_gcc_w_format)
1148 IRC_CFLAGS="$CFLAGS"
1151 if test "$shared_modules" = no; then
1153 MOD_TARGET="libmodules.a"
1154 MODULES_LIBS="../modules/libmodules.a"
1156 AC_DEFINE(STATIC_MODULES, 1, [Define to 1 if dynamic modules can't be used.])
1157 AC_MSG_WARN([shared module support has been disabled!])
1160 dnl Stage 5 - underscores in front of symbol names.
1161 if test "$shared_modules" = yes; then
1163 AC_CHECK_FUNC(nlist,,
1164 AC_CHECK_LIB(dl, nlist, nlist_lib="-ldl",
1165 AC_CHECK_LIB(elf, nlist, nlist_lib="-lelf",)
1169 dnl We need to find out whether underscores are appended to symbol
1170 dnl names in executable files. First, though, we need to see
1171 dnl where nlist.h is hiding.
1172 AC_CHECK_HEADER(libelf/nlist.h, [ nlist_h="libelf/nlist.h" ], )
1173 AC_CHECK_HEADER(elf/nlist.h, [ nlist_h="elf/nlist.h" ], )
1174 AC_CHECK_HEADER(nlist.h, [ nlist_h="nlist.h" ], )
1175 if test x"$nlist_h" = "x"; then
1176 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "", [String containing extra underscores prepended to symbols loaded from modules.])
1178 AC_MSG_CHECKING(for extra underscores prepended to symbol names)
1179 AC_CACHE_VAL(symbol_underscores,
1181 cat << EOF > conftest.c
1185 void _modinit(void);
1186 int main(int argc, char *argv[[]]) {
1188 struct nlist nl[[5]];
1190 /* fill the names in this way, so it'll work almost everywhere */
1191 nl[[0]].n_name = "_modinit";
1192 nl[[1]].n_name = "__modinit";
1193 nl[[2]].n_name = "___modinit";
1194 nl[[3]].n_name = "____modinit";
1195 nl[[0]].n_value = nl[[1]].n_value = nl[[2]].n_value = nl[[3]].n_value = nl[[4]].n_name = NULL;
1197 if(argc < 2 || (nlist(argv[[1]], nl)) == -1) exit(-1);
1198 for(i = 0; i < 4; i++) {
1199 if(nl[[i]].n_value != NULL)
1202 for(j = 0; j < i; j++)
1209 void _modinit(void) { return; }
1211 $CC $CPPFLAGS $IRC_CFLAGS -o conftest conftest.c $nlist_lib >/dev/null 2>&1
1212 symbol_underscores=`./conftest conftest`
1213 AC_MSG_RESULT($symbol_underscores)
1214 $RM -f conftest conftest.c
1216 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "${symbol_underscores}", [String containing extra underscores prepended to symbols loaded from modules.])
1220 IRC_CFLAGS="$IRC_CFLAGS $CWARNS"
1222 AC_SUBST(MODULES_LIBS)
1223 AC_SUBST(MOD_TARGET)
1225 AC_SUBST(SSL_SRCS_ENABLE)
1226 AC_SUBST(SSL_INCLUDES)
1231 AC_SUBST(IRC_CFLAGS)
1235 if test "$prefix" = "NONE"; then
1236 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
1240 dnl Don't get bitten by Cygwin's stupidity if the user specified
1241 dnl a custom prefix with a trailing slash
1243 prefix=`echo $prefix | sed 's/\/$//'`
1244 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
1252 extensions/Makefile \
1260 AC_CONFIG_COMMANDS([tools/genssl_chmod], [chmod 755 tools/genssl])
1264 if test "$cf_openssl_version_ok" = yes; then
1270 if test "$shared_modules" = yes; then
1277 Configuration of ${BRANDING_NAME}-${BRANDING_VERSION}:
1278 Install directory : $prefix
1282 Socket Engine : $SELECT_TYPE
1283 Small network : $small_net
1284 Block allocator : $balloc
1286 Nickname length : $NICKLEN
1287 Topic length : $TOPICLEN
1289 Use (g)make to compile $BRANDING_NAME, then (g)make install to install it.