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.0.0-beta1])
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 Cygwin, 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(Cygwin)
104 AC_MSG_RESULT(SunOS or Solaris)
105 AC_DEFINE(__EXTENSIONS__, 1, [This is needed to use strtok_r on Solaris.])
109 AC_MSG_RESULT(AIX - Sorry you poor bastard..really we are)
110 IRC_CFLAGS="$IRC_CFLAGS -Wl,-brtl -Wl,-G"
117 if test "$ac_cv_c_compiler_gnu" = yes; then
118 AC_MSG_CHECKING(if $CC is Apple GCC)
120 case `$CC -v 2>&1 | tail -n 1` in
131 IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall -std=gnu99"
134 dnl If we support -g, use it!
135 if test "$ac_cv_prog_cc_g" = yes; then
136 dnl Tru64 needs -g3 for -O2
137 if test "$Tru" = yes; then
138 IRC_CFLAGS="$IRC_CFLAGS -g3"
140 IRC_CFLAGS="$IRC_CFLAGS -g"
144 dnl SVR4 SGS based on what we know about the compiler -jmallett
145 AC_MSG_CHECKING(if $CC supports the SVR4 SGS interfaces)
146 if test "$SGS" = "yes"; then
152 dnl We prefer gcc -MM because it's a lot less bloated
153 AC_PATH_PROG(MKDEP, mkdep)
154 AC_PATH_PROG(MAKEDEPEND, makedepend)
156 AC_MSG_CHECKING(how to generate dependency info)
160 if test "$ac_cv_c_compiler_gnu" = yes; then
161 AC_MSG_RESULT(gcc -MM)
163 elif test ! -z "$MKDEP"; then
166 dnl Tru64's mkdep is very loud
167 if test -z "$Tru"; then
170 STDOUT=" 2> /dev/null"
172 elif test "$SunWorkShop" = yes; then
173 AC_MSG_RESULT($CC -xM)
175 STDOUT="> .depend 2> /dev/null"
176 elif test ! -z "$MAKEDEPEND"; then
177 AC_MSG_RESULT(makedepend)
178 MKDEP="$MAKEDEPEND -f-"
180 AC_MSG_RESULT([nothing suitable.. forget it!])
187 dnl check for /dev/null so we can use it to hold evil fd's
188 AC_MSG_CHECKING([for /dev/null])
189 if test -c /dev/null ; then
190 AC_DEFINE(PATH_DEVNULL, "/dev/null", [Path to /dev/null])
193 AC_DEFINE(PATH_DEVNULL, "devnull.log", [Path to /dev/null])
194 AC_MSG_RESULT(no - using devnull.log)
197 dnl jdc -- If CFLAGS is defined, best use it everywhere...
198 dnl NOTE: jv says it must be added to the *END*, because things like
199 dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid.
200 if test ! -z "$CFLAGS"; then
201 IRC_CFLAGS="$IRC_CFLAGS $CFLAGS"
206 AC_PROG_GCC_TRADITIONAL
213 AC_PATH_PROG(SED, sed)
216 AC_PATH_PROG(RANLIB, ranlib)
217 AC_PATH_PROG(TOUCH, touch)
221 dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found
222 if test "$YACC" = "yacc" -a -z "`which $YACC 2>/dev/null`"; then
223 AC_MSG_ERROR([could not locate a suitable parser generator; install bison, yacc, or byacc])
228 if test "$LEX" = ":"; then
229 AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
232 dnl use directory structure of cached as default (hack)
233 if test "$libexecdir" = '${exec_prefix}/libexec' &&
234 test "$localstatedir" = '${prefix}/var'; then
235 libexecdir='${bindir}'
236 localstatedir='${prefix}'
239 dnl Checks for header files.
242 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])
244 dnl Stuff that the memory manager (imalloc) depends on
245 dnl ==================================================
248 if test "$ac_cv_header_machine_endian_h" = "no" ; then
253 AC_CHECK_SIZEOF(short)
255 AC_CHECK_SIZEOF(long)
256 AC_CHECK_SIZEOF(long long)
258 dnl Networking Functions
259 dnl ====================
261 AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])])
263 dnl SunOS/Solaris required libnsl for inet_ntoa()
264 if test x"$SUN" = xyes; then
265 AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])])
268 AC_CHECK_TYPE(socklen_t, ,
269 [AC_DEFINE([socklen_t], [unsigned int],
270 [If we don't have a real socklen_t, unsigned int is good enough.])],
271 [#include <sys/types.h>
272 #include <sys/socket.h>])
275 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
277 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
279 CRYPT_LIB=$ac_cv_search_crypt
281 if test "$CRYPT_LIB" = "none required"; then
283 elif test "$CRYPT_LIB" = no; then
289 if test "$ac_cv_header_sys_wait_h" = yes -o "$ac_cv_header_wait_h" = yes; then
291 dnl We need one of the above to build viconf. Just a sanity check,
292 dnl we don't want to stop people from building the rest of ircd
293 dnl just because they can't build viconf.
300 dnl See whether we can include both string.h and strings.h.
301 AC_CACHE_CHECK([whether string.h and strings.h may both be included],
302 gcc_cv_header_string,
306 #include <strings.h>],
307 [gcc_cv_header_string=yes],
308 [gcc_cv_header_string=no])
311 if test "$gcc_cv_header_string" = "yes"; then
312 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
317 dnl Check for stdarg.h - if we can't find it, halt configure
318 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - ircd-ratbox will not compile without it **])])
320 dnl Checks for the existence of strlcat, strlcpy, basename...
321 dnl This more reliable test only works with gcc though.
323 if test "$ac_cv_c_compiler_gnu" = yes; then
325 AC_MSG_CHECKING(for strlcpy)
327 CFLAGS="$CFLAGS -Wimplicit -Werror"
331 [[#include <string.h>
332 #include <stdlib.h>]],
333 [[char *a = malloc(6);
334 strlcpy(a, "hello", 6);]]
337 AC_DEFINE(HAVE_STRLCPY, 1, [Define if strlcpy is available (most BSDs.)])],
341 AC_MSG_CHECKING(for strlcat)
344 [[#include <string.h>
345 #include <stdlib.h>]],
346 [[char *a = malloc(6);
348 strlcat(a, "hello", 6);]]
351 AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available (most BSDs.)])],
359 dnl Better than nothing. The more complicated test above probably fixes powerpc,
362 AC_CHECK_FUNCS([strlcat strlcpy])
366 AC_CHECK_TYPE([u_int32_t], [],
368 AC_CHECK_TYPE([uint32_t],
370 AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.])
373 AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int])
374 AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.])
378 AC_CHECK_TYPE([u_int16_t], [],
380 AC_CHECK_TYPE([uint16_t],
382 AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute])
385 AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int])
386 AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.])
390 AC_CHECK_TYPE([in_port_t], [],
391 [AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])],
392 [[#include <sys/types.h>
393 #include <netinet/in.h>]])
395 AC_CHECK_TYPE([sa_family_t], [],
396 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
397 [[#include <sys/types.h>
398 #include <sys/socket.h>]])
400 AC_CHECK_TYPES([uintptr_t])
402 dnl check for various functions...
403 AC_CHECK_FUNCS([socketpair vsnprintf mmap gettimeofday strdup strndup ])
407 dnl Specialized functions checks
408 dnl ============================
410 dnl check for nanosleep
411 AC_CHECK_FUNC(nanosleep,,[AC_CHECK_LIB(rt,nanosleep,
413 [AC_CHECK_LIB(posix4,nanosleep, LIBS="${LIBS} -lposix4"
415 if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_posix4_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno
417 AC_MSG_RESULT("nanosleep not found..using select for delay")
419 AC_DEFINE([HAVE_NANOSLEEP], 1, [Define if nanosleep exists])
423 AC_MSG_CHECKING(for OpenSSL)
424 AC_ARG_ENABLE(openssl,
425 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
426 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
427 [cf_enable_openssl=$enableval],
428 [cf_enable_openssl="auto"])
430 if test "$cf_enable_openssl" != "no" ; then
431 cf_openssl_basedir=""
432 if test "$cf_enable_openssl" != "auto" &&
433 test "$cf_enable_openssl" != "yes" ; then
434 dnl Support for --enable-openssl=/some/place
435 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
437 dnl Do the auto-probe here. Check some common directory paths.
438 for dirs in /usr/local/ssl /usr/pkg /usr/local \
439 /usr/local/openssl ; do
440 if test -f "${dirs}/include/openssl/opensslv.h" ; then
441 cf_openssl_basedir="${dirs}"
447 dnl Now check cf_openssl_found to see if we found anything.
448 if test ! -z "$cf_openssl_basedir"; then
449 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
450 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
451 SSL_LIBS="-L${cf_openssl_basedir}/lib"
453 dnl OpenSSL wasn't found in the directory specified. Naughty
455 cf_openssl_basedir=""
458 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
459 dnl are in /usr/include and /usr/lib. In this case, we don't want to
460 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
461 dnl We can't do this check above, because some people want two versions
462 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
463 dnl and they want /usr/local/ssl to have preference.
464 if test -f "/usr/include/openssl/opensslv.h" ; then
465 cf_openssl_basedir="/usr"
469 dnl If we have a basedir defined, then everything is okay. Otherwise,
470 dnl we have a problem.
471 if test ! -z "$cf_openssl_basedir"; then
472 AC_MSG_RESULT($cf_openssl_basedir)
473 cf_enable_openssl="yes"
475 AC_MSG_RESULT([not found. Specify a correct path?])
476 cf_enable_openssl="no"
478 unset cf_openssl_basedir
480 dnl If --disable-openssl was specified
481 AC_MSG_RESULT(disabled)
484 save_CPPFLAGS="$CPPFLAGS"
485 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
487 LIBS="$LIBS $SSL_LIBS"
488 if test "$cf_enable_openssl" != no; then
489 dnl Check OpenSSL version (must be 0.9.6 or above!)
490 AC_MSG_CHECKING(for OpenSSL 0.9.6 or above)
493 [#include <openssl/opensslv.h>
494 #include <stdlib.h>],
495 [[if ( OPENSSL_VERSION_NUMBER >= 0x00906000)
496 exit(0); else exit(1);]]),
497 cf_openssl_version_ok=yes,
498 cf_openssl_version_ok=no,
499 cf_openssl_version_ok=no)
501 if test "$cf_openssl_version_ok" = yes; then
504 dnl Work around pmake/gmake conditional incompatibilities
505 AC_SUBST(ENCSPEED, encspeed)
507 dnl Do all the HAVE_LIBCRYPTO magic -- and check for ciphers
508 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
509 AC_CHECK_LIB(crypto, RSA_free)
510 SSL_LIBS="$SSL_LIBS -lcrypto"
511 SSL_SRCS_ENABLE='$(SSL_SRCS)'
513 AC_MSG_RESULT(no - OpenSSL support disabled)
517 CPPFLAGS="$save_CPPFLAGS"
520 dnl End OpenSSL detection
523 dnl Specialized functions and libraries
524 dnl ===================================
526 AC_ARG_WITH(zlib-path,
527 AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]),
528 [LIBS="$LIBS -L$withval"],)
531 AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]),
532 [zlib=$enableval],[zlib=yes])
534 if test "$zlib" = yes; then
536 AC_CHECK_HEADER(zlib.h, [
537 AC_CHECK_LIB(z, zlibVersion,
539 AC_SUBST(ZLIB_LD, -lz)
540 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.])
546 dnl IO Loop Selection
547 dnl =================
549 AC_ARG_ENABLE(ports, AC_HELP_STRING([--enable-ports],[Force solaris I/O ports subsystem usage.]),
550 [ if test $enableval = yes; then
551 SELECT_TYPE_EXPLICIT="ports"
557 AC_ARG_ENABLE(poll, AC_HELP_STRING([--enable-poll],[Force poll() usage.]),
558 [ if test $enableval = yes; then
559 SELECT_TYPE_EXPLICIT="poll"
565 AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select],[Force select() usage.]),
566 [ if test $enableval = yes; then
567 SELECT_TYPE_EXPLICIT="select"
573 AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
574 [ if test $enableval = yes; then
575 SELECT_TYPE_EXPLICIT="kqueue"
581 AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
582 [ if test $enableval = yes; then
583 SELECT_TYPE_EXPLICIT="epoll"
584 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
590 dnl **********************************************************************
591 dnl Check for --with-confdir
592 dnl **********************************************************************
594 AC_MSG_CHECKING([whether to modify confdir])
596 AC_HELP_STRING([--with-confdir=DIR],
597 [Directory to install config files.]),
598 [ confdir=`echo $withval | sed 's/\/$//'`
600 AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.])
601 AC_SUBST_DIR([confdir]) ],
602 [ confdir='${prefix}/etc'
604 AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.])
605 AC_SUBST_DIR([confdir])]
608 dnl **********************************************************************
609 dnl Check for --with-logdir
610 dnl **********************************************************************
612 AC_MSG_CHECKING([whether to modify logdir])
614 AC_HELP_STRING([--with-logdir=DIR],
615 [Directory where to write logfiles.]),
616 [ logdir=`echo $withval | sed 's/\/$//'`
618 AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.])
619 AC_SUBST_DIR([logdir]) ],
620 [ logdir='${prefix}/logs'
622 AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.])
623 AC_SUBST_DIR([logdir])]
626 dnl **********************************************************************
627 dnl Check for --with-helpdir
628 dnl **********************************************************************
630 AC_MSG_CHECKING([whether to modify helpdir])
632 AC_HELP_STRING([--with-helpdir=DIR],
633 [Directory to install help files.]),
634 [ helpdir=`echo $withval | sed 's/\/$//'`
636 AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help files are installed.])
637 AC_SUBST_DIR([helpdir]) ],
638 [ helpdir='${prefix}/help'
640 AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help file are installed.])
641 AC_SUBST_DIR([helpdir])]
644 dnl **********************************************************************
645 dnl Check for --with-moduledir
646 dnl **********************************************************************
648 AC_MSG_CHECKING([whether to modify moduledir])
649 AC_ARG_WITH(moduledir,
650 AC_HELP_STRING([--with-moduledir=DIR],
651 [Directory to install modules.]),
652 [ moduledir=`echo $withval | sed 's/\/$//'`
654 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
655 AC_SUBST_DIR([moduledir]) ],
656 [ moduledir='${prefix}/modules'
658 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
659 AC_SUBST_DIR([moduledir])]
662 if test ! -z "$SELECT_TYPE_EXPLICIT"; then
663 SELECT_TYPE="$SELECT_TYPE_EXPLICIT";
664 echo "Forcing $SELECT_TYPE to be enabled"
667 if test ! "x$use_ports" = "xno"; then
668 AC_CHECK_FUNCS(port_getn, [haveports=yes], [haveports=no])
669 if test "x$haveports" = "xyes" ; then
674 if test ! "x$use_select" = "xno"; then
675 AC_CHECK_FUNCS(select, [haveselect=yes], [haveselect=no])
676 if test "x$haveselect" = "xyes" ; then
681 if test ! "x$use_poll" = "xno"; then
682 AC_CHECK_FUNCS(poll, [havepoll=yes], [havepoll=no])
683 if test "x$havepoll" = "xyes" ; then
688 if test ! "x$use_kqueue" = "xno"; then
689 AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
690 if test "x$havekqueue" = "xyes" ; then
695 if test ! "x$use_epoll" = "xno"; then
696 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
697 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
698 if test "x$haveepoll" = "xyes" ; then
699 AC_MSG_CHECKING(for epoll support in kernel)
702 #include <sys/param.h>
703 #include <sys/types.h>
704 #include <sys/epoll.h>
705 #include <sys/syscall.h>
709 main(int argc, char **argv)
713 epfd = epoll_create(256);
714 return (epfd == -1 ? 1 : 0);
715 }, [AC_MSG_RESULT(yes)
716 AC_DEFINE(HAVE_EPOLL, 1,
717 [Define if your system supports the epoll system calls])
718 SELECT_TYPE="epoll"],
719 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
725 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
726 if test "x$haveepoll" = "xno" ; then
727 AC_MSG_CHECKING(for epoll system call)
730 #include <sys/param.h>
731 #include <sys/types.h>
732 #include <sys/epoll.h>
733 #include <sys/syscall.h>
737 epoll_create(int size)
739 return (syscall(__NR_epoll_create, size));
743 main(int argc, char **argv)
747 epfd = epoll_create(256);
748 exit (epfd == -1 ? 1 : 0);
749 }, [AC_MSG_RESULT(yes)
750 AC_DEFINE(HAVE_EPOLL, 1,
751 [Define if your system supports the epoll system calls])
752 SELECT_TYPE="epoll"],
753 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
761 if test -z "$SELECT_TYPE"; then
762 AC_MSG_ERROR([Unable to find a usable IO interface],)
765 echo "Using $SELECT_TYPE for select loop."
767 AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE", [This is the type of IO loop we are using])
768 AC_SUBST(SELECT_TYPE)
771 dnl Debug-related options
772 dnl =====================
774 AC_ARG_ENABLE(assert,
775 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
776 [assert=$enableval], [assert=no])
778 if test "$assert" = no; then
779 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
780 elif test "$assert" = soft; then
781 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
782 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
783 elif test "$assert" = yes; then
787 AC_MSG_CHECKING(if you want IO Debugging hooks)
788 AC_ARG_ENABLE(iodebug,
789 AC_HELP_STRING([--enable-iodebug],[Enable IO Debugging hooks]),
790 [iodebug=$enableval], [iodebug=no])
792 if test "$iodebug" = yes; then
793 AC_DEFINE(USE_IODEBUG_HOOKS, 1, [Define this to enable IO Debug hooks.])
800 AC_MSG_CHECKING(if you want to do a profile build)
801 AC_ARG_ENABLE(profile,
802 AC_HELP_STRING([--enable-profile],[Enable profiling]),
803 [profile=$enableval], [profile=no])
805 if test "$profile" = yes; then
806 if test "$ac_cv_c_compiler_gnu" = yes; then
807 IRC_CFLAGS="$IRC_CFLAGS -pg"
808 AC_MSG_RESULT([yes, adding -pg])
809 AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
811 AC_MSG_RESULT([no, profile builds only work with gcc])
817 AC_ARG_ENABLE(balloc,
818 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
819 [balloc=$enableval], [balloc=yes])
821 if test "$balloc" = no; then
822 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
825 AC_ARG_ENABLE(small-net,
826 AC_HELP_STRING([--enable-small-net],[Enable small network support.]),
827 [small_net=$enableval], [small_net=no])
829 if test "$small_net" = yes; then
830 dnl AC_DEFINE([HASHSIZE], 4096, [Max number of buckets in hash tables.])
831 AC_DEFINE([NICKNAMEHISTORYLENGTH], 1500, [Size of the WHOWAS array.])
832 AC_DEFINE([CHANNEL_HEAP_SIZE], 256, [Size of the channel heap.])
833 AC_DEFINE([BAN_HEAP_SIZE], 128, [Size of the ban heap.])
834 AC_DEFINE([CLIENT_HEAP_SIZE], 256, [Size of the client heap.])
835 AC_DEFINE([LCLIENT_HEAP_SIZE], 128, [Size of the local client heap.])
836 AC_DEFINE([PCLIENT_HEAP_SIZE], 32, [Size of the pre-client heap.])
837 AC_DEFINE([USER_HEAP_SIZE], 128, [Size of the user heap.])
838 AC_DEFINE([DNODE_HEAP_SIZE], 256, [Size of the dlink_node heap.])
839 AC_DEFINE([TOPIC_HEAP_SIZE], 256, [Size of the topic heap.])
840 AC_DEFINE([LINEBUF_HEAP_SIZE], 128, [Size of the linebuf heap.])
841 AC_DEFINE([MEMBER_HEAP_SIZE], 256, [Sizeof member heap.])
842 AC_DEFINE([ND_HEAP_SIZE], 128, [Size of the nick delay heap.])
843 AC_DEFINE([CONFITEM_HEAP_SIZE], 128, [Size of the confitem heap.])
844 AC_DEFINE([MONITOR_HEAP_SIZE], 128, [Size of the monitor heap.])
845 AC_DEFINE([FD_HEAP_SIZE], 128, [Size of fd heap.])
846 AC_DEFINE([AWAY_HEAP_SIZE], 128, [Size of away heap.])
848 dnl These settings are for a large network like efnet..they will use lots of memory
849 dnl so enable small net unless you really need this much support
850 AC_DEFINE([NICKNAMEHISTORYLENGTH], 15000, [Size of the WHOWAS array.])
851 AC_DEFINE([CHANNEL_HEAP_SIZE], 8192, [Size of the channel heap.])
852 AC_DEFINE([BAN_HEAP_SIZE], 4096, [Size of the ban heap.])
853 AC_DEFINE([CLIENT_HEAP_SIZE], 8192, [Size of the client heap.])
854 AC_DEFINE([LCLIENT_HEAP_SIZE], 1024, [Size of the local client heap.])
855 AC_DEFINE([PCLIENT_HEAP_SIZE], 256, [Size of the pre-client heap.])
856 AC_DEFINE([USER_HEAP_SIZE], 8192, [Size of the user heap.])
857 AC_DEFINE([DNODE_HEAP_SIZE], 8192, [Size of the dlink_node heap.])
858 AC_DEFINE([TOPIC_HEAP_SIZE], 4096, [Size of the topic heap.])
859 AC_DEFINE([LINEBUF_HEAP_SIZE], 2048, [Size of the linebuf heap.])
860 AC_DEFINE([MEMBER_HEAP_SIZE], 32768, [Sizeof member heap.])
861 AC_DEFINE([ND_HEAP_SIZE], 512, [Size of the nick delay heap.])
862 AC_DEFINE([CONFITEM_HEAP_SIZE], 256, [Size of the confitem heap.])
863 AC_DEFINE([MONITOR_HEAP_SIZE], 1024, [Size of the monitor heap.])
864 AC_DEFINE([FD_HEAP_SIZE], 1024, [Size of fd heap.])
865 AC_DEFINE([AWAY_HEAP_SIZE], 512, [Size of away heap.])
869 AC_HELP_STRING([--with-nicklen=LENGTH],[Set the nick length to LENGTH (default 15, max 50)]),
871 if test $withval -ge 50; then
873 AC_MSG_WARN([NICKLEN has a hard limit of 50. Setting NICKLEN=50])
879 AC_ARG_WITH(topiclen,
880 AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
882 if test $withval -ge 390; then
884 AC_MSG_WARN([TOPICLEN has a hard limit of 390. Setting TOPICLEN=390])
890 AC_DEFINE_UNQUOTED(TOPICLEN, ${TOPICLEN}, [Maximum topic length (<=390)])
891 AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length])
894 dnl Some first-stage sanity checks.
895 if test "$shared_modules" = yes; then
897 if test "$CYGWIN" = yes; then
898 AC_MSG_WARN([disabling shared modules; Cygwin is at present unable to build them.])
902 dnl TenDRA's cc is called tcc too.
903 if test "$CC" = tcc -a "$TenDRA" = "no"; then
904 AC_MSG_WARN([disabling shared modules: Tiny C Compiler can't create PIC])
909 dnl Second stage: check for functions and headers.
910 if test "$shared_modules" = yes; then
912 AC_CHECK_HEADERS(dlfcn.h)
913 AC_SEARCH_LIBS(shl_load, dld,
915 AC_DEFINE(HAVE_SHL_LOAD, 1, [Define if the shl_load function is available.])
917 MOD_TARGET=hpux_shared
923 AC_SEARCH_LIBS(dlopen, [dl c_r],
925 AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
927 MOD_TARGET=shared_modules
929 if test "$AppleGCC" = yes; then
930 AC_CHECK_HEADERS([mach-o/dyld.h])
932 AC_CHECK_FUNC(dlsym, ,
934 AC_MSG_WARN([dlsym is not available, shared modules disabled])
937 AC_CHECK_FUNCS(dlfunc)
945 AC_DEFINE_UNQUOTED(SHARED_SUFFIX, "$SUFFIX", [Suffix for shared libraries on this platform.])
947 dnl Third stage - wrangling the linker.
948 if test "$shared_modules" = yes; then
949 # The GNU linker requires the -export-dynamic option to make
950 # all symbols visible in the dynamic symbol table.
951 hold_ldflags=$LDFLAGS
952 AC_MSG_CHECKING(for the ld -export-dynamic flag)
953 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic -Werror"
954 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
955 LDFLAGS=$hold_ldflags
957 if expr "`uname -s`" : ^IRIX >/dev/null 2>&1; then
958 found="no, IRIX ld uses -B,dynamic"
959 LDFLAGS="${LDFLAGS} -Wl,-B,dynamic"
962 if expr "`uname -s`" : ^AIX >/dev/null 2>&1; then
963 found="no, AIX ld uses -G -brtl"
964 LDFLAGS="${LDFLAGS} -Wl,-G,-brtl"
967 AC_MSG_RESULT($found)
969 if test "$found" = yes; then
970 LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
973 AC_MSG_CHECKING(for compiler option to produce PIC)
974 dnl The order should be here to check for groups of compilers,
975 dnl then for odd compilers, then if no PICFLAGS were set up,
976 dnl check for GCC and set defaults, or else error. -jmallett
977 if test "$SGS" = "yes"; then
978 AC_MSG_RESULT([SVR4 SGS interfaces: -KPIC -DPIC -G])
979 PICFLAGS="-KPIC -DPIC -G"
982 if test "$AppleGCC" = "yes"; then
983 AC_MSG_RESULT([Darwin Mach-O bundles: -fno-common -bundle -flat_namespace -undefined suppress])
984 PICFLAGS="-fno-common -bundle -flat_namespace -undefined suppress"
986 dnl Please note, that on HPUX two different stages of module compilation occurs, since
987 dnl while compiling modules, the compiler does not allow you to give arguments
988 dnl to the linker. (I did not design this)
989 dnl So we need -c in the first stage of module compilation.
990 dnl In the second stage, we link the modules via ld -b.
991 dnl Additionally, HPUX does not like -export-dynamic, it likes -E instead.
993 if test "$HPUX" = "yes" -a "$CC" != gcc; then
994 AC_MSG_RESULT(HP-UX cc: +z -r -q -n)
995 PICFLAGS="+z -r -q -n -c"
996 AC_MSG_CHECKING([if +ESfic is required on this platform])
998 if expr "`$CC +ESfic 2>&1`" : ".*neither supported.*" >/dev/null; then
1002 PICFLAGS="$PICFLAGS +ESfic"
1005 LDFLAGS="${LDFLAGS} -Wl,-E"
1007 if test "$Tru" = yes -a "$CC" != gcc; then
1008 AC_MSG_RESULT([Tru64: -shared -expect_unresolved '*'])
1009 PICFLAGS="-shared -expect_unresolved '*' "
1010 LDFLAGS="-call_shared"
1012 if test -z "$PICFLAGS"; then
1013 if test "$ac_cv_c_compiler_gnu" = "yes"; then
1014 AC_MSG_RESULT(gcc: -fPIC -DPIC -shared)
1015 PICFLAGS="-fPIC -DPIC -shared"
1023 # This must be down here, or it will mess up checks like the ones
1024 # for -Wl,-export-dynamic
1027 AC_ARG_ENABLE(warnings,
1028 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
1030 IRC_CFLAGS="$IRC_CFLAGS -O0"
1031 CFLAGS="$IRC_CFLAGS"
1033 CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
1034 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
1035 CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit)
1036 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
1037 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
1038 CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_float_equal)
1039 CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes)
1040 CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis)
1041 CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w)
1042 CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
1043 CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow)
1044 CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
1045 CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
1046 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
1047 CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_externs)
1048 CHARYBDIS_C_GCC_TRY_FLAGS([-Wbad-function-cast], charybdis_cv_c_gcc_w_bad_function_cast)
1049 CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused)
1050 CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls)
1051 CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
1052 CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wformat-security], charybdis_cv_c_gcc_w_format)
1053 CHARYBDIS_C_GCC_TRY_FLAGS([-pedantic], charybdis_cv_c_gcc_pedantic)
1055 IRC_CFLAGS="$CFLAGS"
1058 if test "$shared_modules" = no; then
1060 MOD_TARGET="libmodules.a"
1061 MODULES_LIBS="../modules/libmodules.a"
1063 AC_DEFINE(STATIC_MODULES, 1, [Define to 1 if dynamic modules can't be used.])
1064 AC_MSG_WARN([shared module support has been disabled!])
1067 dnl Stage 5 - underscores in front of symbol names.
1068 if test "$shared_modules" = yes; then
1070 AC_CHECK_FUNC(nlist,,
1071 AC_CHECK_LIB(dl, nlist, nlist_lib="-ldl",
1072 AC_CHECK_LIB(elf, nlist, nlist_lib="-lelf",)
1076 dnl We need to find out whether underscores are appended to symbol
1077 dnl names in executable files. First, though, we need to see
1078 dnl where nlist.h is hiding.
1079 AC_CHECK_HEADER(libelf/nlist.h, [ nlist_h="libelf/nlist.h" ], )
1080 AC_CHECK_HEADER(elf/nlist.h, [ nlist_h="elf/nlist.h" ], )
1081 AC_CHECK_HEADER(nlist.h, [ nlist_h="nlist.h" ], )
1082 if test x"$nlist_h" = "x"; then
1083 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "", [String containing extra underscores prepended to symbols loaded from modules.])
1085 AC_MSG_CHECKING(for extra underscores prepended to symbol names)
1086 AC_CACHE_VAL(symbol_underscores,
1088 cat << EOF > conftest.c
1092 void _modinit(void);
1093 int main(int argc, char *argv[[]]) {
1095 struct nlist nl[[5]];
1097 /* fill the names in this way, so it'll work almost everywhere */
1098 nl[[0]].n_name = "_modinit";
1099 nl[[1]].n_name = "__modinit";
1100 nl[[2]].n_name = "___modinit";
1101 nl[[3]].n_name = "____modinit";
1102 nl[[0]].n_value = nl[[1]].n_value = nl[[2]].n_value = nl[[3]].n_value = nl[[4]].n_name = NULL;
1104 if(argc < 2 || (nlist(argv[[1]], nl)) == -1) exit(-1);
1105 for(i = 0; i < 4; i++) {
1106 if(nl[[i]].n_value != NULL)
1109 for(j = 0; j < i; j++)
1116 void _modinit(void) { return; }
1118 $CC $CPPFLAGS $IRC_CFLAGS -o conftest conftest.c $nlist_lib >/dev/null 2>&1
1119 symbol_underscores=`./conftest conftest`
1120 AC_MSG_RESULT($symbol_underscores)
1121 $RM -f conftest conftest.c
1123 AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "${symbol_underscores}", [String containing extra underscores prepended to symbols loaded from modules.])
1127 IRC_CFLAGS="$IRC_CFLAGS $CWARNS"
1129 AC_SUBST(MODULES_LIBS)
1130 AC_SUBST(MOD_TARGET)
1132 AC_SUBST(SSL_SRCS_ENABLE)
1133 AC_SUBST(SSL_INCLUDES)
1138 AC_SUBST(IRC_CFLAGS)
1142 if test "$prefix" = "NONE"; then
1143 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
1147 dnl Don't get bitten by Cygwin's stupidity if the user specified
1148 dnl a custom prefix with a trailing slash
1150 prefix=`echo $prefix | sed 's/\/$//'`
1151 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
1158 extensions/Makefile \
1159 unsupported/Makefile \
1169 if test "$cf_openssl_version_ok" = yes; then
1175 if test "$shared_modules" = yes; then
1183 Install directory : $prefix
1187 Socket Engine : $SELECT_TYPE
1188 Small network : $small_net
1189 Block allocator : $balloc
1191 Nickname length : $NICKLEN
1192 Topic length : $TOPICLEN
1194 Use (g)make to compile Charybdis, then (g)make install to install it.