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_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 or HPUX])
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"
114 if test "$ac_cv_c_compiler_gnu" = yes; then
115 AC_MSG_CHECKING(if $CC is Apple GCC)
117 case `$CC -v 2>&1 | tail -n 1` in
128 IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall -std=gnu99"
131 dnl If we support -g, use it!
132 if test "$ac_cv_prog_cc_g" = yes; then
133 dnl Tru64 needs -g3 for -O2
134 if test "$Tru" = yes; then
135 IRC_CFLAGS="$IRC_CFLAGS -g3"
137 IRC_CFLAGS="$IRC_CFLAGS -g"
141 dnl SVR4 SGS based on what we know about the compiler -jmallett
142 AC_MSG_CHECKING(if $CC supports the SVR4 SGS interfaces)
143 if test "$SGS" = "yes"; then
149 dnl We prefer gcc -MM because it's a lot less bloated
150 AC_PATH_PROG(MKDEP, mkdep)
151 AC_PATH_PROG(MAKEDEPEND, makedepend)
153 AC_MSG_CHECKING(how to generate dependency info)
157 if test "$ac_cv_c_compiler_gnu" = yes; then
158 AC_MSG_RESULT(gcc -MM)
160 elif test ! -z "$MKDEP"; then
163 dnl Tru64's mkdep is very loud
164 if test -z "$Tru"; then
167 STDOUT=" 2> /dev/null"
169 elif test "$SunWorkShop" = yes; then
170 AC_MSG_RESULT($CC -xM)
172 STDOUT="> .depend 2> /dev/null"
173 elif test ! -z "$MAKEDEPEND"; then
174 AC_MSG_RESULT(makedepend)
175 MKDEP="$MAKEDEPEND -f-"
177 AC_MSG_RESULT([nothing suitable.. forget it!])
184 dnl check for /dev/null so we can use it to hold evil fd's
185 AC_MSG_CHECKING([for /dev/null])
186 if test -c /dev/null ; then
187 AC_DEFINE(PATH_DEVNULL, "/dev/null", [Path to /dev/null])
190 AC_DEFINE(PATH_DEVNULL, "devnull.log", [Path to /dev/null])
191 AC_MSG_RESULT(no - using devnull.log)
194 dnl jdc -- If CFLAGS is defined, best use it everywhere...
195 dnl NOTE: jv says it must be added to the *END*, because things like
196 dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid.
197 if test ! -z "$CFLAGS"; then
198 IRC_CFLAGS="$IRC_CFLAGS $CFLAGS"
203 AC_PROG_GCC_TRADITIONAL
210 AC_PATH_PROG(SED, sed)
213 AC_PATH_PROG(RANLIB, ranlib)
214 AC_PATH_PROG(TOUCH, touch)
218 dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found
219 if test "$YACC" = "yacc" -a -z "`which $YACC 2>/dev/null`"; then
220 AC_MSG_ERROR([could not locate a suitable parser generator; install bison, yacc, or byacc])
225 if test "$LEX" = ":"; then
226 AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
229 AC_ARG_ENABLE([fhs-paths],
230 [AS_HELP_STRING([--enable-fhs-paths], [Use more FHS-like pathnames (for packagers).])],
232 [dnl detect if the user appears to want --enable-fhs-paths
233 AS_IF([test "$libexecdir" = '${exec_prefix}/libexec' && \
234 test "$localstatedir" = '${prefix}/var' && \
235 test "$libdir" = '${exec_prefix}/lib'],
236 [enable_fhs_paths=no],
237 [enable_fhs_paths=yes])
239 dnl use directory structure of cached as default (hack)
240 AS_IF([test "x$enable_fhs_paths" = "xyes"],
241 [dnl Avoid name collisions.
242 pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}'
243 rundir=${rundir-'${prefix}/run'}
244 pkgrundir='${rundir}/${PACKAGE_TARNAME}'
245 pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'],
246 [libexecdir='${bindir}'
247 pkglibexecdir='${libexecdir}'
248 rundir='${sysconfdir}'
249 pkgrundir='${rundir}'
250 localstatedir='${prefix}'
251 pkglocalstatedir='${sysconfdir}'])
252 pkglibdir='${libdir}/${PACKAGE_TARNAME}'
253 AC_SUBST([pkglibdir])
255 AC_SUBST([pkgrundir])
256 AC_SUBST([pkglocalstatedir])
257 AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as ban database]])
258 AC_SUBST([pkglibexecdir])
259 AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])
261 dnl Checks for header files.
264 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])
266 dnl Stuff that the memory manager (imalloc) depends on
267 dnl ==================================================
270 if test "$ac_cv_header_machine_endian_h" = "no" ; then
275 AC_CHECK_SIZEOF(short)
277 AC_CHECK_SIZEOF(long)
278 AC_CHECK_SIZEOF(long long)
280 dnl Networking Functions
281 dnl ====================
283 AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])])
285 dnl SunOS/Solaris required libnsl for inet_ntoa()
286 if test x"$SUN" = xyes; then
287 AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])])
290 AC_CHECK_TYPE(socklen_t, ,
291 [AC_DEFINE([socklen_t], [unsigned int],
292 [If we don't have a real socklen_t, unsigned int is good enough.])],
293 [#include <sys/types.h>
294 #include <sys/socket.h>])
297 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
299 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
301 CRYPT_LIB=$ac_cv_search_crypt
303 if test "$CRYPT_LIB" = "none required"; then
305 elif test "$CRYPT_LIB" = no; then
311 if test "$ac_cv_header_sys_wait_h" = yes -o "$ac_cv_header_wait_h" = yes; then
313 dnl We need one of the above to build viconf. Just a sanity check,
314 dnl we don't want to stop people from building the rest of ircd
315 dnl just because they can't build viconf.
322 dnl See whether we can include both string.h and strings.h.
323 AC_CACHE_CHECK([whether string.h and strings.h may both be included],
324 gcc_cv_header_string,
328 #include <strings.h>],
329 [gcc_cv_header_string=yes],
330 [gcc_cv_header_string=no])
333 if test "$gcc_cv_header_string" = "yes"; then
334 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
339 dnl Check for stdarg.h - if we can't find it, halt configure
340 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - charybdis will not compile without it **])])
342 dnl Checks for the existence of strlcat, strlcpy, basename...
343 dnl This more reliable test only works with gcc though.
345 if test "$ac_cv_c_compiler_gnu" = yes; then
347 AC_MSG_CHECKING(for strlcpy)
349 CFLAGS="$CFLAGS -Wimplicit -Werror"
353 [[#include <string.h>
354 #include <stdlib.h>]],
355 [[char *a = malloc(6);
356 strlcpy(a, "hello", 6);]]
359 AC_DEFINE(HAVE_STRLCPY, 1, [Define if strlcpy is available (most BSDs.)])],
363 AC_MSG_CHECKING(for strlcat)
366 [[#include <string.h>
367 #include <stdlib.h>]],
368 [[char *a = malloc(6);
370 strlcat(a, "hello", 6);]]
373 AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available (most BSDs.)])],
381 dnl Better than nothing. The more complicated test above probably fixes powerpc,
384 AC_CHECK_FUNCS([strlcat strlcpy])
388 AC_CHECK_TYPE([u_int32_t], [],
390 AC_CHECK_TYPE([uint32_t],
392 AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.])
395 AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int])
396 AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.])
400 AC_CHECK_TYPE([u_int16_t], [],
402 AC_CHECK_TYPE([uint16_t],
404 AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute])
407 AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int])
408 AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.])
412 AC_CHECK_TYPE([in_port_t], [],
413 [AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])],
414 [[#include <sys/types.h>
415 #include <netinet/in.h>]])
417 AC_CHECK_TYPE([sa_family_t], [],
418 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
419 [[#include <sys/types.h>
420 #include <sys/socket.h>]])
422 AC_CHECK_TYPES([uintptr_t])
424 dnl check for various functions...
425 AC_CHECK_FUNCS([socketpair vsnprintf mmap gettimeofday strdup strndup ])
429 dnl Specialized functions checks
430 dnl ============================
432 dnl check for nanosleep
433 AC_CHECK_FUNC(nanosleep,,[AC_CHECK_LIB(rt,nanosleep,
435 [AC_CHECK_LIB(posix4,nanosleep, LIBS="${LIBS} -lposix4"
437 if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_posix4_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno
439 AC_MSG_RESULT("nanosleep not found..using select for delay")
441 AC_DEFINE([HAVE_NANOSLEEP], 1, [Define if nanosleep exists])
445 AC_MSG_CHECKING(for OpenSSL)
446 AC_ARG_ENABLE(openssl,
447 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
448 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
449 [cf_enable_openssl=$enableval],
450 [cf_enable_openssl="auto"])
452 if test "$cf_enable_openssl" != "no" ; then
453 cf_openssl_basedir=""
454 if test "$cf_enable_openssl" != "auto" &&
455 test "$cf_enable_openssl" != "yes" ; then
456 dnl Support for --enable-openssl=/some/place
457 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
459 dnl Do the auto-probe here. Check some common directory paths.
460 for dirs in /usr/local/ssl /usr/pkg /usr/local \
461 /usr/local/openssl ; do
462 if test -f "${dirs}/include/openssl/opensslv.h" ; then
463 cf_openssl_basedir="${dirs}"
469 dnl Now check cf_openssl_found to see if we found anything.
470 if test ! -z "$cf_openssl_basedir"; then
471 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
472 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
473 SSL_LIBS="-L${cf_openssl_basedir}/lib"
475 dnl OpenSSL wasn't found in the directory specified. Naughty
477 cf_openssl_basedir=""
480 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
481 dnl are in /usr/include and /usr/lib. In this case, we don't want to
482 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
483 dnl We can't do this check above, because some people want two versions
484 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
485 dnl and they want /usr/local/ssl to have preference.
486 if test -f "/usr/include/openssl/opensslv.h" ; then
487 cf_openssl_basedir="/usr"
491 dnl If we have a basedir defined, then everything is okay. Otherwise,
492 dnl we have a problem.
493 if test ! -z "$cf_openssl_basedir"; then
494 AC_MSG_RESULT($cf_openssl_basedir)
495 cf_enable_openssl="yes"
497 AC_MSG_RESULT([not found. Specify a correct path?])
498 cf_enable_openssl="no"
500 unset cf_openssl_basedir
502 dnl If --disable-openssl was specified
503 AC_MSG_RESULT(disabled)
506 save_CPPFLAGS="$CPPFLAGS"
507 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
509 LIBS="$LIBS $SSL_LIBS"
510 if test "$cf_enable_openssl" != no; then
511 dnl Check OpenSSL version (must be 0.9.6 or above!)
512 AC_MSG_CHECKING(for OpenSSL 0.9.6 or above)
515 [#include <openssl/opensslv.h>
516 #include <stdlib.h>],
517 [[if ( OPENSSL_VERSION_NUMBER >= 0x00906000)
518 exit(0); else exit(1);]]),
519 cf_openssl_version_ok=yes,
520 cf_openssl_version_ok=no,
521 cf_openssl_version_ok=no)
523 if test "$cf_openssl_version_ok" = yes; then
526 dnl Work around pmake/gmake conditional incompatibilities
527 AC_SUBST(ENCSPEED, encspeed)
529 dnl Do all the HAVE_LIBCRYPTO magic -- and check for ciphers
530 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
531 AC_CHECK_LIB(crypto, RSA_free)
532 SSL_LIBS="$SSL_LIBS -lcrypto"
533 SSL_SRCS_ENABLE='$(SSL_SRCS)'
535 AC_MSG_RESULT(no - OpenSSL support disabled)
539 CPPFLAGS="$save_CPPFLAGS"
542 dnl End OpenSSL detection
545 dnl Specialized functions and libraries
546 dnl ===================================
548 AC_ARG_WITH(zlib-path,
549 AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]),
550 [LIBS="$LIBS -L$withval"],)
553 AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]),
554 [zlib=$enableval],[zlib=yes])
556 if test "$zlib" = yes; then
558 AC_CHECK_HEADER(zlib.h, [
559 AC_CHECK_LIB(z, zlibVersion,
561 AC_SUBST(ZLIB_LD, -lz)
562 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.])
568 dnl Check for shared sqlite
569 dnl ======================
570 AC_ARG_WITH(shared-sqlite,
571 AC_HELP_STRING([--with-shared-sqlite],[Use shared sqlite]),
572 [shared_sqlite=$withval],[shared_sqlite=no])
574 if test "$shared_sqlite" = yes; then
575 PKG_CHECK_MODULES(SQLITE, [sqlite3],
581 if test "$shared_sqlite" = no; then
582 SQLITE_SRC="sqlite3.c"
585 AC_SUBST(SQLITE_LD, "$SQLITE_LIBS")
586 AC_SUBST(SQLITE_INCLUDES, "$SQLITE_CFLAGS")
589 dnl IO Loop Selection
590 dnl =================
592 AC_ARG_ENABLE(ports, AC_HELP_STRING([--enable-ports],[Force solaris I/O ports subsystem usage.]),
593 [ if test $enableval = yes; then
594 SELECT_TYPE_EXPLICIT="ports"
600 AC_ARG_ENABLE(poll, AC_HELP_STRING([--enable-poll],[Force poll() usage.]),
601 [ if test $enableval = yes; then
602 SELECT_TYPE_EXPLICIT="poll"
608 AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select],[Force select() usage.]),
609 [ if test $enableval = yes; then
610 SELECT_TYPE_EXPLICIT="select"
616 AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
617 [ if test $enableval = yes; then
618 SELECT_TYPE_EXPLICIT="kqueue"
624 AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
625 [ if test $enableval = yes; then
626 SELECT_TYPE_EXPLICIT="epoll"
627 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
633 dnl **********************************************************************
634 dnl Check for --with-confdir [deprecated, use --sysconfdir instead]
635 dnl **********************************************************************
637 AC_ARG_WITH([confdir],
638 [AC_HELP_STRING([--with-confdir=DIR],
639 [Directory to install config files [deprecated, use --sysconfdir instead].])],
640 [ sysconfdir=`echo $withval | sed 's/\/$//'` ],
641 [ confdir='${sysconfdir}' ])
642 AC_DEFINE_DIR([ETC_DIR], [sysconfdir], [Prefix where config files are installed.])
644 dnl **********************************************************************
645 dnl Check for --with-logdir
646 dnl **********************************************************************
648 AC_MSG_CHECKING([whether to modify logdir])
650 AC_HELP_STRING([--with-logdir=DIR],
651 [Directory where to write logfiles.]),
652 [ logdir=`echo $withval | sed 's/\/$//'`
654 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
655 [logdir='${localstatedir}/log/${PACKAGE_TARNAME}'],
656 [logdir='${prefix}/logs'])
658 AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.])
659 AC_SUBST_DIR([logdir])
661 dnl **********************************************************************
662 dnl Check for --with-helpdir
663 dnl **********************************************************************
665 AC_MSG_CHECKING([whether to modify helpdir])
667 AC_HELP_STRING([--with-helpdir=DIR],
668 [Directory to install help files.]),
669 [ helpdir=`echo $withval | sed 's/\/$//'`
670 AC_MSG_RESULT(yes) ],
671 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
672 [helpdir='${datadir}/${PACKAGE_TARNAME}/help'],
673 [helpdir='${prefix}/help'])
675 AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.])
676 AC_SUBST_DIR([helpdir])
678 dnl **********************************************************************
679 dnl Check for --with-moduledir
680 dnl **********************************************************************
682 AC_MSG_CHECKING([whether to modify moduledir])
683 AC_ARG_WITH(moduledir,
684 [AC_HELP_STRING([--with-moduledir=DIR],
685 [Directory to install modules.])],
686 [ moduledir=`echo $withval | sed 's/\/$//'`
688 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
689 [moduledir='${pkglibdir}/modules'],
690 [moduledir='${prefix}/modules'])
693 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
694 AC_SUBST_DIR([moduledir])
696 dnl Check for --with-rundir
698 AC_MSG_CHECKING([whether or modify rundir])
699 AC_ARG_WITH([rundir],
700 [AC_HELP_STRING([--with-rundir=DIR],
701 [Directory in which to store pidfile.])],
702 [AC_MSG_RESULT([yes])
703 rundir=`echo $withval | sed 's/\/$//'`],
705 AS_IF([test "x$enable_fhs_paths" = "xyes"],
706 [rundir='${prefix}/run'],
707 [rundir='${sysconfdir}'])])
709 AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.])
711 dnl Installed utility program prefixes (does not affect binaries
712 dnl installed into pkglibexecdir)
713 AC_MSG_CHECKING([for program prefix])
714 AC_ARG_WITH([program-prefix],
715 [AS_HELP_STRING([--with-program-prefix=], [If set, programs installed into PATH will be installed with names prefixed by this prefix.])],
716 [test "x$with_program_prefix" = "xno" && with_program_prefix=],
717 [with_program_prefix=])
718 AC_MSG_RESULT(["$with_program_prefix"])
719 PROGRAM_PREFIX="$with_program_prefix"
720 AC_SUBST([PROGRAM_PREFIX])
721 AC_DEFINE_UNQUOTED([PROGRAM_PREFIX], ["$with_program_prefix"], [String with which all programs intended to be in PATH are prefixed.])
723 dnl **********************************************************************
725 dnl **********************************************************************
727 AC_MSG_CHECKING([whether custom branding is requested])
728 AC_ARG_WITH(custom-branding,
729 AC_HELP_STRING([--with-custom-branding=NAME],
730 [Custom branding name.]),
731 [BRANDING_NAME=$withval
732 AC_MSG_RESULT([yes])],
733 [BRANDING_NAME=$PACKAGE_NAME
737 AC_MSG_CHECKING([whether a custom version is requested])
738 AC_ARG_WITH(custom-version,
739 AC_HELP_STRING([--with-custom-version=NAME],
740 [Custom version branding.]),
741 [BRANDING_VERSION=$withval
742 AC_MSG_RESULT([yes])],
743 [BRANDING_VERSION=$PACKAGE_VERSION
747 AC_DEFINE_UNQUOTED(BRANDING_NAME, ["$BRANDING_NAME"], [Custom branding name.])
748 AC_DEFINE_UNQUOTED(BRANDING_VERSION, ["$BRANDING_VERSION"], [Custom branding name.])
750 if test "x$BRANDING_NAME" != "x$PACKAGE_NAME"; then
751 AC_DEFINE(CUSTOM_BRANDING, 1, [Define if custom branding is enabled.])
754 if test ! -z "$SELECT_TYPE_EXPLICIT"; then
755 SELECT_TYPE="$SELECT_TYPE_EXPLICIT";
756 echo "Forcing $SELECT_TYPE to be enabled"
759 if test ! "x$use_ports" = "xno"; then
760 AC_CHECK_FUNCS(port_getn, [haveports=yes], [haveports=no])
761 if test "x$haveports" = "xyes" ; then
766 if test ! "x$use_select" = "xno"; then
767 AC_CHECK_FUNCS(select, [haveselect=yes], [haveselect=no])
768 if test "x$haveselect" = "xyes" ; then
773 if test ! "x$use_poll" = "xno"; then
774 AC_CHECK_FUNCS(poll, [havepoll=yes], [havepoll=no])
775 if test "x$havepoll" = "xyes" ; then
780 if test ! "x$use_kqueue" = "xno"; then
781 AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
782 if test "x$havekqueue" = "xyes" ; then
787 if test ! "x$use_epoll" = "xno"; then
788 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
789 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
790 if test "x$haveepoll" = "xyes" ; then
791 AC_MSG_CHECKING(for epoll support in kernel)
794 #include <sys/param.h>
795 #include <sys/types.h>
796 #include <sys/epoll.h>
797 #include <sys/syscall.h>
801 main(int argc, char **argv)
805 epfd = epoll_create(256);
806 return (epfd == -1 ? 1 : 0);
807 }, [AC_MSG_RESULT(yes)
808 AC_DEFINE(HAVE_EPOLL, 1,
809 [Define if your system supports the epoll system calls])
810 SELECT_TYPE="epoll"],
811 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
817 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
818 if test "x$haveepoll" = "xno" ; then
819 AC_MSG_CHECKING(for epoll system call)
822 #include <sys/param.h>
823 #include <sys/types.h>
824 #include <sys/epoll.h>
825 #include <sys/syscall.h>
829 epoll_create(int size)
831 return (syscall(__NR_epoll_create, size));
835 main(int argc, char **argv)
839 epfd = epoll_create(256);
840 exit (epfd == -1 ? 1 : 0);
841 }, [AC_MSG_RESULT(yes)
842 AC_DEFINE(HAVE_EPOLL, 1,
843 [Define if your system supports the epoll system calls])
844 SELECT_TYPE="epoll"],
845 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
853 if test -z "$SELECT_TYPE"; then
854 AC_MSG_ERROR([Unable to find a usable IO interface],)
857 echo "Using $SELECT_TYPE for select loop."
859 AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE", [This is the type of IO loop we are using])
860 AC_SUBST(SELECT_TYPE)
863 dnl Debug-related options
864 dnl =====================
866 AC_ARG_ENABLE(assert,
867 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
868 [assert=$enableval], [assert=no])
870 if test "$assert" = no; then
871 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
872 elif test "$assert" = soft; then
873 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
874 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
875 elif test "$assert" = yes; then
879 AC_MSG_CHECKING(if you want IO Debugging hooks)
880 AC_ARG_ENABLE(iodebug,
881 AC_HELP_STRING([--enable-iodebug],[Enable IO Debugging hooks]),
882 [iodebug=$enableval], [iodebug=no])
884 if test "$iodebug" = yes; then
885 AC_DEFINE(USE_IODEBUG_HOOKS, 1, [Define this to enable IO Debug hooks.])
892 AC_MSG_CHECKING(if you want to do a profile build)
893 AC_ARG_ENABLE(profile,
894 AC_HELP_STRING([--enable-profile],[Enable profiling]),
895 [profile=$enableval], [profile=no])
897 if test "$profile" = yes; then
898 if test "$ac_cv_c_compiler_gnu" = yes; then
899 IRC_CFLAGS="$IRC_CFLAGS -pg"
900 AC_MSG_RESULT([yes, adding -pg])
901 AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
903 AC_MSG_RESULT([no, profile builds only work with gcc])
909 AC_ARG_ENABLE(balloc,
910 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
911 [balloc=$enableval], [balloc=yes])
913 if test "$balloc" = no; then
914 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
917 AC_ARG_ENABLE(small-net,
918 AC_HELP_STRING([--enable-small-net],[Enable small network support.]),
919 [small_net=$enableval], [small_net=no])
921 if test "$small_net" = yes; then
922 dnl AC_DEFINE([HASHSIZE], 4096, [Max number of buckets in hash tables.])
923 AC_DEFINE([NICKNAMEHISTORYLENGTH], 1500, [Size of the WHOWAS array.])
924 AC_DEFINE([CHANNEL_HEAP_SIZE], 256, [Size of the channel heap.])
925 AC_DEFINE([BAN_HEAP_SIZE], 128, [Size of the ban heap.])
926 AC_DEFINE([CLIENT_HEAP_SIZE], 256, [Size of the client heap.])
927 AC_DEFINE([LCLIENT_HEAP_SIZE], 128, [Size of the local client heap.])
928 AC_DEFINE([PCLIENT_HEAP_SIZE], 32, [Size of the pre-client heap.])
929 AC_DEFINE([USER_HEAP_SIZE], 128, [Size of the user heap.])
930 AC_DEFINE([DNODE_HEAP_SIZE], 256, [Size of the dlink_node heap.])
931 AC_DEFINE([TOPIC_HEAP_SIZE], 256, [Size of the topic heap.])
932 AC_DEFINE([LINEBUF_HEAP_SIZE], 128, [Size of the linebuf heap.])
933 AC_DEFINE([MEMBER_HEAP_SIZE], 256, [Sizeof member heap.])
934 AC_DEFINE([ND_HEAP_SIZE], 128, [Size of the nick delay heap.])
935 AC_DEFINE([CONFITEM_HEAP_SIZE], 128, [Size of the confitem heap.])
936 AC_DEFINE([MONITOR_HEAP_SIZE], 128, [Size of the monitor heap.])
937 AC_DEFINE([FD_HEAP_SIZE], 128, [Size of fd heap.])
938 AC_DEFINE([AWAY_HEAP_SIZE], 128, [Size of away heap.])
940 dnl These settings are for a large network like efnet..they will use lots of memory
941 dnl so enable small net unless you really need this much support
942 AC_DEFINE([NICKNAMEHISTORYLENGTH], 15000, [Size of the WHOWAS array.])
943 AC_DEFINE([CHANNEL_HEAP_SIZE], 8192, [Size of the channel heap.])
944 AC_DEFINE([BAN_HEAP_SIZE], 4096, [Size of the ban heap.])
945 AC_DEFINE([CLIENT_HEAP_SIZE], 8192, [Size of the client heap.])
946 AC_DEFINE([LCLIENT_HEAP_SIZE], 1024, [Size of the local client heap.])
947 AC_DEFINE([PCLIENT_HEAP_SIZE], 256, [Size of the pre-client heap.])
948 AC_DEFINE([USER_HEAP_SIZE], 8192, [Size of the user heap.])
949 AC_DEFINE([DNODE_HEAP_SIZE], 8192, [Size of the dlink_node heap.])
950 AC_DEFINE([TOPIC_HEAP_SIZE], 4096, [Size of the topic heap.])
951 AC_DEFINE([LINEBUF_HEAP_SIZE], 2048, [Size of the linebuf heap.])
952 AC_DEFINE([MEMBER_HEAP_SIZE], 32768, [Sizeof member heap.])
953 AC_DEFINE([ND_HEAP_SIZE], 512, [Size of the nick delay heap.])
954 AC_DEFINE([CONFITEM_HEAP_SIZE], 256, [Size of the confitem heap.])
955 AC_DEFINE([MONITOR_HEAP_SIZE], 1024, [Size of the monitor heap.])
956 AC_DEFINE([FD_HEAP_SIZE], 1024, [Size of fd heap.])
957 AC_DEFINE([AWAY_HEAP_SIZE], 512, [Size of away heap.])
961 AC_HELP_STRING([--with-nicklen=LENGTH],[Set the upper-bound nick length to LENGTH (default 31, max 50)]),
963 if ! expr "$withval" + 0 >/dev/null 2>&1; then
964 AC_ERROR([NICKLEN must be a numeric value])
966 if test $withval -gt 50; then
968 AC_MSG_WARN([NICKLEN has a hard limit of 50. Setting NICKLEN=50])
969 elif test $withval -lt 9; then
971 AC_MSG_WARN([NICKLEN has a lower limit of 9. Setting NICKLEN=9])
977 AC_ARG_WITH(topiclen,
978 AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
980 if test $withval -ge 390; then
982 AC_MSG_WARN([TOPICLEN has a hard limit of 390. Setting TOPICLEN=390])
988 AC_DEFINE_UNQUOTED(TOPICLEN, ${TOPICLEN}, [Maximum topic length (<=390)])
989 AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length])
992 dnl Some first-stage sanity checks.
993 if test "$shared_modules" = yes; then
994 dnl TenDRA's cc is called tcc too.
995 if test "$CC" = tcc -a "$TenDRA" = "no"; then
996 AC_MSG_WARN([disabling shared modules: Tiny C Compiler can't create PIC])
1001 dnl Second stage: check for functions and headers.
1002 if test "$shared_modules" = yes; then
1004 AC_CHECK_HEADERS(dlfcn.h)
1005 AC_SEARCH_LIBS(shl_load, dld,
1007 AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if the shl_load function is available.])
1009 MOD_TARGET=hpux_shared
1010 SEDOBJ="s/\.o/.sl/g"
1015 AC_SEARCH_LIBS(dlopen, [dl c_r],
1017 AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
1019 MOD_TARGET=shared_modules
1020 SEDOBJ="s/\.o/.so/g"
1021 if test "$AppleGCC" = yes; then
1022 AC_CHECK_HEADERS([mach-o/dyld.h])
1024 AC_CHECK_FUNC(dlsym, ,
1026 AC_MSG_WARN([dlsym is not available, shared modules disabled])
1029 AC_CHECK_FUNCS(dlfunc)
1037 AC_DEFINE_UNQUOTED(SHARED_SUFFIX, "$SUFFIX", [Suffix for shared libraries on this platform.])
1039 dnl Third stage - wrangling the linker.
1040 if test "$shared_modules" = yes; then
1041 # The GNU linker requires the -export-dynamic option to make
1042 # all symbols visible in the dynamic symbol table.
1043 hold_ldflags=$LDFLAGS
1044 AC_MSG_CHECKING(for the ld -export-dynamic flag)
1045 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic -Werror"
1046 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1047 LDFLAGS=$hold_ldflags
1049 if expr "`uname -s`" : ^IRIX >/dev/null 2>&1; then
1050 found="no, IRIX ld uses -B,dynamic"
1051 LDFLAGS="${LDFLAGS} -Wl,-B,dynamic"
1054 if expr "`uname -s`" : ^AIX >/dev/null 2>&1; then
1055 found="no, AIX ld uses -G -brtl"
1056 LDFLAGS="${LDFLAGS} -Wl,-G,-brtl"
1059 AC_MSG_RESULT($found)
1061 if test "$found" = yes; then
1062 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
1065 AC_MSG_CHECKING(for compiler option to produce PIC)
1066 dnl The order should be here to check for groups of compilers,
1067 dnl then for odd compilers, then if no PICFLAGS were set up,
1068 dnl check for GCC and set defaults, or else error. -jmallett
1069 if test "$SGS" = "yes"; then
1070 AC_MSG_RESULT([SVR4 SGS interfaces: -KPIC -DPIC -G])
1071 PICFLAGS="-KPIC -DPIC -G"
1074 if test "$AppleGCC" = "yes"; then
1075 AC_MSG_RESULT([Darwin Mach-O bundles: -fno-common -bundle -flat_namespace -undefined suppress])
1076 PICFLAGS="-fno-common -bundle -flat_namespace -undefined suppress"
1078 dnl Please note, that on HPUX two different stages of module compilation occurs, since
1079 dnl while compiling modules, the compiler does not allow you to give arguments
1080 dnl to the linker. (I did not design this)
1081 dnl So we need -c in the first stage of module compilation.
1082 dnl In the second stage, we link the modules via ld -b.
1083 dnl Additionally, HPUX does not like -export-dynamic, it likes -E instead.
1085 if test "$HPUX" = "yes" -a "$CC" != gcc; then
1086 AC_MSG_RESULT(HP-UX cc: +z -r -q -n)
1087 PICFLAGS="+z -r -q -n -c"
1088 AC_MSG_CHECKING([if +ESfic is required on this platform])
1090 if expr "`$CC +ESfic 2>&1`" : ".*neither supported.*" >/dev/null; then
1094 PICFLAGS="$PICFLAGS +ESfic"
1097 LDFLAGS="${LDFLAGS} -Wl,-E"
1099 if test "$Tru" = yes -a "$CC" != gcc; then
1100 AC_MSG_RESULT([Tru64: -shared -expect_unresolved '*'])
1101 PICFLAGS="-shared -expect_unresolved '*' "
1102 LDFLAGS="-call_shared"
1104 if test -z "$PICFLAGS"; then
1105 if test "$ac_cv_c_compiler_gnu" = "yes"; then
1106 AC_MSG_RESULT(gcc: -fPIC -DPIC -shared)
1107 PICFLAGS="-fPIC -DPIC -shared"
1115 # rpath, for finding libratbox.so at run time
1116 hold_ldflags=$LDFLAGS
1117 AC_MSG_CHECKING(for the ld -rpath flag)
1118 LDFLAGS="${LDFLAGS} -Wl,-rpath=${libdir}"
1119 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
1120 LDFLAGS=$hold_ldflags
1121 AC_MSG_RESULT($found)
1122 if test "$found" = yes; then
1123 LDFLAGS="${LDFLAGS} -Wl,-rpath=\${libdir}"
1126 # This must be down here, or it will mess up checks like the ones
1127 # for -Wl,-export-dynamic
1130 AC_ARG_ENABLE(warnings,
1131 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
1133 IRC_CFLAGS="$IRC_CFLAGS -O0"
1134 CFLAGS="$IRC_CFLAGS"
1136 CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
1137 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
1138 CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit)
1139 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
1140 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
1141 CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_write_strings)
1142 CHARYBDIS_C_GCC_TRY_FLAGS([-Werror-implicit-function-declaration], charybdis_cv_c_gcc_w_error_implicit_function_declaration)
1143 CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes)
1144 CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis)
1145 CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w)
1146 CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
1147 CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow)
1148 CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
1149 CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
1150 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
1151 CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_externs)
1152 CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused)
1153 CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls)
1154 CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
1155 CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wno-format-security], charybdis_cv_c_gcc_w_format)
1157 IRC_CFLAGS="$CFLAGS"
1160 if test "$shared_modules" = no; then
1162 MOD_TARGET="libmodules.a"
1163 MODULES_LIBS="../modules/libmodules.a"
1165 AC_DEFINE(STATIC_MODULES, 1, [Define to 1 if dynamic modules can't be used.])
1166 AC_MSG_WARN([shared module support has been disabled!])
1169 dnl Stage 5 - underscores in front of symbol names.
1170 if test "$shared_modules" = yes; then
1172 AC_CHECK_FUNC(nlist,,
1173 AC_CHECK_LIB(dl, nlist, nlist_lib="-ldl",
1174 AC_CHECK_LIB(elf, nlist, nlist_lib="-lelf",)
1178 dnl We need to find out whether underscores are appended to symbol
1179 dnl names in executable files. First, though, we need to see
1180 dnl where nlist.h is hiding.
1181 AC_CHECK_HEADER(libelf/nlist.h, [ nlist_h="libelf/nlist.h" ], )
1182 AC_CHECK_HEADER(elf/nlist.h, [ nlist_h="elf/nlist.h" ], )
1183 AC_CHECK_HEADER(nlist.h, [ nlist_h="nlist.h" ], )
1184 if test x"$nlist_h" = "x"; then
1185 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "", [String containing extra underscores prepended to symbols loaded from modules.])
1187 AC_MSG_CHECKING(for extra underscores prepended to symbol names)
1188 AC_CACHE_VAL(symbol_underscores,
1190 cat << EOF > conftest.c
1194 void _modinit(void);
1195 int main(int argc, char *argv[[]]) {
1197 struct nlist nl[[5]];
1199 /* fill the names in this way, so it'll work almost everywhere */
1200 nl[[0]].n_name = "_modinit";
1201 nl[[1]].n_name = "__modinit";
1202 nl[[2]].n_name = "___modinit";
1203 nl[[3]].n_name = "____modinit";
1204 nl[[0]].n_value = nl[[1]].n_value = nl[[2]].n_value = nl[[3]].n_value = nl[[4]].n_name = NULL;
1206 if(argc < 2 || (nlist(argv[[1]], nl)) == -1) exit(-1);
1207 for(i = 0; i < 4; i++) {
1208 if(nl[[i]].n_value != NULL)
1211 for(j = 0; j < i; j++)
1218 void _modinit(void) { return; }
1220 $CC $CPPFLAGS $IRC_CFLAGS -o conftest conftest.c $nlist_lib >/dev/null 2>&1
1221 symbol_underscores=`./conftest conftest`
1222 AC_MSG_RESULT($symbol_underscores)
1223 $RM -f conftest conftest.c
1225 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "${symbol_underscores}", [String containing extra underscores prepended to symbols loaded from modules.])
1229 IRC_CFLAGS="$IRC_CFLAGS $CWARNS"
1231 AC_SUBST(MODULES_LIBS)
1232 AC_SUBST(MOD_TARGET)
1234 AC_SUBST(SSL_SRCS_ENABLE)
1235 AC_SUBST(SSL_INCLUDES)
1240 AC_SUBST(IRC_CFLAGS)
1244 if test "$prefix" = "NONE"; then
1245 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
1249 dnl Don't get bitten by Cygwin's stupidity if the user specified
1250 dnl a custom prefix with a trailing slash
1252 prefix=`echo $prefix | sed 's/\/$//'`
1253 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
1261 extensions/Makefile \
1269 AC_CONFIG_COMMANDS([tools/genssl_chmod], [chmod 755 tools/genssl])
1273 if test "$cf_openssl_version_ok" = yes; then
1279 if test "$shared_modules" = yes; then
1286 Configuration of ${BRANDING_NAME}-${BRANDING_VERSION}:
1287 Install directory : $prefix
1291 Socket Engine : $SELECT_TYPE
1292 Small network : $small_net
1293 Block allocator : $balloc
1295 Nickname length : $NICKLEN
1296 Topic length : $TOPICLEN
1298 Use (g)make to compile $BRANDING_NAME, then (g)make install to install it.