]> jfr.im git - solanum.git/blob - configure.ac
modules: use lt_dlopenext() to make the config look nicer
[solanum.git] / configure.ac
1 dnl TODO: clean up all the OpenSSL and shared module checking stuff;
2 dnl the most major changes have already been made and it looks like
3 dnl said functions need to be just about as complex as they already are.
4
5 AC_PREREQ(2.57)
6
7 AC_INIT([charybdis], [3.6.0-dev])
8
9 AC_PREFIX_DEFAULT($HOME/ircd)
10 AC_CONFIG_MACRO_DIR([m4])
11 AC_CONFIG_HEADER(include/setup.h)
12
13 AC_CONFIG_AUX_DIR([libltdl/config])
14 AC_CONFIG_MACRO_DIR([libltdl/m4])
15 AM_INIT_AUTOMAKE([])
16 AM_SILENT_RULES([yes])
17 AM_PROG_AR
18
19 LT_INIT([dlopen disable-static])
20
21 LT_CONFIG_LTDL_DIR([extra/libltdl])
22 LTDL_INIT
23
24 build_ltdl=$with_included_ltdl
25 AM_CONDITIONAL([BUILD_LTDL], [test x"$build_ltdl" = x"yes"])
26
27 AC_PROG_CC_C99([], [AC_MSG_ERROR(charybdis requires a C99 capable compiler)])
28
29 AC_GNU_SOURCE
30
31 OLD_CFLAGS="$CFLAGS"
32 dnl Checks for programs.
33 AC_PROG_CC
34 AC_LANG(C)
35
36 dnl Make sure autoconf doesn't interfere with cflags -jmallett
37 CFLAGS="$OLD_CFLAGS"
38
39 AC_CONFIG_SUBDIRS(libratbox)
40
41 if test "$ac_cv_c_compiler_gnu" = yes; then
42 IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall -std=gnu99"
43 fi
44
45 dnl If we support -g, use it!
46 if test "$ac_cv_prog_cc_g" = yes; then
47 IRC_CFLAGS="$IRC_CFLAGS -g"
48 fi
49
50 dnl check for /dev/null so we can use it to hold evil fd's
51 AC_MSG_CHECKING([for /dev/null])
52 if test -c /dev/null ; then
53 AC_DEFINE(PATH_DEVNULL, "/dev/null", [Path to /dev/null])
54 AC_MSG_RESULT(yes)
55 else
56 AC_DEFINE(PATH_DEVNULL, "devnull.log", [Path to /dev/null])
57 AC_MSG_RESULT(no - using devnull.log)
58 fi
59
60 dnl jdc -- If CFLAGS is defined, best use it everywhere...
61 dnl NOTE: jv says it must be added to the *END*, because things like
62 dnl "gcc -O9 -O2" will result in -O2 getting preference. How stupid.
63 if test ! -z "$CFLAGS"; then
64 IRC_CFLAGS="$IRC_CFLAGS $CFLAGS"
65 fi
66
67 AC_ISC_POSIX
68 AC_C_INLINE
69 AC_PROG_GCC_TRADITIONAL
70 AC_PROG_MAKE_SET
71 AC_PROG_INSTALL
72 AC_PATH_PROG(RM, rm)
73 AC_PATH_PROG(CP, cp)
74 AC_PATH_PROG(MV, mv)
75 AC_PATH_PROG(LN, ln)
76 AC_PATH_PROG(SED, sed)
77 AC_PATH_PROG(AR, ar)
78 AC_PATH_PROG(LD, ld)
79 AC_PATH_PROG(RANLIB, ranlib)
80 AC_PATH_PROG(TOUCH, touch)
81
82 AC_PROG_YACC
83
84 dnl AC_PROG_YACC defaults to yacc unconditionally if nothing can be found
85 if test "$YACC" = "yacc" -a -z "`which $YACC 2>/dev/null`"; then
86 AC_MSG_ERROR([could not locate a suitable parser generator; install bison, yacc, or byacc])
87 fi
88
89 AC_PROG_LEX
90
91 if test "$LEX" = ":"; then
92 AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
93 fi
94
95 AC_ARG_ENABLE([fhs-paths],
96 [AS_HELP_STRING([--enable-fhs-paths], [Use more FHS-like pathnames (for packagers).])],
97 [],
98 [dnl detect if the user appears to want --enable-fhs-paths
99 AS_IF([test "$libexecdir" = '${exec_prefix}/libexec' && \
100 test "$localstatedir" = '${prefix}/var' && \
101 test "$libdir" = '${exec_prefix}/lib'],
102 [enable_fhs_paths=no],
103 [enable_fhs_paths=yes])
104 ])
105 dnl use directory structure of cached as default (hack)
106 AS_IF([test "x$enable_fhs_paths" = "xyes"],
107 [dnl Avoid name collisions.
108 pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}'
109 rundir=${rundir-'${prefix}/run'}
110 pkgrundir='${rundir}/${PACKAGE_TARNAME}'
111 pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'],
112 [libexecdir='${bindir}'
113 pkglibexecdir='${libexecdir}'
114 rundir='${sysconfdir}'
115 pkgrundir='${rundir}'
116 localstatedir='${prefix}'
117 pkglocalstatedir='${sysconfdir}'])
118 pkglibdir='${libdir}/${PACKAGE_TARNAME}'
119 AC_SUBST([pkglibdir])
120 AC_SUBST([rundir])
121 AC_SUBST([pkgrundir])
122 AC_SUBST([pkglocalstatedir])
123 AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as ban database]])
124 AC_SUBST([pkglibexecdir])
125 AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])
126
127 dnl Checks for header files.
128 AC_HEADER_STDC
129
130 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])
131
132 dnl Stuff that the memory manager (imalloc) depends on
133 dnl ==================================================
134
135 AC_C_CONST
136 if test "$ac_cv_header_machine_endian_h" = "no" ; then
137 AC_C_BIGENDIAN
138 fi
139 AC_TYPE_PID_T
140 AC_TYPE_SIZE_T
141 AC_CHECK_SIZEOF(short)
142 AC_CHECK_SIZEOF(int)
143 AC_CHECK_SIZEOF(long)
144 AC_CHECK_SIZEOF(long long)
145
146 dnl Networking Functions
147 dnl ====================
148
149 AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR([You have no socket()! Aborting.])])
150
151 dnl SunOS/Solaris required libnsl for inet_ntoa()
152 if test x"$SUN" = xyes; then
153 AC_SEARCH_LIBS(inet_ntoa, nsl,, [AC_MSG_ERROR([libnsl not found! Aborting.])])
154 fi
155
156 AC_CHECK_TYPE(socklen_t, ,
157 [AC_DEFINE([socklen_t], [unsigned int],
158 [If we don't have a real socklen_t, unsigned int is good enough.])],
159 [#include <sys/types.h>
160 #include <sys/socket.h>])
161
162 AC_ARG_ENABLE(ipv6,
163 AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),[ipv6=$enableval],[ipv6=no])
164
165 AC_SEARCH_LIBS(crypt, [crypt descrypt],,)
166
167 CRYPT_LIB=$ac_cv_search_crypt
168
169 if test "$CRYPT_LIB" = "none required"; then
170 unset CRYPT_LIB
171 elif test "$CRYPT_LIB" = no; then
172 unset CRYPT_LIB
173 fi
174
175 AC_SUBST(CRYPT_LIB)
176
177 if test "$ac_cv_header_sys_wait_h" = yes -o "$ac_cv_header_wait_h" = yes; then
178 VICONF=viconf
179 dnl We need one of the above to build viconf. Just a sanity check,
180 dnl we don't want to stop people from building the rest of ircd
181 dnl just because they can't build viconf.
182 else
183 VICONF=""
184 fi
185
186 AC_SUBST(VICONF)
187
188 dnl See whether we can include both string.h and strings.h.
189 AC_CACHE_CHECK([whether string.h and strings.h may both be included],
190 gcc_cv_header_string,
191 [
192 AC_COMPILE_IFELSE(
193 [#include <string.h>
194 #include <strings.h>],
195 [gcc_cv_header_string=yes],
196 [gcc_cv_header_string=no])
197 ])
198
199 if test "$gcc_cv_header_string" = "yes"; then
200 AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
201 fi
202
203 AC_C_BIGENDIAN
204
205 dnl Check for stdarg.h - if we can't find it, halt configure
206 AC_CHECK_HEADER(stdarg.h, , [AC_MSG_ERROR([** stdarg.h could not be found - charybdis will not compile without it **])])
207
208 dnl Checks for the existence of strlcat, strlcpy, basename...
209 dnl This more reliable test only works with gcc though.
210
211 if test "$ac_cv_c_compiler_gnu" = yes; then
212
213 AC_MSG_CHECKING(for strlcpy)
214 save_CFLAGS=$CFLAGS
215 CFLAGS="$CFLAGS -Wimplicit -Werror"
216
217 AC_LINK_IFELSE(
218 [AC_LANG_PROGRAM(
219 [[#include <string.h>
220 #include <stdlib.h>]],
221 [[char *a = malloc(6);
222 strlcpy(a, "hello", 6);]]
223 )],
224 [AC_MSG_RESULT(yes)
225 AC_DEFINE(HAVE_STRLCPY, 1, [Define if strlcpy is available (most BSDs.)])],
226 [AC_MSG_RESULT(no)]
227 )
228
229 AC_MSG_CHECKING(for strlcat)
230 AC_LINK_IFELSE(
231 [AC_LANG_PROGRAM(
232 [[#include <string.h>
233 #include <stdlib.h>]],
234 [[char *a = malloc(6);
235 a[0] = '\0';
236 strlcat(a, "hello", 6);]]
237 )],
238 [AC_MSG_RESULT(yes)
239 AC_DEFINE(HAVE_STRLCAT, 1, [Define if strlcat is available (most BSDs.)])],
240 [AC_MSG_RESULT(no)]
241 )
242
243 CFLAGS=$save_CFLAGS
244
245 else
246
247 dnl Better than nothing. The more complicated test above probably fixes powerpc,
248 dnl so who cares.
249
250 AC_CHECK_FUNCS([strlcat strlcpy])
251
252 fi
253
254 AC_CHECK_TYPE([u_int32_t], [],
255 [
256 AC_CHECK_TYPE([uint32_t],
257 [
258 AC_DEFINE(u_int32_t, [uint32_t], [If system does not define u_int32_t, define a reasonable substitute.])
259 ],
260 [
261 AC_MSG_WARN([system has no u_int32_t or uint32_t, default to unsigned long int])
262 AC_DEFINE(u_int32_t, [unsigned long int], [If system does not define u_int32_t, define to unsigned long int here.])
263 ])
264 ])
265
266 AC_CHECK_TYPE([u_int16_t], [],
267 [
268 AC_CHECK_TYPE([uint16_t],
269 [
270 AC_DEFINE(u_int16_t, [uint16_t], [If system does not define u_int16_t, define a usable substitute])
271 ],
272 [
273 AC_MSG_WARN([system has no u_int16_t or uint16_t, default to unsigned short int])
274 AC_DEFINE(u_int16_t, [unsigned short int], [If system does not define u_int16_t, define a usable substitute.])
275 ])
276 ])
277
278 AC_CHECK_TYPE([in_port_t], [],
279 [AC_DEFINE(in_port_t, [u_int16_t], [If system does not define in_port_t, define it to what it should be.])],
280 [[#include <sys/types.h>
281 #include <netinet/in.h>]])
282
283 AC_CHECK_TYPE([sa_family_t], [],
284 [AC_DEFINE(sa_family_t, [u_int16_t], [If system does not define sa_family_t, define it here.])],
285 [[#include <sys/types.h>
286 #include <sys/socket.h>]])
287
288 AC_CHECK_TYPES([uintptr_t])
289
290 dnl check for various functions...
291 AC_CHECK_FUNCS([socketpair vsnprintf mmap gettimeofday strdup strndup ])
292
293 AC_FUNC_ALLOCA
294
295 dnl Specialized functions checks
296 dnl ============================
297
298 dnl check for nanosleep
299 AC_CHECK_FUNC(nanosleep,,[AC_CHECK_LIB(rt,nanosleep,
300 LIBS="${LIBS} -lrt",
301 [AC_CHECK_LIB(posix4,nanosleep, LIBS="${LIBS} -lposix4"
302 )])])
303 if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_posix4_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno
304 then
305 AC_MSG_RESULT("nanosleep not found..using select for delay")
306 else
307 AC_DEFINE([HAVE_NANOSLEEP], 1, [Define if nanosleep exists])
308 fi
309
310 dnl OpenSSL support
311 AC_MSG_CHECKING(for OpenSSL)
312 AC_ARG_ENABLE(openssl,
313 [AC_HELP_STRING([--enable-openssl[=DIR]],[Enable OpenSSL support (DIR optional).])
314 AC_HELP_STRING([--disable-openssl],[Disable OpenSSL support.])],
315 [cf_enable_openssl=$enableval],
316 [cf_enable_openssl="auto"])
317
318 if test "$cf_enable_openssl" != "no" ; then
319 cf_openssl_basedir=""
320 if test "$cf_enable_openssl" != "auto" &&
321 test "$cf_enable_openssl" != "yes" ; then
322 dnl Support for --enable-openssl=/some/place
323 cf_openssl_basedir="`echo ${cf_enable_openssl} | sed 's/\/$//'`"
324 else
325 dnl Do the auto-probe here. Check some common directory paths.
326 for dirs in /usr/local/ssl /usr/pkg /usr/local \
327 /usr/local/openssl ; do
328 if test -f "${dirs}/include/openssl/opensslv.h" ; then
329 cf_openssl_basedir="${dirs}"
330 break
331 fi
332 done
333 unset dirs
334 fi
335 dnl Now check cf_openssl_found to see if we found anything.
336 if test ! -z "$cf_openssl_basedir"; then
337 if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
338 SSL_INCLUDES="-I${cf_openssl_basedir}/include"
339 SSL_LIBS="-L${cf_openssl_basedir}/lib"
340 else
341 dnl OpenSSL wasn't found in the directory specified. Naughty
342 dnl administrator...
343 cf_openssl_basedir=""
344 fi
345 else
346 dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
347 dnl are in /usr/include and /usr/lib. In this case, we don't want to
348 dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
349 dnl We can't do this check above, because some people want two versions
350 dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
351 dnl and they want /usr/local/ssl to have preference.
352 if test -f "/usr/include/openssl/opensslv.h" ; then
353 cf_openssl_basedir="/usr"
354 fi
355 fi
356
357 dnl If we have a basedir defined, then everything is okay. Otherwise,
358 dnl we have a problem.
359 if test ! -z "$cf_openssl_basedir"; then
360 AC_MSG_RESULT($cf_openssl_basedir)
361 cf_enable_openssl="yes"
362 else
363 AC_MSG_RESULT([not found. Specify a correct path?])
364 cf_enable_openssl="no"
365 fi
366 unset cf_openssl_basedir
367 else
368 dnl If --disable-openssl was specified
369 AC_MSG_RESULT(disabled)
370 fi
371
372 save_CPPFLAGS="$CPPFLAGS"
373 CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
374 save_LIBS="$LIBS"
375 LIBS="$LIBS $SSL_LIBS"
376 if test "$cf_enable_openssl" != no; then
377 dnl Check OpenSSL version (must be 0.9.6 or above!)
378 AC_MSG_CHECKING(for OpenSSL 0.9.6 or above)
379 AC_RUN_IFELSE(
380 AC_LANG_PROGRAM(
381 [#include <openssl/opensslv.h>
382 #include <stdlib.h>],
383 [[if ( OPENSSL_VERSION_NUMBER >= 0x00906000)
384 exit(0); else exit(1);]]),
385 cf_openssl_version_ok=yes,
386 cf_openssl_version_ok=no,
387 cf_openssl_version_ok=no)
388
389 if test "$cf_openssl_version_ok" = yes; then
390 AC_MSG_RESULT(found)
391
392 dnl Work around pmake/gmake conditional incompatibilities
393 AC_SUBST(ENCSPEED, encspeed)
394
395 dnl Do all the HAVE_LIBCRYPTO magic -- and check for ciphers
396 CPPFLAGS="$CPPFLAGS $SSL_LIBS"
397 AC_CHECK_LIB(crypto, RSA_free)
398 SSL_LIBS="$SSL_LIBS -lcrypto"
399 SSL_SRCS_ENABLE='$(SSL_SRCS)'
400 else
401 AC_MSG_RESULT(no - OpenSSL support disabled)
402 fi
403 fi
404
405 CPPFLAGS="$save_CPPFLAGS"
406 LIBS="$save_LIBS"
407
408 dnl End OpenSSL detection
409
410
411 dnl Specialized functions and libraries
412 dnl ===================================
413
414 AC_ARG_WITH(zlib-path,
415 AC_HELP_STRING([--with-zlib-path=DIR],[Path to libz.so for ziplinks support.]),
416 [LIBS="$LIBS -L$withval"],)
417
418 AC_ARG_ENABLE(zlib,
419 AC_HELP_STRING([--disable-zlib],[Disable ziplinks support]),
420 [zlib=$enableval],[zlib=yes])
421
422 if test "$zlib" = yes; then
423
424 AC_CHECK_HEADER(zlib.h, [
425 AC_CHECK_LIB(z, zlibVersion,
426 [
427 AC_SUBST(ZLIB_LD, -lz)
428 AC_DEFINE(HAVE_LIBZ, 1, [Define to 1 if zlib (-lz) is available.])
429 ], zlib=no)
430 ], zlib=no)
431
432 fi
433
434 dnl Check for shared sqlite
435 dnl ======================
436 AC_ARG_WITH(shared-sqlite,
437 AC_HELP_STRING([--with-shared-sqlite],[Use shared sqlite]),
438 [shared_sqlite=$withval],[shared_sqlite=no])
439
440 if test "$shared_sqlite" = yes; then
441 PKG_CHECK_MODULES(SQLITE, [sqlite3],
442 [
443 shared_sqlite=yes
444 ], shared_sqlite=no)
445 fi
446
447 if test "$shared_sqlite" = no; then
448 SQLITE_OBJ='sqlite3.$(OBJEXT)'
449 fi
450
451 AC_SUBST(SQLITE_LD, "$SQLITE_LIBS")
452 AC_SUBST(SQLITE_INCLUDES, "$SQLITE_CFLAGS")
453 AC_SUBST(SQLITE_OBJ)
454
455 dnl IO Loop Selection
456 dnl =================
457
458 AC_ARG_ENABLE(ports, AC_HELP_STRING([--enable-ports],[Force solaris I/O ports subsystem usage.]),
459 [ if test $enableval = yes; then
460 SELECT_TYPE_EXPLICIT="ports"
461 else
462 use_ports=no
463 fi
464 ],)
465
466 AC_ARG_ENABLE(poll, AC_HELP_STRING([--enable-poll],[Force poll() usage.]),
467 [ if test $enableval = yes; then
468 SELECT_TYPE_EXPLICIT="poll"
469 else
470 use_poll=no
471 fi
472 ],)
473
474 AC_ARG_ENABLE(select, AC_HELP_STRING([--enable-select],[Force select() usage.]),
475 [ if test $enableval = yes; then
476 SELECT_TYPE_EXPLICIT="select"
477 else
478 use_select=no
479 fi
480 ],)
481
482 AC_ARG_ENABLE(kqueue, AC_HELP_STRING([--enable-kqueue],[Force kqueue() usage.]),
483 [ if test $enableval = yes; then
484 SELECT_TYPE_EXPLICIT="kqueue"
485 else
486 use_kqueue=no
487 fi
488 ],)
489
490 AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll],[Force sys_epoll usage (Linux only).]),
491 [ if test $enableval = yes; then
492 SELECT_TYPE_EXPLICIT="epoll"
493 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
494 else
495 use_epoll=no
496 fi
497 ],)
498
499 dnl **********************************************************************
500 dnl Check for --with-confdir [deprecated, use --sysconfdir instead]
501 dnl **********************************************************************
502
503 AC_ARG_WITH([confdir],
504 [AC_HELP_STRING([--with-confdir=DIR],
505 [Directory to install config files [deprecated, use --sysconfdir instead].])],
506 [ sysconfdir=`echo $withval | sed 's/\/$//'` ],
507 [ confdir='${sysconfdir}' ])
508 AC_DEFINE_DIR([ETC_DIR], [sysconfdir], [Prefix where config files are installed.])
509
510 dnl **********************************************************************
511 dnl Check for --with-logdir
512 dnl **********************************************************************
513
514 AC_MSG_CHECKING([whether to modify logdir])
515 AC_ARG_WITH(logdir,
516 AC_HELP_STRING([--with-logdir=DIR],
517 [Directory where to write logfiles.]),
518 [ logdir=`echo $withval | sed 's/\/$//'`
519 AC_MSG_RESULT(yes)],
520 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
521 [logdir='${localstatedir}/log/${PACKAGE_TARNAME}'],
522 [logdir='${prefix}/logs'])
523 AC_MSG_RESULT(no)])
524 AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.])
525 AC_SUBST_DIR([logdir])
526
527 dnl **********************************************************************
528 dnl Check for --with-helpdir
529 dnl **********************************************************************
530
531 AC_MSG_CHECKING([whether to modify helpdir])
532 AC_ARG_WITH(helpdir,
533 AC_HELP_STRING([--with-helpdir=DIR],
534 [Directory to install help files.]),
535 [ helpdir=`echo $withval | sed 's/\/$//'`
536 AC_MSG_RESULT(yes) ],
537 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
538 [helpdir='${datadir}/${PACKAGE_TARNAME}/help'],
539 [helpdir='${prefix}/help'])
540 AC_MSG_RESULT(no) ])
541 AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.])
542 AC_SUBST_DIR([helpdir])
543
544 dnl **********************************************************************
545 dnl Check for --with-moduledir
546 dnl **********************************************************************
547
548 AC_MSG_CHECKING([whether to modify moduledir])
549 AC_ARG_WITH(moduledir,
550 [AC_HELP_STRING([--with-moduledir=DIR],
551 [Directory to install modules.])],
552 [ moduledir=`echo $withval | sed 's/\/$//'`
553 AC_MSG_RESULT(yes)],
554 [ AS_IF([test "x$enable_fhs_paths" = "xyes"],
555 [moduledir='${pkglibdir}/modules'],
556 [moduledir='${prefix}/modules'])
557 AC_MSG_RESULT(no)
558 ])
559 AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
560 AC_SUBST_DIR([moduledir])
561
562 dnl Check for --with-rundir
563
564 AC_MSG_CHECKING([whether or modify rundir])
565 AC_ARG_WITH([rundir],
566 [AC_HELP_STRING([--with-rundir=DIR],
567 [Directory in which to store pidfile.])],
568 [AC_MSG_RESULT([yes])
569 rundir=`echo $withval | sed 's/\/$//'`],
570 [AC_MSG_RESULT([no])
571 AS_IF([test "x$enable_fhs_paths" = "xyes"],
572 [rundir='${prefix}/run'],
573 [rundir='${sysconfdir}'])])
574 AC_SUBST([rundir])
575 AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.])
576
577 dnl Installed utility program prefixes (does not affect binaries
578 dnl installed into pkglibexecdir)
579 AC_MSG_CHECKING([for program prefix])
580 AC_ARG_WITH([program-prefix],
581 [AS_HELP_STRING([--with-program-prefix=], [If set, programs installed into PATH will be installed with names prefixed by this prefix.])],
582 [test "x$with_program_prefix" = "xno" && with_program_prefix=],
583 [with_program_prefix=])
584 AC_MSG_RESULT(["$with_program_prefix"])
585 PROGRAM_PREFIX="$with_program_prefix"
586 AC_SUBST([PROGRAM_PREFIX])
587 AC_DEFINE_UNQUOTED([PROGRAM_PREFIX], ["$with_program_prefix"], [String with which all programs intended to be in PATH are prefixed.])
588
589 dnl **********************************************************************
590 dnl Branding
591 dnl **********************************************************************
592
593 AC_MSG_CHECKING([whether custom branding is requested])
594 AC_ARG_WITH(custom-branding,
595 AC_HELP_STRING([--with-custom-branding=NAME],
596 [Custom branding name.]),
597 [BRANDING_NAME=$withval
598 AC_MSG_RESULT([yes])],
599 [BRANDING_NAME=$PACKAGE_NAME
600 AC_MSG_RESULT([no])]
601 )
602
603 AC_MSG_CHECKING([whether a custom version is requested])
604 AC_ARG_WITH(custom-version,
605 AC_HELP_STRING([--with-custom-version=NAME],
606 [Custom version branding.]),
607 [BRANDING_VERSION=$withval
608 AC_MSG_RESULT([yes])],
609 [BRANDING_VERSION=$PACKAGE_VERSION
610 AC_MSG_RESULT([no])]
611 )
612
613 AC_DEFINE_UNQUOTED(BRANDING_NAME, ["$BRANDING_NAME"], [Custom branding name.])
614 AC_DEFINE_UNQUOTED(BRANDING_VERSION, ["$BRANDING_VERSION"], [Custom branding name.])
615
616 if test "x$BRANDING_NAME" != "x$PACKAGE_NAME"; then
617 AC_DEFINE(CUSTOM_BRANDING, 1, [Define if custom branding is enabled.])
618 fi
619
620 if test ! -z "$SELECT_TYPE_EXPLICIT"; then
621 SELECT_TYPE="$SELECT_TYPE_EXPLICIT";
622 echo "Forcing $SELECT_TYPE to be enabled"
623 else
624
625 if test ! "x$use_ports" = "xno"; then
626 AC_CHECK_FUNCS(port_getn, [haveports=yes], [haveports=no])
627 if test "x$haveports" = "xyes" ; then
628 SELECT_TYPE="ports"
629 fi
630 fi
631
632 if test ! "x$use_select" = "xno"; then
633 AC_CHECK_FUNCS(select, [haveselect=yes], [haveselect=no])
634 if test "x$haveselect" = "xyes" ; then
635 SELECT_TYPE="select"
636 fi
637 fi
638
639 if test ! "x$use_poll" = "xno"; then
640 AC_CHECK_FUNCS(poll, [havepoll=yes], [havepoll=no])
641 if test "x$havepoll" = "xyes" ; then
642 SELECT_TYPE="poll"
643 fi
644 fi
645
646 if test ! "x$use_kqueue" = "xno"; then
647 AC_CHECK_FUNCS(kevent, [havekqueue=yes], [havekqueue=no])
648 if test "x$havekqueue" = "xyes" ; then
649 SELECT_TYPE="kqueue"
650 fi
651 fi
652
653 if test ! "x$use_epoll" = "xno"; then
654 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], [haveepoll=no])
655 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
656 if test "x$haveepoll" = "xyes" ; then
657 AC_MSG_CHECKING(for epoll support in kernel)
658 AC_TRY_RUN(
659 #include <stdint.h>
660 #include <sys/param.h>
661 #include <sys/types.h>
662 #include <sys/epoll.h>
663 #include <sys/syscall.h>
664 #include <unistd.h>
665
666 int
667 main(int argc, char **argv)
668 {
669 int epfd;
670
671 epfd = epoll_create(256);
672 return (epfd == -1 ? 1 : 0);
673 }, [AC_MSG_RESULT(yes)
674 AC_DEFINE(HAVE_EPOLL, 1,
675 [Define if your system supports the epoll system calls])
676 SELECT_TYPE="epoll"],
677 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
678 fi
679 fi
680
681 haveepollsyscall=no
682
683 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
684 if test "x$haveepoll" = "xno" ; then
685 AC_MSG_CHECKING(for epoll system call)
686 AC_TRY_RUN(
687 #include <stdint.h>
688 #include <sys/param.h>
689 #include <sys/types.h>
690 #include <sys/epoll.h>
691 #include <sys/syscall.h>
692 #include <unistd.h>
693
694 int
695 epoll_create(int size)
696 {
697 return (syscall(__NR_epoll_create, size));
698 }
699
700 int
701 main(int argc, char **argv)
702 {
703 int epfd;
704
705 epfd = epoll_create(256);
706 exit (epfd == -1 ? 1 : 0);
707 }, [AC_MSG_RESULT(yes)
708 AC_DEFINE(HAVE_EPOLL, 1,
709 [Define if your system supports the epoll system calls])
710 SELECT_TYPE="epoll"],
711 AC_MSG_RESULT(no), AC_MSG_RESULT(no))
712 fi
713 fi
714
715 fi
716
717 fi
718
719 if test -z "$SELECT_TYPE"; then
720 AC_MSG_ERROR([Unable to find a usable IO interface],)
721 fi
722
723 echo "Using $SELECT_TYPE for select loop."
724
725 AC_DEFINE_UNQUOTED(SELECT_TYPE, "$SELECT_TYPE", [This is the type of IO loop we are using])
726 AC_SUBST(SELECT_TYPE)
727
728
729 dnl Debug-related options
730 dnl =====================
731
732 AC_ARG_ENABLE(assert,
733 AC_HELP_STRING([--enable-assert],[Enable assert(). Choose between soft(warnings) and hard(aborts the daemon)]),
734 [assert=$enableval], [assert=no])
735
736 if test "$assert" = no; then
737 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
738 elif test "$assert" = soft; then
739 AC_DEFINE(SOFT_ASSERT, 1, [Define this to enable soft asserts.])
740 AC_DEFINE(NDEBUG, 1, [Define this to disable debugging support.])
741 elif test "$assert" = yes; then
742 assert = "hard";
743 fi
744
745 AC_MSG_CHECKING(if you want IO Debugging hooks)
746 AC_ARG_ENABLE(iodebug,
747 AC_HELP_STRING([--enable-iodebug],[Enable IO Debugging hooks]),
748 [iodebug=$enableval], [iodebug=no])
749
750 if test "$iodebug" = yes; then
751 AC_DEFINE(USE_IODEBUG_HOOKS, 1, [Define this to enable IO Debug hooks.])
752 AC_MSG_RESULT(yes)
753 else
754 AC_MSG_RESULT(no)
755 fi
756
757
758 AC_MSG_CHECKING(if you want to do a profile build)
759 AC_ARG_ENABLE(profile,
760 AC_HELP_STRING([--enable-profile],[Enable profiling]),
761 [profile=$enableval], [profile=no])
762
763 if test "$profile" = yes; then
764 if test "$ac_cv_c_compiler_gnu" = yes; then
765 IRC_CFLAGS="$IRC_CFLAGS -pg"
766 AC_MSG_RESULT([yes, adding -pg])
767 AC_DEFINE(CHARYBDIS_PROFILE, 1, [Define this if you are profiling.])
768 else
769 AC_MSG_RESULT([no, profile builds only work with gcc])
770 fi
771 else
772 AC_MSG_RESULT(no)
773 fi
774
775 AC_ARG_ENABLE(balloc,
776 AC_HELP_STRING([--disable-balloc],[Disable the block allocator.]),
777 [balloc=$enableval], [balloc=yes])
778
779 if test "$balloc" = no; then
780 AC_DEFINE([NOBALLOC], 1, [Define to 1 if you wish to disable the block allocator.])
781 fi
782
783 AC_ARG_ENABLE(small-net,
784 AC_HELP_STRING([--enable-small-net],[Enable small network support.]),
785 [small_net=$enableval], [small_net=no])
786
787 if test "$small_net" = yes; then
788 dnl AC_DEFINE([HASHSIZE], 4096, [Max number of buckets in hash tables.])
789 AC_DEFINE([NICKNAMEHISTORYLENGTH], 1500, [Size of the WHOWAS array.])
790 AC_DEFINE([CHANNEL_HEAP_SIZE], 256, [Size of the channel heap.])
791 AC_DEFINE([BAN_HEAP_SIZE], 128, [Size of the ban heap.])
792 AC_DEFINE([CLIENT_HEAP_SIZE], 256, [Size of the client heap.])
793 AC_DEFINE([LCLIENT_HEAP_SIZE], 128, [Size of the local client heap.])
794 AC_DEFINE([PCLIENT_HEAP_SIZE], 32, [Size of the pre-client heap.])
795 AC_DEFINE([USER_HEAP_SIZE], 128, [Size of the user heap.])
796 AC_DEFINE([DNODE_HEAP_SIZE], 256, [Size of the dlink_node heap.])
797 AC_DEFINE([TOPIC_HEAP_SIZE], 256, [Size of the topic heap.])
798 AC_DEFINE([LINEBUF_HEAP_SIZE], 128, [Size of the linebuf heap.])
799 AC_DEFINE([MEMBER_HEAP_SIZE], 256, [Sizeof member heap.])
800 AC_DEFINE([ND_HEAP_SIZE], 128, [Size of the nick delay heap.])
801 AC_DEFINE([CONFITEM_HEAP_SIZE], 128, [Size of the confitem heap.])
802 AC_DEFINE([MONITOR_HEAP_SIZE], 128, [Size of the monitor heap.])
803 AC_DEFINE([FD_HEAP_SIZE], 128, [Size of fd heap.])
804 AC_DEFINE([AWAY_HEAP_SIZE], 128, [Size of away heap.])
805 else
806 dnl These settings are for a large network like efnet..they will use lots of memory
807 dnl so enable small net unless you really need this much support
808 AC_DEFINE([NICKNAMEHISTORYLENGTH], 15000, [Size of the WHOWAS array.])
809 AC_DEFINE([CHANNEL_HEAP_SIZE], 8192, [Size of the channel heap.])
810 AC_DEFINE([BAN_HEAP_SIZE], 4096, [Size of the ban heap.])
811 AC_DEFINE([CLIENT_HEAP_SIZE], 8192, [Size of the client heap.])
812 AC_DEFINE([LCLIENT_HEAP_SIZE], 1024, [Size of the local client heap.])
813 AC_DEFINE([PCLIENT_HEAP_SIZE], 256, [Size of the pre-client heap.])
814 AC_DEFINE([USER_HEAP_SIZE], 8192, [Size of the user heap.])
815 AC_DEFINE([DNODE_HEAP_SIZE], 8192, [Size of the dlink_node heap.])
816 AC_DEFINE([TOPIC_HEAP_SIZE], 4096, [Size of the topic heap.])
817 AC_DEFINE([LINEBUF_HEAP_SIZE], 2048, [Size of the linebuf heap.])
818 AC_DEFINE([MEMBER_HEAP_SIZE], 32768, [Sizeof member heap.])
819 AC_DEFINE([ND_HEAP_SIZE], 512, [Size of the nick delay heap.])
820 AC_DEFINE([CONFITEM_HEAP_SIZE], 256, [Size of the confitem heap.])
821 AC_DEFINE([MONITOR_HEAP_SIZE], 1024, [Size of the monitor heap.])
822 AC_DEFINE([FD_HEAP_SIZE], 1024, [Size of fd heap.])
823 AC_DEFINE([AWAY_HEAP_SIZE], 512, [Size of away heap.])
824 fi
825
826 AC_ARG_WITH(nicklen,
827 AC_HELP_STRING([--with-nicklen=LENGTH],[Set the upper-bound nick length to LENGTH (default 31, max 50)]),
828 [
829 if ! expr "$withval" + 0 >/dev/null 2>&1; then
830 AC_ERROR([NICKLEN must be a numeric value])
831 fi
832 if test $withval -gt 50; then
833 NICKLEN=50
834 AC_MSG_WARN([NICKLEN has a hard limit of 50. Setting NICKLEN=50])
835 elif test $withval -lt 9; then
836 NICKLEN=9
837 AC_MSG_WARN([NICKLEN has a lower limit of 9. Setting NICKLEN=9])
838 else
839 NICKLEN="$withval"
840 fi
841 ], [NICKLEN=31])
842
843 AC_ARG_WITH(topiclen,
844 AC_HELP_STRING([--with-topiclen=NUMBER],[Set the max topic length to NUMBER (default 390, max 390)]),
845 [
846 if test $withval -ge 390; then
847 TOPICLEN=390
848 AC_MSG_WARN([TOPICLEN has a hard limit of 390. Setting TOPICLEN=390])
849 else
850 TOPICLEN=$withval
851 fi
852 ], [TOPICLEN=390])
853
854 AC_DEFINE_UNQUOTED(TOPICLEN, ${TOPICLEN}, [Maximum topic length (<=390)])
855 AC_DEFINE_UNQUOTED(NICKLEN, (${NICKLEN}+1), [Nickname length])
856
857 # rpath, for finding libratbox.so at run time
858 hold_ldflags=$LDFLAGS
859 AC_MSG_CHECKING(for the ld -rpath flag)
860 LDFLAGS="${LDFLAGS} -Wl,-rpath=${libdir}"
861 AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
862 LDFLAGS=$hold_ldflags
863 AC_MSG_RESULT($found)
864 if test "$found" = yes; then
865 LDFLAGS="${LDFLAGS} -Wl,-rpath=\${libdir}"
866 fi
867
868 # This must be down here, or it will mess up checks like the ones
869 # for -Wl,-export-dynamic
870 # -- jilles
871 CWARNS=""
872 AC_ARG_ENABLE(warnings,
873 AC_HELP_STRING([--enable-warnings],[Enable all sorts of warnings for debugging.]),
874 [
875 IRC_CFLAGS="$IRC_CFLAGS -O0"
876 CFLAGS="$IRC_CFLAGS"
877
878 CHARYBDIS_C_GCC_TRY_FLAGS([-Wall], charybdis_cv_c_gcc_w_all)
879 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpointer-arith], charybdis_cv_c_gcc_w_pointer_arith)
880 CHARYBDIS_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], charybdis_cv_c_gcc_w_implicit)
881 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-align], charybdis_cv_c_gcc_w_cast_align)
882 CHARYBDIS_C_GCC_TRY_FLAGS([-Wcast-qual], charybdis_cv_c_gcc_w_cast_qual)
883 CHARYBDIS_C_GCC_TRY_FLAGS([-Wwrite-strings], charybdis_cv_c_gcc_w_write_strings)
884 CHARYBDIS_C_GCC_TRY_FLAGS([-Werror-implicit-function-declaration], charybdis_cv_c_gcc_w_error_implicit_function_declaration)
885 CHARYBDIS_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], charybdis_cv_c_gcc_prototypes)
886 CHARYBDIS_C_GCC_TRY_FLAGS([-Wparenthesis], charybdis_cv_c_gcc_parenthesis)
887 CHARYBDIS_C_GCC_TRY_FLAGS([-W -Wno-unused], charybdis_cv_c_gcc_w)
888 CHARYBDIS_C_GCC_TRY_FLAGS([-Wextra], charybdis_cv_c_gcc_w_extra)
889 CHARYBDIS_C_GCC_TRY_FLAGS([-Wshadow], charybdis_cv_c_gcc_w_shadow)
890 CHARYBDIS_C_GCC_TRY_FLAGS([-Wmissing-noreturn], charybdis_cv_c_gcc_w_missing_noreturn)
891 CHARYBDIS_C_GCC_TRY_FLAGS([-Wundef], charybdis_cv_c_gcc_w_undef)
892 CHARYBDIS_C_GCC_TRY_FLAGS([-Wpacked], charybdis_cv_c_gcc_w_packed)
893 CHARYBDIS_C_GCC_TRY_FLAGS([-Wnested-externs], charybdis_cv_c_gcc_w_nested_externs)
894 CHARYBDIS_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], charybdis_cv_c_gcc_w_unused)
895 CHARYBDIS_C_GCC_TRY_FLAGS([-Wredundant-decls], charybdis_cv_c_gcc_w_redundant_decls)
896 CHARYBDIS_C_GCC_TRY_FLAGS([-Wfloat-equal], charybdis_cv_c_gcc_w_float_equal)
897 CHARYBDIS_C_GCC_TRY_FLAGS([-Wformat -Wformat-y2k -Wno-format-security], charybdis_cv_c_gcc_w_format)
898
899 IRC_CFLAGS="$CFLAGS"
900 ],[])
901
902 IRC_CFLAGS="$IRC_CFLAGS $CWARNS"
903
904 AC_SUBST(MODULES_LIBS)
905 AC_SUBST(MOD_TARGET)
906
907 AC_SUBST(SSL_SRCS_ENABLE)
908 AC_SUBST(SSL_INCLUDES)
909 AC_SUBST(SSL_LIBS)
910
911 AC_SUBST(LDFLAGS)
912 AC_SUBST(PICFLAGS)
913 AC_SUBST(IRC_CFLAGS)
914 AC_SUBST(SEDOBJ)
915
916
917 if test "$prefix" = "NONE"; then
918 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
919
920 else
921
922 dnl Don't get bitten by Cygwin's stupidity if the user specified
923 dnl a custom prefix with a trailing slash
924
925 prefix=`echo $prefix | sed 's/\/$//'`
926 AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
927
928 fi
929
930 AC_CONFIG_FILES( \
931 Makefile \
932 bandb/Makefile \
933 ssld/Makefile \
934 extensions/Makefile \
935 ircd/Makefile \
936 modules/Makefile \
937 tools/Makefile \
938 tools/genssl \
939 doc/Makefile \
940 help/Makefile \
941 )
942 AC_CONFIG_COMMANDS([tools/genssl_chmod], [chmod 755 tools/genssl])
943
944 AC_OUTPUT
945
946 if test "$cf_openssl_version_ok" = yes; then
947 openssl="yes"
948 else
949 openssl="no"
950 fi
951
952 echo "
953 Configuration of ${BRANDING_NAME}-${BRANDING_VERSION}:
954 Install directory : $prefix
955
956 Ziplinks : $zlib
957 OpenSSL : $openssl
958 Socket Engine : $SELECT_TYPE
959 Small network : $small_net
960 Block allocator : $balloc
961
962 Nickname length : $NICKLEN
963 Topic length : $TOPICLEN
964
965 Use (g)make to compile $BRANDING_NAME, then (g)make install to install it.
966 "